错误:(1) 处的语句标签中的非数字字符? [英] Error: Non-numeric character in statement label at (1)?

查看:18
本文介绍了错误:(1) 处的语句标签中的非数字字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用fortran写了以下两行

I wrote the following two lines in fortran

C23456789
    REAL H3 = 0                                                       
    H3=H*H*H  

我从 gdb 收到以下错误:

and I received the following errors from gdb :

ljmd.f:186.5:

    REAL H3 = 0                                                         
     1
Error: Non-numeric character in statement label at (1)
ljmd.f:187.5:

    H3=H*H*H                                                            
     1
Error: Non-numeric character in statement label at (1)
ljmd.f:187.6:

    H3=H*H*H                                                            
      1

在别人的 fortran 程序中创建和使用新变量的正确方法是什么?C23456789 是我在程序中使用的当前列的标签.

What is the proper way to create and use new variables in the middle of someone else's fortran program? C23456789 is my label of the current column used in the program.

推荐答案

这是在任何随机的 Fortran 教程中.我希望你有固定的来源表格.那么任何语句必须从第 7 列或更远的列开始.

This is in any random Fortran tutorial. I expect you have the fixed source form. Then any statement must start at column 7 or farther.

还有,

REAL H3 = 0

在自由形式的源 Fortran 中是不合法的,并且以固定形式做完全不同的事情(请参阅@francesalus 的评论).在您的情况下,根本没有理由初始化变量.你可以这样做

isn't legal in free form source Fortran and does a completely different thing in fixed form (see @francesalus' comment). And in your case there is no reason to initialize the variable at all. You can just do

  REAL H3
  H3 = H**3

如果您碰巧需要在其他地方进行初始化,则必须使用

If you happen to need the initialization somewhere else, you either must use

  real :: a = 0

(需要 Fotran 90),或

(requires Fotran 90), or

  REAL A
  DATA A/0/

(在 Fortran77 中).请注意,这两个版本都会生成变量 SAVE,您可能在其他语言中将其称为 static.

(in Fortran77). Beware, both version make the variable SAVE which you may know as static from other languages.

最后一点,你不能在程序中间"的任何地方引入变量,变量的声明在每个编译单元(程序、函数、子程序……)的开头都有它们的位置.

The last point, you cannot introduce variables anywhere "in the middle of program", the declaration of variables have their place at the beginning of each compilation unit (program, function, subroutine,...).

这篇关于错误:(1) 处的语句标签中的非数字字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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