继续在gfortran 5.2.0 [英] Continuation in gfortran 5.2.0
问题描述
我需要在我的Macbook Pro上使用Fortran90代码,这是多年前在Microsoft Developer Tools上编写的。作为一个免费的选项,我在我的Macbook上安装了 gfortran
来编译它。原始代码包含&
长字符串的连续字符,但我无法使用它。没有&
字符,一切正常。可能是什么问题?我是否需要激活某些功能才能使用&
字符?
例如,我认为应该这样:
x = 1
y = 2
z = x +
& y
end
但是,我有这个错误。这可能是行结束错误。我该如何解决它?
3:72:错误:表达式中的语法错误(1)
4:9:错误:无效字符(1)
在自由格式的Fortran ,行末尾的续行字符(&
)将继续。您的代码应为:
程序测试
x = 1
y = 2
z = x +& amp ;
y
结束程序
这在Fortran标准(此处为2008 ,但也适用于Fortran 90),Cl。 3.3.2.4自由格式语句的继续:
<1>字符&用于表示语句在下一行不是注释行。 [b]
2如果要继续使用非字符上下文,则&应该是行上的最后一个非空字符,或最后一个非空字符在!之前。 [...]
I need to work on Fortran90 code on my Macbook Pro, which was written on Microsoft Developer Tools years ago. As a free option, I have installed gfortran
on my Macbook to be able to compile it. The original code includes &
continuation character for the long lines but I am not able to use it. Without &
character, everything works fine. What might be the problem? Do I need to activate something to be able to use &
character?
For example, I think something like this should work:
x = 1
y = 2
z = x+
&y
end
But instead, I am having this error. It might be end of line error. How can I solve it?
3:72: Error: Syntax error in expression at (1)
4:9: Error: Invalid character in name at (1)
In free-form Fortran, the line continuation character (&
) at the end of the line to be continued. Your code should read:
program test
x = 1
y = 2
z = x+ &
y
end program
This is stated in the Fortran Standard (here: 2008, but applicable as well for Fortran 90), Cl. 3.3.2.4 "Free form statement continuation":
1 The character "&" is used to indicate that the statement is continued on the next line that is not a comment line. [...]
2 If a noncharacter context is to be continued, an "&" shall be the last nonblank character on the line, or the last nonblank character before an "!". [...]
这篇关于继续在gfortran 5.2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!