Visible to Intel only — GUID: GUID-30F016DD-25AC-4BF8-ABE5-7AA00DCB11A5
Visible to Intel only — GUID: GUID-30F016DD-25AC-4BF8-ABE5-7AA00DCB11A5
fpp Preprocessing
The Intel® Fortran Compiler includes the preprocessor fpp. 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 tasks such as preprocessor symbol (macro) substitution, conditional compilation, and file inclusion. Intel® Fortran predefined symbols are described in topic Predefined Preprocessor Symbols.
fpp has some of the capabilities of the ANSI C preprocessor and supports a similar set of preprocessor directives. Preprocessor directives can begin in any column of a Fortran source file. Preprocessor directives are not part of the Fortran language and not subject to the rules for Fortran statements. Syntax for preprocessor 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 fpp preprocessor. For more information, see compiler 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 file extension .FPP, .fpp, .F, .F90, .FOR, or .FTN on Linux, and file extension .fpp on Windows.
For example, the following command preprocesses a source file that contains fpp preprocessor directives, then passes the preprocessed file to the compiler and linker:
ifx source.fpp
If you want to preprocess files that have other Fortran extensions than those listed, you have to explicitly specify the preprocessor by using compiler option fpp.
The fpp preprocessor can process both free-format and fixed-format Fortran source files. By default, file names with the extension .f or .F, .for or .FOR, .ftn or .FTN, and .fpp or .FPP are assumed to be fixed format. File names with a suffix of .F90 or .f90 (or any other suffix not specifically mentioned here) are assumed to be free format. You can explicitly indicate free format by specifying compiler option free. You can explicitly indicate fixed format by specifying compiler option fixed.
The fpp preprocessor recognizes tab format in a source line in fixed form.
Run fpp to Preprocess Files
You can explicitly run fpp in the following ways:
On the command line, use the ifx or ifort command with the fpp compiler option. By default, the specified files are then compiled and linked. To retain the intermediate (.i or .i90) file, specify the [Q]save-temps compiler option.
On the command line, use the fpp command. In this case, the compiler is not invoked. When using fpp on the command line, you need to specify the input file and the intermediate (.i or .i90) output file. For more information, type fpp -help (Linux) or fpp /help (Windows) on the command line.
In the Microsoft Visual Studio* IDE, set the Preprocess Source File option to Yes in the Fortran Preprocessor Option Category. To retain the intermediate files, add /Qsave-temps to Additional Options in the Fortran Command Line Category.
The following table lists some common cpp features that are supported by fpp and some 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.
Using a preprocessor that does not support Fortran can damage your Fortran code.
For example, consider the following code:
FORMAT (\\I4)
In this case, most C++ and C preprocessors will change the meaning of the program by interpreting the double backslash "\\" as end-of-record.
fpp Source Files
A source file can contain fpp tokens in the following forms:
fpp preprocessor directive names
For more information on fpp preprocessor directives, see topic fpp Preprocessor Directives.
Symbolic names
fpp permits the same characters in names as Fortran. For more information on symbolic names, see topic Predefined Preprocessor Symbols.
Constants
Integer, real, double, and quadruple precision real, binary, octal, hexadecimal (including alternate notation), character, and Hollerith constants are allowed.
Special characters, space, tab, and newline characters
Fortran language comments
A fixed-form source line containing one of the symbols C, c, *, d, or D in the first position is considered a comment line.
The ! symbol is interpreted as the beginning of a comment extending to the end of the line, except when the ! occurs within a constant-expression in an #if or #elif directive. Within such comments, macro expansions are not performed, but they can be switched ON by specifying -f-com=no.
fpp comments
These comments appear between symbols /* and */. They are excluded from the output and macro expansions are not performed within these symbols. fpp comments can be nested: for each /* there must be a corresponding */.
fpp comments are useful for excluding from the compilation large portions of source instead of commenting every line with a Fortran comment symbol.
C++-like line comments
These comments begin with symbol // (double-slash)
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.
fpp always places identifiers on one line. 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 following form:
#line_number file_name
These lines indicate the original source line number and file name of the output line that follows. Use the fpp preprocessor option P to disable the generation of these lines.
Diagnostics
There are three kinds of fpp diagnostic messages:
Warnings
fpp preprocessing continues but the return value is set to zero.
Errors
fpp preprocessing continues but the return value is set to a nonzero value indicating the number of errors.
Fatal errors
fpp stops preprocessing and returns a nonzero value.
The messages produced by fpp are intended to be self-explanatory. The line number and file name where the error occurred are displayed along with the diagnostic on stderr.