HP Fortran Programmer's Guide (B3908-90031; September 2011)

Porting to HP Fortran
Using porting options
Chapter 11244
Using porting options
HP Fortran provides a number of compile-line options for porting programs. The most important of these is
the +langlvl=90 option. Compiling your program with this option will cause the compiler to issue
warning messages for all nonstandard features.
In addition, HP Fortran includes options that provide compatibility by changing the compilers assumptions
about the program or by causing the compiler to generate code that executes compatibly with the original
implementation. The advantage of using options when porting is that they minimize having to edit and
modify source code.
The following sections describe how options can help when porting programs that contain:
Initialized variables
Data types that are larger than the default sizes of HP Fortran data types
Names that clash with HP-specific intrinsics
Names that end in the underscore character (_)
One-trip DO loops
Different formats
Escape sequences
Uninitialized variables
As noted in “Automatic and static variables” on page 101, the default behavior of HP Fortran is to allocate
storage for program variables from the stack. However, older implementations of Fortran often allocate
static storage for variables. One of the differences between stack storage and static storage is that static
variables are initialized to 0s by the compiler, whereas automatic variables (variables allocated from the
stack) must be explicitly initialized by the programmer.
Programs written for implementations of Fortran that allocate static storage by default sometimes rely on the
compiler to initialize variables. Compiling and executing such programs on implementations that allocate
stack storage can have disastrous results. To make HP Fortran compatible with implementations that allocate
static storage, compile with the +save option. This option causes the compiler to act as though all local
variables had the SAVE attribute.
As mentioned in “Automatic and static variables” on page 101, saving all variables in static storage can
degrade performance. If performance is an issue, consider using the +Oinitcheck option. Unlike the
+save option, +Oinitcheck does not “save” variables—it does not move variables into static storage.