最近,我找到了一个包含许多特殊功能的f90文件。我需要使用subroutine pbdv ( v, x, dv, dp, pdf, pdd )
,我看一下这六个变量的定义,dp和dv的定义如下所示。
real ( kind = 8 ) dp(0:*)
real ( kind = 8 ) dv(0:*)
那么如何调用这个子程序用什么样的数组定义?该子例程的整个定义是here。
答案 0 :(得分:-1)
这是一种直截了当的方式。你也可以使它不可分配,并从中删除所有分配的东西。
PROGRAM MAIN
...
real ( kind = 8 ), DIMENSION(:), ALLOCATABLE :: dp
real ( kind = 8 ), DIMENSION(-2:80) :: dv
...
ALLOCATE(dp(0:100))
...
CALL yourSub1('dp', dp)
CALL yourSub2('dv', dv)
...
IF(ALLOCATED(DP)) DEALLOCATE(DP)
END PROGRAM
SUBROUTINE YourSub1(Label, ddd)
IMPLICIT NONE
CHARACTER(LEN=*) , INTENT(IN ) :: Label
real(kind=8), DIMENSION(:), ALLOCATABLE, INTENT(INOUT) :: ddd
WRITE(*,22) Label, LBOUND(DDD, DIM=1), label, LBOUND(DDD, DIM=1)
22 FORMAT(' LBOUND(',A,')=',I7,' UBOUND(',A,'=',I6)
RETURN
END SUBROUTINE YourSub1
SUBROUTINE YourSub2(Label, ddd)
IMPLICIT NONE
CHARACTER(LEN=*) , INTENT(IN ) :: Label
real(kind=8), DIMENSION(:), INTENT(INOUT) :: ddd
WRITE(*,22) Label, LBOUND(DDD, DIM=1), label, LBOUND(DDD, DIM=1)
22 FORMAT(' LBOUND(',A,')=',I7,' UBOUND(',A,'=',I6)
RETURN
END SUBROUTINE YourSub2