[Fortran] 纯文本查看 复制代码
module global_data
implicit none
Integer , parameter :: QP = Selected_real_kind( 18 )
real(kind=QP),allocatable::h(:),u(:)
Integer , parameter :: ne=100
end module
program main
use global_data
implicit none
integer::NERR
ALLOCATE(h(ne),u(ne),STAT=NERR)
IF(NERR>0)THEN
WRITE(6,*) 'ERROR IN ALLOCATE'
STOP
ENDIF
call tvdd(h)
call tvdd(u)
DEALLOCATE(h,u)
end
subroutine tvdd(t) !这个参数该怎么设置,现在这样写肯定不行,t无法声明,我想把h和u传进来,每次传一个,每次不一样
use global_data
implicit none
t=t+1
endsubroutine
[Fortran] 纯文本查看 复制代码
module global_data
implicit none
Integer , parameter :: QP = Selected_real_kind( 18 )
real(kind=QP),allocatable::h(:),u(:)
Integer , parameter :: ne=100
contains
subroutine tvdd(t) !//把 tvdd 包含在module里,方便使用
real(kind=QP) :: t(:)
t=t+1
endsubroutine
end module
program main
use global_data
implicit none
integer::NERR
ALLOCATE(h(ne),u(ne),STAT=NERR)
IF(NERR>0)THEN
WRITE(6,*) 'ERROR IN ALLOCATE'
STOP
ENDIF
call tvdd(h)
call tvdd(u)
DEALLOCATE(h,u)
end