! This file: http://ftp.aset.psu.edu/pub/ger/fortran/hdk/farray3.f90 ! ! farray3.for ! Function that returns an array, technique 3. module test_1_pars integer, parameter :: N = 5 end module test_1_pars module test_1 use test_1_pars interface subroutine sub1 (in,out) use test_1_pars integer :: in, out(N) end subroutine sub1 function fun1 (in) result (out) use test_1_pars integer :: in, out(N) end function fun1 end interface end module test_1 subroutine sub1 (in,out) use test_1_pars integer :: in, out(N) out = in end subroutine sub1 function fun1 (in) result (out) use test_1_pars integer :: in, out(N) out = in end function fun1 program test use test_1 integer :: out(N) call sub1 (3,out) write (*,*) out ! outputs 3 3 3 3 3 out = fun1(3) write (*,*) out pause end program test