FORTRAN

Cray Fortran

The Fortran compiler on Phoenix is Cray Fortran. It supports the Fortran 95 standard and some features of Fortran 2003. Unlike other Fortran compilers that have multiple commands (e.g., f77, f90), the Cray compiler has only one command.

As on other Cray systems, the ftn command will automatically link against MPI (-lmpi) and SciLib (-lsci), so you don’t have to.

Fortran Options

General

The following options control how source files are translated into machine code:

Option Description
-O SSP Creates an executable to run in single-streaming mode.
-O MSP Creates an executable to run in multistreaming mode. This is the default.
-O command Creates an executable to run serially on a support node (login node).
-f 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, .f77, and .F77.
-f 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, .ftn, .FTN.
-F Enables preprocessor macros to be expanded throughout the file. By default, macros are expanded only on lines with preprocessor directives (lines starting with “#”).
-s default64 Makes the default size of variables the same as for previous generations of Cray systems, 8 bytes for all but double precision. Without this option, the default size of these variables is 4 bytes, as on most non-Cray systems.
-s real64 Makes the default size of real variables 8 bytes for all but double precision. Without this option, the default size of these variables is 4 bytes, as on most non-Cray systems.
-d p Disables double precision, which can be turned off only when the default data size is 64 bits (via -s default64 or -s real64). Often used in conjunction with -s default64 and/or -s real64.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Debugging

The following options control the amount of debugging information generated by the compiler. They can adversely affect optimization.

Option Description
-g Generate symbolic debug information. Turns off optimization.
-G1 Block-level debugging. Limits optimization.
-G2 Post-mortem (core file) debugging. Allows most optimization.

 

 

 

 

Optimization

For most cases, the usual levels of optimization are appropriate (-O0,
-O1, -O2 [default], -O3). Here are a few exceptions.

Option Description
-rm Generates a loopmark listing. The listing appears in a file with the suffix .lst. Loopmarks illustrate where optimization did and did not occur and why.
-Omodinline Allows procedures in modules to be in-lined into procedures that use those modules. In-lining can be critical for vectorization. This option is the default for compiler versions 5.2 and beyond.
-Ogen_private_callee Generates the code necessary to call each procedure from within a stream. With this option, the procedures may be called as usual or from within a multistreamed region.
-Otask0 This option ensures that the compiler does not try to use OpenMP parallelism. This option is good for safety.
-Z Compiles Co-Array Fortran.

 

 

 

 

 

 

 

 

 

 

 

Profiling

On many systems you must specify compiler options to create an executable that provides profiling data. On Phoenix you instead instrument an existing executable using the pat_build tool as follows:

pat_build <original_executable> <instrumented_executable>

You then run the instrumented executable, which produces a .xf file. Use pat_report to generate a profile.

pat_report <file>.xf

See man pat_build and man pat_report for more information on the types of profiles you can produce.

Fortran Documentation

See \\man ftn for a full list of compiler options. PDF and HTML documentation is also available online from Cray at the following URL.

http://docs.cray.com/

In particular, see the following documents:

  • Optimizing Applications on the Cray X1 Series Systems
  • Fortran Language Reference Manual, Volume 1
  • Fortran Language Reference Manual, Volume 2
  • Fortran Language Reference Manual, Volume 3
  • Cray Fortran Compiler Commands and Directives Reference Manual