fpp
command line
fpp
fpp
options
fpp
diagnostics
fpp
— the Fortran language preprocessor for the NAG Fortran compiler.
fpp
command linefpp [option]... [input-file [output-file]]
fpp
fpp is the preprocessor used by the NAG Fortran compiler. It optionally accepts two filenames as arguments: input-file and output-file are, respectively, the input file read and the output file written by the preprocessor. By default standard input and output are used.
When used via nagfor
, either because the input source file type was
automatically recognised as requiring preprocessing (e.g. .ff90
files),
or the -fpp option was used, the macro
__NAG_COMPILER_RELEASE
is automatically defined to be the integer
release number (major*10+minor, e.g. 61
for release 6.1), and the
macro __NAG_COMPILER_BUILD
is automatically defined to be the build
number (for release 6.1 this will have a value greater than 6100
).
fpp
options
1
(one).
This is the same as if a -Dname=1 option appeared on the fpp
command line, or as if a
#define
name 1
#define
directive.
This is the same as if a
#define
name def
#include
files whose names do not begin with
‘/
’.
If the #include
file name is enclosed in double-quotes
("..."
), it is searched for first in the directory of the file
with the #include
line; if the file name was enclosed in
angle brackets (<...>
) this directory is not searched.
Then, the file is searched for in directories named in -I
options, and finally in directories from the standard list.
#
line-number file-name
Operating System:
unix
, __unix
and __SVR4
;
Hardware:
sun
, __sun
, sparc
and __sparc
.
#include
files.
.f
’,
‘.ff
’, ‘.for
’ or ‘.ftn
’ are assumed
to be fixed form source files.
All other files (e.g. those with the extension ‘.ff90
’) are
assumed to be free form source files.
These assumptions can be overridden by the -fixed and
-free options.
Tab format lines are recognised in fixed form.
A source file may contain fpp tokens. An fpp token is similar to a Fortran token, and is one of:
#
line-number file-name
#
) as the
first character on a line.
Blank and tab characters may appear after the initial ‘#
’
to indent the directive.
The directives are divided into the following groups:
#define
directive is used to define both simple string
variables and more complicated macros:
#define
name token-string
This is the definition of an fpp variable. Wherever ‘name’ appears in the source lines following the definition, ‘token-string’ will be substituted for it.
#define
name([argname1[,argname2]...]) token-string
This is the definition of a function-like macro. Occurrences of the macro ‘name’ followed by a comma-separated list of arguments within parentheses are substituted by the token string produced from the macro definition. Every occurrence of an argument name from the macro definition's argument list is substituted by the token sequence of the corresponding macro actual argument.
Note that there must be no space or tab between the macro name and the left parenthesis of the argument list in this directive; otherwise, it will be interpreted as a simple macro definition with the left parenthesis treated as the first character of the replacement token-string.
#undef
name
Remove any macro definition for name, whether such a definition was
produced by a -D option, a #define
directive or
by default.
No additional tokens are permitted on the directive line after the name.
The macro NAGFOR is defined by default.
#include "
filename"
#include <
filename>
Read in the contents of filename at this location. The lines read in from the file are processed by fpp as if they were part of the current file.
When the <
filename>
notation is used, filename is only
searched for in the standard “include” directories.
See the -I and -Y options above for more
detail.
No additional tokens are permitted in the directive line after the final
‘"
’ or ‘>
’.
#
line-number
["
filename"
]
Generate line control information for the next pass of the compiler.
The line-number must be an unsigned integer literal constant, and
specifies the line number of the following line.
If "
filename"
does not appear, the current filename is
unchanged.
#if condition_1 block_1 #elif condition_2 block_2 #else block_n #endif
#ifdef name block_1 #elif condition block_2 #else block_n #endif
#ifndef name block_1 #elif condition block_2 #else block_n #endif
The “#else” and “#elif” parts are optional.
There may be more than one “#elif” part.
Each condition is an expression consisting of fpp constants, macros and
macro functions.
Condition expressions are similar to cpp expressions, and may
contain any cpp operations and operands with the exception
of C long, octal and hexadecimal constants.
Additionally, fpp will accept and evaluate the Fortran logical operations
.NOT.
, .AND.
, .OR.
, .EQV.
, .NEQV.
,
the relational operators .GT.
, .LT.
, .LE.
, .GE.
,
and the logical constants .TRUE.
and .FALSE.
.
#include
d files) from that
definition line to the end of the current file.
However, it does not affect:
INCLUDE
lines;
IMPLICIT
single letter specifications;
FORMAT
statements;
The scope of the macro effect can be limited by means
of the #undef
directive.
For example:
#define long_macro_name(x,\ y) x*y
#undef
name
After this directive, ‘name’ will not be interpreted by fpp as a macro or variable name. This directive has no effect if ‘name’ is not a macro name.
#if
condition
Condition is a constant expression, as specified below.
Subsequent lines up to the first matching #elif
, #else
or
#endif
directive appear in the output only if
the condition is true.
The lines following a #elif
directive appear
in the output only if
#if
directive was false,
#elif
directives were false, and
#elif
directive is true.
If the condition is true, all subsequent matching #elif
and #else
directives are ignored up to the matching #endif
.
The lines following a #else
directive appear in the output only if
all previous conditions in the construct were false.
The macro function ‘defined’ can be used in a constant expression; it is true if and only if its argument is a defined macro name.
The following operations are allowed.
<
, >
, ==
, !=
, >=
,
<=
, +
, -
, /
, *
, %
, <<
,
>>
, &
, ~
, |
, !
, &&
and ||
.
These are interpreted in accordance with
C language semantics, for compatibility with cpp.
.AND.
, .OR.
, .NEQV.
,
.XOR.
, .EQV.
, .NOT.
, .GT.
, .LT.
,
.LE.
, .GE.
, .NE.
, .EQ.
and **
.
.TRUE.
and .FALSE.
.
!=
’ (not equal) can be used in #if
or
#elif
directives, but cannot be used in a #define
directive,
where the character ‘!
’ is interpreted as the start of
a Fortran comment.
#ifdef
name#ifndef
name#elif
constant-expression#else
#else
and the matching #endif
are ignored.
If the preceding conditional indicates that lines would
be ignored, subsequent lines are included in the output.
for #include "
filename"
:
#include <
filename>
:
#
character)
can be placed anywhere in the source code,
in particular immediately before a Fortran continuation line.
The only exception is the prohibition of fpp
directives within a macro call divided on several lines by means
of continuation symbols.
C
’, ‘c
’, ‘*
’,
‘d
’ or ‘D
’ in the first column
is considered to be a comment line.
Within such lines macro expansions are not performed.
The ‘!
’ character is interpreted as the beginning of a
comment extending to the end of the line. The only exception
is the case when this symbol occurs within a
constant expression in a #if
or #elif
directive.
/*
’ and ‘*/
’
character sequences.
These are excluded from the output.
Fpp comments can be nested so that for each opening sequence ‘/*
’
there must be a corresponding closing sequence ‘*/
’.
Fpp comments are suitable for excluding the compilation of
large portions of source instead of commenting every line
with Fortran comment symbols.
Using “#if 0 ... #endif
” achieves the same effect without
being ridiculous.
defined
(name) or defined
name
expands to .TRUE.
if name is defined as a macro,
and to .FALSE.
otherwise.
In fixed form there are limitations on macro expansion in the label part of the line (columns 1-5):
#define call p(x) call f(x) call p(0)
fpp can not determine with certainty how to interpret the ‘call p’ token sequence. It could be considered as a macro name. The current implementation does the following:
warning: possibly incorrect substitution of macro callp
It should be noted that this situation appears only when preprocessing fixed form source code and when the blank character is not being interpreted as a token delimiter. It should be said also that if a macro name coincides with a keyword beginning part, as in the following case:
#define INT INTEGER*8 INTEGER kthen in accordance with the described algorithm, the INTEGER keyword will be found earlier than the INT macro name. Thus, there will be no warning when preprocessing such a macro definition.
fpp
diagnosticsThere are three kinds of diagnostic messages:
nagfor(1).