Translates a FORTRAN program into a RATFOR program.
The struct command translates the FORTRAN program specified by File (standard input default) into a RATFOR program. Wherever possible, RATFOR control constructs replace the original FORTRAN. Statement numbers appear only where still necessary. Cosmetic changes are made, including changing Hollerith strings into quoted strings and relational operators into symbols (for example, .GT. into >). The output is appropriately indented.
The struct command knows FORTRAN 66 syntax, but not full FORTRAN 77. If an input FORTRAN program contains identifiers that are reserved words in RATFOR, the structured version of the program will not be a valid RATFOR program. The labels generated cannot go above 32767. If you get a goto statement without a target, try using the -e flag.
Item | Description |
---|---|
-a | Turn sequences of else-if statements into a non-RATFOR
switch of the form:
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. |
-b | Generates goto statements instead of multilevel break statements. |
-c Number | Increments successive labels in the output program by the nonzero integer Number. The default is 1. Do not insert a space between -c and Number. |
-e Number | If Number is 0 (default), places code within a loop only if it can lead to an iteration of the loop. Do not insert a space between -e and Number. |
-i | Do not turn computed goto statements into switches. (RATFOR does not turn switches back into computed goto statements.) |
-n | Generates goto statements instead of multilevel next statements. |
-s | Input is accepted in standard format. Comments are specified by a c, C, or * in column 1, and continuation lines are specified by a nonzero, nonblank character in column 6. Input is in the form accepted by the f77 command. |
-t Number | Makes the nonzero integer Number the lowest valued label in the output program. The default is 10. Do not insert a space between -t and Number. |
If Number is nonzero, admits small code segments to a loop if otherwise the loop would have exits to several places including the segment, and the segment can be reached only from the loop. In this case, small is close to, but not equal to, the number of statements in the code segment. Values of Number under 10 are suggested.
To translate the test.f FORTRAN program into the newtest.ratfor RATFOR program, enter:
struct -s -i -n -t2 test.f > newtest.ratfor
Item | Description |
---|---|
/tmp/struct* | Temporary files used during processing of the struct command. |
/usr/lib/struct/structure | File that handles processing for the struct command. |
/usr/lib/struct/beautify | File that handles processing for the struct command. |
/usr/ucb/struct | Contains the struct command. |