add $(EXEEXT) to executable targets during installation for MinGW
[suif.git] / html / man_sf2c.1.html
blob7b6459137c94ab1bbc832aed159d5e584d0418ce
1 <!-- manual page source format generated by PolyglotMan v3.0.7, -->
2 <!-- available via anonymous ftp from ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z -->
4 <HTML>
5 <HEAD>
6 <TITLE>Man page for sf2c.1</TITLE>
7 </HEAD>
8 <BODY bgcolor=white>
9 <A HREF="#toc">Table of Contents</A><P>
11 <H2><A NAME="sect0" HREF="#toc0">Name</A></H2>
13 <P>
14 sf2c - first pass of the SUIF Fortran 77 front end
16 <H2><A NAME="sect1" HREF="#toc1"><B>Synopsis</B></A></H2>
18 <P>
19 <B>sf2c</B> [ <I>options</I> ] <I>infile</I>
21 <H2><A NAME="sect2" HREF="#toc2"><B>Description</B></A></H2>
23 <P>
24 The <I>sf2c</I> program forms the first part of the SUIF Fortran
25 77 front end. It is typically run automatically by <I>scc,</I>
26 not directly by the user. The output of <I>sf2c</I> should be
27 run through <I>cpp</I> (the usual C pre-processor, not a part of
28 SUIF) <I>snoot,</I> <I>fixfortran,</I> and the <I>porky</I> <I>-defaults</I> passes,
29 in that order, to complete the SUIF Fortran front end.
30 <P>
31 The <I>sf2c</I> pass converts Fortran code into a special kind of
32 C code. The C code is legal and has the same semantics as
33 the Fortran program, but it also has special Fortran-specific
34 information encoded in things like assignments to
35 dummy variables. The most important information this
36 encodes is the original array type and bound information,
37 including symbolic bounds.
38 <P>
39 This special C program is passed through <I>cpp</I> and then
40 <I>snoot,</I> the regular ANSI C front end, to translate it into
41 SUIF code. Then fixfortran extracts the Fortran information
42 that had been encoded in C, restoring array types,
43 call-by-reference and common-block variables, and more,
44 when possible. Note that fixfortran is tightly coupled
45 with sf2c and expects its input to be in exactly the form
46 sf2c put it in. Other Fortran to C converters will not
47 work. It is vital that no changes are made to the C code
48 before <I>cpp</I> and <I>snoot</I> or to the SUIF code coming out of
49 snoot before it gets to fixfortran. If any changes are
50 made, fixfortran will become confused and probably die
51 with some error message, but it is possible it will produce
52 incorrect code in that case.
53 <P>
54 Our <I>sf2c</I> pass is based largely on a version of the Bell
55 Labs <I>f2c</I> Fortran-to-C converter. Most of the original <I>f2c</I>
56 options and features are available in <I>sf2c.</I> The major
57 changes we've made have been aimed at getting more highlevel
58 Fortran information encoded in the C output. There
59 are some strange contortions we put <I>sf2c</I> and fixfortran
60 through to preserve this information given the structure
61 of the old <I>f2c.</I> It is strongly recommended that the output
62 of <I>sf2c</I> never be used directly; the entire front end
63 of <I>sf2c-cpp-snoot-fixfortran-porky</I> should be treated as a
64 black box. There are a few command line flags to sf2c
65 that might be of general interest, but the internals of
66 the front end are not.
67 <P>
68 The <I>sf2c</I> pass takes arguments that end with <I>.f</I> or <I>.F</I> as
69 Fortran 77 source programs. If no output file is specified
70 (the <B>-o</B> option), the output (the special C file) is
71 given the same name but put in the current directory with
72 an extension of <I>.c.</I> If no arguments are given, then <I>sf2c</I>
73 reads Fortran from standard input and writes the special C
74 file to standard output.
75 <P>
76 The resulting C code needs to include the <I>sf2c.h</I> header
77 file, but this is normally taken care of automatically by
78 <I>scc.</I> The code must eventually be linked with the
79 libraries <I>libF77</I> (or its variant, <I>libF77</I><B>_</B><I>doall,</I> in the
80 case of parallelized code) and <I>libI77,</I> which are included
81 in the SUIF distribution. This, too, is normally handled
82 automatically when you use scc to link.
84 <H2><A NAME="sect3" HREF="#toc3"><B>Options</B> <B>Added</B> <B>for</B> <B>Suif</B></A></H2>
87 <DL>
89 <DT><B>-g</B> </DT></DT>
90 <DD> Insert C ``#line'' directives to indicate the line
91 numbers in the original Fortran source. That way
92 the eventual SUIF file's \x01line\x02 annotations will
93 correctly refer to line numbers in the Fortran
94 source, not an intermediate Fortran file.
95 </DD>
96 </DL>
97 <P>
98 Unfortunately, <I>f2c</I> was not set up to keep careful
99 track of line numbers, so the result is line numbers
100 that are often off by one in some parts of the
101 program. They are close enough to be quite useful,
102 though.
104 Note that this option replaces the <B>-g</B> flag in <I>f2c.</I>
105 The old version of this flag printed the line numbers
106 in comments, not ``#line'' directives.
108 <DL>
110 <DT><B>-o</B> <I>filename</I></DT></DT>
111 <DD>
112 Use the given <I>filename</I> as the output file, instead
113 of trying to figure out an output file based on the
114 input file name.
115 </DD>
117 <DT><B>-pp</B> </DT></DT>
118 <DD> Put each array reference on a separate line. Line
119 breaks are introduced after each array reference if
120 this option is used. Then if the <B>-g</B> option is not
121 used, array refernce instructions can be uniquely
122 identified by their line numbers.
123 </DD>
125 <DT><B>-lab</B> </DT></DT>
126 <DD>Put a semicolon after each label. Why this might
127 be useful is unclear.
128 </DD>
130 <DT><B>-version</B></DT></DT>
131 <DD>
132 Print version information to stderr and exit immediately.
133 This is consistent with the <B>-version</B> flag
134 for most other SUIF passes that is implemented in
135 the main SUIF library.
136 </DD>
138 <DT><B>-quiet</B> Do </DT></DT>
139 <DD>not print verbose commentary while compiling.
140 Without this flag, <I>sf2c</I> prints out the names of
141 procedures as they are encountered, among other
142 things.
143 </DD>
144 </DL>
146 <H2><A NAME="sect4" HREF="#toc4"><B>OPTIONS</B> <B>IDENTICAL</B> <B>TO</B> <B>f77</B> <B>AND</B> <B>f2c</B></A></H2>
149 <DL>
151 <DT><B>-C</B> </DT></DT>
152 <DD> Compile code to check that subscripts are within
153 declared array bounds.
154 </DD>
156 <DT><B>-I2</B> </DT></DT>
157 <DD> Render INTEGER and LOGICAL as short, INTEGER*4 as
158 long int. Assume the default <I>libF77</I> and <I>libI77</I>:
159 allow only INTEGER*4 (and no LOGICAL) variables in
160 INQUIREs. This flag is incompatible with the <I>-I4</I>
161 flag.
162 </DD>
164 <DT><B>-onetrip</B></DT></DT>
165 <DD>
166 The semantics of a DO loop are changed so that
167 their bodies are performed at least once if
168 reached. (Fortran 77 DO loops are not performed at
169 all if the upper limit is smaller than the lower
170 limit.)
171 </DD>
173 <DT><B>-U</B> </DT></DT>
174 <DD> Honor the case of variables and external names.
175 Fortran keywords must be in lower case.
176 </DD>
178 <DT><B>-u</B> </DT></DT>
179 <DD> Make the default type of a variable `undefined'
180 rather than using the default Fortran rules.
181 </DD>
183 <DT><B>-w</B></DT></DT>
184 <DD>
185 <B>-w66</B> Suppress warning messages. The <B>-w</B> form supresses
186 all warning messages, the <B>-w66,</B> form supresses only
187 Fortran 66 compatibility warnings.
188 </DD>
189 </DL>
191 <H2><A NAME="sect5" HREF="#toc5"><B>OPTIONS</B> <B>RETAINED</B> <B>FROM</B> <B>f2c</B></A></H2>
194 <DL>
196 <DT><B>-A</B> </DT></DT>
197 <DD> Use ANSI C constructs. The default is old-style
198 (pre-ANSI) C. SUIF note: this option is irrelevant
199 as far as SUIF is concerned because the old-style C
200 used is a common subset of old C and ANSI C. The
201 <I>snoot</I> pass is fine with or without this option, as
202 it understands the complete ANSI C language.
203 </DD>
205 <DT><B>-a</B> </DT></DT>
206 <DD> Give local variables automatic (rather than static)
207 storage unless they appear in a DATA, EQUIVALENCE,
208 or SAVE statement. SUIF note: for SUIF it's usually
209 better to use this option because it's easier
210 to analyze automatic variables. But SUIF will
211 still be correct whether or not this flag is set.
212 </DD>
214 <DT><B>-c</B> </DT></DT>
215 <DD> Insert comments showing the original Fortran
216 source. SUIF note: if this option is used along
217 with the appropriate <I>cpp</I> and <I>snoot</I> options, comments
218 can be retained all through the SUIF code in
219 the form of annotations on mark instructions.
220 </DD>
222 <DT><B>-E</B> </DT></DT>
223 <DD> Declare uninitialized struct created for COMMON to
224 be Extern (which <I>sf2c.h</I> CW#defines to be extern if
225 it is otherwise undefined).
226 </DD>
228 <DT><B>-ec</B></DT></DT>
229 <DD>
230 <B>-e1c</B> These options are meaningless for SUIF. They cause
231 <B>sf2c</B> to emit a separate file for each uninitialized
232 COMMON; e.g. COMMON /ABC/ yields abc_com.c, which
233 defines abc_. If the option is <B>-e1c,</B> then bundle
234 the separate files that would result from <B>-ec</B> into
235 the output file, along with comments giving a <I>sed</I>
236 <I>(1)</I> script that separates the output file into the
237 files that <B>-ec</B> would give.
238 </DD>
240 <DT><B>-ext</B> </DT></DT>
241 <DD>Complain about f77 extensions.
242 </DD>
244 <DT><B>-i2</B> </DT></DT>
245 <DD> Do something similar to what is done by <B>-I2,</B> but
246 assume a modified <I>libF77</I> and <I>libI77</I> (compiled with
247 -Df2c_i2), so INTEGER and LOGICAL variables may be
248 assigned in INQUIREs. This is incompatible with
249 the <I>-I4</I> option.
250 </DD>
252 <DT><B>-R</B> </DT></DT>
253 <DD> Do not promote REAL functions and operations to
254 DOUBLE PRECISION (as <I>f77</I> does).
255 </DD>
257 <DT><B>-r8</B> </DT></DT>
258 <DD> Promote REAL to DOUBLE PRECISION, COMPLEX to DOUBLE
259 COMPLEX.
260 </DD>
262 <DT><B>-T</B><I>dir</I> </DT></DT>
263 <DD>Put temporary files in directory <I>dir</I> instead of
264 /tmp, the default. Note that the <I>TMPDIR</I> environment
265 variable may also be used to choose the directory
266 to use for temporary files. The <B>-T</B> option
267 overrides the <I>TMPDIR</I> environment variable if both
268 are specified.
269 </DD>
271 <DT><B>-w8</B> </DT></DT>
272 <DD> Do not complain when COMMON or EQUIVALENCE forces
273 doubles to be word-aligned.
274 </DD>
276 <DT><B>-W</B><I>n</I> </DT></DT>
277 <DD> Assume <I>n</I> characters/word (default 4) when initializing
278 numeric variables with character data.
279 </DD>
281 <DT><B>-z</B> </DT></DT>
282 <DD> Do not implicitly recognize DOUBLE COMPLEX.
283 </DD>
285 <DT><B>!I</B> </DT></DT>
286 <DD> Disable the included statement.
287 </DD>
288 </DL>
290 <H2><A NAME="sect6" HREF="#toc6"><B>OPTIONS</B> <B>THAT</B> <B>ARE</B> <B>UNDOCUMENTED</B> <B>IN</B> <B>f77</B></A></H2>
293 <B>-66</B> Disallow all extensions to Fortran 66.
295 <DL>
297 <DT><B>-d</B> </DT></DT>
298 <DD> Turn on debugging mode. Some effects of debugging
299 mode are that temporary intermediate files are not
300 removed and some verbose information is generated.
301 </DD>
303 <DT><B>-1</B> </DT></DT>
304 <DD> Undocumented synonym for the <B>-onetrip</B> flag.
305 </DD>
307 <DT><B>-I4</B> </DT></DT>
308 <DD> Render INTEGER and LOGICAL as `long int'. If this
309 option is used, neither of the options <B>-I2</B> or <B>-i2</B>
310 may be used, as they contradict this option.
311 </DD>
313 <DT><B>-Is</B> </DT></DT>
314 <DD> Use `short int' as the type for array subscripts.
315 </DD>
317 <DT><B>-O</B><I>n</I> </DT></DT>
318 <DD> Set the maximum number of register variables to
319 use. For SUIF we ignore whether the variable was
320 declared ``register'' in C anyway, so this option
321 is meaningless.
322 </DD>
324 <DT><B>-Nq</B><I>n</I></DT></DT>
325 <DD>
326 <B>-Nx</B><I>n</I>
327 <B>-Ns</B><I>n</I>
328 <B>-Nc</B><I>n</I>
329 <B>-Nn</B><I>n</I> Set various implementation size limits (internal
330 table sizes). These flags set, respectively, limits
331 on the number of equivalences (default 150),
332 external symbols (default 200), statement labels
333 (default 801), nesting of loops or if-then-elses
334 (default 20), and identifier names (default 401).
335 </DD>
337 <DT><B>-p</B> </DT></DT>
338 <DD> Use #defines within each procedure to make references
339 to common block variables look to human readers
340 like local variables. For SUIF this is irrelevant
341 since the macros will have been expanded by
342 the C pre-processor before SUIF code is ever produced.
343 SUIF's Fortran mode allows SUIF programs to
344 see common block variables as locals.
345 </DD>
347 <DT><B>-Fr</B><I>format-string</I></DT></DT>
348 <DD>
349 <B>-Fd</B><I>format-string</I>
350 Use the specified string to format, respectively,
351 `float' or `double' data written to the output C
352 file. The defaults are \x01(float)%s\x02 (or \x01%sf\x02 if
353 the <B>-A</B> flag is used to specify ANSI-C) for `float'
354 and \x01%.17g\x02 for `double'.
355 </DD>
357 <DT><B>-ev</B> </DT></DT>
358 <DD> This option might mean to #define things in equivalences
359 to look like ordinary local variables to
360 human readers of the C file. If so, it is irrelevant
361 to SUIF since the C pre-processor substitutes
362 for the macros before the code is converted to
363 SUIF.
364 </DD>
365 </DL>
367 <H2><A NAME="sect7" HREF="#toc7"><B>Environment</B> <B>Variables</B></A></H2>
370 <B>TMPDIR</B> This variable specifies the directory to use for
371 temporary files instead of the default /tmp directory.
372 See also the <B>-T</B> option.
374 <H2><A NAME="sect8" HREF="#toc8"><B>See</B> <B>Also</B></A></H2>
377 <I>scc,</I> <I>snoot,</I> <I>fixfortran,</I> <I>porky,</I> and <I>f77.</I>
379 <H2><A NAME="sect9" HREF="#toc9"><B>History</B></A></H2>
382 The version of <I>f2c</I> upon which <I>sf2c</I> is based calls itself,
383 \x01VERSION 14 December 1989 7:55:33". It was adapted for an
384 early version of SUIF by Dror Maydan. Chris Wilson made
385 more modifications to get the information required by the
386 current SUIF system.
388 Parts of this document were taken from the man page distributed
389 with <I>f2c.</I>
392 <HR><P>
393 <A NAME="toc"><B>Table of Contents</B></A><P>
394 <UL>
395 <LI><A NAME="toc0" HREF="#sect0">Name</A></LI>
396 <LI><A NAME="toc1" HREF="#sect1">Synopsis</A></LI>
397 <LI><A NAME="toc2" HREF="#sect2">Description</A></LI>
398 <LI><A NAME="toc3" HREF="#sect3">Options Added for Suif</A></LI>
399 <LI><A NAME="toc4" HREF="#sect4">OPTIONS IDENTICAL TO f77 AND f2c</A></LI>
400 <LI><A NAME="toc5" HREF="#sect5">OPTIONS RETAINED FROM f2c</A></LI>
401 <LI><A NAME="toc6" HREF="#sect6">OPTIONS THAT ARE UNDOCUMENTED IN f77</A></LI>
402 <LI><A NAME="toc7" HREF="#sect7">Environment Variables</A></LI>
403 <LI><A NAME="toc8" HREF="#sect8">See Also</A></LI>
404 <LI><A NAME="toc9" HREF="#sect9">History</A></LI>
405 </UL>
406 </BODY></HTML>