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

13,703

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

Share:
13,703
linuxfreebird
Author by

linuxfreebird

Updated on June 12, 2022

Comments

  • linuxfreebird
    linuxfreebird almost 2 years

    I wrote the following two lines in fortran

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

    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
    

    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.