F2C(1)

NAME
f2c - Convert Fortran 77 to C or C++

SYNOPSIS
f2c [-AaCcEfgpRrsUuvw] [-C++] [-cd] [-d dir] [-ec] [-e1c] [-ext] [-h[d]] [-I2] [-i2] [-i90] [-kr[d]] [-o name] [-onetrip] [-P[s]] [-r8] [-72] [-T dir] [-w8] [-Wn] [-z] [-!bs] [-!c] [-!I] [-!i8] [-!it] [-!P] file ...

DESCRIPTION
F2c converts Fortran 77 source code in files with names ending 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.

OPTIONS

-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  Compile code to check that subscripts are within declared array bounds.

-C++
    Output C++ code.

-c  Include original Fortran source as comments.

-cd Do not recognize cdabs, cdcos, cdexp, cdlog, cdsin, and cdsqrt as synonyms for the double complex intrinsics zabs, zcos, zexp, zlog, zsin, and zsqrt, respectively.

-d dir
    Write `.c' files in directory dir instead of the current directory

-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.

-e1c
    See -ec.

-ext
    Complain about Fortran 77 extensions.

-f  Assume free-format input: accept text after column 72 and do not pad fixed-format lines shorter than 72 characters with blanks.

-72 Treat text appearing after column 72 as an error.

-g  Include original Fortran line numbers in #line lines.

-h[d]
    Emulate Fortran 66's treatment of Hollerith: try to align character strings on word (or, if the option is -hd, on double-word) boundaries.

-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.

-i2 Similar to -I2, but assume a modified libF77 and libI77 (compiled with -Df2c_i2 -), so INTEGER and LOGICAL variables may be assigned by INQUIRE and array lengths are stored in short ints

-i90
    Do not recognize the Fortran 90 bit-manipulation intrinsics btest, iand, ibclr, ibits, ibset, ieor, ior, ishft, and ishftc.

-kr[d]
    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.

-o name
    The C source code is written into file name.

-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.)

-P[s]
    Write a file.P of ANSI (or C++) prototypes for definitions in each input file.f or file.F. When reading Fortran from standard input, write prototypes at the beginning of standard output. Option -Ps implies -P and gives exit status 4 if rerunning f2c may change prototypes or declarations.

-p  Supply preprocessor definitions to make common-block members look like local variables.

-v  Echo the file name, program name, and procedure name(s) during compilation.

-R  Do not promote REAL functions and operations to DOUBLE PRECISION. Option -!R confirms the default, which imitates Fortran 77.

-r  Cast values of REAL functions (including intrinsics) to REAL.

-r8 Promote REAL to DOUBLE PRECISION, COMPLEX to DOUBLE COMPLEX.

-s  Preserve multidimensional subscripts.

-T dir
    Put temporary files in directory dir.

-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.

-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.

-!i8
    Disallow INTEGER*8.

-!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.

Object code should be loaded by with ld(1) or cc(1) and the following libraries need to specified: -lf2c -lm.

FILES
file.[fF] input file file.c output file /usr/include/f2c.h header file /usr/lib/libf2c.a intrinsic function library and Fortran 77 I/O library

SEE ALSO
S. I. Feldman, P. J. Weinberger, A Portable Fortran 77 Compiler, UNIX Time Sharing System Programmer's Manual, Volume 2, 1990, AT&T Bell Laboratories, Tenth Edition.

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.

There are several undocumented valid options for f2c. These options are discussed at the top of /usr/src/usr.bin/f2c/main.c.