HP Fortran Programmer's Guide (September 2007)

Performance and optimization
Using options to control optimization
Chapter 6144
Using options to control optimization
HP Fortran includes a rich set of command-line options for controlling optimization. For most
applications, we recommend optimizing with -O, which enables the default level of
optimization. (For information about the default level of optimization, refer to Table on
page 145; look up +O2 in the first column.) You can raise or lower the level of optimization
with the +O
opt-level
option, and you can use the +O
optimization
option to control the
kinds of optimizations that are available at each level.
The following sections describe how to use the +O
opt-level
and +O
optimization
options.
For detailed descriptions of the optimization options, see the HP Fortran Programmer’s
Reference.
Using +O to set optimization levels
HP Fortran provides four levels of optimization. Each higher level is a superset of the lower
levels; level 4 is the highest level and can result in a significant increase in program
performance. Level 2 is the default level of optimization.
You invoke optimization by compiling with the +O
opt-level
option, where
opt-level
is an
integer in the range 0 - 4. The following command line invokes the optimizer at the highest
level:
$ f90 +O4
file
.f90
You can invoke level 2 (the default level) by specifying the -O option.
Table 6-1 summarizes each level, giving the option that invokes that level, the advantages,
disadvantages, and recommended usages. For technical information about the specific
optimizations at each level, refer to the HP PA-RISC Compiler Optimization Technology White
Paper. A PostScript version of this document is available online in
/opt/langtools/newconfig/white_papers/optimize.ps.
NOTE You can debug programs optimized up to level 2. To prepare an optimized
program for debugging, use the command line:
$ f90 -g +O
opt-level
prog.f90