The f2c program comes standard with all GNU/Linux distributions with
which I am familiar. The home site of f2c is at
AT&T's netlib software
f2c converts standard Fortran-77 code to
standard C code. On GNU/linux, this is further compiled into assembly
by gcc. Three immediate advantages of f2c are:
A further advantage, if you are a nuclear or
particle physicist, is that
- it is free,
- it is extremely well-debugged,
- and it produces pretty fast code when coupled with gcc.
Disadvantages of f2c+gcc are that
- it has been used to compile all of the CERN libraries,
so using it you can get your favorite GEANT code or data
Debugging f2c+gcc-compiled code --- There are two ways to do
- it really accepts standard Fortran-77 code,
and little else. Most Fortran programs out there in the
physics world (in my experience) use many extensions, so
you might have to do some editing. Trivial examples I've
seen are the "q" format specifier, and the TYPE * statement
which are both VAXisms. These two are fairly easy to fix.
A nontrivial example is the STRUCTURE
data type. If your code makes heavy use of it, you're looking
at a serious rewrite if you want to use f2c+gcc.
Look at Wolfgang Wander's
f77 Problem Page
for more information
Getting correct results ---
firstname.lastname@example.org (T.Schuetze) pointed out that if one turns on
optimization, the "paranoia" suite fails.
This can be cured by passing the option -ffloat-store to the
gcc phase of the compilation.
If you use fort77 as a compiler driver, you can simply specify
the option as printed above; some other compiler drivers
may require you to
pass it to gcc using some special option prefix.
-ffloat-store forces all real variables to have their stated (either
real*4 or real*8) precision.
If you don't specify it, certain variables which only live in registers
may have the precision of the Intel FP registers, which is different
than real*4 or real*8.
f77/reorder. This allows your code to be debugged
- Install the f2c_stabs package (available from standard
linux software archives.) This package only runs under
the Emacs editor.
Last modified: Wed Apr 11 14:54:45 EDT 2001