fortran数组函数

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

猜你喜欢

转载自blog.csdn.net/chd_lkl/article/details/83867208
今日推荐