next up previous 211
Next: inscnf - Wrap %VAL arguments with CNF_PVAL in Fortran 77
Up: Description of tools
Previous: crepint - Replace int by INT_BIG in C


frepint - Replace INTEGER by INTEGER*8 in Fortran 77

Description:
This program is a filter which takes FORTRAN 77 source code and modifies it so that INTEGER declarations are rewritten as `INTEGER * 8'. It also attempts to warn if there are usages which might cause trouble given this change.

Additionally, if there appear to be actual arguments to subroutines or functions which are literal integers, the program will attempt to replace them with symbolic constants, and to define these constants in the declaration section of the module. Thus the line

CALL SUB( X, 5, STATUS )

will be replaced by

CALL SUB( X, INT__5, STATUS )

and the corresponding declaration statements

INTEGER * 8 INT__5

and

PARAMETER ( INT__5 = 5 )

will be inserted in the declaration section of the module. The program will attempt to insert these declarations near an INCLUDE statement, and if it cannot find one, it will write a warning to standard error, including the text of the declarations that it would have made.

Attention is paid to fortran 77 source format, so that lines more than 72 characters long are avoided (unless they were there in the first place).

Some attention is paid to the aesthetic qualities of the output: line breaks are made, where possible, following the usage in, e.g., KAPPA. An attempt is made to copy the style of case usage from the input.

No changes are made to comment lines so that, for instance, the Arguments stanza of subroutine prologues will not have argument types modified from `INTEGER' to `INTEGER * 8'.

No change is made to references to INTEGER type in IMPLICIT statements.

The program will write a warning on standard error for certain constructions in the code which are likely to cause trouble after the mass redeclaration of INTEGER as INTEGER*8 has occurred. These constructions are:

  • INTEGER * n declarations which already exist in the code (these are not modified)

  • EQUIVALENCE statements

  • Use of INTEGER Specific names for standard intrinsic functions (IABS, ISIGN, MAX0, AMAX0, MIN0, IMIN0). IDIM could also go in this list, but since it is a common variable name, and an uncommon intrinsic, no warning is given for IDIM.

  • Any module (SUBROUTINE, FUNCTION or BLOCK DATA) which does not include an IMPLICIT NONE statement.


Usage:
frepint [ in [ out ] ]

Notes:
The program is not infallible at identifying function calls, which it needs to do in order to replace integer literals, since they look like array references. It uses the rule of thumb that it if the would-be function name contains an underscore it is a function, otherwise it is an array.

It will also not identify an INTEGER-type expression as such unless it is a single integer literal; for instance the expression `3 * 5' as actual argument of a subroutine/function ought to be retyped, but will not be spotted.

In a few cases, the line breaks are not made in very beautiful places. They should, however, always be correct.

Although this program behaves as a filter, it is written on the assumption that it will be run on a file of a finite length: it may buffer large amounts of input before writing output, and it may not free up memory.



next up previous 211
Next: inscnf - Wrap %VAL arguments with CNF_PVAL in Fortran 77
Up: Description of tools
Previous: crepint - Replace int by INT_BIG in C


Starlink System Note 73
Mark Taylor
13 August 2001
E-mail:ussc@star.rl.ac.uk

Copyright © 2001 Council for the Central Laboratory of the Research Councils