Q901: Indent Fortran Source

Author(s): M. Metcalf Library: PGMLIB
Submitter: Submitted: 01.04.1983
Language: Fortran Revised:

The program reads Fortran source from a specified input file and writes the indented source code to a specified output file.

Structure:

Complete PROGRAM
User Entry Names: INDENT
Files Referenced: Input and output units, either default or user defined.

Usage:

INDENT reads from the default input unit four integer values in a single record. The default values are taken if this record is absent.
Indenting shift (Default = 3)
Maximal indenting level (Default = 10)
File number of source input (Default = 5)
File number of transformed source output (Default = 6)

Note that the first column of the output file will be taken as carriage control information if the output unit is a line printer.

Method:

The program detects the beginning and end of each DO- and IF-block, and indents each following source line by a shift corresponding to the nesting level. Continuation lines are constructed when necessary, but variable names are never split across two lines.

PATCHY control records are treated as comment lines, and so complete PAMs can be handled.

Restrictions:

Lines containing FORMAT statements, or character strings with multiple embedded blanks are not indented.

Sequences of more than 200 comment lines may have their order with respect to the following statement modified.

Assembler code gets destroyed.

Error handling:

Primitive syntax checks protect the program from most non-Fortran source input.

References:

  1. M. Metcalf, FORTRAN Optimization, Academic Press London (1982), Appendix B.
tex2html_wrap_inline63

Michel Goossens Wed Jun 5 07:58:07 METDST 1996