From: burley@wookumz.gnu.ai.mit.edu (Craig Burley) Subject: Re: Fortran, f2c and so on... Date: 30 Jun 1993 15:28:33
In article <20sjcg$1ag@urmel.informatik.rwth-aachen.de> fricke@ikki.informatik.rwth-aachen.de (Thomas Fricke) writes:
1. Is there any Compiler?
The answer is NO, but there is a fortran-to-C converter (f2c),
which allows to translate STANDARD F77 into K&R C, Ansi C or C++
(optional).
It is a PD distribution made by Bell-Labs force the migration AWAY
from fortran. If you have clean standard sources, it is a very fine
program to translate numerical libraries into the world of C.
I disagree. f2c is neither made to force migration away from Fortran,
nor is it intend to translate Fortran into C source as implied above.
f2c is made to translate Fortran into a form of C that can be compiled
by C compilers but generally not maintained by humans. Even the f2c
documentation makes that point clear.
Generally, it is a good idea to use f2c to translate clean and
regular F sources to C. If you have some programs using a lot
of machine specific extensions, OR if you cannot catch the the
author of the spaghetti code, OR it uses some kinds exceptions
as the regular way to leave a subroutine (the worsest thing
to make even object oriented languages to a spaghetti machine)
DO NOT EVEN THINK ABOUT IT! F2c is useful as a migration tool,
not as the regular part of a fc.
While f2c does not support many popular extensions, it does support
several useful ones, and within that context, it is a reasonable
component of a Fortran compiler. Especially using f2c options that,
from what I've read on USENET (and am too lazy to look up on one
of my other VCs :-), maintain source-line numbering and put
original code in C comments so debugging with gdb is feasible.
I wouldn't use f2c to translate Fortran source to C sources, however,
except as an extremely quick and dirty start to what would likely
be rather painful process to continue for any length of time. And
I certainly wouldn't do it to code containing any appreciable
amount of Fortran I/O, CHARACTER, or EQUIVALENCE code.
f2c is fine as a component of f77 as shipped by, for example, SLS.
(It seems to work fine on my ancient SLS system, which I hope to upgrade
soon.) At the very least, it serves as an excellent stopgap until
GNU Fortran becomes available.
In the meantime, if you really want to convert Fortran code to C,
you probably should consider looking at the Fortran FAQ on comp.answers
and learning about the commercial products that do a better job of
making C _source_ code out of Fortran than f2c (which just transforms
Fortran to C _compilable_ code -- there is a big difference, just
as there's a big difference between hand-written 386 assembler code
in terms of comments, speed, maintainability, etc., and the output
of gcc -S).