Module testMod
implicit none
contains
function testfunc( n ) result( res )
implicit none
integer :: i, n
real :: res(n)
forall ( i = 1:size(res) )
res(i) = i*1.0
end forall
end function testfunc
End module testMod
Program main
use testMod
implicit none
integer :: n = 5
write( *,'(*(g0,3x))' ) testfunc(n)
End program main