1As shipped, "makefile" is a copy of "makefile.u", a Unix makefile.
2Variants for other systems have names of the form makefile.* and
3have initial comments saying how to invoke them. You may wish to
4copy one of the other makefile.* files to makefile.
5
6If you use a C++ compiler, first say
7
8 make hadd
9
10to create a suitable f2c.h from f2c.h0 and f2ch.add. Otherwise,
11
12 make f2c.h
13
14will just copy f2c.h0 to f2c.h .
15
16If your compiler does not recognize ANSI C headers,
17compile with KR_headers defined: either add -DKR_headers
18to the definition of CFLAGS in the makefile, or insert
19
20#define KR_headers
21
22at the top of f2c.h .
23
24If your system lacks onexit() and you are not using an ANSI C
25compiler, then you should compile main.c with NO_ONEXIT defined.
26See the comments about onexit in makefile.u.
27
28If your system has a double drem() function such that drem(a,b)
29is the IEEE remainder function (with double a, b), then you may
30wish to compile r_mod.c and d_mod.c with IEEE_drem defined.
31
32To check for transmission errors, issue the command
33 make check
34or
35 make -f makefile.u check
36
37This assumes you have the xsum program whose source, xsum.c,
38is distributed as part of "all from f2c/src", and that it
39is installed somewhere in your search path. If you do not
40have xsum, you can obtain xsum.c by sending the following E-mail
41message to netlib@netlib.bell-labs.com
42 send xsum.c from f2c/src
43
44For convenience, the f2c.h0 in this directory is a copy of netlib's
45"f2c.h from f2c". It is best to install f2c.h in a standard place,
46so "include f2c.h" will work in any directory without further ado.
47Beware that the makefiles do not cause recompilation when f2c.h is
48changed.
49
50On machines, such as those using a DEC Alpha processor, on which
51sizeof(short) == 2, sizeof(int) == sizeof(float) == 4, and
52sizeof(long) == sizeof(double) == 8, it suffices to modify f2c.h by
53removing the first occurrence of "long " on each line containing
54"long ". On Unix systems, you can do this by issuing the commands
55 mv f2c.h f2c.h0
56 sed 's/long int /int /' f2c.h0 >f2c.h
57On such machines, one can enable INTEGER*8 by uncommenting the typedefs
58of longint and ulongint in f2c.h and adjusting them, so they read
59 typedef long longint;
60 typedef unsigned long ulongint;
61and by compiling libf2c with -DAllow_TYQUAD, as discussed below.
62
63
64Most of the routines in libf2c are support routines for Fortran
65intrinsic functions or for operations that f2c chooses not
66to do "in line". There are a few exceptions, summarized below --
67functions and subroutines that appear to your program as ordinary
68external Fortran routines.
69
70If you use the REAL valued functions listed below (ERF, ERFC,
71DTIME, and ETIME) with "f2c -R", then you need to compile the
72corresponding source files with -DREAL=float. To do this, it is
73perhaps simplest to add "-DREAL=float" to CFLAGS in the makefile.
74
751. CALL ABORT prints a message and causes a core dump.
76
772. ERF(r) and DERF(d) and the REAL and DOUBLE PRECISION
78 error functions (with x REAL and d DOUBLE PRECISION);
79 DERF must be declared DOUBLE PRECISION in your program.
80 Both ERF and DERF assume your C library provides the
81 underlying erf() function (which not all systems do).
82
833. ERFC(r) and DERFC(d) are the complementary error functions:
84 ERFC(r) = 1 - ERF(r) and DERFC(d) = 1.d0 - DERFC(d)
85 (except that their results may be more accurate than
86 explicitly evaluating the above formulae would give).
87 Again, ERFC and r are REAL, and DERFC and d are DOUBLE
88 PRECISION (and must be declared as such in your program),
89 and ERFC and DERFC rely on your system's erfc().
90
914. CALL GETARG(n,s), where n is an INTEGER and s is a CHARACTER
92 variable, sets s to the n-th command-line argument (or to
93 all blanks if there are fewer than n command-line arguments);
94 CALL GETARG(0,s) sets s to the name of the program (on systems
95 that support this feature). See IARGC below.
96
975. CALL GETENV(name, value), where name and value are of type
98 CHARACTER, sets value to the environment value, $name, of
99 name (or to blanks if $name has not been set).
100
1016. NARGS = IARGC() sets NARGS to the number of command-line
102 arguments (an INTEGER value).
103
1047. CALL SIGNAL(n,func), where n is an INTEGER and func is an
105 EXTERNAL procedure, arranges for func to be invoked when n
106 occurs (on systems where this makes sense).
107
108If your compiler complains about the signal calls in main.c, s_paus.c,
109and signal_.c, you may need to adjust signal1.h suitably. See the
110comments in signal1.h.
111
1128. ETIME(ARR) and DTIME(ARR) are REAL functions that return
113 execution times. ARR is declared REAL ARR(2). The elapsed
114 user and system CPU times are stored in ARR(1) and ARR(2),
115 respectively. ETIME returns the total elapsed CPU time,
116 i.e., ARR(1) + ARR(2). DTIME returns total elapsed CPU
117 time since the previous call on DTIME.
118
1199. CALL SYSTEM(cmd), where cmd is of type CHARACTER, passes
120 cmd to the system's command processor (on systems where
121 this can be done).
122
12310. CALL FLUSH flushes all buffers.
124
12511. FTELL(i) is an INTEGER function that returns the current
126 offset of Fortran unit i (or -1 if unit i is not open).
127
12812. CALL FSEEK(i, offset, whence, *errlab) attemps to move
129 Fortran unit i to the specified offset: absolute offset
130 if whence = 0; relative to the current offset if whence = 1;
131 relative to the end of the file if whence = 2. It branches
132 to label errlab if unit i is not open or if the call
133 otherwise fails.
134
135The routines whose objects are makefile.u's $(I77) are for I/O.
136The following comments apply to them.
137
138If your system lacks /usr/include/local.h ,
139then you should create an appropriate local.h in
140this directory. An appropriate local.h may simply
141be empty, or it may #define VAX or #define CRAY
142(or whatever else you must do to make fp.h work right).
143Alternatively, edit fp.h to suite your machine.
144
145If your system lacks /usr/include/fcntl.h , then you
146should simply create an empty fcntl.h in this directory.
147If your compiler then complains about creat and open not
148having a prototype, compile with OPEN_DECL defined.
149On many systems, open and creat are declared in fcntl.h .
150
151If your system's sprintf does not work the way ANSI C
152specifies -- specifically, if it does not return the
153number of characters transmitted -- then insert the line
154
155#define USE_STRLEN
156
157at the end of fmt.h . This is necessary with
158at least some versions of Sun software.
159In particular, if you get a warning about an improper
160pointer/integer combination in compiling wref.c, then
161you need to compile with -DUSE_STRLEN .
162
163If your system's fopen does not like the ANSI binary
164reading and writing modes "rb" and "wb", then you should
165compile open.c with NON_ANSI_RW_MODES #defined.
166
167If you get error messages about references to cf->_ptr
168and cf->_base when compiling wrtfmt.c and wsfe.c or to
169stderr->_flag when compiling err.c, then insert the line
170
171#define NON_UNIX_STDIO
172
173at the beginning of fio.h, and recompile everything (or
174at least those modules that contain NON_UNIX_STDIO).
175
176Unformatted sequential records consist of a length of record
177contents, the record contents themselves, and the length of
178record contents again (for backspace). Prior to 17 Oct. 1991,
179the length was of type int; now it is of type long, but you
180can change it back to int by inserting
181
182#define UIOLEN_int
183
184at the beginning of fio.h. This affects only sue.c and uio.c .
185
186If you have a really ancient K&R C compiler that does not understand
187void, add -Dvoid=int to the definition of CFLAGS in the makefile.
188
189On VAX, Cray, or Research Tenth-Edition Unix systems, you may
190need to add -DVAX, -DCRAY, or -DV10 (respectively) to CFLAGS
191to make fp.h work correctly. Alternatively, you may need to
192edit fp.h to suit your machine.
193
194If your compiler complains about the signal calls in main.c, s_paus.c,
195and signal_.c, you may need to adjust signal1.h suitably. See the
196comments in signal1.h.
197
198You may need to supply the following non-ANSI routines:
199
200 fstat(int fileds, struct stat *buf) is similar
201to stat(char *name, struct stat *buf), except that
202the first argument, fileds, is the file descriptor
203returned by open rather than the name of the file.
204fstat is used in the system-dependent routine
205canseek (in the libf2c source file err.c), which
206is supposed to return 1 if it's possible to issue
207seeks on the file in question, 0 if it's not; you may
208need to suitably modify err.c . On non-UNIX systems,
209you can avoid references to fstat and stat by compiling
210with NON_UNIX_STDIO defined; in that case, you may need
211to supply access(char *Name,0), which is supposed to
212return 0 if file Name exists, nonzero otherwise.
213
214 char * mktemp(char *buf) is supposed to replace the
2156 trailing X's in buf with a unique number and then
216return buf. The idea is to get a unique name for
217a temporary file.
218
219On non-UNIX systems, you may need to change a few other,
220e.g.: the form of name computed by mktemp() in endfile.c and
221open.c; the use of the open(), close(), and creat() system
222calls in endfile.c, err.c, open.c; and the modes in calls on
223fopen() and fdopen() (and perhaps the use of fdopen() itself
224-- it's supposed to return a FILE* corresponding to a given
225an integer file descriptor) in err.c and open.c (component ufmt
226of struct unit is 1 for formatted I/O -- text mode on some systems
227-- and 0 for unformatted I/O -- binary mode on some systems).
228Compiling with -DNON_UNIX_STDIO omits all references to creat()
229and almost all references to open() and close(), the exception
230being in the function f__isdev() (in open.c).
231
232If you wish to use translated Fortran that has funny notions
233of record length for direct unformatted I/O (i.e., that assumes
234RECL= values in OPEN statements are not bytes but rather counts
235of some other units -- e.g., 4-character words for VMS), then you
236should insert an appropriate #define for url_Adjust at the
237beginning of open.c . For VMS Fortran, for example,
238#define url_Adjust(x) x *= 4
239would suffice.
240
241By default, Fortran I/O units 5, 6, and 0 are pre-connected to
242stdin, stdout, and stderr, respectively. You can change this
243behavior by changing f_init() in err.c to suit your needs.
244Note that f2c assumes READ(*... means READ(5... and WRITE(*...
245means WRITE(6... . Moreover, an OPEN(n,... statement that does
246not specify a file name (and does not specify STATUS='SCRATCH')
247assumes FILE='fort.n' . You can change this by editing open.c
248and endfile.c suitably.
249
250Unless you adjust the "#define MXUNIT" line in fio.h, Fortran units
2510, 1, ..., 99 are available, i.e., the highest allowed unit number
252is MXUNIT - 1.
253
254Lines protected from compilation by #ifdef Allow_TYQUAD
255are for a possible extension to 64-bit integers in which
256integer = int = 32 bits and longint = long = 64 bits.
257
258The makefile does not attempt to compile pow_qq.c, qbitbits.c,
259and qbitshft.c, which are meant for use with INTEGER*8. To use
260INTEGER*8, you must modify f2c.h to declare longint and ulongint
261appropriately; then add $(QINT) to the end of the makefile's
262dependency list for libf2c.a (if makefile is a copy of makefile.u;
263for the PC makefiles, add pow_qq.obj qbitbits.obj qbitshft.obj
264to the library's dependency list and adjust libf2c.lbc or libf2c.sy
265accordingly). Also add -DAllow_TYQUAD to the makefile's CFLAGS
266assignment. To make longint and ulongint available, it may suffice
267to add -DINTEGER_STAR_8 to the CFLAGS assignment.
268
269Following Fortran 90, s_cat.c and s_copy.c allow the target of a
270(character string) assignment to be appear on its right-hand, at
271the cost of some extra overhead for all run-time concatenations.
272If you prefer the extra efficiency that comes with the Fortran 77
273requirement that the left-hand side of a character assignment not
274be involved in the right-hand side, compile s_cat.c and s_copy.c
275with -DNO_OVERWRITE .
276
277Extensions (Feb. 1993) to NAMELIST processing:
278 1. Reading a ? instead of &name (the start of a namelist) causes
279the namelist being sought to be written to stdout (unit 6);
280to omit this feature, compile rsne.c with -DNo_Namelist_Questions.
281 2. Reading the wrong namelist name now leads to an error message
282and an attempt to skip input until the right namelist name is found;
283to omit this feature, compile rsne.c with -DNo_Bad_Namelist_Skip.
284 3. Namelist writes now insert newlines before each variable; to omit
285this feature, compile xwsne.c with -DNo_Extra_Namelist_Newlines.
286 4. (Sept. 1995) When looking for the &name that starts namelist
287input, lines whose first non-blank character is something other
288than &, $, or ? are treated as comment lines and ignored, unless
289rsne.c is compiled with -DNo_Namelist_Comments.
290
291Nonstandard extension (Feb. 1993) to open: for sequential files,
292ACCESS='APPEND' (or access='anything else starting with "A" or "a"')
293causes the file to be positioned at end-of-file, so a write will
294append to the file.
295
296Some buggy Fortran programs use unformatted direct I/O to write
297an incomplete record and later read more from that record than
298they have written. For records other than the last, the unwritten
299portion of the record reads as binary zeros. The last record is
300a special case: attempting to read more from it than was written
301gives end-of-file -- which may help one find a bug. Some other
302Fortran I/O libraries treat the last record no differently than
303others and thus give no help in finding the bug of reading more
304than was written. If you wish to have this behavior, compile
305uio.c with -DPad_UDread .
306
307If you want to be able to catch write failures (e.g., due to a
308disk being full) with an ERR= specifier, compile dfe.c, due.c,
309sfe.c, sue.c, and wsle.c with -DALWAYS_FLUSH. This will lead to
310slower execution and more I/O, but should make ERR= work as
311expected, provided fflush returns an error return when its
312physical write fails.
313
314Carriage controls are meant to be interpreted by the UNIX col
315program (or a similar program). Sometimes it's convenient to use
316only ' ' as the carriage control character (normal single spacing).
317If you compile lwrite.c and wsfe.c with -DOMIT_BLANK_CC, formatted
318external output lines will have an initial ' ' quietly omitted,
319making use of the col program unnecessary with output that only
320has ' ' for carriage control.
321
322The Fortran 77 Standard leaves it up to the implementation whether
323formatted writes of floating-point numbers of absolute value < 1 have
324a zero before the decimal point. By default, libI77 omits such
325superfluous zeros, but you can cause them to appear by compiling
326lwrite.c, wref.c, and wrtfmt.c with -DWANT_LEAD_0 .
327
328If your (Unix) system lacks a ranlib command, you don't need it.
329Either comment out the makefile's ranlib invocation, or install
330a harmless "ranlib" command somewhere in your PATH, such as the
331one-line shell script
332
333 exit 0
334
335or (on some systems)
336
337 exec /usr/bin/ar lts $1 >/dev/null
338
339By default, the routines that implement complex and double complex
340division, c_div.c and z_div.c, call sig_die to print an error message
341and exit if they see a divisor of 0, as this is sometimes helpful for
342debugging. On systems with IEEE arithmetic, compiling c_div.c and
343z_div.c with -DIEEE_COMPLEX_DIVIDE causes them instead to set both
344the real and imaginary parts of the result to +INFINITY if the
345numerator is nonzero, or to NaN if it vanishes.
346
347Nowadays most Unix and Linux systems have function
348 int ftruncate(int fildes, off_t len);
349defined in system header file unistd.h that adjusts the length of file
350descriptor fildes to length len. Unless endfile.c is compiled with
351-DNO_TRUNCATE, endfile.c #includes "unistd.h" and calls ftruncate() if
352necessary to shorten files. If your system lacks ftruncate(), compile
353endfile.c with -DNO_TRUNCATE to make endfile.c use the older and more
354portable scheme of shortening a file by copying to a temporary file
355and back again.
356
357The initializations for "f2c -trapuv" are done by _uninit_f2c(),
358whose source is uninit.c, introduced June 2001. On IEEE-arithmetic
359systems, _uninit_f2c should initialize floating-point variables to
360signaling NaNs and, at its first invocation, should enable the
361invalid operation exception. Alas, the rules for distinguishing
362signaling from quiet NaNs were not specified in the IEEE P754 standard,
363nor were the precise means of enabling and disabling IEEE-arithmetic
364exceptions, and these details are thus system dependent. There are
365#ifdef's in uninit.c that specify them for some popular systems. If
366yours is not one of these systems, it may take some detective work to
367discover the appropriate details for your system. Sometimes it helps
368to look in the standard include directories for header files with
369relevant-sounding names, such as ieeefp.h, nan.h, or trap.h, and
370it may be simplest to run experiments to see what distinguishes a
371signaling from a quiet NaN. (If x is initialized to a signaling
372NaN and the invalid operation exception is masked off, as it should
373be by default on IEEE-arithmetic systems, then computing, say,
374y = x + 1 will yield a quiet NaN.)
375