Showing posts with label GNU Fortran. Show all posts
Showing posts with label GNU Fortran. Show all posts

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)

OS X: GNU Fortran

Command:

$ brew install gfortran


Result:

Error: No available formula with the name "gfortran" 
GNU Fortran is now provided as part of GCC, and can be installed with:
  brew install gcc


Command:

$ gfortran --version


Result:

GNU Fortran (Homebrew gcc 5.3.0) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING