oliver@fire.berkeley.edu (05/15/91)
I recently posted a question asking where I can find a copy of the Fortran->C translator called f2c. I received helpful replies from the following people: Mark.Maimone@A.GP.CS.CMU.EDU burley@gnu.ai.mit.edu (Craig Burley) herbst@seq.uncwil.edu (R.T. Herbst) David Edelsohn <edelsohn@sccs.syr.edu> Keith.Bierman@Eng.Sun.COM Marco.Zagha@ENQUIRER.SCANDAL.CS.CMU.EDU sam@sarnoff.com (Scott A. Markel x2683) jrbd@craycos.com (James Davies) Melvin Klassen <KLASSEN@UVVM.UVic.CA> The short answer is that the files are available in the directory dist/f2c on the FTP server research.att.com. I'm appending an announcement of availability (which describes mail server access for those without FTP), and the man page. I hope this is useful to someone ... thanks again to everyone who responded. Cheers, - Oliver ********************************* The announcement: ------------------------------------------------------------------------------ Source for f2c, a Fortran 77 to C translator jointly developed by folks from Bell Labs, Bellcore, and Carnegie Mellon, is now freely available. F2c was derived from the original UNIX operating system's f77(1), and the generated C follows f77's calling conventions; on some machines, the resulting object files are interchangeable with (and behave indistinguishably from) objects compiled by f77. The main "advantage" of f2c is that it converts ANSI standard Fortran 77 into C without manual intervention, at least when invoked by a suitable script or makefile (that may need to exercise an f2c option to ensure that COMMON blocks are defined just once). The main "problems" are that f2c does no code restructuring (e.g., gotos are preserved) and that Fortran I/O gets converted into a bunch of calls; thus the translated C code doesn't look too pretty, and in general one would need to maintain the Fortran rather than its translation into C. [F2c is not meant to displace the services of commercial vendors whose business is to convert Fortran into maintainable C.] There is a plethora of options, many of which exist to support different compilation environments for the translated C (e.g., ANSI C or C++ compatability, different type sizes, separate files for COMMON blocks to appease "smart" linkers). So far f2c (and f2c-generated source) has compiled successfully on many machines: Sun, Vax, IBMRT, Apollo, SGI, MIPS, and Cray to name a few. F2c has been under test by the net community since the Fall of 1989 and has been verified on the NBS tests, several large math libraries, floating point tests, even code for laying cable on the ocean floor! To find out about f2c, send the following E-mail message to netlib (netlib@research.att.com or research!netlib): send index from f2c Your message will be answered automatically (by a program -- see CACM vol. 30 #5 (May, 1987), pp. 403-407). You will receive a reply explaining how to automatically acquire f2c source (about 600K), f2c library source (130K), and supporting info (man page, etc). Or you can anonymous-FTP to research.att.com and look in directory dist/f2c at these files: all.Z -- 250K compressed shar file for f2c f2c.ps.Z -- 24 page tech report describing f2c index -- general info about files libf77.Z, libi77.Z -- compressed shar files for libraries ********************************* The man page: F2C(1) UNIX Programmer's Manual F2C(1) NAME f2c - Convert Fortran 77 to C or C++ SYNOPSIS f2c [ option ... ] file ... DESCRIPTION F2c converts Fortran 77 source code in files with names end- ing in `.f' or `.F' to C (or C++) source files in the current directory, with `.c' substituted for the final `.f' or `.F'. If no Fortran files are named, f2c reads Fortran from standard input and writes C on standard output. File names that end with `.p' or `.P' are taken to be prototype files, as produced by option `-P', and are read first. The following options have the same meaning as in f77(1). -C Compile code to check that subscripts are within declared array bounds. -I2 Render INTEGER and LOGICAL as short, INTEGER*4 as long int. Assume the default libf77 and libi77: allow only INTEGER*4 (and no LOGICAL) variables in INQUIREs. Option `-I4' confirms the default rendering of INTEGER as long int. -onetrip Compile DO loops that are performed at least once if reached. (Fortran 77 DO loops are not performed at all if the upper limit is smaller than the lower limit.) -U Honor the case of variable and external names. Fortran keywords must be in lower case. -u Make the default type of a variable `undefined' rather than using the default Fortran rules. -w Suppress all warning messages. If the option is `-w66', only Fortran 66 compatibility warnings are suppressed. The following options are peculiar to f2c. -A Produce ANSI C. Default is old-style C. -a Make local variables automatic rather than static unless they appear in a DATA, EQUIVALENCE, NAMELIST, or SAVE statement. -C++ Output C++ code. -c Include original Fortran source as comments. -E Declare uninitialized COMMON to be Extern (overridably defined in f2c.h as extern). -ec Place uninitialized COMMON blocks in separate files: COMMON /ABC/ appears in file abc_com.c. Option `-e1c' bundles the separate files into the output file, with comments that give an unbundling sed(1) script. -ext Complain about f77(1) extensions. -g Include original Fortran line numbers as comments. -h Try to align character strings on word (or, if the option is `-hd', on double-word) boundaries. -i2 Similar to -I2, but assume a modified libf77 and libi77 (compiled with -Df2c_i2), so INTEGER and LOGICAL vari- ables may be assigned by INQUIRE. -kr Use temporary values to enforce Fortran expression evaluation where K&R (first edition) parenthesization rules allow rearrangement. If the option is `-krd', use double precision temporaries even for single- precision operands. -P Write a file.P of ANSI (or C++) prototypes for pro- cedures defined in each input file.f or file.F. When reading Fortran from standard input, write prototypes at the beginning of standard output. Implies -A unless option `-C++' is present. Option -Ps implies -P , and gives exit status 4 if rerunning f2c may change proto- types or declarations. -p Supply preprocessor definitions to make common-block members look like local variables. -R Do not promote REAL functions and operations to DOUBLE PRECISION. Option `-!R' confirms the default, which imitates f77. -r Cast values of REAL functions (including intrinsics) to REAL. -r8 Promote REAL to DOUBLE PRECISION, COMPLEX to DOUBLE COMPLEX. -Tdir Put temporary files in directory dir. -w8 Suppress warnings when COMMON or EQUIVALENCE forces odd-word alignment of doubles. -Wn Assume n characters/word (default 4) when initializing numeric variables with character data. -z Do not implicitly recognize DOUBLE COMPLEX. -!bs Do not recognize backslash escapes (\", \', \0, \\, \b, \f, \n, \r, \t, \v) in character strings. -!c Inhibit C output, but produce -P output. -!I Reject include statements. -!it Don't infer types of untyped EXTERNAL procedures from use as parameters to previously defined or prototyped procedures. -!P Do not attempt to infer ANSI or C++ prototypes from usage. The resulting C invokes the support routines of f77; object code should be loaded by f77 or with ld(1) or cc(1) options -lf77 -li77 -lm. Calling conventions are those of f77: see the reference below. FILES file.[fF] input file *.c output file /usr/misc/include/f2c.h header file /usr/misc/lib/libf77.a intrinsic function library /usr/misc/lib/libi77.a Fortran I/O library /usr/cs/lib/libc.a C library, see section 3 SEE ALSO S. I. Feldman and P. J. Weinberger, `A Portable Fortran 77 Compiler', UNIX Time Sharing System Programmer's Manual, Tenth Edition, Volume 2, AT&T Bell Laboratories, 1990. DIAGNOSTICS The diagnostics produced by f2c are intended to be self- explanatory. BUGS Floating-point constant expressions are simplified in the floating-point arithmetic of the machine running f2c, so they are typically accurate to at most 16 or 17 decimal places. Untypable EXTERNAL functions are declared int. Send bug reports (at Carnegie Mellon) to Mark Maimone (mwm@cs.cmu.edu)