====== old index for f2c, now "readme from f2c" ============ FILES: f2c.h Include file necessary for compiling output of the converter. See the second NOTE below. f2c.1 Man page for f2c. f2c.1t Source for f2c.1 (to be processed by troff -man or nroff -man). libf77 Library of non I/O support routines the generated C may need. Fortran main programs result in a C function named MAIN__ that is meant to be invoked by the main() in libf77. libi77 Library of Fortran I/O routines the generated C may need. Note that some vendors (e.g., BSD, Sun and MIPS) provide a libF77 and libI77 that are incompatible with f2c -- they provide some differently named routines or routines with the names that f2c expects, but with different calling sequences. On such systems, the recommended procedure is to merge libf77 and libi77 into a single library, say libf2c, and to install it where you can access it by specifying -lf2c . The definition of link_msg in sysdep.c assumes this arrangement. f2c.ps Postscript for a technical report on f2c. After you strip the mail header, the first line should be "%!PS". fixes The complete change log, reporting bug fixes and other changes. (Some recent change-log entries are given below). fc A shell script that uses f2c and imitates much of the behavior of commonly found f77 commands. You will almost certainly need to adjust some of the shell-variable assignments to make this script work on your system. SUBDIRECTORY: f2c/src Source for the converter itself, including a file of checksums and source for a program to compute the checksums (to verify correct transmission of the source), is available: ask netlib (e.g., netlib@research.att.com) to send all from f2c/src If the checksums show damage to just a few source files, or if the change log file (see "fixes" below) reports corrections to some source files, you can request those files individually "from f2c/src". For example, to get defs.h and xsum0.out, you would ask netlib to send defs.h xsum0.out from f2c/src "all from f2c/src" is about 640 kilobytes long; for convenience (and checksums), it includes copies of f2c.h, f2c.1, and f2c.1t. Tip: if asked to send over 99,000 bytes in one request, netlib breaks the shipment into 1000 line pieces and sends each piece separately (since otherwise some mailers might gag). To avoid the hassle of reassembling the pieces, try to keep each request under 99,000 bytes long. The final number in each line of xsum0.out gives the length of each file in f2c/src. For example, send exec.c expr.c from f2c/src send format.c format_data.c from f2c/src will give you slightly less hassle than send exec.c expr.c format.c format_data.c from f2c/src Alternatively, if all the mailers in your return path allow long messages, you can supply an appropriate mailsize line in your netlib request, e.g. mailsize 200k send exec.c expr.c format.c format_data.c from f2c/src If you have trouble generating gram.c, you can ask netlib to send gram.c from f2c/src Then `xsum gram.c` should report gram.c 1814e302 57355 NOTE: For now, you may exercise f2c by sending netlib a message whose first line is "execute f2c" and whose remaining lines are the Fortran 77 source that you wish to have converted. Return mail brings you the resulting C, with f2c's error messages between #ifdef uNdEfInEd and #endif at the end. (To understand line numbers in the error messages, regard the "execute f2c" line as line 0. It is stripped away by the netlib software before f2c sees your Fortran input.) Options described in the man page may be transmitted to netlib by having the first line of input be a comment whose first 6 characters are "c$f2c " and whose remaining characters are the desired options, e.g., "c$f2c -R -u". This scheme may change -- ask netlib to send index from f2c if you do not get the behavior you expect. During the initial experimental period, incoming Fortran will be saved in a file. Don't send any secrets! BUGS: Please send bug reports (including the shortest example you can find that illustrates the bug) to research!dmg or dmg@research.att.com . You might first check whether the bug goes away when you turn optimization off. NOTE: f2c.h defines several types, e.g., real, integer, doublereal. The definitions in f2c.h are suitable for most machines, but if your machine has sizeof(double) > 2*sizeof(long), you may need to adjust f2c.h appropriately. f2c assumes sizeof(doublecomplex) = 2*sizeof(doublereal) sizeof(doublereal) = sizeof(complex) sizeof(doublereal) = 2*sizeof(real) sizeof(real) = sizeof(integer) sizeof(real) = sizeof(logical) sizeof(real) = 2*sizeof(shortint) EQUIVALENCEs may not be translated correctly if these assumptions are violated. On machines, such as those using a DEC Alpha processor, on which sizeof(short) == 2, sizeof(int) == sizeof(float) == 4, and sizeof(long) == sizeof(double) == 8, it suffices to modify f2c.h by removing the first occurrence of "long " on each line containing "long ", e.g., by issuing the commands mv f2c.h f2c.h0 sed 's/long //' f2c.h0 >f2c.h On such machines, one can enable INTEGER*8 by uncommenting the typedef of longint in f2c.h, so it reads typedef long longint; by compiling libI77 with -DAllow_TYQUAD, and by adjusting libF77/makefile as described in libF77/README. Some machines may have sizeof(int) == 4 and sizeof(long long) == 8. On such machines, adjust f2c.h by changing "long int " to "long long ", e.g., by saying mv f2c.h f2c.h0 sed 's/long int /long long /' f2c.h0 >f2c.h One can enable INTEGER*8 on such machines as described above, but with typedef long long longint; There exists a C compiler that objects to the lines typedef VOID C_f; /* complex function */ typedef VOID H_f; /* character function */ typedef VOID Z_f; /* double complex function */ in f2c.h . If yours is such a compiler, do two things: 1. Complain to your vendor about this compiler bug. 2. Find the line #define VOID void in f2c.h and change it to #define VOID int (For readability, the f2c.h lines shown above have had two tabs inserted before their first character.) FTP: All the material described above is now available by anonymous ftp from netlib.att.com (login: anonymous; Password: your E-mail address; cd netlib/f2c). Note that you can say, e.g., cd /netlib/f2c/src binary prompt mget *.Z to get all the .Z files in src. You must uncompress the .Z files once you have a copy of them, e.g., by uncompress *.Z Subdirectory msdos contains two PC versions of f2c, f2c.exe.Z and f2cx.exe.Z; the latter uses extended memory. The README in that directory provides more details. Changes appear first in the f2c files available by E-mail from netlib@research.att.com. If the deamons work right, changed files are available the next day by ftp from netlib.att.com. In due course, they reach other netlib servers. ----------------- Recent change log (partial) ----------------- Tue May 10 07:55:12 EDT 1994 Trivial changes to exec.c, p1output.c, parse_args.c, proc.c, and putpcc.c: change arguments from type foo[] to type *foo for consistency with defs.h. For most compilers, this makes no difference. Thu Jun 2 12:18:18 EDT 1994 Fix bug in handling FORMAT statements that have adjacent character (or Hollerith) strings: an extraneous \002 appeared between the strings. libf77: under -DNO_ONEXIT, arrange for f_exit to be called just once; previously, upon abnormal termination (including stop statements), it was called twice. Mon Jun 6 15:52:57 EDT 1994 libf77: Avoid references to SIGABRT and SIGIOT if neither is defined; Version.c not changed. libi77: Add cast to definition of errfl() in fio.h; this only matters on systems with sizeof(int) < sizeof(long). Under -DNON_UNIX_STDIO, use binary mode for direct formatted files (to avoid any confusion connected with \n characters). Fri Jun 10 16:47:31 EDT 1994 Fix bug under -A in handling unreferenced (and undeclared) external arguments in subroutines with multiple entry points. Example: subroutine m(fcn,futil) external fcn,futil call fcn entry mintio(i1) ! (D_fp)0 rather than (U_fp)0 for futil end Wed Jun 15 10:38:14 EDT 1994 Allow char(constant expression) function in parameter declarations. (This was probably broken in the changes of 29 March 1994.) Fri Jul 1 23:54:00 EDT 1994 Minor adjustments to makefile (rule for f2c.1 commented out) and sysdep.h (#undef KR_headers if __STDC__ is #defined, and base test for ANSI_Libraries and ANSI_Prototypes on KR_headers rather than __STDC__); version.c touched but not changed. libi77: adjust fp.h so local.h is only needed under -DV10. Tue Jul 5 03:05:46 EDT 1994 Fix segmentation fault in subroutine foo(a,b,k) data i/1/ double precision a(k,1) ! sequence error: must precede data b = a(i,1) end libi77: Fix bug (introduced 6 June 1994?) in reopening files under NON_UNIX_STDIO. Fix some error messages caused by illegal Fortran. Examples: * 1. x(i) = 0 !Missing declaration for array x call f(x) !Said Impossible storage class 8 in routine mkaddr end !Now says invalid use of statement function x * 2. f = g !No declaration for g; by default it's a real variable call g !Said invalid class code 2 for function g end !Now says g cannot be called * 3. intrinsic foo !Invalid intrinsic name a = foo(b) !Said intrcall: bad intrgroup 0 end !Now just complains about line 1 Tue Jul 5 11:14:26 EDT 1994 Fix glitch in handling erroneous statement function declarations. Example: a(j(i) - i) = a(j(i) - i) + 1 ! bad statement function call foo(a(3)) ! Said Impossible type 0 in routine mktmpn end ! Now warns that i and j are not used Wed Jul 6 17:31:25 EDT 1994 Tweak test for statement functions that (illegally) call themselves; f2c will now proceed to check for other errors, rather than bailing out at the first recursive statement function reference. Warn about but retain divisions by 0 (instead of calling them "compiler errors" and quiting). On IEEE machines, this permits double precision nan, ninf, pinf nan = 0.d0/0.d0 pinf = 1.d0/0.d0 ninf = -1.d0/0.d0 write(*,*) 'nan, pinf, ninf = ', nan, pinf, ninf end to print nan, pinf, ninf = NaN Infinity -Infinity libi77: wref.c: protect with #ifdef GOOD_SPRINTF_EXPONENT an optimization that requires exponents to have 2 digits when 2 digits suffice. lwrite.c wsfe.c (list and formatted external output): omit ' ' carriage-control when compiled with -DOMIT_BLANK_CC . Off-by-one bug fixed in character count for list output of character strings. Omit '.' in list-directed printing of Nan, Infinity. Mon Jul 11 13:05:33 EDT 1994 src/gram.c updated. Tue Jul 12 10:24:42 EDT 1994 libi77: wrtfmt.c: under G11.4, write 0. as " .0000 " rather than " .0000E+00". Thu Jul 14 17:55:46 EDT 1994 Fix glitch in changes of 6 July 1994 that could cause erroneous "division by zero" warnings (or worse). Example: subroutine foo(a,b) y = b a = a / y ! erroneous warning of division by zero end Mon Aug 1 16:45:17 EDT 1994 libi77: lread.c rsne.c: for benefit of systems with a buggy stdio.h, declare ungetc when neither KR_headers nor ungetc is #defined. Wed Aug 3 01:53:00 EDT 1994 libi77: lwrite.c (list output): do not insert a newline when appending an oversize item to an empty line. Mon Aug 8 00:51:01 EDT 1994 Fix bug (introduced 3 Feb. 1993) that, under -i2, kept LOGICAL*2 variables from appearing in INQUIRE statements. Under -I2, allow LOGICAL*4 variables to appear in INQUIRE. Fix intrinsic function LEN so it returns a short value under -i2, a long value otherwise. exec.c: fix obscure memory fault possible with bizarre (and highly erroneous) DO-loop syntax. Fri Aug 12 10:45:57 EDT 1994 libi77: fix glitch that kept ERR= (in list- or format-directed input) from working after a NAMELIST READ. Thu Aug 25 13:58:26 EDT 1994 Suppress -s when -C is specified. Wed Sep 7 22:13:20 EDT 1994 libi77: typesize.c: adjust to allow types LOGICAL*1, LOGICAL*2, INTEGER*1, and (under -DAllow_TYQUAD) INTEGER*8 in NAMELISTs. Fri Sep 16 17:50:18 EDT 1994 Change name adjustment for reserved words: instead of just appending "_" (a single underscore), append "_a_" to local variable names to avoid trouble when a common block is named a reserved word and the same reserved word is also a local variable name. Example: common /const/ a,b,c real const(3) equivalence (const(1),a) a = 1.234 end Arrange for ichar() to treat characters as unsigned. libf77: s_cmp.c: treat characters as unsigned in comparisons. These changes for unsignedness only matter for strings that contain non-ASCII characters. Now ichar() should always be >= 0. Sat Sep 17 11:19:32 EDT 1994 fc: set rc=$? before exit (to get exit code right in trap code). Mon Sep 19 17:49:43 EDT 1994 libf77: s_paus.c: flush stderr after PAUSE; add #ifdef MSDOS stuff. libi77: README: point out general need for -DMSDOS under MS-DOS. Tue Sep 20 11:42:30 EDT 1994 Fix bug in comparing identically named common blocks, in which all components have the same names and types, but at least one is dimensioned (1) and the other is not dimensioned. Example: subroutine foo common /ab/ a a=1. !!! translated correctly to ab_1.a = (float)1.; end subroutine goo common /ab/ a(1) a(1)=2. !!! translated erroneously to ab_1.a[0] = (float)2. end Tue Sep 27 23:47:34 EDT 1994 Fix bug introduced 16 Sept. 1994: don't add _a_ to C keywords used as external names. In fact, return to earlier behavior of appending __ to C keywords unless they are used as external names, in which case they get just one underscore appended. Adjust constant handling so integer and logical PARAMETERs retain type information, particularly under -I2. Example: SUBROUTINE FOO INTEGER I INTEGER*1 I1 INTEGER*2 I2 INTEGER*4 I4 LOGICAL L LOGICAL*1 L1 LOGICAL*2 L2 LOGICAL*4 L4 PARAMETER (L=.FALSE., L1=.FALSE., L2=.FALSE., L4=.FALSE.) PARAMETER (I=0,I1=0,I2=0,I4=0) CALL DUMMY(I, I1, I2, I4, L, L1, L2, L4) END f2c.1t: Change f\^2c to f2c (omit half-narrow space) in line following ".SH NAME" for benefit of systems that cannot cope with troff commands in this context. Wed Sep 28 12:45:19 EDT 1994 libf77: s_cmp.c fix glitch in -DKR_headers version introduced 12 days ago. Thu Oct 6 09:46:53 EDT 1994 libi77: util.c: omit f__mvgbt (which is never used). f2c.h: change "long" to "long int" to facilitate the adjustments by means of sed described above. Comment out unused typedef of Long. Fri Oct 21 18:02:24 EDT 1994 libf77: add s_catow.c and adjust README to point out that changing "s_cat.o" to "s_catow.o" in the makefile will permit the target of a concatenation to appear on its right-hand side (contrary to the Fortran 77 Standard and at the cost of some run-time efficiency). Wed Nov 2 00:03:58 EST 1994 Adjust -g output to contain only one #line line per statement, inserting \ before the \n ending lines broken because of their length [this insertion was recanted 10 Dec. 1994]. This change accommodates an idiocy in the ANSI/ISO C standard, which leaves undefined the behavior of #line lines that occur within the arguments to a macro call. Wed Nov 2 14:44:27 EST 1994 libi77: under compilation with -DALWAYS_FLUSH, flush buffers at the end of each write statement, and test (via the return from fflush) for write failures, which can be caught with an ERR= specifier in the write statement. This extra flushing slows execution, but can abort execution or alter the flow of control when a disk fills up. f2c/src/io.c: Add ERR= test to e_wsle invocation (end of list-directed external output) to catch write failures when libI77 is compiled with -DALWAYS_FLUSH. Thu Nov 3 10:59:13 EST 1994 Fix bug in handling dimensions involving certain intrinsic functions of constant expressions: the expressions, rather than pointers to them, were passed. Example: subroutine subtest(n,x) real x(2**n,n) ! pow_ii(2,n) was called; now it's pow_ii(&c__2,n) x(2,2)=3. end Tue Nov 8 23:56:30 EST 1994 malloc.c: remove assumption that only malloc calls sbrk. This appears to make malloc.c useful on RS6000 systems. Sun Nov 13 13:09:38 EST 1994 Turn off constant folding of integers used in floating-point expressions, so the assignment in subroutine foo(x) double precision x x = x*1000000*500000 end is rendered as *x = *x * 1000000 * 500000; rather than as *x *= 1783793664; Sat Dec 10 16:31:40 EST 1994 Supply a better error message (than "Impossible type 14") for subroutine foo foo = 3 end Under -g, convey name of included files to #line lines. Recant insertion of \ introduced (under -g) 2 Nov. 1994. Thu Dec 15 14:33:55 EST 1994 New command-line option -Idir specifies directories in which to look for non-absolute include files (after looking in the directory of the current input file). There can be several -Idir options, each specifying one directory. All -Idir options are considered, from left to right, until a suitably named file is found. The -I2 and -I4 command-line options have precedence, so directories named 2 or 4 must be spelled by some circumlocation, such as -I./2 . f2c.ps updated to mention the new -Idir option, correct a typo, and bring the man page at the end up to date. lex.c: fix bug in reading line numbers in #line lines. fc updated to pass -Idir options to f2c. Thu Dec 29 09:48:03 EST 1994 Fix bug (e.g., addressing fault) in diagnosing inconsistency in the type of function eta in the following example: function foo(c1,c2) double complex foo,c1,c2 double precision eta foo = eta(c1,c2) end function eta(c1,c2) double complex eta,c1,c2 eta = c1*c2 end Mon Jan 2 13:27:26 EST 1995 Retain casts for SNGL (or FLOAT) that were erroneously optimized away. Example: subroutine foo(a,b) double precision a,b a = float(b) ! now rendered as *a = (real) (*b); end Use float (rather than double) temporaries in certain expressions of type complex. Example: the temporary for sngl(b) in complex a double precision b a = sngl(b) - (3.,4.) is now of type float. Fri Jan 6 00:00:27 EST 1995 Adjust intrinsic function cmplx to act as dcmplx (returning double complex rather than complex) if either of its args is of type double precision. The double temporaries used prior to 2 Jan. 1995 previously gave it this same behavior. Thu Jan 12 12:31:35 EST 1995 Adjust -krd to use double temporaries in some calculations of type complex. libf77: pow_[dhiqrz][hiq].c: adjust x**i to work on machines that sign-extend right shifts when i is the most negative integer. Current timestamps of files in "all from f2c/src", sorted by time, appear below (mm/dd/year hh:mm:ss). To bring your source up to date, obtain source files with a timestamp later than the time shown in your version.c. Note that the time shown in the current version.c is the timestamp of the source module that immediately follows version.c below: 1/12/1995 12:31:15 xsum0.out 1/10/1995 19:06:23 version.c 1/10/1995 19:06:14 proc.c 1/05/1995 19:14:27 intr.c 1/02/1995 13:26:49 putpcc.c 1/02/1995 9:19:52 expr.c 1/02/1995 8:45:01 Notice 12/16/1994 15:25:18 README 12/15/1994 13:47:30 f2c.1 12/15/1994 13:37:53 f2c.1t 12/15/1994 13:00:26 main.c 12/15/1994 12:28:06 lex.c 12/10/1994 15:24:15 niceprintf.c 12/09/1994 23:48:20 format.c 11/30/1994 16:35:41 exec.c 11/08/1994 23:40:55 malloc.c 11/03/1994 10:10:46 vax.c 11/02/1994 14:38:06 io.c 10/06/1994 9:46:11 f2c.h 9/27/1994 23:11:18 init.c 9/27/1994 23:11:00 defs.h 9/27/1994 23:09:35 put.c 9/27/1994 23:03:16 data.c 9/27/1994 22:09:21 names.c 9/27/1994 18:27:26 misc.c 9/16/1994 16:56:14 output.c 7/01/1994 23:46:42 sysdep.h 7/01/1994 23:24:55 makefile 5/10/1994 7:42:53 p1output.c 5/10/1994 7:42:53 parse_args.c 3/05/1994 0:57:28 sysdep.c 3/04/1994 23:42:15 pread.c 2/25/1994 22:18:14 xsum.c 2/25/1994 10:56:33 error.c 2/25/1994 10:25:21 gram.head 2/25/1994 10:24:54 mem.c 2/25/1994 10:24:54 formatdata.c 2/25/1994 10:24:53 equiv.c 2/25/1994 10:24:52 cds.c 2/25/1994 2:07:19 parse.h 2/22/1994 19:07:20 iob.h 2/22/1994 18:56:53 p1defs.h 2/22/1994 18:53:46 output.h 2/22/1994 18:51:14 names.h 2/22/1994 18:30:41 format.h 1/18/1994 18:12:52 gram.dcl 1/18/1994 18:12:52 tokens 3/06/1993 14:13:58 gram.expr 3/04/1993 14:59:25 gram.exec 1/28/1993 9:03:16 ftypes.h 1/25/1993 11:26:33 defines.h 4/06/1990 0:00:57 gram.io 2/03/1990 0:58:26 niceprintf.h 1/29/1990 13:26:52 memset.c 1/07/1990 1:20:01 usignal.h 11/27/1989 8:27:37 machdefs.h 7/01/1989 11:59:44 pccdefs.h