|
6#
楼主 |
发表于 2018-12-5 16:19:19
|
只看该作者
本帖最后由 BNUPHYKLIANG 于 2018-12-5 17:42 编辑
好的,谢谢您!
那和编译器也没关系吗?我看网上有个外国论坛说了什么用ifort 和gFortran 编译运行的结果不一样,并且有一次 类似read(....)x,y,z 出错,ifort read了3个数据,gfortran read了1个数据截图如下
图中错误代码是:
[Fortran] 纯文本查看 复制代码 do i = 1, N_Param
curr => cfg%record(i)
curr%id = i
curr%pname = PARAM_NAME(i)
curr%ptype = PARAM_TYPE(i)
curr%isArray = PARAM_ARRAY(i)
curr%defaultval = PARAM_DVAL(i)
if (curr%ptype .eq. TYPE_REAL) then
read(curr%defaultval,*) curr%rval
else if (curr%ptype .eq. TYPE_INTEGER) then
read(curr%defaultval,*) curr%ival
else if (curr%ptype .eq. TYPE_COMPLEX) then
read(curr%defaultval,*) curr%cval
end if
就是倒数第二行出错,根据curr%defaultval = PARAM_DVAL(i) 我找到了 PARAM_DVAL如下:
[Fortran] 纯文本查看 复制代码 character(len=*), parameter :: PARAM_DVAL(N_Param) = &
&(/"-1 ", "HSF.in ", "HSF.out ", "12 ", "0.0 ", &
& "0 ", &
& "0.001 ", "0.0 ", "8 ", "0.125 ", "0.001 ", &
& "quest ", "geom.def", "8 ", "0.0 ", "8 ", &
& "16 ", "10 ", "50 ", "4 ", "12 ", &
& "12 ", "5000 ", "30 ", "0 ", "1000 ", &
& "12 ", "4 ", "4 ", "2 ", "0.0001 ", &
& "0 ", "1.0 ", "10 "/)
本来我先想办法看看是第几次循环出错
在循环中加入了print *,i :就在do i=1,N_Param 后面。
[Fortran] 纯文本查看 复制代码 do i = 1, N_Param
print *, i
curr => cfg%record(i)
curr%id = i
curr%pname = PARAM_NAME(i)
curr%ptype = PARAM_TYPE(i)
curr%isArray = PARAM_ARRAY(i)
curr%defaultval = PARAM_DVAL(i)
if (curr%ptype .eq. TYPE_REAL) then
read(curr%defaultval,*) curr%rval
else if (curr%ptype .eq. TYPE_INTEGER) then
read(curr%defaultval,*) curr%ival
else if (curr%ptype .eq. TYPE_COMPLEX) then
read(curr%defaultval,*) curr%cval
end if
再make并运行,出现了变化,从1显示到第33,也就是第33次循环除了问题,我看第33个数明明是1.0 不应该判断它是复数啊,而在下面出错时却是
else if (curr%ptype .eq. TYPE_COMPLEX) then
read(curr%defaultval,*) curr%cval
所以是不是在程序运行过程中数据被改变了
|
|