allocatable arrays and intent(out)
807575Aug 22 2008 — edited Aug 27 2008I found a strange behaviour, at least for me, of f95 compiler.
When a subroutine has an array as argument, declared intent(out), but without the allocatable argument (then "automatic array"), I can access to the values stored in the array, and modidy these values in the subroutine.
When the declaration in the subroutine is "allocatable" then the array is disallocated during the subroutine call and I have a segmentation fault when I try to access to the array's values.
According to what I found on the internet, the second behaviour looks OK : intent(out) make the variables undefined, and then disallocate the array.
Why is the array not undefined in the first case ?
Of course everything is fine with intent(inout) .... Which seems to me to be the correct syntax.
I've made a trial with a derived type instead of an array. with intent(out), the derived type is always undefined by the subroutine call.