Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

fortran

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.

like image 222
linuxfreebird Avatar asked May 29 '14 19:05

linuxfreebird


Video Answer


1 Answers

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

like image 164
Vladimir F Героям слава Avatar answered Sep 21 '22 14:09

Vladimir F Героям слава