Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

fortran

This is the program I compile on ubuntu 14.04 using

f95 First.f -o First 

and the program is

!My first program program first print *,'This is my first program' end program first 

And I get the following error

Error:Non-numeric character at statement label at (1) First.f:2.1:  program first 

How do you address this error?

like image 383
Chikorita Rai Avatar asked Nov 12 '14 13:11

Chikorita Rai


2 Answers

Rename your file from First.f to First.f90.

You have encountered an issue which is easily avoided. Compilers generally assume that .f files are written in what is known as fixed source form, which has been obsolescent since Fortran 90. With the .f90 suffix your compiler should expect to encounter free source form and not complain as it has done. In fixed source form, cols 1-6 in each line are reserved for a (numeric) statement label.

Now, use your favorite Fortran resources to understand, if you care, the differences between the two source forms.

like image 168
High Performance Mark Avatar answered Sep 22 '22 14:09

High Performance Mark


As the other answer mentions, free source form is a great idea, but

If for some reason you have to keep the program in fixed source form, then leave 6 spaces (first 6 columns) and start from the 7th column.

The format had the first five columns reserved for statement labels. The first column was used to denote comments by a letter C. The sixth column was used to denote a statement continuation (by inserting any character other than a zero '0'). The last 8 columns were used for card identification and sequencing, which was pretty valuable if you dropped your deck of cards on the floor! The character coding for punched cards had only a limited set of characters and was upper case only.

For this reason, the compiler expects numerical statement labels or blank space for the first 6 columns. Error:Non-numeric character at statement label at (1) is the result of this.

Source


TLDR: if you must use fixed source form (.f extension) leave 6 blank spaces and start from the 7th column like this :

      program first       print *,'This is my first program'       end program first 
like image 30
Shriraj Hegde Avatar answered Sep 21 '22 14:09

Shriraj Hegde