summaryrefslogtreecommitdiffstats
path: root/usr.bin/f2c/f2c.1
blob: 08e99ed1703de83aa80bec268a9d59f350fe4afc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
.\" mdoc translation of the f2c.1 manpage (deprecated -man format) supplied
.\" with f2c.  The original manpage did not have a copyright statement, but
.\" the file /usr/src/bin/f2c/Notice states:
.\"
.\"/****************************************************************
.\"Copyright 1990 - 1997 by AT&T Bell Laboratories and Bellcore.
.\"
.\"Permission to use, copy, modify, and distribute this software
.\"and its documentation for any purpose and without fee is hereby
.\"granted, provided that the above copyright notice appear in all
.\"copies and that both that the copyright notice and this
.\"permission notice and warranty disclaimer appear in supporting
.\"documentation, and that the names of AT&T Bell Laboratories or
.\"Bellcore or any of their entities not be used in advertising or
.\"publicity pertaining to distribution of the software without
.\"specific, written prior permission.
.\"
.\"AT&T and Bellcore disclaim all warranties with regard to this
.\"software, including all implied warranties of merchantability
.\"and fitness.  In no event shall AT&T or Bellcore be liable for
.\"any special, indirect or consequential damages or any damages
.\"whatsoever resulting from loss of use, data or profits, whether
.\"in an action of contract, negligence or other tortious action,
.\"arising out of or in connection with the use or performance of
.\"this software.
.\"****************************************************************/
.\"
.Dd April 19, 1996
.Os "AT&T Bell Lab and Bellcore"
.Dt F2C 1
.Sh NAME
.Nm f2c
.Nd Convert Fortran 77 to C or C++
.Sh SYNOPSIS
.Nm f2c
.Op Fl AaCcEfgpRrsUuvw
.Op Fl C++
.Op Fl cd
.Op Fl d Ar dir
.Op Fl ec
.Op Fl e1c
.Op Fl ext
.Op Fl h Ns Op Cm d
.Op Fl \&I2
.Op Fl \&i2
.Op Fl i90
.Op Fl kr Ns Op Cm d
.Op Fl o Ar name
.Op Fl onetrip
.Op Fl P Ns Op Cm s
.Op Fl r8
.Op Fl 72
.Op Fl T Ar dir
.Op Fl w8
.Op Fl W Ns Ar n
.Op Fl z
.Op Fl !bs
.Op Fl !c
.Op Fl !I
.Op Fl !i8
.Op Fl !it
.Op Fl !P
.Ar file ...
.Sh DESCRIPTION
.Nm F2c
converts Fortran 77 source code in
.Ar files
with names ending in
.So \&.f Sc
or
.So \&.F Sc
to C (or C++) source files in the current directory, with
.So \&.c Sc
substituted for the final
.So \&.f Sc
or
.So \&.F Sc .
If no Fortran files are named,
.Nm f2c
reads Fortran from standard input and writes C on standard output.
.Ar File
names that end with
.So \&.p Sc
or
.So \&.P Sc
are taken to be prototype files, as produced by option
.Fl P ,
and are read first.
.Sh OPTIONS
.Bl -tag -width flag
.It Fl A
Produce ANSI C.  Default is old-style C.
.It Fl a
Make local variables automatic rather than static unless they appear in a
DATA , EQUIVALENCE , NAMELIST , or SAVE statement.
.It Fl C
Compile code to check that subscripts are within declared array bounds.
.It Fl C++
Output C++ code.
.It Fl c
Include original Fortran source as comments.
.It Fl 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.
.It Fl d Ar dir
Write `.c' files in directory 
.Ar dir 
instead of the current directory
.It Fl E
Declare uninitialized COMMON to be Extern (overridably defined in
.Pa f2c.h
as
.Em extern
).
.It Fl ec
Place uninitialized COMMON blocks in separate files:
COMMON ABC appears in file abc_com.c .
Option
.Fl e1c
bundles the separate files
into the output file, with comments that give an unbundling
.Xr sed 1
script.
.It Fl e1c
See
.Fl ec .
.It Fl ext
Complain about Fortran 77 extensions.
.It Fl f
Assume free-format input: accept text after column 72 and do not
pad fixed-format lines shorter than 72 characters with blanks.
.It Fl 72
Treat text appearing after column 72 as an error.
.It Fl g
Include original Fortran line numbers in
.Sy #line
lines.
.It Fl h Ns Op Cm d
Emulate Fortran 66's treatment of Hollerith: try to align character strings on
word (or, if the option is
.Fl hd ,
on double-word) boundaries.
.It Fl \&I2
Render INTEGER and LOGICAL as short, INTEGER*4 as long int.  Assume the
default
.Em libF77
and
.Em libI77
allow only INTEGER*4 (and no LOGICAL) variables in INQUIREs.  Option
.Fl \&I4
confirms the default rendering of INTEGER as long int.
.It Fl \&i2
Similar to
.Fl \&I2 ,
but assume a modified
.Em libF77
and
.Em libI77
(compiled with
.Fl Df2c_i2 ),
so INTEGER and LOGICAL variables may be assigned by INQUIRE and array lengths
are stored in short ints
.It Fl i90 
Do not recognize the Fortran 90 bit-manipulation intrinsics btest,
iand, ibclr, ibits, ibset, ieor, ior, ishft, and ishftc.
.It Fl kr Ns Op Cm d
Use temporary values to enforce Fortran expression evaluation
where K&R (first edition) parenthesization rules allow rearrangement.
If the option is
.Fl krd ,
use double precision temporaries even for single-precision operands.
.It Fl o Ar name
The C source code is written into file
.Ar name .
.It Fl 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.)
.It Fl P Ns Op Cm s
Write a
.Ar file Ns \&.P
of ANSI (or C++) prototypes for definitions in each input
.Ar file Ns \&.f
or
.Ar file Ns \&.F .
When reading Fortran from standard input, write prototypes at the beginning of
standard output.  Option
.Fl Ps
implies
.Fl P
and gives exit status 4 if rerunning
.Nm f2c
may change prototypes or declarations.
.It Fl p
Supply preprocessor definitions to make common-block members look like local
variables.
.It Fl v
Echo the file name, program name, and procedure name(s) during compilation.
.It Fl R
Do not promote REAL functions and operations to DOUBLE PRECISION.  Option
.Fl !R
confirms the default, which imitates Fortran 77.
.It Fl r
Cast values of REAL functions (including intrinsics) to REAL.
.It Fl r8
Promote REAL to DOUBLE PRECISION, COMPLEX to DOUBLE COMPLEX.
.It Fl s
Preserve multidimensional subscripts.
.It Fl T Ar dir
Put temporary files in directory
.Ar dir .
.It Fl U
Honor the case of variable and external names.  Fortran keywords must be in
.Em lower
case.
.It Fl u
Make the default type of a variable
.So undefined Sc
rather than using the default Fortran rules.
.It Fl w
Suppress all warning messages.  If the option is
.Fl w66 ,
only Fortran 66 compatibility warnings are suppressed.
.It Fl w8
Suppress warnings when COMMON or EQUIVALENCE forces odd-word alignment of
doubles.
.It Fl W Ns Ar n
Assume
.Ar n
characters/word (default 4) when initializing numeric variables with character
data.
.It Fl z
Do not implicitly recognize DOUBLE COMPLEX.
.It Fl !bs
Do not recognize
.Em backslash
escapes
(\e", \e', \e0, \e\e, \eb, \ef, \en, \er, \et, \ev) in character strings.
.It Fl !c
Inhibit C output, but produce
.Fl P
output.
.It Fl !I
Reject
.Sy include
statements.
.It Fl !i8
Disallow INTEGER*8.
.It Fl !it
Don't infer types of untyped EXTERNAL procedures from use as parameters to
previously defined or prototyped procedures.
.It Fl !P
Do not attempt to infer ANSI or C++ prototypes from usage.
.El
.Pp
Object code should be loaded by with
.Xr ld 1
or
.Xr cc 1
and the following libraries need to specified:
.Fl lf2c lm .
.Sh FILES
.Ar file Ns \&.[fF]
input file

.Ar file Ns \&.c
output file

.Pa /usr/include/f2c.h
header file

.Pa /usr/lib/libf2c.a
intrinsic function library and Fortran 77 I/O library

.Sh "SEE ALSO"
.Rs
.%A S. I. Feldman
.%A P. J. Weinberger
.%T A Portable Fortran 77 Compiler
.%B UNIX Time Sharing System Programmer's Manual
.%V Volume 2
.%D 1990
.%O AT&T Bell Laboratories
.%N Tenth Edition
.Re
.Sh DIAGNOSTICS
The diagnostics produced by
.Nm f2c
are intended to be
self-explanatory.
.Sh BUGS
Floating-point constant expressions are simplified in
the floating-point arithmetic of the machine running
.Nm f2c
so they are typically accurate to at most 16 or 17 decimal places.
.Pp
Untypable EXTERNAL functions are declared int.
.Pp
There are several undocumented valid options for
.Nm f2c .
These options are discussed at the top of 
.Pa /usr/src/usr.bin/f2c/main.c .
OpenPOWER on IntegriCloud