Wednesday, September 7, 2016

GNU Fortran: Hello World

Command:

$ cat myfile.f90

program hello
print *, "Hello World!"
end program hello


Result:

$ gfortran myfile.f90 -o myfile

$ ./myfile
 Hello World!


Syntax error because of the file extension


Command:

$ cat myfile.f


Result:

program hello
print *, "Hello World!"
end program hello


Command:

$ gfortran myfile.f -o myfile


Result:

myfile.f:1:1:

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

 program hello
 1
Error: Unclassifiable statement at (1)
myfile.f:2:1:

 print *, "Hello World!"
 1
Error: Non-numeric character in statement label at (1)
myfile.f:2:1:

 print *, "Hello World!"
 1
Error: Unclassifiable statement at (1)
myfile.f:3:1:

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

 end program hello
 1
Error: Unclassifiable statement at (1)