[comp.lang.fortran] Is there a fort2c?

jayhawk@cbnewsh.ATT.COM (R.Moats) (12/05/89)

I am posting this request for a friend who has not caught up
with where news access is now located.  Anyway, I digress...

Is there, was there, will there be a tool to convert fortran
code to C code.  We are talking here mainly F66 or F77, but he
will take anything.   The tool needs to operate under either
MSDOS or UNIX (preferrably Sys V but again, he's flexible [read
desperate ... ;-)])

Price:  "...the cheaper the better, free is the best".

Anyway, help would be greatly appreciated.  I don't read these
newsgroup regularly (like once every decade), so please email
to me at either ...!att!cygni!jayhawk or rdmi@homxb.att.com

Thanks,
Ryan Moats
AT&T Bell Laboratories
Holmdel, NJ

keffer@blake.acs.washington.edu (Thomas Keffer) (12/05/89)

In article <6258@cbnewsh.ATT.COM> jayhawk@cbnewsh.ATT.COM (R.Moats) writes:
>
>I am posting this request for a friend who has not caught up
>with where news access is now located.  Anyway, I digress...
>
>Is there, was there, will there be a tool to convert fortran
>code to C code.  We are talking here mainly F66 or F77, but he
>will take anything.   The tool needs to operate under either
>MSDOS or UNIX (preferrably Sys V but again, he's flexible [read
>desperate ... ;-)])
>
>Price:  "...the cheaper the better, free is the best".

We bought a $40 cheapie from Austin CodeWorks.  Don't bother.
It's worth about what paid: not much (this is no reflection on 
ACW, which generally supplies Good Stuff).  It can handle the most
simple stuff, but something as straightforward as an indexed array 
caused it to freeze up.

A more expensive alternative is offered by Cobalt Blue ("For_C").  
About $700.  (408) 723-0474.

Tom Keffer
Rogue Wave
P.O. Box 85341
Seattle, WA 98145-1341
(206) 523-5831

keffer@ocean.washington.edu

hirchert@uxe.cso.uiuc.edu (12/06/89)

Ryan Moats (jayhawk@cbnewsh.ATT.COM) asks:
>Is there, was there, will there be a tool to convert fortran
>code to C code.

The following sounds like what you might be looking for:

>From: Norm Schryer <nls@research.att.com>
>Date: Thu, 16 Nov 89 17:17:35 EST
>Subject: Fortran 77 to C Converter Available via Netlib
>
>The Unix command
>
>    (echo filter f2c; cat file) | mail netlib@research.att.com
>
>converts the Fortran 77 in "file" to C and returns it via email.
>
>The converted C requires a "header" file which can be obtained by:
>
>    echo "send f2c.h from f2c" | mail netlib@research.att.com
>
>The command
>
>    echo "send index from f2c" | mail netlib@research.att.com
>
>returns an index of useful f2c information available from Netlib
>including a "man page", source for libraries, etc.
>
>F2c "just" prints out the C parse tree internally produced by f77,
>the reliable old Fortran 77 compiler of Stu Feldman.
>The programming was done by D. M. Gay of Bell Labs and
>Mark Maimone of Carnegie-Mellon University.
>
>The usual caveat applies:
>    The service is free and you get what you pay for.
>
>An additional caveat is that a daemon saves the Fortran submitted
>to Netlib so we can do regression testing on f2c.
>
>We intend to put f2c in the public domain and want as much
>experience with it as possible before foisting it on the world.
>
>Comments, questions and complaints to
>
>        Norm Schryer, nls@research.att.com, 201-582-2912.

Since you both work for AT&T, maybe they'll even let you use it directly
instead of over the network.

Kurt W. Hirchert     hirchert@ncsa.uiuc.edu
National Center for Supercomputing Applications

andrew@alice.UUCP (Andrew Hume) (12/07/89)

there is a good f77 -> c conversion facility available.
i am not sure of the details; i believe you mail
source to a magic mailbox and back comes c source.
ask dmg@research.att.com for details.
(or uunet!research!dmg)

DVL@PSUVM.BITNET (Roger Christman) (12/08/89)

My Masters thesis here at Penn State U is to write a Fortran/C
translator.  I'm doing it mostly off the top of my head.
It is a bit more complex (and therefore better) than simple
line-by-line translation.  It is designed to accept any Fortran 66
program and translate it into an equivalent C source.  Program flow
structure is analyzed so that even the messiest GOTO arrangements
should find themselves better approximating such things as loops
and switches.

The program is not yet completed -- I am in the middle of handling
subroutine parameters.  It will determine which parameters are more
appropriate as call by value, instead of Fortran's default to call
by reference.

The upshot of all this is that the resulting program will be more
intuitively structured, as well as more efficient than the original.
As an example of current benchmarks, using the F77 and CC compilers
on a Sun Workstation Unix machine, my program is doing quite well.
The time required to translate into C and compile there is less than
the original Fortran compilation time.  Also, the object code in C
executes faster than the original Fortran.

If you would like to find out more later on, when I approach the end
of the project, please send me mail at this address.  I must warn you
that this project is for academic reasons alone, and is not designed
with production-scale error-checking.  If your program will not compile
in Fortran 66, don't expect this translator to give you very meaningful
results.

To quote from my finger plan:
Plan:
        Make sense of the most inscrutable Fortran code.
        To translate such code into a C source which will ru
^^}}---^^^^ggggggggg`````
Segmentation fault (core dumped)

Roger Christman
No Sig