The following program illustrates the different effects of the +autodbl and +autodbl4 options. The program assigns the same
•x, a default (that is,
•y, a real that is declared as
•z, a
Example
PROGRAM main
REAL x
REAL(KIND=16) y
DOUBLE PRECISION z
!Assign a
PRINT 10, ‘Stored in x: ‘, x
!Assign a
!has been explicitly sized for
y = 3.14159265358979323846_16 PRINT 10, ‘Stored in y: ‘, y
!Assign a
!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
$ 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:
$ f90 +autodbl4 precision2.f90 $ a.out
Stored in x: 3.14159265358979310000
Stored in y: 3.14159265358979323846
Stored in z: 3.14159265358979310000
Though useful for increasing the range and precision of numerical data, the +autodbl and +autodbl4 options are especially useful when porting; see “Large word size” (page 145). For detailed information about these options, see the HP Fortran Programmer’s Reference. For detailed information about how
Increasing default data sizes | 71 |