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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

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