Intel® Fortran Compiler 16.0 User and Reference Guide

Using the fpp Preprocessor

The Fortran compiler preprocessor, fpp, is provided as part of the Intel® Fortran product. When you use a preprocessor for Intel® Fortran source files, the generated output files are used as input source files by the Compiler.

Preprocessing performs such tasks as preprocessor symbol (macro) substitution, conditional compilation, and file inclusion. Intel Fortran predefined symbols are described in Using Predefined Preprocessor Symbols.

fpp has some of the capabilities of the ANSI C preprocessor and supports a similar set of directives. Directives must begin in column 1 of any Fortran source files. Preprocessor directives are not part of the Fortran language and not subject to the rules for Fortran statements. Syntax for directives is based on that of the C preprocessor.

The compiler includes a limited conditional compilation capability, based on directives, that does not require use of fpp. The IF directive construct provides the capability of limited conditional compilation.

Note that you can also specify an alternate Fortran preprocessor instead of the Intel® Fortran fpp preprocessor. For more information, see option fpp-name.

Automatic Preprocessing by the Compiler

By default, the preprocessor is not run on files before compilation. However, the Intel Fortran compiler automatically calls fpp when compiling source files that have the .fpp, .F, .F90, .FOR, .FTN, or .FPP. For example, the following command preprocesses a source file that contains fpp preprocessor directives, then passes the preprocessed file to the compiler and linker:

ifort source.fpp

If you want to preprocess files that have other Fortran extensions than those listed, you have to explicitly specify the preprocessor with the fpp compiler option.

The fpp preprocessor can process both free- and fixed-form Fortran source files. By default, filenames with the suffix of .F, .f, .for, or .fpp are assumed to be in fixed form. Filenames with a suffix of .F90 or .f90 (or any other suffix not specifically mentioned here) are assumed to be free form. You can use the free compiler option to specify free form and the fixed compiler option to explicitly specify fixed form.

The fpp preprocessor recognizes tab format in a source line in fixed form.

Running fpp to Preprocess Files

You can explicitly run fpp in these ways:

The following lists some common cpp features that are supported by fpp; it also shows common cpp features that are not supported.

Supported cpp features:

Unsupported cpp features:

#define, #undef, #ifdef, #ifndef, #if, #elif, #else, #endif, #include, #error, #warning, #line

#pragma and #ident

# (stringsize) and ## (concatenation) operators

spaces or tab characters preceding the initial "#" character

# followed by empty line

! as negation operator

\ backslash-newline

Unlike cpp, fpp does not merge continued lines into a single line when possible.

You do not usually need to specify preprocessing for Fortran source programs unless your program uses fpp preprocessing commands, such as those listed above.

Caution

Using a preprocessor that does not support Fortran can damage your Fortran code, especially with "FORMAT (\\I4)" with cpp changes the meaning of the program because the double backslash "\\" indicates end-of-record with most C/C++ preprocessors.

fpp Source Files

A source file can contain fpp tokens in the following forms:

A string that is a token can occupy several lines, but only if its input includes continued line characters using the Fortran continuation character &. fpp will not merge such lines into one line.

Identifiers are always placed on one line by fpp. For example, if an input identifier occupies several lines, it will be merged by fpp into one line.

fpp Output

Output consists of a modified copy of the input, plus lines of the form:

#line_number  file_name

These are inserted to indicate the original source line number and filename of the output line that follows. Use the fpp P preprocessor option to disable the generation of these lines.

Diagnostics

There are three kinds of fpp diagnostic messages:

The messages produced by fpp are intended to be self-explanatory. The line number and filename where the error occurred are displayed along with the diagnostic on stderr.

See Also