Upon successful completion each input file is backed up to file.orig and is replaced by the polished output file.
If -declare is set all implicit names in the program are declared explicitly. A section named "Previously untyped names" is added to each program unit's declarations. Otherwise the declarations in the input program are untouched.
nag_decs considers the program unit to begin with an optional program unit header with preceding and following comments, followed by a number (possibly zero) of "declarative sections" and then by the executable statements.
Statement function definitions and DATA statements are considered to be declarative statements and so are placed into their own declarative sections; these sections (if they exist) are always the last declarative sections to be output.
Type statements in a declarative section are ordered according to the nag_decs option settings, and the elements in each type statement are ordered alphabetically. If both scalars and arrays are being typed in a single section, they will be placed in separate type statements.
nag_decs will itself insert all necessary declarative sections which do not appear in the source code.
The order in which the declarative sections occur, if there are any, in the input file is preserved by nag_decs.
Each declarative section begins with a nag_decs section header and ends (optionally) with a nag_decs section trailer. The body of a declarative section consists of a number of comments (possibly none) followed by the declarations themselves. nag_decs checks to see if the header and trailer comments exist already and only inserts them if they do not. This allows nag_decs to be applied to a program unit more than once without duplication of comments.
The nag_decs section headers have the form: "C .. Section Name ..", where there may be any number of spaces between the 'C' and the '..', and the rest of the header matches the name of a declarative section. If the text following the '..' doesn't match a section name, then a warning message is issued and the comment is treated as a normal comment. The comparison between the source and the section names is done on a case-insensitive basis, and if a match is found the source form is replaced by the standard form (this has 5 spaces between the C and the first period).
The optional nag_decs section trailer has the form "C .." where there may be any number of spaces between the 'C' and the '..'.
The following list shows the names of all possible declarative sections.
Parameters
Scalar Arguments
Array Arguments
Function Arguments
Subroutine Arguments
Scalars in Common
Arrays in Common
Local Scalars
Local Arrays
External Functions
External Subroutines
Intrinsic Functions
Common blocks
Entry Points
Statement Functions
Equivalences
Save statements
Statement Function Definitions
Executable Statements
Previously untyped names
DATA Statements
nag_decs recognises the ANSI standard Fortran 77 intrinsic functions, the US Military Standard intrinsic functions, and the double complex intrinsics defined in nag_Fortran77. Explicitly typing an intrinsic function will cause a warning message to be issued, and that function name will still be treated as intrinsic. To declare a user-defined function with the same name as an intrinsic function the EXTERNAL statement must be used to prevent nag_decs from thinking that it is an intrinsic.
nag_decs does not check to see whether any of the array parameters are adjustable arrays with the variables in COMMON blocks. As the default order of declarative sections puts the arguments before the common blocks, this could cause illegal Fortran to be generated (if the implicit type of the variable is not integer).
To avoid this problem the "Scalars in Common" declarative section header may be inserted into the program text so that the type declarations for the array arguments will occur after the declarations for the variables used to dimension the arrays.
There are three instances where nag_decs cannot convert an intrinsic function to its generic form:
1. when a function has been used as an actual parameter to another function or subroutine,
2. when the function has been explicitly typed, and
3. when the generic function name it would have been converted to has been used for some other purpose within the program unit, for example as an array name.
In these cases nag_decs will issue a warning message saying that it cannot convert the function for that reason.
Copyright, Numerical Algorithms Group, Oxford, 1991-2001