读取名称列表会导致错误“重复次数过多”

时间:2019-02-06 04:47:16

标签: fortran mingw

我有一个包含名称列表的程序:

implicit none
real,dimension(20)::Rc,Ic
integer::n_cyl,degree=4
namelist /vars/ n_cyl,degree,Rc,Ic
open(1,file='vars.txt')
read(1,nml=vars)  ! line 19
close(1)
! ..............
open(1,file='vars.txt',STATUS='UNKNOWN',RECL=1000)
write(1,nml=vars)
close(1)
end

vars.txt:

&VARS
 N_CYL=         12,
 DEGREE=          4,
 RC= 0.256000012    , 0.512000024    , 0.768000007    ,  1.02400005    ,  1.27999997    ,
   1.43700004    ,  1.59399998    ,  1.72000003    ,  1.84599996    ,  1.97200000    ,  2.09800005    ,
   2.40289998    , 8*0.00000000      ,
 IC=  1.77999997    ,  1.71000004    ,  1.57000005    ,  1.44000006    ,  1.25000000    ,
   1.01999998    , 0.870000005    , 0.680000007    , 0.540000021    , 0.379999995    , 0.259999990    ,
  0.170000002    , 8*0.00000000      ,
 /

如果在Linux上使用gfortran进行编译,则可以正常工作,但是在MinGW(Win32)上使用gfortran进行编译并运行时,会引发错误:

At line 19 of file elen.f90 (unit = 1, file = 'vars.txt'):
Fortran runtime error: Repeat count too large for namelist object rc

这是一个错误,还是代码有问题?

1 个答案:

答案 0 :(得分:0)

gfortran中存在一个使用名称列表重复计数的已知错误。看到: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82086