Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!usc!samsung!munnari.oz.au!sirius.ucs.adelaide.edu.au!spam!wvenable From: wvenable@spam.ua.oz (Bill Venables) Newsgroups: comp.lang.c Subject: Re: XXX -> C (actually Fortran -> C) Keywords: struct, Ratfor, Fortran to C converter. Message-ID: <328@spam.ua.oz> Date: 7 Jul 90 06:16:55 GMT References: <55422@lanl.gov> Organization: Statistics, Pure and Applied Maths, University of Adelaide Lines: 46 In article <55422@lanl.gov> rdw2030@venus.tamu.edu writes: >C is really taking over! Everyone needs converters now! &c &c Anyone used to the look and feel of C is going to find the prospect of working with large quantities of elderly Fortran code distasteful. The sort of things that are most off-putting are statement numbers, fixed card layout, (particularly the silent ignoring of anything past column 72), weird control structures, endemic goto-isms, exotic I/O, bulk use of upper case and the general all round anti-structured flavour. There is, however, a nice tool that does a good job of converting Fortran code to a form instantly recognizable, nicely indented and fully readable to any C programmer. 95% of the statement numbers are removed, for example. It's called struct(1), it's part of most BSD Unix releases, and it converts Fortran into Ratfor. It should be more widely known and used. However it is and old program, and is somewhat limited to fairly deadpan Fortran. If you are faced with converting middling amounts of Fortran to C, (for example one or two standard linear algebra or eigenvalue subroutines), you have three main choices: 1) Use a Fortran to C converter (and usually end up with very odd C code), 2) Go right back to the algorithm and hand code it in C from scratch, and 3) Convert the code to Ratfor using `struct', and then manually convert that code to graceful C. On occasion I have found 3) a useful alternative, particularly when the original Fortran code is good code, and contains no I/O (which is always going to be a problem.) There are still difficulties in converting Ratfor into idiomatic C, particularly if multiply subscripted arrays are involved, but they are an order of magniture less than trying to convert raw Fortran into C, either by hand or by converter. Does anyone know of an updated version of struct? Has anyone tackled the job of writing a Ratfor to C converter? (This job could almost be done in emacs using a few tricky macros.) -- Bill Venables, Dept. Statistics, | Email: wvenable@spam.ua.oz.au Univ. of Adelaide, South Australia. | Phone: +61 8 228 5412