数组不在12个元素之后编译? [英] Array not compiling after 12 elements?
问题描述
我试图创建一个数组,但如果我的数组中有12个以上的元素,我的程序将无法编译。例如:
I'm trying to create an array, but my program will not compile if I have more than 12 elements in the array. For example:
PROGRAM dprime
REAL, DIMENSION(12) :: array
array = (/50.0,52.0,54.0,56.0,58.0,60.0,62.0,64.0,66.0,68.0,70.0,72.0/)
END PROGRAM dprime
现在,如果将其更改为 DIMENSION(13)
并在 72.0后添加另一个元素, code>我得到以下错误:
Now, if I change it to DIMENSION(13)
and add another element after 72.0,
I get the following error:
错误#5082:语法错误,期望一个$时发现END-OF-STATEMENT b $ b of:,(/:/).
Error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: , (/ : /).
这段代码无法编译:
PROGRAM dprime
REAL, DIMENSION(13) :: array
array =(/50.0,52.0,54.0,56.0,58.0,60.0,62.0,64.0,66.0,68.0,70.0,72.0,74.0/)
END PROGRAM
在哪里可能会出现错误?
Where could there be an error?
推荐答案
您可能超出允许的行长度。
You are probably beyond the allowed line length.
对于gfortran,请在命令行中添加 -ffree-line-length-none
选项。
For gfortran, add the option -ffree-line-length-none
to the command line.
编辑:
很可能,只需将您的文件重命名为 *。f90
,然后您会被设置为大多数编译器,包括您正在使用的ifort。这个策略有一个限制:超过132个字符,你必须在一行的末尾使用字符&
的连续行。
Most probably, just rename your file to *.f90
and you'll be set with most compilers, including ifort that you are using. This strategy has a limit: beyond 132 characters you must use continuation lines with the character &
at the end of a line.
这篇关于数组不在12个元素之后编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!