In particular, it can be applied to the output of pretty(1L) to supply indentation for Fortran 77 block-IF statements, which pretty(1L) presently does not recognize as candidates for indentation. It is at least 20 times faster than pretty (1L), and processes about 275 lines/sec on a Sun 3/50 (15MHz Motorola 68020) system, so it can be routinely applied to code without serious time penalties.
Following the conventions of DEC Fortran compilers, an initial tab on a line blank-fills through column 6 if the next character is not a digit, and otherwise fills through column 5, placing the following digit in column 6 as a continuation character. Tabs embedded in lines are expanded by blank padding through the next column which is a multiple of 8 (thus preserving layout in comments). The output contains no tab characters.
In order to preserve neat indentation according to control structure level, long character strings are split, preferably at a blank. In executable statements, the concatenation operator, //, is used to merge them back into one string (usually at compile time). In FORMAT statements, comma separators are inserted. In DATA statements, where string expressions are not permitted by Fortran 77, the break is made at column 72, and the same string continues in column 6 of the next line. Because some compilers (erroneously) fail to pad input statements to column 72 before merging continuation lines, trailing blanks on a line in such a split string can be lost. To prevent this, if column 72 is blank when a string is wrapped, a hyphen will be output in column 73; it will be ignored by the compiler, but will protect against erroneous string truncation. Otherwise, trailing blanks are trimmed from the output.
To increase its utility, the analyzer also recognizes numerous language extensions present in commonly-used Fortran compilers. These are summarized in the following table. Note that some extensions are supported by multiple vendors.
Vendor
If a negative number appears in the list, then all columns from the preceding number to the absolute value of the negative one are declaration columns. The shorthand of, say, -k26,-72 says that any column in the range 26 through 72 is a declaration column; in other words, variables will appear successfully without intervening space.
If no keystring is specified, CDFKOV is assumed; this selects all options except the one affecting Fortran INCLUDE statements. Because they contain file names whose letter case may be significant on some operating systems, they are never modified unless explicitly requested.
- C
- constants (except quoted and Hollerith strings)
- D
- SFTRAN3 directives
- F
- FORMAT fields
- I
- Fortran INCLUDE statements
- K
- keywords
- O
- operators
- V
- variables, subroutines, functions, and other user-defined names
Letter case of comments and character strings is never altered. By default, input letter case is preserved. However, -ucdfikov could be used to convert all but comments and strings to upper case (ANSI standard), and -lCDFKIOV would correspondingly convert to lower case. If both switches are given with the same letter options, the last one specified is used.
The value is selected by or'ing together any of the following values, or by specifying the desired values in separate options, and it may be specified in decimal, octal (0nn), or hexadecimal (0xnnn):
- 0x00001
- =
- 0x00002
- + -
- 0x00004
- * /
- 0x00008
- logical operators (.and., .eqv., .neqv., .not., .or., .xor.)
- 0x00010
- relational operators (.eq., .ge., .gt., .le., .lt., .ne.)
- 0x00020
- logical constants (.false., .true.)
- 0x00040
- comma
- 0x00080
- SFTRAN3 structure labels
- 0x00100
- SFTRAN3 inline comments
- 0x00200
- concatenation operator (//)
- 0x00400
- exponentiation operator (**)
- 0x00800
- colon
- 0x01000
- ampersand
- 0x02000
- left parenthesis
- 0x04000
- right parenthesis
- 0x08000
- semicolon
- 0x10000
- keywords
- 0x20000
- user-defined names
If a value 0 is specified, the internal defaults are cleared, so that original spacing will be preserved. The default value is -s0x183fb.
To support consistent prettyprinting style, it is convenient to be able to supply standardly-used options in a default startup file. This file is called .sf3pretty on UNIX systems, or sf3pretty.opt on others, and it is searched for in the current directory, or if not found there, in the login directory. If the file is found, up to 72 characters of its first line are read and parsed into command line options. These should not be protected by shell quotes; for example, the command line argument '-c*' should appear simply as -c*.
Standard input and standard output.
Nelson H. F. Beebe Center for Scientific Computing Department of Mathematics University of Utah Salt Lake City, UT 84112 USATel: +1 801 581 5254 FAX: +1 801 581 4148
Email: beebe@math.utah.edu