HP Fortran Programmer's Guide (March 2010)
Porting to HP Fortran
Using porting options
Chapter 11 253
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. Instead, it causes the compiler to search for all local, nonarray,
nonstatic variables that have not been defined before being used. Any that it finds are
initialized to 0 on the stack each time the procedure in which they are declared is invoked.
For detailed information about the +save and +Oinitcheck options, see
HP Fortran Programmer’s Reference.
Large word size
The word size of default integers, reals, and logicals in HP Fortran is 4 bytes. However, some
implementations of Fortran 90—notably, Cray—use an 8-byte word size. Programs written for
these implementations may rely on the increased precision and range in their computations.
You can double the sizes of default integer, real, and logicals by compiling with the +autodbl
option, making them compatible with implementations that use the larger word size. This
option also doubles the sizes of items declared with the COMPLEX and DOUBLE PRECISION
statements, but not the BYTE and DOUBLE COMPLEX) statements.
Increasing the size of double-precision items can degrade the performance of your program. If
you do not need the extra precision for items declared with the DOUBLE PRECISION statement,
use the +autodbl4 option, which increases single-precision items only. Compiling with this
option results in items declared as default real and double precision real having the same
precision—a violation of the Standard.
For usage information about the +autodbl and +autodbl4 options, see “Increasing default
data sizes” on page 106). For detailed descriptions of these options, refer to the
HP Fortran Programmer’s Reference.
One-trip DO loops
If a DO loop is coded so that its initial loop count is greater than its final loop count, standard
Fortran 90 requires that the loop never execute. However, under some implementations of
FORTRAN 66, if a DO loop is reached, it executes for at least one iteration, even if the DO
variable is initialized to a value greater than the final value. This is called a one-trip DO
loop.
To duplicate the behavior of a one-trip DO loop in an HP Fortran program, compile with the
+onetrip option. To see the effects of this option, consider the following program:
PROGRAM main
DO 10 i = 2, 1