Error: Non-numeric character in statement label at (1)?

前端 未结 1 426
鱼传尺愫
鱼传尺愫 2020-12-11 19:12

I wrote the following two lines in fortran

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

相关标签:
1条回答
  • 2020-12-11 19:25

    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.

    Also,

    REAL H3 = 0
    

    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
    

    (requires Fotran 90), or

      REAL A
      DATA A/0/
    

    (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,...).

    0 讨论(0)
提交回复
热议问题