What are common errors when compiling a simple Fortran code?

In summary, the conversation discusses an issue with compiling a simple Fortran code on an Ubuntu machine. The user had saved the code as a .f file instead of .f90, causing errors to occur during compilation. After changing the file extension, the code compiled successfully.
  • #1
MathematicalPhysicist
Gold Member
4,695
373
So I have a Ubuntu machine with gfortran installed in it.

I wrote the following simple code in fortran:
Fortran:
program calculation
   print *, 55+55
end program calculation
I saved it as 'calculation.f' file and then tried to compile it in the terminal, but got the following errors:
Code:
calculation.f:1:1:

 program calculation
 1
Error: Non-numeric character in statement label at (1)
calculation.f:1:1:

 program calculation
 1
Error: Unclassifiable statement at (1)
calculation.f:3:1:

 end program calculation
 1
Error: Non-numeric character in statement label at (1)
calculation.f:3:1:

 end program calculation
 1
Error: Unclassifiable statement at (1)
f951: Error: Unexpected end of file in ‘calculation.f’
Where did I go wrong here?

Thanks.
 
Technology news on Phys.org
  • #2
You didn't paste the error you got, but I suspect what it is. Since you are using free form, not the fixed column format (left over from the punch card era), the filename should end in .f90 instead of .f.
 
  • #3
Works fine now.
 

Similar threads

Replies
25
Views
2K
Replies
5
Views
1K
Replies
3
Views
1K
Replies
4
Views
2K
Replies
17
Views
5K
Replies
5
Views
4K
Replies
2
Views
7K
Replies
16
Views
2K
Back
Top