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