NAGWare Fortran Tools - f77 Tools - nag_apt

 

Index

NAME
DESCRIPTION
OPTIONS
TRANSFORMATION DETAILS
FURTHER INFORMATION
DIAGNOSTICS
SEE ALSO
 

NAME

nag_apt - Arithmetic Precision Transformer

 

DESCRIPTION

nag_apt transforms a Fortran 77 source file from single to double precision or from double to single precision.

Upon successful completion each input file is backed up to file.orig and is replaced by the polished output file.

 

OPTIONS

"Output Precision" (-double, -single)
Specifies the arithmetic precision of the output program. The default is -double.

"Double Complex Form" (-keywords, -byte)
Specifies the form of declarations generated for double precision complex variables. With -keywords double precision complex is declared as DOUBLE COMPLEX. With -byte this is declared as COMPLEX*16. The default is -keywords.

 

TRANSFORMATION DETAILS

This section lists the major details of the transformations performed by nag_apt. nag_apt should always produce correct output except when it detects an error. Although nag_apt does not attempt to ensure that the transformation will be reversible, the only differences will be where the code was originally of mixed precision, or an difficult (see 6(b below) intrinsic function (such as MAX1) was used.


1. The keyword REAL is changed to/from DOUBLE PRECISION, and the keyword COMPLEX is changed to/from DOUBLE COMPLEX or COMPLEX*16 (according to whether the option -double or -single was specified).


2. Declarations are added for implicitly typed names which have changed precision.


3. Real constants are transformed to/from double precision, and if appropriate "D0" will be added to or deleted from the end of the constant.


4. Single-precision complex constants are transformed to/from double-precision complex constants (if both parts of a single-precision complex constant are integers, the first will be made into a double-precision constant by adding the suffix "D0").


5. The E-format format descriptor is transformed to/from the D-format descriptor. This will not change the "Ew.dEe" form of the E-format descriptor, as there is no D-format equivalent.


6. REAL-valued intrinsic functions are transformed to/from DOUBLE PRECISION functions (by replacing the name). COMPLEX-valued intrinsic functions are transformed to/from DOUBLE COMPLEX functions similiarly. Generic functions are not converted except when used as an argument to a routine (in which case they lose their generic properties). Certain difficult functions are handled separately; the conversions possible are described below. nag_apt will produce an error if it finds an occurrence of an intrinsic function which it cannot transform.


(a) DPROD. [S->D]: DPROD(expr1,expr2) is transformed to "expr1*expr2", with parentheses around the expressions if necessary.


(b) MAX1. [S->D]: is transformed to INT(MAX(...)).


(c) AMAX0. [S->D]: is transformed to DBLE(MAX(...)). [D->S]: DBLE(AMAX0(...)) is transformed to AMAX0(...).


(d) MIN1 and AMIN0 are treated similarly to MAX1 and AMAX0.


7. EQUIVALENCE statements are checked to ensure that their meaning does not change during the transformation; if it does then an error message is produced.

 

FURTHER INFORMATION

nag_apt recognises the set of intrinsic functions defined in nag_Fortran77. This consists of those listed in the ANSI Fortran-77 standard together with the DOUBLE COMPLEX functions DCMPLX, DIMAG, CDABS and DCONJG. (The US Military Standard Extensions are irrelevant to this tool.)

If the input program has implicitly typed names which change precision, then the output program will contain declarations of the new type of these names. These are inserted, one name per statement, immediately after the last point where IMPLICIT statements can occur (i.e. just before the first statement which is not a program-unit header, IMPLICIT statement or PARAMETER statement). If a more tidy appearance of the declarations is desired, the option -decs may be used to invoke the declaration standardiser to re-format the declarations completely.

nag_apt will sometimes be unable to remove declarations of intrinsic functions which are no longer used. In this case an informational message will be output. These unnecessary declarations may be removed by processing the program with the options -decs and -logremove.

 

DIAGNOSTICS

If the name of an intrinsic function which nag_apt wishes to insert has already been used for some other purpose, e.g. as a variable name, nag_apt will abort with an error message.

 

SEE ALSO

nag_Fortran77, nag_polopt

Copyright, Numerical Algorithms Group, Oxford, 1991-2001