我想端口一段代码的Fortran 77到Fortran 90的,我有关于Fortran 77中追赶排名不匹配参数等级不匹配的没有报告
这是一个问题在Fortran 90的
program test
use my_module
real ml_time
call gettimes(cdfid,ml_time,ml_ntimes)
代码在调用子例程,这是通过可变如何定义
module my_module
use netcdf
subroutine gettimes(cdfid,times,ntimes)
real times(*)
call check(nf90_inq_dimid(cdfid,'time', timid))
call check(nf90_inquire_dimension(cdfid, timid, len = ntimes))
call check(nf90_inq_varid(cdfid,'time',timid))
call check(nf90_get_var(cdfid,timid,times(1:ntimes)))
end subroutine gettimes
在Fortran 77的(.f文件)和gfortran 5.4为什么这个无会产生编译错误?
将代码移植到Fortran 90时出现相同的代码会产生排名不匹配的编译错误。
这是在Fortran 77的Fortran 90中
add2p.f90:191:22:
call gettimes(cdfid,ml_time,ml_ntimes)
1
Error: Rank mismatch in argument ‘times’ at (1) (rank-1 and scalar)
错误这是代码是如何组织的
program test
real ml_time
call gettimes(cdfid,ml_time,ml_ntimes)
在另一个文件xyz.f
subroutine gettimes(cdfid,times,ntimes,ierr)
include "netcdf.inc"
integer ierr,i
real times(*)
integer didtim,ntimes
integer cdfid,idtime
do 10 i=1,ntimes
call ncvgt1(cdfid,idtime,i,times(i)) ! get times
10 continue
end
当然我摆脱了错误,使他们相同的排名,但我想知道为什么在Fortran 77中没有报告编译器错误。
请显示在Fortran 90中生成的错误以及一些合理的*完整*代码示例[mcve]。 –
整个结构是需要的,不仅仅是子程序,看到我的答案为什么。 –
@VladimirF - 我做出了可接受的更改吗? – gansub