COMPILING AND RUNNING
Getting answers from a Fortran code is a two-step process. First, the source code must compile be compiled to generate a version in machine language. This step is where most of the programming errors will be found (but not all of them). Once a compiled version of the code, known as an executable, exists, then it can be run to obtain the code results. Typically the code is compiled once, and then the executable is run multiple times to generate results from the compiled code. For example, in many commercial codes, only an executable version of the code will be provided.
Compilers can be found for free or for purchase on the internet. The website http://gcc.gnu.org/fortran/ has Fortran 95/2003/2008, as well as Fortran 77 and Fortran 90 compilers for free.
HOW TO COMPILE A FORTRAN PROGRAM
The compile command has the form:
Consider using GNU Fortran 90 to compile your source code that you named test.F:
will generate an executable code named a.out. a.out is the default executable name. The compiler option, -o < filename > can be invoked to rename the executable. Some useful, generic compiler options are included in Table 2↓, but one should look at the documentation for the compiler that is used.
<compile command> [options] <yoursourcecodename>
Consider using GNU Fortran 90 to compile your source code that you named test.F:
gfortran test.F
will generate an executable code named a.out. a.out is the default executable name. The compiler option, -o < filename > can be invoked to rename the executable. Some useful, generic compiler options are included in Table 2↓, but one should look at the documentation for the compiler that is used.
Compilers typically can handle various versions of Fortran source files, and can be linked with routines written in C (for example for faster file input/output, known as I/O). The Fortran type is denoted via the file suffix. A few of the more well-known file formats are provided in Table 3↓.