Compiling Fortran Program

First, make sure you have installed the gcc compiler. Then create a new file, called helloworld.f:

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

To compile the program, run the following command:

gfortran48 --free-form -Wl,-rpath=/usr/local/lib/gcc48 helloworld.f -o helloworld

To run the program, run:

./helloworld

Note: Note: If you use the .f90 file extension, you can omit the —free-form option.

Sources:
1. https://en.wikibooks.org/wiki/Fortran/Hello_world
2. https://lists.freebsd.org/pipermail/freebsd-current/2012-November/037865.html
3. https://gcc.gnu.org/ml/gcc-help/2005-12/msg00017.html
4. https://en.wikibooks.org/wiki/Fortran/Beginning_Fortran#Free_Form_and_Fixed_Form
5. https://gcc.gnu.org/wiki/GFortranGettingStarted

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License