! This file: http://ftp.aset.psu.edu/pub/ger/fortran/hdk/farray1.f90 ! ! Function that returns an array (fun1) whose size is defined ! in another subprogram (sub1). ! ! Compilers tested: Windows: Lahay LF95, Salford FTN95, CVF ! Unix: AIX XLF90 ! Note that sub1 and fun1 may be compiled (external) separately. ! ! Output: ! Array valued Function result: 1 2 3 4 5 !Adapted from Mirek Gruszkiewicz, ORNL module test_1 implicit none integer :: N end module test_1 module inter implicit none interface function fun1 () result (out) use test_1 integer :: out(N) end function fun1 end interface end module inter function fun1 () result (out) use test_1 implicit none integer, dimension (N) :: out integer :: i out= (/(I,I=1,N)/) ! Define some result values. end function fun1 subroutine sub1(N) Integer, Intent(out) :: N N=5 ! Define array size. end subroutine sub1 program test use inter use test_1 implicit none call sub1(N) write (*,*)' Array valued Function result:',fun1() end program test