NAGWare Fortran Tools - f95 Tools - nag_chname95

 

Index

NAME
DESCRIPTION
OPTIONS
CHANGES FILE
BEHAVIOUR
SEE ALSO

 

NAME

nag_chname95 - Name changer

 

DESCRIPTION

nag_chname95 is the NAGWare f95 Tools name changer. This tool systematically changes names in Fortran source file(s).

If a filename with no extension is provided the tool will look for a file with the extension `.f95', and if that does not exist, for a file with the extension `.f90'.

If a file has the extension `.f90' or `.f95', it will be assumed to contain free format Fortran code. If a file has the extension `.f', `.for', `.f77', or `.ftn', the file is assumed to contain fixed format Fortran code. The options -fixed and -free may be used to override this behaviour.

The input file is backed up to infile.original and the output file replaces the input file.

Include files are expected to exist in the current working directory or in a directory named by the -I option.

 

OPTIONS

   General Options
"Source format" (-fixed, -free)
Forces the tool to assume fixed or free format for the input file. If "Automatic" is set, .f90 files will be assumed to contain free format code , .f, .for, .f77, or .ftn are assumed to contain fixed format code.

"Include and module directories" (-I)
Add pathname to the list of directories which are to be searched for include files. The current working directory is always searched first, then any directories named in -I options.

"Fixed format source line length" (-132)
Increase the length of each fixed source form input line from 72 characters to 132 characters. This has no effect on free source form input.

"Allow double complex specific intrinsics" (-dcfuns)
Enable recognition of non-standard double precision complex intrinsic functions. These act as specific versions of the standard generic intrinsics as follows:

    Non-standard      Equivalent Fortran 95 Intrinsic
     CDABS(A)            ABS(A)
     DCMPLX(X,Y)         CMPLX(X,Y,KIND=KIND(0d0))
     DCONJG(Z)           CONJG(Z)
     DIMAG(Z)            AIMAG(Z)
     DREAL(Z)            REAL(Z) or DBLE(Z)

"Downgrade legacy code errors to warning" (-dusty)
Allows the analysis of ``legacy'' software by downgrading the category of common errors found in such software from ``Error'' to ``Warning'' (which may then be suppressed entirely with the -w option).

"Suppress information messages" (-info)
Suppress output of tool analysis stages information messages.

"Continuation line limit" (-maxcontin)
Increase the limit on the number of continuation lines to N. The default, as specified by the Fortran standard, is 19 for fixed source form and 39 for free source form. This will not decrease the limit below the standard number.

"Output strict Fortran 95 obsolescent messages" (-strict95)
Produce obsolescence warning messages for use of ``CHARACTER*'' syntax. This message is not produced by default since most programs contain this syntax.

"Suppress warning messages" (-w=all)
Switch on or off tool analysis stages warning messages.

"Suppress obsolescent feature warning messages" (-w=obs)
Switch on or off warning messages about the use of obsolescent features.

"Suppress unused entity warning messages" (-w=unused)
Suppresses warning messages about unused entities. It is equivalent to -w=uda -w=uei -w=ulv -w=usy.

"Suppress unused dummy argument warning messages" (-w=uda)
Switch on or off warning messages about unused dummy arguments.

"Suppress unused explicit import warning messages" (-w=uei)
Switch on or off warning messages about unused explicit imports.

"Suppress unused local variable warning messages" (-w=ulv)
Switch on or off warning messages about unused local variables.

"Suppress unused symbol warning messages" (-w=usy)
Switch on or off warning messages about unused symbols.

"Suppress Fortran 77 extension warning messages" (-w=x77)
Switch on or off extension warnings for common extensions to FORTRAN 77. These are TAB format, byte-length specifiers and Hollerith constants.

"Suppress Fortran 95 extension warning messages" (-w=x95)
Switch on or off extension warnings for extensions to Fortran 95.

 

CHANGES FILE

The changes file consists of a number of lines of change requests of the form:

FLAGS OLDSTRING NEWSTRING

where ``OLDSTRING'' is the string to be replaced. ``NEWSTRING'' is the string with which it should be replaced and ``FLAGS'' indicates to which area of the program the changes should be applied. No spaces are allowed in FLAGS. If ``OLDSTRING'' or ``NEWSTRING'' is a regular expression containing spaces (or ``NEWSTRING'' is a zero length replacement string) it must be surrounded in single quotes. Spaces are only useful in search and replacement strings that are applied to comments and strings. If the string contains a single quote this must be preceded by ``\''. In Fortran strings, an embedded quote, i.e.~two quotes in the source text, is stored as one quote. On output this is converted back to two quotes.

FLAGS takes the form of a string of `t's and `f's in the following layout.

<names><comments><strings><case-fold><regex>

thus ``tffff'' will change only names, ``tftff'' will change both names and strings.

A typical line might look like this:-

tffff OLD_VAR NEW_VAR

which will replace ``OLD_VAR'' with ``NEW_VAR'' in names only. In direct replacement, see below, names are not case-sensitive so all such names will be changed.

`f's to the right may be omitted, thus

tffff ABC XYZ

is equivalent to

t ABC XYZ

The <names> and <strings> flags turn on or off replacement in names and strings, respectively. If <case-fold> is true, case folding is applied and the search string will be matched irrespective of case. The <regex> flag may be set independently to interpret each change request as a regular expression (t) or a direct replacement (f).

 

BEHAVIOUR

This tool is not a simple text editor, although it can be used as such with regular expressions on strings and comments. When editing names nag_chname95 acts upon tokens, which are the elements of the Fortran language. Normally it is obvious what a name token is, but in the case of structure components it should be noted that the structure name and the component name are two separate tokens, e.g. with ``X%Y'' any change request that matched Y would replace all structure components named Y.

When operating on strings and comments in direct replacement mode the tool matches words delimited by white space or characters other than alphanumerics, dollar sign and underscore.

Regular expressions used with names should not start with the metacharacters ``^'' or end with ``$''. All regular expressions applied to names have the beginning of line metacharacter prepended and the end of line metacharacter appended.

The program contains both a regular expression and a direct replacement mode. Many of the features of the two techniques are different and so they are discussed separately in the next two sections. It is much better to use the direct replacement rather than regular expressions where possible as it is likely to be much faster.

Both direct replacement and regular expressions may be specified in the same control file. The direct replacements are performed before the regular expression matches. If a direct replacement is made on a token or word no attempt is made to match any regular expressions on that token or word. Otherwise all regular expressions are applied to that token or word in the order specified and subsequent regular expressions are hence applied to the results of previous substitutions.

Direct replacement

This replaces a whole word (or identifier) with another whole word (or identifier).

Where an identifier is being replaced, the resulting case will be the same as any other identifier, as specified in the polish options file. Where a word is in a string or comment, the case matches that of the search string, as far as is possible. The case of change requests is not important and the `case folding' switch has no effect with `Direct replacement' mode.

Regular expressions

Regular expressions, based on GNU emacs and Unix egrep, may contain any of the following metacharacters:

     any single character        .
     beginning of line           ^
     end of line                 $
     zero or more repeats        *
     one or more repeats         +
     zero or one repeat          ?
     any character in set        [...]
     any character not in set    [^...]
     escape character            \ 
     tag field, see below        \(...\)
     recall nth tag field        \n
     tab character               \t
     word break                  \b

Escape Character

The escape character (see table above) is used to introduce special characters, e.g. tag field recall. It may also be used to quote special characters to be used. For example, `\$' is the dollar sign.

Sets of Characters

A string of characters enclosed in square brackets `[ ]' matches any character in the string unless the first character is a `^', when the regular expression matches any character not in the string (other than newline). The string of characters may be abbreviated to a character range of the form a-z, 0-9, P-Y etc.

Tag Fields

It is possible to tag up to 9 character fields in the regular expression that can be recalled in any order in the replacement text. Tag fields are opened and closed using the metacharacter listed above. Tag fields may be nested but may not overlap; the fields are numbered 1 to 9 in the order in which they are opened. Tag field 0 is the whole matched pattern. In the replacement text the tag fields are recalled using the metacharacter shown above followed by the tag field number.

Word Break

The metacharacter `\b' matches a transition between alpha-numeric characters and non-alpha-numeric characters or vice versa.

 

SEE ALSO

nag_polopt95.

Copyright, Numerical Algorithms Group, Oxford, 1997-2001