Note that the switch -s is required if the input is standard-form Fortran (that is, it is not Unix free-form). Use of a non-zero argument to the -e option is recommended, to eliminate GOTO statements which are likely to remain if the default is assumed. A typical application would be: strsf3 -e20 -s myprogram.f > myprogram.sf3
switch { case pred1: code case pred2: code case pred3: code default: code }
The case predicates are tested in order; the code appropriate to only one case is executed (this generalized form of switch statement does not occur in Ratfor).
0 no debug information 4 tokens 8 line break decisions 16 Hollerith/string recognitions 32 depth-first searches 64 vxparts at graph nodes 128 structure labels
SFTRAN/3 Installation Guide, Nelson H. F. Beebe, Departments of Physics and Chemistry, University of Utah, Salt Lake City, 1980.
SFTRAN3 Programmer's Reference Manual (JPL Document no. 1846-98), C. L. Lawson and J. Flynn, Jet Propulsion Laboratory, California Institute of Technology, Pasadena, December 1, 1978.
Statements involved in flow-of-control will in general be reformatted, and indented according to the SFTRAN3 nesting level, but continuation lines will usually have their original spacing and indentation preserved. The emacs(1L) SFTRAN3 Mode function ^R FORTRAN Eliminate Multiple Spaces (normally attached to M-space) can be used to reliably reformat such continued statements.
strsf3 attaches comments immediately preceding a labelled statement to that statement, so that they will be moved if the statement is moved. Since most programmers place comments before the statements they refer to, this is the desirable action. However, if comments refer to preceding statements, and are immediately followed by a labelled statement, they may be incorrectly placed in the output, and some manual editing may be necessary.
strsf3 does not do a complete parse of its input Fortran code. In particular, Hollerith and quoted string constants are not identified as such. Consequently, when a continuation line must be generated in the SFTRAN3 output routine, the statement buffer is scanned backwards to find a suitable place to break the statement (after one of the characters contained within the following pair of double quotation marks, including the space character: ",)=/: "), and then the scan continues to find any Hollerith or quoted string constructs which would be split across the line boundary. If no string appears to be split, the break is accepted and a continuation line is generated. If a string split would occur, then if the string is short enough to fit on a continuation line, the break is made before it. Otherwise, the break is made in column 72 and indentation of the continuation line is suppressed so that it begins in column 7. This is adequate for most purposes and has worked quite successfully on the conversion of the entire <PLOT79> source (about 700 routines and 150,000 lines of code). It can, however, fail to recognize Hollerith strings embedded in quoted strings, or vice versa, and may make a bad split.
Code rearrangement may require the negation of the conditions in IF statements, which is accomplished by turning IF (cond) etc into IF (.NOT.(cond)) etc If cond already begins with a .NOT., this generates a double negative which could be removed but is not. Similarly, if cond is of the form (exp1) .relop. (exp2) then .NOT.(cond) could be rewritten by negating the relational operator. This is not done either, since strsf3 has not parsed the conditional expression.
In order to reliably repair these two cases and improve the readability, the emacs(1L) SFTRAN3/Fortran Mode function UnNot can be applied to the source code. It will leave intact any expressions which contain more than one logical or relational operator, and will convert all of the others which begin with ".NOT.(" and ".NOT.(.NOT.". It handles only one expression at a time, so that the user has the opportunity to reformat the statement with M-space.
If an input Fortran program contains identifiers which are reserved words in strsf3, the structured version of the program will not be a valid strsf3 program.
Unused FORMAT statements appear without statement numbers, producing compilation errors; these statements must be removed manually.
The ERR=xx exit on I/O statements is not recognized. Consequently, output code contains a branch to a non-existent label. The correct SFTRAN3 syntax is LOGICAL FLAG,EOFILE READ (...,FLAG=ERR,EOFILE=END) ... if (FLAG) ... if (EOFILE) ...
strsf3 produces many inverted logical expressions of the form IF (.NOT.(...)) A partial solution ot this problem is provided in the sed(1) script strsf3.sed, which does regular expression substitutions to simplify such expressions; this script is automatically invoked upon the output. However, because regular expressions cannot count, it is not possible to produce balanced parentheses in complicated expressions. For example, IF (.NOT.(scalar.LE.scalar)) is converted properly, but IF (.NOT.(vector(index).LE.vector(index))) is not. Similarly, because sed(1) cannot recognize expressions split across lines, other logical expressions are missed.
A Fortran statement of the form: IF (expr) n1,n2,n3 will be converted into an SFTRAN3 statement of the form: IF (expr .relop. 0) etc If expr is not of type INTEGER, the IF contains a mixed mode expression.
A computed GOTO in which labels appear more than once, such as: GOTO (10,10,20,30),K will generate an illegal SFTRAN3 CASE statement in which a case number is repeated (as in: CASE 1,2). strsf3 does not duplicate code, so this must be patched manually.
Under certain rare circumstances, strsf3 may move a loop inside another loop which has the same index. The patch is simply to rename the index of the innermost loop.
If an END FOREVER statement immediately precedes the END PROGRAM statement, the SFTRAN3 preprocessor will incorrectly generate an unreachable labelled CONTINUE statement following the GOTO which terminates the loop. In such a case, the RETURN or STOP inside the DO FOREVER ... END FOREVER loop can be changed to an EXIT FOREVER and the RETURN/STOP moved to the end of the program unit, or it may be possible to rewrite the DO FOREVER as a DO UNTIL or DO WHILE.