[comp.lang.fortran] FORTRAN to C converter wanted. Also tweaking code.

wgh@Grumpy.UUCP (William G. Hutchison) (10/05/88)

In article <6441@batcomputer.tn.cornell.edu>, braner@batcomputer.tn.cornell.edu (Moshe Braner) writes:
> Does anybody know about software to automatically convert FORTRAN code
> to C?  If it turns out good C, all the better, but if it makes ugly C
> code but does the conversion fast, one could think of it as a preprocessor,
> part of the compiler.  The code is (of course) scientific, numerical.

 Your timing is good: I have been collecting info about commercial
FORTRAN->C converters for our portation centers.  I am planning to post soon,
and I will do it sooner if there is interest. (I know about 3 now:
Rapitech, COBALT BLUE, and PROMULA.FORTRAN).

 How about some lateral thinking:
  some of the big hassles of translating FORTRAN->C are
   (1) origin-1 indexing
   (2) subroutine argument pass-by-reference
   (3) variables declared by default in-line (initial ijklmn) (this is easily
       solved by a 2-pass conversion, but why do all that work?)
   (4) equivalencing of variables
        ...
items (1), (2), and (3) can be solved more conveniently in C++ than in C:
   (1) by declaring your own array class (like class Vec in Stroustrup's
       C++ book)
   (2) by using C++ pass-by-reference
   (3) by making use of the fact that declarations may be sprinkled 
       through the executable part of the C++ program
   (4) equivalence is still a nuisance, but who said there was an ultimate
       programming language, anyway?

-- 
Bill Hutchison, DP Consultant	rutgers!cbmvax!burdvax!Grumpy!wgh
Unisys UNIX Portation Center	"What one fool can do, another can!"
P.O. Box 500, M.S. B121		Ancient Simian Proverb, quoted by
Blue Bell, PA 19424		Sylvanus P. Thompson, in _Calculus Made Easy_