我需要在程序中将一些可分配的数组传递给子程序,并且我需要知道我所做的方式是否符合标准。
如果您知道在哪里可以搜索Fortran的标准,请告诉我。
这是一个小代码,比文字更能说明问题。
program test
use modt99
implicit none
real(pr), dimension(:), allocatable :: vx
allocate(vx(-1:6))
vx=(/666,214,558,332,-521,-999,120,55/)
call test3(vx,vx,vx)
deallocate(vx)
end program test
使用 modt99 模块
module modt99
contains
subroutine test3(v1,v2,v3)
real(pr), dimension(:), intent(in) :: v1
real(pr), dimension(0:), intent(in) :: v2
real(pr), dimension(:), allocatable, intent(in) :: v3
print*,'================================'
print*,v1(1:3)
print*,'================================'
print*,v2(1:3)
print*,'================================'
print*,v3(1:3)
print*,'================================'
end subroutine test3
end module modt99
屏幕上,我看到了。
================================
666.000000000000 214.000000000000 558.000000000000
================================
214.000000000000 558.000000000000 332.000000000000
================================
558.000000000000 332.000000000000 -521.000000000000
================================
那么,在子程序test3中使用的三种虚拟参数的方式是否合法(在哪个版本的Fortran中,90、95、2003?),它们的行为是否正常?