fortran90动态数组传递参数的问题
!程序的目的是在主程序里声明一个一维动态数组,但数组的长度及内容通过子程序来定module tt
contains
subroutine test(s)
implicit none
integer i
integer,allocatable::s(:)
allocate(s(5))
do i=1,5
s(i)=i
end do
end subroutine test
end module
program main
use tt
integer,allocatable::(s)
call test(s)
m=ubound(s,1)
write(*,*)m
write(*,*)s
pause
end program main
但是,问题是m=4,而不是想象中的m=5 为什么是这样,请高手指点 请问楼主用的是什么编译器,windows环境下ivf计算结果为m=5。 gfortran表示也是5module tt
contains
subroutine test(s)
implicit none
integer i
integer,allocatable::s(:)
allocate(s(5))
do i=1,5
s(i)=i
end do
end subroutine test
end module
program main
use tt
integer,allocatable::s(:)
call test(s)
m=ubound(s,1)
write(*,*)m
write(*,*)s
end program main
页:
[1]