Fortran
Portland Group Fortran
As on other Cray systems, the ftn command will automatically link against MPI (-lmpi) and SciLib
(-lsci), so you don’t have to.
To build Fortran code for the Linux service nodes, you can call the PGI compilers directly. We strongly suggest that you don’t call the PGI compilers directly if you are building code to run on the compute nodes.
Recent PGI Fortran compilers have three commands:
-
pgf77: Fortran 77 compiler
-
pgf90: Fortran 90/95 compiler (alias for
pgf95) -
pgf95: Fortran 90/95 compiler
while the PGI 5.2-4 compiler only has pgf77 and pgf90 commands.
Fortran Options
General
The following options control how source files are translated into machine code.
| Option | Description |
|---|---|
| -M fixed | The source code uses fixed-form syntax, as in Fortran 77. This option is on by default for source files ending in .f, .F, .for, and .fpp. |
| -M free | The source code uses free-form syntax, introduced in Fortran 90. This option is on by default for source files ending in .f90, .F90, .f95, .F95. |
| -F | This option preprocesses each file and leaves the output in a file named file.f for each file named file.F. |
| -i8 | This option treats INTEGER variables as 8 bytes.For operations involving integers, uses 64 bits for computations. |
| -r8 | This option interprets REAL variables as DOUBLE PRECISION.Equivalent to using the options -Mr8 and -Mr8intrinsics. |
Debugging
The following options control the amount of debugging information generated by the compiler. They can adversely affect optimization.
| Option | Description |
|---|---|
| -g | Generates symbolic debugging information. Turns off optimization. |
| -Mbounds | Adds array bound checking. |
| -Mchkptr | Checks for unintended dereferencing of null pointers. |
Optimization
For most cases, the usual levels of optimization are appropriate (-O0, -O1, -O2 [default], -O3). Here are a few exceptions.
| Option | Description |
|---|---|
| -fast | Chooses generally optimal flags for the target platform. Use pgf90 -fast -help to see the equivalent switches.Note this sets the optimization level to a minimum of 2; see -O. |
| -fastsse | Chooses generally optimal flags for a processor that supports the SSE (Pentium 3/4, AthlonXP/MP, Opteron) and SSE2 (Pentium 4, Opteron) instructions. Use pgf90 -fastsse -help to see the equivalent switches. |
| -Mflushz | Sets SSE to flush-to-zero mode. |
| -pg -ql -Mprof |
Instrument program for profiling. These flags imply different types of profiling. Please check the pgf77 or pgf90 man page. |
| -Minfo | Generates an optimization report to standard error. This has several suboptions, so check the man page. |
| -Mlist | Generates a listing file. |
| -mp | Enables the compiler to generate multithreaded code based on the OpenMP directives. |
Fortran Documentation
See man ftn for use of the ftn command. See man pgf77 or man pgf90 for a full list of compiler options. PDF and HTML documentation is also available online from PGI at http://www.pgroup.com/resources/docs.htm. Documentation is also available from http://docs.cray.com.