Fortran What are common errors when compiling a simple Fortran code?

  • Thread starter Thread starter MathematicalPhysicist
  • Start date Start date
  • Tags Tags
    Gfortran Teaching
AI Thread Summary
The user encountered compilation errors while trying to compile a Fortran program on an Ubuntu machine using gfortran. The code, saved as 'calculation.f', resulted in multiple errors indicating non-numeric characters and unclassifiable statements. The solution provided suggests that the issue arose from using the wrong file extension; since the code is in free form, it should be saved with a .f90 extension instead of .f. Changing the file extension resolved the compilation errors.
MathematicalPhysicist
Science Advisor
Gold Member
Messages
4,662
Reaction score
372
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
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.
 
Works fine now.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
25
Views
3K
Replies
5
Views
2K
Replies
17
Views
6K
Replies
5
Views
5K
Replies
16
Views
2K
Back
Top