Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Fortran 90 Compiler for HP-UX: Fortran 90 Programmer's Guide > Chapter 3 Controlling data storage

Increasing default data sizes

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

The +autodbl and +autodbl4 options enable you to increase the default sizes (that is, the number of storage bytes) for both constants and variables of default numeric and logical types. Unlike the +real_constant option, the +autodbl and +autodbl4 options affect both constants and variables of both real and integer types. (For information about using the +real_constant option, see “Increasing the precision of constants”.)

When compiled with the +autodbl and +autodbl4 options, constants are treated as though they had twice the default number of bytes (4) available for evaluating them. The effect of these options is to increase the range of default integers and the precision of default reals.

The +autodbl and +autodbl4 options have no effect on the size of entities declared with the CHARACTER, BYTE, or DOUBLE COMPLEX statements, nor on entities that are explicitly sized. That is, if a variable is declared with a kind parameter or if a constant has a kind parameter, it is unchanged by +autodbl or +autodbl4.

NOTE: HP Fortran 90 interprets the kind parameter as indicating the number of storage bytes to allocate for a variable. When used with variables and constants of type real, the kind parameter also indicates the precision: 4 for single-precision, 8 for double-precision, and 16 for quad-precision.

Promoting double-precision variables to quad-precision can have a severe impact on performance because the instructions to perform quad-precision operations are implemented in software. If you are concerned about performance and want to increase default data sizes, consider using the +autodbl4 option, which does not promote variables declared with the DOUBLE PRECISION statement. There is no other difference between +autodbl or +autodbl4.

These options affect all files on the command line. To increase the size or precision of selected variables and constants, use the kind parameter.

Figure 3-1 “Increasing default data sizes” shows the default data types whose sizes are changed by the +autodbl and +autodbl4 options.

Figure 3-1 Increasing default data sizes

Increasing default data sizes

The following program illustrates the different effects of the +autodbl and +autodbl4 options. The program assigns the same quad-precision constant to three variables:

  • x, a default (that is, single-precision) real

  • y, a real that is declared as double-precision with the kind parameter

  • z, a double-precision real that is declared with the DOUBLE PRECISION statement

The following program includes PRINT statements to show the stored values.

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:

$ 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”. For detailed information about these options, see the HP Fortran 90 Programmer's Reference. For detailed information about how floating-point arithmetic is implemented on HP 9000 computers and how floating-point behavior affects the programmer, refer to the HP-UX Floating-Point Guide.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.