! This file: http://ftp.aset.psu.edu/pub/ger/fortran/hdk/farray2.f90 ! ! Example2: Function that returns a matrix. module Test2 integer, parameter :: N = 5, M=3 contains function fun1 (in) result (out) ! FUN1 is an array valued function, in this case set to ! to a constant, in (which could be a matrix). integer :: in, out(N,M) out = in end function fun1 end module test2 program Example2 ! Simple test driver program. use test2 integer :: out(N,M), I ! Call an array valued function whose value is an array. out = fun1(123) ! To illustrate, define matrix as a constant. Do I =1,N write (*,*) out(I,:) end Do end program Example2