[comp.lang.fortran] The "struct" program

dmocsny@minerva.che.uc.edu (Daniel Mocsny) (12/04/90)

I stumbled across a quite useful program called "struct" in the
distribution of the VAX Ultrix version of UNIX. "struct" converts
spaghetti-code FORTRAN-66 or FORTRAN-77 into nice, clean "ratfor".
It does a very good job of replacing GOTO constructs into 
equivalent IF-THEN-ELSE, FOR, WHILE, and SWITCH-CASE-DEFAULTs.

I'm impressed, anyway. Having de-spaghetti-fied "ratfor" makes 
hand-translation to C pretty straightforward in many cases, since
"ratfor" looks a lot like C. It's also a lot easier to read than 
spaghetti FORTRAN...

Anyway, my question for the NET is: why don't I see this program
anywhere in the FORTRAN stuff on HP-UX and SunOS? Both of those
systems have the "ratfor" preprocessor, but no "struct" that I can
see. Who wrote "struct", and why I haven't I found it talked about 
in the Ultrix-32 Supplementary Documents, Volume 2, where "f77" and
"ratfor" have their entries?


--
Dan Mocsny				Snail:
Internet: dmocsny@minerva.che.uc.edu	Dept. of Chemical Engng. M.L. 171
	  dmocsny@uceng.uc.edu		University of Cincinnati
513/751-6824 (home) 513/556-2007 (lab)	Cincinnati, Ohio 45221-0171

roth@dtoa1.dt.navy.mil (Roth) (12/06/90)

I would guess that struct was put together by Brian Kernighan
at Bell Labs. Or one of the gang: McIlroy, Thompson, Aho, etc.
Struct is a neat program that makes some of the old programs
we have lying around here understandable, and I've uncovered some
bugs in the original code using it...

Peter N Roth

jrbd@craycos.com (James Davies) (12/07/90)

In article <6861@uceng.UC.EDU> dmocsny@minerva.che.uc.edu (Daniel Mocsny) writes:
>I stumbled across a quite useful program called "struct" in the
>distribution of the VAX Ultrix version of UNIX. "struct" converts
>spaghetti-code FORTRAN-66 or FORTRAN-77 into nice, clean "ratfor".
>It does a very good job of replacing GOTO constructs into 
>equivalent IF-THEN-ELSE, FOR, WHILE, and SWITCH-CASE-DEFAULTs.
  ...
>Who wrote "struct", and why I haven't I found it talked about 
>in the Ultrix-32 Supplementary Documents, Volume 2, where "f77" and
>"ratfor" have their entries?

There is a paper on struct in the Journal of the ACM, Jan. 1977,
"An Algorithm for Structuring Programs," by B.S. Baker.  As to why it
isn't in the manuals or on all Unix systems, beats me.  Maybe because
ratfor isn't used much any more?

mwm@VACATION.VENARI.CS.CMU.EDU (Mark Maimone) (12/07/90)

See Journal of the ACM, January 1977 (Vol 24 no 1), pp 98-120 for "An
Algorithm for Structuring Flowgraphs" by Brenda Baker, then of AT&T Bell
Labs.  I believe this was the first paper on the algorithm STRUCT uses.

----------------------------------------------------------------------
Mark Maimone				phone: (412) 268 - 7698
Carnegie Mellon Computer Science	email: mwm@cs.cmu.edu
grad student, vocal jazz and PDQ Bach enthusiast