Someone might have done this as a research project, but
- that's something like a decompiler (not many of those to discuss), and
- ratfor doesn't have a lot of developers to begin with.
That said, all that I see in the area is old (which is expected given the two points mentioned):
- Reverse Compilation Techniques, Cristina Cifuentes, 1994, mentions a program described in B.S. Baker. An algorithm for structuring flowgraphs.
Journal of the ACM,
24(1):98–120, January 1977.
Baker[Bak77] presented an algorithm to structure flowgraph
s into equivalent flowgraphs
that made use of the following control structures:
next, and endless loops.
Gotos were used whenever the graph could not be structured
using the previous structures. The algorithm was extended to irreducible graphs as well.
It was demonstrated that the algorithm generated well-formed and properly nested programs, and that any
statements in the final graph jumped forward. This algorithm
was implemented in the
program on a PDP11/54 running under Unix. It was used
to rewrite Fortran programs into Ratfor, an extended Fortran language that made use of
control structures. The
program was later used by J.Reuter in the
decompiler to structure graphs built from object files with symbol
- Help on disassembler/decompilers, usenet thread in 1990, comment by Mark William Hopkin says
There is a standard UNIX utility (at least for the 4.3 bsd we're running) that
does something just like this:
"struct". This utility takes standard
Fortran-77 programs and generated from it Ratfor code. Ratfor is a
'rationalized' Fortran that includes all the Algol-derived control structured.
As you can see, both comment on the same program from the 1970s. The comment about 4.3BSD shows that you might find its source online. What I found concludes the manual page with this:
Struct knows Fortran 66 syntax, but not full Fortran 77.
If an input Fortran program contains identifiers which 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 without a target, try −e .
That is, the program was not complete, and (aside from another research project) likely would not do what you need.