Fortran FORMAT 语句中的语法错误 [英] Syntax error in a Fortran FORMAT statement

查看:64
本文介绍了Fortran FORMAT 语句中的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 gfortran 编译器,但找不到语法错误在行中.谁能告诉我给定行中的语法错误?

I am using the gfortran compiler and I am unable to find the syntax error in the line. Can anyone tell me the syntax error in the given line?

7 FORMAT(1X, 'a=',F8.8, 1X,'b=',F8.8, 2X, 'REAL=',F8.5, 2X, 'IMAG=',F8.5, 2X, 'k1=',F8.8, 2X, 'LDF=',F8.8)

推荐答案

我认为你的问题源于格式语句太长.我刚刚运行了一个简短的 f77 文件,并在文件中放置了一个长度超过 72 个空格的格式语句.这会生成一条错误消息,并表示格式语句太长.我建议你把那条线分开,第二半在下一行.当您这样做时,在第 6 列中放置一个字符以向编译器表明它是一个续行.现在你的格式声明应该是这样的:

I think your problem stems from the fact that the format statement is too long. I just ran a short f77 file and I put a format statement in the file that was longer than 72 spaces. This generated an error message and said the format statement was too long. I suggest you split that line with 2nd half being on the next line. When you do that put a character in column 6 to indicate to compiler that its a continuation line. Now your format statement should look like this:

7  FORMAT(1X, 'a=',F8.8, 1X,'b=',F8.8, 2X, 'REAL=',F8.5, 2X, 
  >      'IMAG=',F8.5, 2X, 'k1=',F8.8, 2X, 'LDF=',F8.8)

注意 '>' 字符必须在第 6 列中..

Notice the '>' character must be in column 6..

如果您的编辑器没有指明列号,请在您的代码中键入如下所示的一行:

If your editor doesn't indicate column number then type a line in your code that looks like this:

C123456789012345678901234567890123456789012345678901234567890

C123456789012345678901234567890123456789012345678901234567890

您可以使用它来确定列.另请注意,C 必须在第 1 列中,因为这表明该行是注释,编译器不会尝试编译它.

you can use this to determine columns. Also notice that the C must be in column 1 because that indicates that the line is a comment and the compiler won't try to compile it.

这篇关于Fortran FORMAT 语句中的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆