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

Controlling data storage
Increasing default data sizes
Chapter 3 111
Example 3-2 precision.f90
PROGRAM main
REAL x
REAL(KIND=16) y
DOUBLE PRECISION z
! Assign a quad-precision constant to a default real:
x = 3.14159265358979323846_16
PRINT 10, ‘Stored in x: ‘, x
! Assign a quad-precision constant to a variable that
! has been explicitly sized for quad-precision:
y = 3.14159265358979323846_16
PRINT 10, ‘Stored in y: ‘, y
! Assign a quad-precision constant to a variable
! declared with the DOUBLE PRECISION statement:
z = 3.14159265358979323846_16
PRINT 10, ‘Stored in z: ‘, z
10 FORMAT (A, F22.20)
END PROGRAM main
Following are three different sets of command lines to compile and execute this program, including sample
output from each compilation. Note that variable y remains the same for each compilation: the compiler
does not promote variables that are sized with the kind parameter.
First, the program is compiled without any option:
$ f90 precision2.f90
$ a.out
Stored in x: 3.14159274101257320000
Stored in y: 3.14159265358979323846
Stored in z: 3.14159265358979310000
Next, the program is compiled with the +autodbl option. As shown in the output, x is promoted to
double-precision and z to quad-precision:
$ f90 +autodbl precision2.f90
$ a.out
Stored in x: 3.14159265358979310000
Stored in y: 3.14159265358979323846
Stored in z: 3.14159265358979323846
Finally, the program is compiled with the +autodbl4 option. As shown in the output, x is promoted, but z
is not: