我需要在一个程序中将一些可分配的数组传递给子程序,我需要知道我的方式是否符合标准.
如果你知道我在哪里可以搜索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
Run Code Online (Sandbox Code Playgroud)
使用模块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
Run Code Online (Sandbox Code Playgroud)
在屏幕上,我明白了
================================
666.000000000000 214.000000000000 558.000000000000
================================
214.000000000000 558.000000000000 332.000000000000
================================
558.000000000000 332.000000000000 -521.000000000000
================================
Run Code Online (Sandbox Code Playgroud)
在子程序test3 legal(在什么版本的fortran,90,95,2003中?)中它们的行为是否正常?