HP Fortran Programmer Guide (766160-001, March 2014)
stat_val = 1
auto_val = 124
stat_val = 2
auto_val = 1
stat_val = 3
auto_val = 65
stat_val = 4
auto_val = 65
NOTE: HP Fortran provides the AUTOMATIC and STATIC statements as porting extensions. The
STATIC statement is functionally the same as the SAVE statement, and the AUTOMATIC statement
may be used to declare a variable as automatic. However, such a declaration is generally pointless
because variables compiled under HP Fortran are automatic by default.
The HP Fortran Programmer's Reference provides detailed information about the AUTOMATIC,
SAVE, and STATIC statements.
Increasing the precision of constants
By default, HP Fortran evaluates all floating-point constants as single-precision. For example, the
compiler treats following constant
3.14159265358979323846
as though you had specified:
3.1415927
Although the loss of precision might be acceptable when assigning to single-precision variables,
it is might be less acceptable when assigning to double-precision variables or when using
floating-point constants in expressions where the loss in precision might result in significant round-off
differences.
NOTE: HP Fortran provides two ways to override the default precision of individual constants:
the kind parameter and the exponent form. The kind parameter indicates the precision of
floating-point constants: 4 for single-precision, 8 for double-precision, and 16 for quad-precision.
In the following example, the kind parameter _8 specifies that the constant is to be evaluated as
double-precision:
3.14159265358979323846_8
To change the precision of all floating-point constants (except those having a kind parameter), you
can use the +real_constantoption. This option takes two forms, +real_constant=double
and +real_constant=single, which specify (respectively) double-precision and single-precision
for floating-point constants in the files compiled with this option. The
+real_constant=singleform is the default. Neither form of the option has any affect on
constants that have the kind parameter.
To promote all floating-point constants in the source files x.f, y.f, and z.f, compile with the
command line:
$ f90 +real_constant=double x.f y.f z.f
The +real_constant=singleoption specifies that all floating-point constants in a file are to be
treated as single-precision (the default). The following command line specifies single-precision for
all floating-point constants in the files a.f, b.f, andc.f :
$ f90 +real_constant=single a.f b.f c.f
Note that +real_constant=singledoes not demote constants that use either the kind parameter
or the exponent form (for example, 4.0D0) .
For information about increasing the precision of variables, see “Increasing default data sizes”
(page 70). The HP Fortran Programmer’s Reference describes the syntax of the kind parameter
and the exponent form and the +real_constant option. For detailed information about how
Increasing the precision of constants 69