|
|
1.1 ! root 1: .EQ ! 2: define dollar % "\f(CW$\fP" % ! 3: delim $$ ! 4: define f2c % "f\|2c" % ! 5: define F2c % "F\^2c" % ! 6: define libF77 % "libF77" % ! 7: define libI77 % "libI77" % ! 8: define LibF77 % "LibF77" % ! 9: define LibI77 % "LibI77" % ! 10: .EN ! 11: .TL ! 12: Availability of $f2c$ \(em a Fortran to C Converter ! 13: .AU ! 14: S. I. Feldman ! 15: .AI ! 16: Bellcore ! 17: Morristown, NJ 07960 ! 18: .AU ! 19: D. M. Gay ! 20: .AI ! 21: .MH ! 22: .AU ! 23: M. W. Maimone ! 24: .AI ! 25: Carnegie-Mellon University ! 26: Pittsburgh, PA 15213 ! 27: .AU ! 28: N. L. Schryer ! 29: .AI ! 30: .MH ! 31: .AB \ ! 32: .AE ! 33: .PP ! 34: Automatic conversion of Fortran 77 ! 35: .[ [ ! 36: ANSI FORTRAN 1978 ! 37: .]] ! 38: to C ! 39: .[ [ ! 40: Kernighan Ritchie 1988 ! 41: .]] ! 42: is desirable for ! 43: several reasons. Sometimes it is useful to run a ! 44: well-tested Fortran program on a machine that has a C ! 45: compiler but no Fortran compiler. At other times, it ! 46: is convenient to mix C and Fortran. Some things are ! 47: impossible to express in Fortran 77 or are harder ! 48: to express in Fortran than in C ! 49: (e.g. storage management, some character operations, ! 50: arrays of functions, heterogeneous data structures, ! 51: and calls that depend on the operating system), ! 52: and some programmers simply prefer C to Fortran. ! 53: There is a large body of well tested ! 54: Fortran source code for carrying out a wide variety of ! 55: useful calculations, and it is sometimes desirable to ! 56: exploit some of this Fortran source in a C environment. ! 57: Many vendors provide some way of mixing C and Fortran, but ! 58: the details vary from system to system. ! 59: Automatic Fortran to C conversion lets one create a ! 60: .I portable ! 61: C program that exploits Fortran source code. ! 62: .PP ! 63: A side benefit of automatic Fortran 77 to C conversion is that ! 64: it allows tools like ! 65: .I lint ! 66: \ ! 67: .[[ ! 68: v101 ! 69: .]] ! 70: to provide Fortran 77 programs with some of the consistency ! 71: and portability checks that the Pfort Verifier ! 72: .[ [ ! 73: Ryder 1974 ! 74: .]] ! 75: made available to Fortran 66 programs. ! 76: .PP ! 77: Starting from Feldman's original $f77$ compiler ! 78: .[ [ ! 79: Feldman Weinberger Portable Fortran ! 80: .]] ! 81: (the original UNIX\u\(rg\d Fortran 77 compiler), ! 82: we have created a program called $f2c$ that converts ! 83: Fortran 77 source code into C. ! 84: Our report ! 85: .[ [ ! 86: Feldman Gay Maimone Schryer ! 87: .]] ! 88: describes $f2c$'s conversions in considerable detail; ! 89: the purpose of this note is to point out the availability ! 90: both of our report and of the source for $f2c$ itself. ! 91: On request, we are happy to send out paper copies of the report. ! 92: You can also obtain a Postscript version of it by electronic ! 93: mail by sending the message ! 94: .ce ! 95: \f(CWsend f2c.ps from f2c\fR ! 96: to \f([email protected]\fR. Source for both $f2c$ ! 97: and the support libraries assumed by the C it produces ! 98: is available by electronic mail and by $ftp$. For details, ! 99: send the electronic-mail message ! 100: .ce ! 101: \f(CWsend index from f2c\fR ! 102: to \f([email protected]\fR. You can also $ftp$ to ! 103: \f(CWresearch.att.com\fR; in subdirectory \f(CWdist/f2c\fR you ! 104: will find a copy of the \f(CWindex\fR file and of source for ! 105: $f2c$ and its support libraries. ! 106: (As of this writing, 426 different people had ! 107: obtained $f2c$ source from ! 108: .I netlib , ! 109: i.e., by electronic mail, ! 110: and 644 had obtained it by $ftp$.) ! 111: .PP ! 112: We have used $f2c$ to convert various large programs and ! 113: subroutine libraries to C automatically (i.e., with no manual intervention); ! 114: these include the \s-2PORT3\s+2 subroutine library (\s-2PORT1\s+2 ! 115: is described in ! 116: .[ [ ! 117: Fox Hall Schryer Algorithm 1978 ! 118: .] ! 119: .[ ! 120: Fox Hall Schryer port 1978 ! 121: .]]), ! 122: MINOS ! 123: .[ [ ! 124: Murtagh Saunders 1987 ! 125: .]], ! 126: and Schryer's floating-point test ! 127: .[ [ ! 128: Schryer floating ! 129: .]]. ! 130: In addition to our own testing, we have been helped by feedback ! 131: from many people and by observing $f2c$'s behavior on some 21 megabytes ! 132: of Fortran submitted to $netlib$'s experimental ``\f(CWexecute f2c\fR'' ! 133: service; the feedback and our observations have led us to isolate ! 134: and repair numerous bugs and to extend $f2c$ in various ways. ! 135: .PP ! 136: Although we have tried to make $f2c$'s output reasonably readable, ! 137: our goal of strict compatibility with $f77$ implies some nasty ! 138: looking conversions. Input/output statements, in particular, ! 139: generally get expanded into ! 140: a series of calls on routines in $libI77$ ($f77$'s I/O library). ! 141: Thus the C output of $f2c$ would probably be something of a nightmare ! 142: to maintain as C; it is much more sensible to maintain the original ! 143: Fortran, translating it anew each time it changes. Some commercial ! 144: vendors, e.g., those listed in an appendix to our report, ! 145: seek to perform translations yielding C that one ! 146: might reasonably maintain directly; in general, these translations ! 147: require some manual intervention. ! 148: .PP ! 149: $F2c$ optionally emits special files called ! 150: .I prototype ! 151: files that summarize the calling sequences of ! 152: the translated subprograms. ! 153: A side benefit of $f2c$ is that it can read prototype ! 154: files and check the consistency of calling sequences ! 155: across files. We have found this to be a useful debugging aid. ! 156: Use of prototypes is slightly more convenient than invoking ! 157: .I lint , ! 158: but ! 159: .I lint ! 160: warns of other possible errors, such as variables that may be ! 161: referenced before they are set. ! 162: ! 163: .ce ! 164: REFERENCES ! 165: .LP ! 166: .so tmac.sdisp1 ! 167: .[ ! 168: $LIST$ ! 169: .]
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.