HP Fortran Programmer Guide (766160-001, March 2014)

9 Using Fortran directives
Compiler directives are commands within the source program that affect how the program is
compiled. They are similar in function to command-line options, but generally provide more local
control. The directives provided by HP Fortran use a syntax that causes them to be treated as
comments (and so ignored) when ported to another processor or when incorrectly formatted. The
following sections describe the HP Fortran directives. HP Fortran also recognizes C Preprocessor
(cpp) directives. If you compile with the +cpp=yesoption or if the name of the source ends in the
.Fextension, the source files are first passed to the C preprocessor for processing. For information
about the C preprocessor, refer to cpp((1)).
Directive syntax
The syntax for specifying directives in HP Fortran source files varies according to the type of
directive:
C preprocessor directives take the form:
#[line]cpp-directive
wherecpp-directive is ANSI C-conforming except that the linekeyword is optional, making
it compatible with the HP C compiler.
HP Fortran compiler directives take the form:
comment-character $HP$ directive-name
where is comment-character! in free-source format or C, !, or * in fixed-source format; and
directive-nameis one of the directives described in this chapter.
There must be no space between comment-characterand $HP$. In fixed-source format,
comment-charactermust be in column 1.
Using HP Fortran directives
HP Fortran provides a number of compiler directives that are useful for controlling certain functions
(for example, optimization) within the source file. Table 9-1 lists and briefly describes these
directives; they are listed in the order in which they appear in the sections below.
Table 35 Table 9-1 HP Fortran directives
FunctionDirective
Associates the name of a subroutine, function, entry, or common block
with an external name.
$HP$ ALIAS
Generates code to trap integer overflows.$HP$ CHECK_OVERFLOW
Controls output of source lines in listing file.$HP$ LIST
Controls optimization within the source file.$HP$ OPTIMIZE
Passes on to the compiler an estimate of how frequently the current
block is executed.
If the current block is an 'if' block, then 'f' must be 0&lt = f &lt = 1. In
this case, 'f' indicates the probability of executing this block compared
$HP$ ESTIMATED FREQUENCY
to the corresponding 'if' block. If the current block is a loop, then 'f'
must be f&gt= 0. In this case, 'f' indicates the number of times the loop
might get executed (trip count).
NOTE: For a detailed description of Optimization directives, Parallelizing directives, OpenMP
directives and Data privatization directives, see Parallel Programming Guide for HP-UX Systems.
Directive syntax 123