The following program creates an array ia, and then calls function f1, which in turn calls function f2 to assign some values to the array. Function f2 apparently is returning ia as undefined. If you change f2 to a subroutine, the behaviour is as expected.
I am using FTN95 version 8.83. I have not tried this program with other versions.
Module m
Integer, Dimension(:), Allocatable, Public :: ia
Contains
!
Subroutine s1 (n)
Integer, Intent(In) :: n
!
Allocate (ia(n))
Return
End Subroutine s1
!
Function f1()
Integer :: f1
f1 = f2(ia(:))
print*,'f1:',ia(:)
!
Return
End Function f1
!
Function f2(ia2)
Integer :: f2
Integer, Dimension(:), Intent(Out) :: ia2
!
ia2(:) = 1
Print*,'f2:',ia2(:)
f2 = 0
Return
End Function f2
End Module m
!
Program p
Use m
Integer :: i
Call s1(5)
i = f1()
End Program p