数组读入到几千行的时候报错
源码就不往上贴了,太大。定义一个数组,并用data赋值(r8是一个kind的数值)
---------------------------------------------------------------------------------------------------------
real (r8), dimension (45, 45, 91) :: saar_ref
data saar_ref / &
8.9999999999999998e+90_r8, 8.9999999999999998e+90_r8, 8.9999999999999998e+90_r8,&
8.9999999999999998e+90_r8, 8.9999999999999998e+90_r8, 8.9999999999999998e+90_r8,&
.....................此处省略好多........................................&
/
---------------------------------------------------------------------------------------------------------
现在的问题是,编译这个文件,报错:
---------------------------------------------------------------------------------------------------------
yangxd@latecomer03:modules> ifort -c gsw_mod_saar_data.f90
gsw_mod_saar_data.f90(4421): catastrophic error: Statement too long
8.9999999999999998e+90_r8, 8.9999999999999998e+90_r8, 8.9999999999999998e+90_r8,&
-----------------------------------------------------^
compilation aborted for gsw_mod_saar_data.f90 (code 1)
---------------------------------------------------------------------------------------------------------
这个地方的statement too long是什么原因呢?
真心找不到原因,谢谢各位了:'(。
虽然有续行,但是编译器依然对总的行的长度有限定。
较大的数组,建议采用文件读入。
如果整个数组都是 8.9999999999999998e+90_r8 的胡,可以这样写:
real (r8), dimension (45, 45, 91) :: saar_ref = 8.9999999999999998e+90_r8 fcode 发表于 2017-6-2 09:29
虽然有续行,但是编译器依然对总的行的长度有限定。
较大的数组,建议采用文件读入。
你好,谢谢你的回复。
------------------------------------------------------------
我的数组里面,不全是这个数字。
你的意思是,我可以先把数组内容放到文本文件里面,然后通过READ读入数组?
另,怎样知道我的编译器对总行数的限制呢?
再次感谢。 是的,我正是这个意思。
编译器对续行的限定,可以看编译器的帮助文档。关于 Compiler Limit 的说明。
比如 ifort 的帮助里就说到:
Continuation lines - free form
Depends on line complexity and the number of lexical tokens allowed.
Continuation lines - fixed form
Depends on line complexity and the number of lexical tokens allowed.
Lexical tokens per statement
40000
这说明,对于 ifort 来说,续行行数没有限定。但是每个语句只能有最多 40000 个 token。
(token 包含,变量名,逗号,括号,等于号等等) fcode 发表于 2017-6-5 11:39
是的,我正是这个意思。
编译器对续行的限定,可以看编译器的帮助文档。关于 Compiler Limit 的说明。
嗯嗯,明白了,真是太谢谢你了。
再就是对token这个词,我以前以为只是逗号或括号。
页:
[1]