33

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?

2 Answers 2

42

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.

1
  • 1
    I'm trying to teach myself Fortran using gfortran-9 and the recent 2018 standard. Is there an extension specific to each Fortran standard?
    – user7851115
    Oct 21, 2019 at 18:42
4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.