Module testMod
implicit none
contains
function testfunc( a ) result( res )
implicit none
real, allocatable :: res(:)
integer :: i
real :: a(:)
if ( allocated( res ) ) then
write( *,'(1x,a)' ) 'the distributable function is allocated!'
deallocate( res )
!.. reallocate
allocate( res(size(a)) )
else
write( *,'(1x,a)' ) 'the distributable function is not allocated!'
allocate( res(size(a)) )
end if
forall ( i = 1:size(res) )
res(i) = a(i) * 10.0
end forall
end function testfunc
End module testMod
Program main
use testMod
implicit none
real :: a(5)
call random_seed
call random_number( a )
write( *,'(*(g0,3x))' ) testfunc(a)
End program main