--- cfortran-4.4.orig/cfortran.html +++ cfortran-4.4/cfortran.html @@ -4,9 +4,6 @@
-
-![]() |
- SunOS> CC +p +w # Clean compiles.
- IRIX> CC # Clean compiles.
- IRIX> CC -fullwarn # Still some warnings to be overcome.
- GNU> g++ -Wall # Compiles are clean, other than warnings for unused
+ SunOS> CC +p +w # Clean compiles.
+ IRIX> CC # Clean compiles.
+ IRIX> CC -fullwarn # Still some warnings to be overcome.
+ GNU> g++ -Wall # Compiles are clean, other than warnings for unused
# cfortran.h static routines.
@@ -123,7 +120,7 @@
The complete cfortran.h package consists of 4 files: the documentation in cfortran.doc, the engine cfortran.h, examples in cfortest.c and -cfortex.f/or. [cfortex.for under VMS, +cfortex.f/or. [cfortex.for under VMS, cfortex.f on other machines.]
The cfortran.h package continues to be developed.
@@ -142,9 +139,9 @@
link a trivial FORTRAN program using the FORTRAN compilers verbose option,
in order to see how the FORTRAN compiler drives the linker. e.g.
- unix> cat f.f
+ unix> cat f.f
END
- unix> f77 -v f.f
+ unix> f77 -v f.f
.. lots of info. follows ...
@@ -160,125 +157,125 @@
The f77 verbose option, usually -v, may point to a solution.
- cfortran.h generates interfaces for the default i
+ cfortran.h generates interfaces for the default
FORTRAN compiler. The default can be overridden by defining with
- one of the follwoing methods,
+ one of the following methods,
- f2c, by default promotes REAL functions to double.
-cfortran.h does not (yet)
-support this, so the f2c -R option must be used to turn this promotion off.
+f2c and g77 by default promote REAL functions to
+double. As of December 9, 2005, the Debian package of cfortran supports this
+behavior, so the f2c -R option must NOT be used to turn this
+promotion off.
[Thanks to Dario Autiero for pointing out the following.]
@@ -693,11 +691,19 @@
/* Last three lines are a work-around for the strange f2c naming feature. */
+gfortran behaves similarly to f2c and g77, EXCEPT
+that it does NOT by default promote REAL functions to
+double. Therefore you should use -DgFortran instead of
+-Dg77Fortran or -Df2cFortran to let cfortran.h
+know about this difference.
+
The FORTRAN 77 subset of FORTRAN 90 is supported.
Extending cfortran.h to
interface C with all of FORTRAN 90 has not yet been examined.
-
On some machines the above error causes compilation to stop; one must then use
-K&R C, as with old HP compilers which don't support function prototyping.
-cfortran.h has to be informed that K&R C is to being used, e.g.
+K&R C, as with old HP compilers which don't support function prototyping.
+cfortran.h has to be informed that K&R C is to being used, e.g.
The same problem with a similar solution exists on the HP.
Old versions of cc(1), say <~1986, may require help for cfortran.h
+ Old versions of cc(1), say <~1986, may require help for cfortran.h
applications:
vcc (1) with f77 is not supported. Although:
-RS/6000> # Users are strongly urged to use f77 -qextname and cc -Dextname
-RS/6000> # Use -Dextname=extname if extname is a symbol used in the C code.
-RS/6000> xlf -c -qextname cfortex.f
-RS/6000> cc -c -Dextname cfortest.c
-RS/6000> xlf -o cfortest cfortest.o cfortex.o && cfortest
-
-DECFortran> #Only DECstations with DECFortran for Ultrix RISC Systems.
-DECFortran> cc -c -DDECFortran cfortest.c
-DECFortran> f77 -o cfortest cfortest.o cfortex.f && cfortest
+RS/6000> # Users are strongly urged to use f77 -qextname and cc -Dextname
+RS/6000> # Use -Dextname=extname if extname is a symbol used in the C code.
+RS/6000> xlf -c -qextname cfortex.f
+RS/6000> cc -c -Dextname cfortest.c
+RS/6000> xlf -o cfortest cfortest.o cfortex.o && cfortest
+
+DECFortran> #Only DECstations with DECFortran for Ultrix RISC Systems.
+DECFortran> cc -c -DDECFortran cfortest.c
+DECFortran> f77 -o cfortest cfortest.o cfortex.f && cfortest
IRIX xxxxxx 5.2 02282015 IP20 mips
-MIPS> # DECstations and Silicon Graphics using the MIPS compilers.
-MIPS> cc -o cfortest cfortest.c cfortex.f -lI77 -lU77 -lF77 && cfortest
-MIPS> # Can also let f77 drive linking, e.g.
-MIPS> cc -c cfortest.c
-MIPS> f77 -o cfortest cfortest.o cfortex.f && cfortest
-
-Apollo> # Some 'C compiler 68K Rev6.8' break. [See Section II o) Notes: Apollo]
-Apollo> f77 -c cfortex.f && cc -o cfortest cfortest.c cfortex.o && cfortest
-
-VMS> define lnk$library sys$library:vaxcrtl
-VMS> cc cfortest.c
-VMS> fortran cfortex.for
-VMS> link/exec=cfortest cfortest,cfortex
-VMS> run cfortest
+MIPS> # DECstations and Silicon Graphics using the MIPS compilers.
+MIPS> cc -o cfortest cfortest.c cfortex.f -lI77 -lU77 -lF77 && cfortest
+MIPS> # Can also let f77 drive linking, e.g.
+MIPS> cc -c cfortest.c
+MIPS> f77 -o cfortest cfortest.o cfortex.f && cfortest
+
+Apollo> # Some 'C compiler 68K Rev6.8' break. [See Section II o) Notes: Apollo]
+Apollo> f77 -c cfortex.f && cc -o cfortest cfortest.c cfortex.o && cfortest
+
+VMS> define lnk$library sys$library:vaxcrtl
+VMS> cc cfortest.c
+VMS> fortran cfortex.for
+VMS> link/exec=cfortest cfortest,cfortex
+VMS> run cfortest
OSF1 xxxxxx V3.0 347 alpha
-Alpha/OSF> # Probably better to let cc drive linking, e.g.
-Alpha/OSF> f77 -c cfortex.f
-Alpha/OSF> cc -o cfortest cfortest.c cfortex.o -lUfor -lfor -lFutil -lots -lm
-Alpha/OSF> cfortest
-Alpha/OSF> # Else may need 'cc -Dmain=MAIN__' to let f77 drive linking.
-
-Sun> # Some old cc(1) need a little help. [See Section II o) Notes: Sun]
-Sun> f77 -o cfortest cfortest.c cfortex.f -lc -lm && cfortest
-Sun> # Some older f77 may require 'cc -Dmain=MAIN_'.
-
-CRAY> cft77 cfortex.f
-CRAY> cc -c cfortest.c
-CRAY> segldr -o cfortest.e cfortest.o cfortex.o
-CRAY> ./cfortest.e
+Alpha/OSF> # Probably better to let cc drive linking, e.g.
+Alpha/OSF> f77 -c cfortex.f
+Alpha/OSF> cc -o cfortest cfortest.c cfortex.o -lUfor -lfor -lFutil -lots -lm
+Alpha/OSF> cfortest
+Alpha/OSF> # Else may need 'cc -Dmain=MAIN__' to let f77 drive linking.
+
+Sun> # Some old cc(1) need a little help. [See Section II o) Notes: Sun]
+Sun> f77 -o cfortest cfortest.c cfortex.f -lc -lm && cfortest
+Sun> # Some older f77 may require 'cc -Dmain=MAIN_'.
+
+CRAY> cft77 cfortex.f
+CRAY> cc -c cfortest.c
+CRAY> segldr -o cfortest.e cfortest.o cfortex.o
+CRAY> ./cfortest.e
-NEC> cc -c -Xa cfortest.c
-NEC> f77 -o cfortest cfortest.o cfortex.f && cfortest
+NEC> cc -c -Xa cfortest.c
+NEC> f77 -o cfortest cfortest.o cfortex.f && cfortest
-VAX/Ultrix/cc> # For cc on VAX Ultrix only, do the following once to cfortran.h.
-VAX/Ultrix/cc> mv cfortran.h cftmp.h && grep -v "^#pragma"
By changing the SELECTion ifdef of cfortest.c and recompiling one can try out
@@ -359,7 +356,7 @@
are defined and used.
/* hbook.h */
-#include "cfortran.h"
+#include <cfortran.h>
:
PROTOCCALLSFSUB6(HBOOK1,hbook1,INT,STRING,INT,FLOAT,FLOAT,FLOAT)
#define HBOOK1(ID,CHTITLE,NX,XMI,XMA,VMX) \
@@ -404,7 +401,7 @@
Example 2
Many VMS System calls are most easily called from FORTRAN, but
cfortran.h now gives that ease in C.
-#include "cfortran.h"
+#include <cfortran.h>
PROTOCCALLSFSUB3(LIB$SPAWN,lib$spawn,STRING,STRING,STRING)
#define LIB$SPAWN(command,input_file,output_file) \
@@ -434,8 +431,8 @@
END
/* cstring.c */
-#include
+
-
one of the following before including cfortran.h:
@@ -645,11 +642,12 @@
on all machines, including t3e.
The NAG f90 library hij acks the main() of any program and starts the user's
+
The NAG f90 library hijacks the main() of any program and starts the user's
program with a call to: void f90_main(void);
While this in itself is only a minor hassle, a major problem arises because
NAG f90 provides no mechanism to access command line arguments.
@@ -738,10 +744,10 @@
At least one release of the HP /lib/cpp.ansi
preprocessor is broken and will
go into an infinite loop when trying to process cfortran.h with the
-## catenation operator. The K&R version of cfortran.h must then be used and the
-K&R preprocessor must be specified. e.g.
+## catenation operator. The K&R version of cfortran.h must then be used and the
+K&R preprocessor must be specified. e.g.
-HP9000> cc -Aa -tp,/lib/cpp -c source.c
+HP9000> cc -Aa -tp,/lib/cpp -c source.c
The same problem with a similar solution exists on the Apollo.
An irrelevant error message '0: extraneous name /usr/include'
@@ -757,10 +763,10 @@
/lib/cpp
-HP9000> cc -D__CF__KnR -c source.c
+HP9000> cc -D__CF__KnR -c source.c
-sun> mv cfortran.h cftmp.h && grep -v "^#pragma"
#ifdef mc68000 /* 5 lines Copyright (c) 1988 by Sun Microsystems, Inc. */
#define FLOATFUNCTIONTYPE int
- #define RETURNFLOAT(x) return (*(int *)(&(x)))
- #define ASSIGNFLOAT(x,y) *(int *)(&x) = y
+ #define RETURNFLOAT(x) return (*(int *)(&(x)))
+ #define ASSIGNFLOAT(x,y) *(int *)(&x) = y
#endif
@@ -815,8 +821,8 @@
-VAXUltrix> f77 -c cfortex.f
-VAXUltrix> vcc -o cfortest cfortest.c cfortex.o -lI77 -lU77 -lF77 && cfortest
+VAXUltrix> f77 -c cfortex.f
+VAXUltrix> vcc -o cfortest cfortest.c cfortex.o -lI77 -lU77 -lF77 && cfortest
will link and run. However, the FORTRAN standard I/O is NOT merged
with the
@@ -849,7 +855,7 @@
At line number 777 in DISK:[DIR]FILE.C;1.
This SPR can be staved off, with the simple modification to cfortran.h, such
that the relevant CCALLSFSUBn (or CCALLSFFUNn or
@@ -895,7 +901,7 @@
cfortran.h encourages the exact specification of the type and dimension of
array parameters because it allows the C compiler to detect errors in the
@@ -1262,7 +1268,7 @@
-From the 2nd or ANSI ed. of K&R C, p.31, last paragraph:
+From the 2nd or ANSI ed. of K&R C, p.31, last paragraph:
i)
An external variable must be defined, exactly once, outside of any function;
this sets aside storage for it.
@@ -1977,7 +1983,7 @@
Therefore, new machinery is required to do:
-From K&R ANSI C p. 231:
+From K&R ANSI C p. 231:
Unlike all other C compilers supported by cfortran.h,
'gcc -traditional' promotes to double all functions returning float
-as demonstrated bu the following example.
+as demonstrated by the following example.
C FORTRAN /* C */
- integer function f() #include
Where:
-'n' = 0->14 [SUBROUTINE's ->27] (easily expanded in cfortran.h to > 14 [27]) is
+'n' = 0->14 [SUBROUTINE's ->27] (easily expanded in cfortran.h to > 14 [27]) is
the number of arguments to the routine.
Routine_name = C name of the routine (IN UPPER CASE LETTERS).[see 2.below]
ROUTINE_NAME = FORTRAN name of the routine (IN UPPER CASE LETTERS).
@@ -979,7 +985,7 @@
STRINGV, ZTRINGV.
For vectors of vectors, i.e. 2 dim. arrays use
= BYTEVV, DOUBLEVV, FLOATVV, INTVV, LOGICALVV, LONGVV, SHORTVV.
- For n-dim. arrays, 1<=n<=7 [7 is the maximum in FORTRAN 77],
+ For n-dim. arrays, 1<=n<=7 [7 is the maximum in FORTRAN 77],
= BYTEV..nV's..V, DOUBLEV..V, FLOATV..V, INTV..V, LOGICALV..V,
LONGV..V, SHORTV..V.
N.B. Array dimensions and types are checked by the C compiler.
@@ -1042,7 +1048,7 @@
/* Pass the address of a structure, using a type called PSTRUCT */
#define PSTRUCT_cfN( T,A) void *A
-#define PSTRUCT_cfB( T,A) (void *) &(A)
+#define PSTRUCT_cfB( T,A) (void *) &(A)
/* Pass an integer by value, (not standard F77 ), using a type called INTVAL */
#define INTVAL_cfN( T,A) int A
@@ -1067,7 +1073,7 @@
unique name, but in practice, the name of the FORTRAN routine in UPPER CASE
works everywhere and would seem to be an obvious choice.
-
Routine_name = the C name of the routine. [see 9. below]
@@ -1343,7 +1349,7 @@
to C, the same holds true for each element in (P)STRINGV. Space is malloc'd in
all cases big enough to hold the original string (elements) as well as C's
terminating '\0'. i.e. The useful size of the string (elements) is the same in
-both languages. P(N)STRING(V) => the string (elements) will be copied from the
+both languages. P(N)STRING(V) => the string (elements) will be copied from the
malloc'd space back into the FORTRAN bytes. If one of the two escape mechanisms
mentioned below for PNSTRING has been used, the copying back to FORTRAN is
obviously not relevant.
@@ -1371,7 +1377,7 @@
C FORTRAN /* C */
- character*40 str #include "cfortran.h"
+character*40 str #include <cfortran.h>
C Set up a NULL as : void cs(char *s) {if (s) printf("%s.\n",s);}
C i) 4 NUL characters. FCALLSCSUB1(cs,CS,cs,STRING)
C ii) NULL pointer.
@@ -1413,7 +1419,7 @@
C FORTRAN /* C */
- character*10 s,sn #include "cfortran.h"
+character*10 s,sn #include <cfortran.h>
void ps(char *s) {strcpy(s,"hello");}
C Can call ps with undef. s. FCALLSCSUB1(ps,PS,ps,PSTRING)
call ps(s) FCALLSCSUB1(ps,PNS,pns,PNSTRING)
@@ -1542,9 +1548,9 @@
routine_name is as above.
- i [i=1->n.] specifies the argument number of a STRING VECTOR.
+ i [i=1->n.] specifies the argument number of a STRING VECTOR.
j would specify a fixed number of elements.
- k [k=1->n. k!=i] would specify an integer argument which specifies the
+ k [k=1->n. k!=i] would specify an integer argument which specifies the
number of elements.
l [char] the terminating character at the beginning of an
element, indicating to cfortran.h that the preceding
@@ -1798,7 +1804,7 @@
of C and FORTRAN, but the following information may help
resolve problems.
-application.h + cfortran.h => final_application.h
+application.h + cfortran.h => final_application.h
The following example may help clarify the means and ends:
@@ -1990,7 +1996,7 @@
preprocessor being used, e.g. cpp -Umips -DCRAY ... ] :
-#include "cfortran.h"
+#include <cfortran.h>
PROTOCCALLSFSUB6(HBOOK1,hbook1,INT,STRING,INT,FLOAT,FLOAT,FLOAT)
/*#define HBOOK1(ID,CHTITLE,NX,XMI,XMA,VMX) \*/
CCALLSFSUB6(HBOOK1,hbook1,INT,STRING,INT,FLOAT,FLOAT,FLOAT, \
@@ -2075,23 +2081,23 @@
Condolences to long suffering ultrix users!
DEC supplies a working C front end for alpha/OSF, but not for ultrix.
- ultrix> cat cat.c
+ ultrix> cat cat.c
#define cat(x, y) x ## y
#define xcat(x,y) cat(x,y)
cat(cat(1,2),3)
xcat(xcat(1,2),3)
- ultrix> cc -E cat.c
- 123 <---- Should be: cat(1,2)3
- 123 <---- Correct.
- ultrix>
+ ultrix> cc -E cat.c
+ 123 <---- Should be: cat(1,2)3
+ 123 <---- Correct.
+ ultrix>
The problem for cfortran.h, preventing use of -std and -std1:
- ultrix> cat c.c
+ ultrix> cat c.c
#define cat(x, y) x ## y
#define xcat(x,y) cat(x,y)
#define AB(X) X+X
@@ -2099,19 +2105,19 @@
#define X(E,F,G) xcat(E,F)(G)
C(A,B,2)
X(A,B,2)
- ultrix> cc -std1 -E c.c
+ ultrix> cc -std1 -E c.c
2+2
- AB (2) <---- ?????????????
- ultrix>
- ultrix> cc -std0 -E c.c
+ AB (2) <---- ?????????????
+ ultrix>
+ ultrix> cc -std0 -E c.c
2+2
- AB(2) <---- ?????????????
- ultrix>
+ AB(2) <---- ?????????????
+ ultrix>
Due to further ultrix preprocessor problems,
for all definitions of definitions with arguments,
-cfortran.h >= 3.0 includes the arguments and recommends the same,
+cfortran.h >= 3.0 includes the arguments and recommends the same,
even though it is not required by ANSI C.
e.g. Users are advised to do
@@ -2145,17 +2151,17 @@
cc: SC3.0.1 13 Jul 1994
or equivalently
ULTRIX 4.4 0 RISC using cc -oldc
- are K&R C preprocessors that suffer from infinite loop macros, e.g.
+ are K&R C preprocessors that suffer from infinite loop macros, e.g.
- zedy03> cat src.c
- #include "cfortran.h"
+ zedy03> cat src.c
+ #include <cfortran.h>
PROTOCCALLSFFUN1(INT,FREV,frev, INTV)
#define FREV(A1) CCALLSFFUN1( FREV,frev, INTV, A1)
/* To avoid the problem, deletete these ---^^^^--- spaces. */
main() { static int a[] = {1,2}; FREV(a); return EXIT_SUCCESS; }
- zedy03> cc -c -Xs -v -DMAX_PREPRO_ARGS=31 -D__CF__KnR src.c
+ zedy03> cc -c -Xs -v -DMAX_PREPRO_ARGS=31 -D__CF__KnR src.c
"src.c", line 4: FREV: actuals too long
"src.c", line 4: FREV: actuals too long
.... 3427 more lines of the same message
@@ -2190,20 +2196,20 @@
/* m.c */
-#include
@@ -2298,7 +2304,7 @@
July '91.
2.0
-
April'93. 3.0
-
@@ -2494,7 +2500,8 @@
THIS PACKAGE, I.E. CFORTRAN.H, THIS DOCUMENT, AND THE CFORTRAN.H EXAMPLE
PROGRAMS ARE PROPERTY OF THE AUTHOR WHO RESERVES ALL RIGHTS. THIS PACKAGE AND
-THE CODE IT PRODUCES MAY BE FREELY DISTRIBUTED WITHOUT FEES, SUBJECT TO THE
+THE CODE IT PRODUCES MAY BE FREELY DISTRIBUTED WITHOUT FEES, SUBJECT
+(AT YOUR CHOICE) EITHER TO THE GNU LIBRARY GENERAL PUBLIC LICENSE OR TO THE
FOLLOWING RESTRICTIONS:
- YOU MUST ACCOMPANY ANY COPIES OR DISTRIBUTION WITH THIS (UNALTERED) NOTICE.
- YOU MAY NOT RECEIVE MONEY FOR THE DISTRIBUTION OR FOR ITS MEDIA
--- cfortran-4.4.orig/cfortran.h
+++ cfortran-4.4/cfortran.h
@@ -11,11 +11,108 @@
MODIFYING, COPYING AND DISTRIBUTING THE CFORTRAN.H PACKAGE.
*/
+/* THIS PACKAGE, I.E. CFORTRAN.H, THIS DOCUMENT, AND THE CFORTRAN.H EXAMPLE
+PROGRAMS ARE PROPERTY OF THE AUTHOR WHO RESERVES ALL RIGHTS. THIS PACKAGE AND
+THE CODE IT PRODUCES MAY BE FREELY DISTRIBUTED WITHOUT FEES, SUBJECT
+(AT YOUR CHOICE) EITHER TO THE GNU LIBRARY GENERAL PUBLIC LICENSE
+AT http://www.gnu.org/licenses/lgpl.html OR TO THE FOLLOWING RESTRICTIONS:
+- YOU MUST ACCOMPANY ANY COPIES OR DISTRIBUTION WITH THIS (UNALTERED) NOTICE.
+- YOU MAY NOT RECEIVE MONEY FOR THE DISTRIBUTION OR FOR ITS MEDIA
+ (E.G. TAPE, DISK, COMPUTER, PAPER.)
+- YOU MAY NOT PREVENT OTHERS FROM COPYING IT FREELY.
+- YOU MAY NOT DISTRIBUTE MODIFIED VERSIONS WITHOUT CLEARLY DOCUMENTING YOUR
+ CHANGES AND NOTIFYING THE AUTHOR.
+- YOU MAY NOT MISREPRESENTED THE ORIGIN OF THIS SOFTWARE, EITHER BY EXPLICIT
+ CLAIM OR BY OMISSION.
+
+THE INTENT OF THE ABOVE TERMS IS TO ENSURE THAT THE CFORTRAN.H PACKAGE NOT BE
+USED FOR PROFIT MAKING ACTIVITIES UNLESS SOME ROYALTY ARRANGEMENT IS ENTERED
+INTO WITH ITS AUTHOR.
+
+THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
+EXPRESSED OR IMPLIED. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST
+OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. THE AUTHOR IS NOT RESPONSIBLE
+FOR ANY SUPPORT OR SERVICE OF THE CFORTRAN.H PACKAGE.
+
+ Burkhard Burow
+ burow@desy.de
+*/
+
+/* The following modifications were made by the authors of CFITSIO or by me.
+ * They are flagged below with CFITSIO, the author's initials, or KMCCARTY.
+ * PDW = Peter Wilson
+ * DM = Doug Mink
+ * LEB = Lee E Brotzman
+ * MR = Martin Reinecke
+ * WDP = William D Pence
+ * BR = Bastien ROUCARIES
+ * -- Kevin McCarty, for Debian (19 Dec. 2005) */
+
+/*******
+ Modifications:
+ Oct 1997: Changed symbol name extname to appendus (PDW/HSTX)
+ (Conflicted with a common variable name in FTOOLS)
+ Nov 1997: If g77Fortran defined, also define f2cFortran (PDW/HSTX)
+ Feb 1998: Let VMS see the NUM_ELEMS code. Lets programs treat
+ single strings as vectors with single elements
+ Nov 1999: If macintoxh defined, also define f2cfortran (for Mac OS-X)
+ Apr 2000: If WIN32 defined, also define PowerStationFortran and
+ VISUAL_CPLUSPLUS (Visual C++)
+ Jun 2000: If __GNUC__ and linux defined, also define f2cFortran
+ (linux/gcc environment detection)
+ Apr 2002: If __CYGWIN__ is defined, also define f2cFortran
+ Nov 2002: If __APPLE__ defined, also define f2cfortran (for Mac OS-X)
+
+ Nov 2003: If __INTEL_COMPILER or INTEL_COMPILER defined, also define
+ f2cFortran (KMCCARTY)
+ Dec 2005: If f2cFortran is defined, enforce REAL functions in FORTRAN
+ returning "double" in C. This was one of the items on
+ Burkhard's TODO list. (KMCCARTY)
+ Dec 2005: Modifications to support 8-byte integers. (MR)
+ USE AT YOUR OWN RISK!
+ Feb 2006 Added logic to typedef the symbol 'LONGLONG' to an appropriate
+ intrinsic 8-byte integer datatype (WDP)
+ Apr 2006: Modifications to support gfortran (and g77 with -fno-f2c flag)
+ since by default it returns "float" for FORTRAN REAL function.
+ (KMCCARTY)
+ May 2008: Revert commenting out of "extern" in COMMON_BLOCK_DEF macro.
+ Add braces around do-nothing ";" in 3 empty while blocks to
+ get rid of compiler warnings. Thanks to ROOT developers
+ Jacek Holeczek and Rene Brun for these suggestions. (KMCCARTY)
+ Aug 2008: If __GNUC__ is defined and no FORTRAN compiler is specified
+ via a #define or -D, default to gfortran behavior rather than
+ g77 behavior. (KMCCARTY)
+ Oct 2009: Add warning if guessing default fortran. Move g77 above guessing bloc
+ *******/
+
/*
Avoid symbols already used by compilers and system *.h:
__ - OSF1 zukal06 V3.0 347 alpha, cc -c -std1 cfortest.c
- */
+*/
+
+/*
+ Determine what 8-byte integer data type is available.
+ 'long long' is now supported by most compilers, but older
+ MS Visual C++ compilers before V7.0 use '__int64' instead. (WDP)
+*/
+
+#ifndef LONGLONG_TYPE /* this may have been previously defined */
+#if defined(_MSC_VER) /* Microsoft Visual C++ */
+
+#if (_MSC_VER < 1300) /* versions earlier than V7.0 do not have 'long long' */
+ typedef __int64 LONGLONG;
+#else /* newer versions do support 'long long' */
+ typedef long long LONGLONG;
+#endif
+
+#else
+ typedef long long LONGLONG;
+#endif
+
+#define LONGLONG_TYPE
+#endif
/* First prepare for the C compiler. */
@@ -75,7 +172,13 @@
/* Remainder of cfortran.h depends on the Fortran compiler. */
-#if defined(CLIPPERFortran) || defined(pgiFortran)
+/* 11/29/2003 (KMCCARTY): add *INTEL_COMPILER symbols here */
+/* 04/05/2006 (KMCCARTY): add gFortran symbol here */
+#if defined(CLIPPERFortran) || defined(pgiFortran) || defined(__INTEL_COMPILER) || defined(INTEL_COMPILER) || defined(gFortran)
+#define f2cFortran
+#endif
+
+#if defined(g77Fortran) /* 11/03/97 PDW (CFITSIO) */
#define f2cFortran
#endif
@@ -84,12 +187,37 @@
#if !(defined(NAGf90Fortran)||defined(f2cFortran)||defined(hpuxFortran)||defined(apolloFortran)||defined(sunFortran)||defined(IBMR2Fortran)||defined(CRAYFortran))
#if !(defined(mipsFortran)||defined(DECFortran)||defined(vmsFortran)||defined(CONVEXFortran)||defined(PowerStationFortran)||defined(AbsoftUNIXFortran)||defined(AbsoftProFortran)||defined(SXFortran))
/* If no Fortran compiler is given, we choose one for the machines we know. */
+#if defined(__GNUC__) || defined(WIN32) /* 10/2009 BR: warm if guess */
+#warning "Please specify the fortran compiler using -D flags. Try to guess the compiler used"
+#endif
#if defined(lynx) || defined(VAXUltrix)
#define f2cFortran /* Lynx: Only support f2c at the moment.
VAXUltrix: f77 behaves like f2c.
Support f2c or f77 with gcc, vcc with f2c.
f77 with vcc works, missing link magic for f77 I/O.*/
#endif
+/* 04/13/00 DM (CFITSIO): Add these lines for NT */
+/* with PowerStationFortran and and Visual C++ */
+#if defined(WIN32) && !defined(__CYGWIN__)
+#define PowerStationFortran
+#define VISUAL_CPLUSPLUS
+#endif
+#if defined(__CYGWIN__) /* 04/11/02 LEB (CFITSIO) */
+#define f2cFortran
+#define gFortran /* 8/26/08 (KMCCARTY) */
+#endif
+#if defined(__GNUC__) && defined(linux) /* 06/21/00 PDW (CFITSIO) */
+#define f2cFortran
+#define gFortran /* 8/26/08 (KMCCARTY) */
+#endif
+#if defined(macintosh) /* 11/1999 (CFITSIO) */
+#define f2cFortran
+#define gFortran /* 8/26/08 (KMCCARTY) */
+#endif
+#if defined(__APPLE__) /* 11/2002 (CFITSIO) */
+#define f2cFortran
+#define gFortran /* 8/26/08 (KMCCARTY) */
+#endif
#if defined(__hpux) /* 921107: Use __hpux instead of __hp9000s300 */
#define hpuxFortran /* Should also allow hp9000s7/800 use.*/
#endif
@@ -131,6 +259,7 @@
#if !(defined(mipsFortran)||defined(DECFortran)||defined(vmsFortran)||defined(CONVEXFortran)||defined(PowerStationFortran)||defined(AbsoftUNIXFortran)||defined(AbsoftProFortran)||defined(SXFortran))
/* If your compiler barfs on ' #error', replace # with the trigraph for # */
#error "cfortran.h: Can't find your environment among:\
+ - GNU gcc (gfortran) on Linux. \
- MIPS cc and f77 2.0. (e.g. Silicon Graphics, DECstations, ...) \
- IBM AIX XL C and FORTRAN Compiler/6000 Version 01.01.0000.0000 \
- VAX VMS CC 3.1 and FORTRAN 5.4. \
@@ -147,11 +276,14 @@
- VAXUltrix: vcc,cc or gcc with f2c. gcc or cc with f77. \
- f77 with vcc works; but missing link magic for f77 I/O. \
- NO fort. None of gcc, cc or vcc generate required names.\
- - f2c : Use #define f2cFortran, or cc -Df2cFortran \
+ - f2c/g77: Use #define f2cFortran, or cc -Df2cFortran \
+ - gfortran: Use #define gFortran, or cc -DgFortran \
+ (also necessary for g77 with -fno-f2c option) \
- NAG f90: Use #define NAGf90Fortran, or cc -DNAGf90Fortran \
- Absoft UNIX F77: Use #define AbsoftUNIXFortran or cc -DAbsoftUNIXFortran \
- Absoft Pro Fortran: Use #define AbsoftProFortran \
- - Portland Group Fortran: Use #define pgiFortran"
+ - Portland Group Fortran: Use #define pgiFortran \
+ - Intel Fortran: Use #define INTEL_COMPILER"
/* Compiler must throw us out at this point! */
#endif
#endif
@@ -164,7 +296,8 @@
/* Throughout cfortran.h we use: UN = Uppercase Name. LN = Lowercase Name. */
-#if defined(f2cFortran) || defined(NAGf90Fortran) || defined(DECFortran) || defined(mipsFortran) || defined(apolloFortran) || defined(sunFortran) || defined(CONVEXFortran) || defined(SXFortran) || defined(extname)
+/* "extname" changed to "appendus" below (CFITSIO) */
+#if defined(f2cFortran) || defined(NAGf90Fortran) || defined(DECFortran) || defined(mipsFortran) || defined(apolloFortran) || defined(sunFortran) || defined(CONVEXFortran) || defined(SXFortran) || defined(appendus)
#define CFC_(UN,LN) _(LN,_) /* Lowercase FORTRAN symbols. */
#define orig_fcallsc(UN,LN) CFC_(UN,LN)
#else
@@ -453,7 +586,7 @@
{char *e;
e = s + strlen(s);
if (e>s) { /* Need this to handle NULL string.*/
- while (e>s && *--e==t); /* Don't follow t's past beginning. */
+ while (e>s && *--e==t) {;} /* Don't follow t's past beginning. */
e[*e==t?0:1] = '\0'; /* Handle s[0]=t correctly. */
} return s; }
@@ -469,7 +602,7 @@
{
if (e==s) *e = '\0'; /* Kill the string makes sense here.*/
else if (e>s) { /* Watch out for neg. length string.*/
- while (e>s && *--e==t); /* Don't follow t's past beginning. */
+ while (e>s && *--e==t){;} /* Don't follow t's past beginning. */
e[*e==t?0:1] = '\0'; /* Handle s[0]=t correctly. */
} return s; }
@@ -512,7 +645,7 @@
*( (F).dsc$l_m[0]=(F).dsc$bounds[0].dsc$l_u=(ELEMNO) ), \
(F).dsc$a_a0 = ( (F).dsc$a_pointer=(C) ) - (F).dsc$w_length ,(F))
-#else
+#endif /* PDW: 2/10/98 (CFITSIO) -- Let VMS see NUM_ELEMS definitions */
#define _NUM_ELEMS -1
#define _NUM_ELEM_ARG -2
#define NUM_ELEMS(A) A,_NUM_ELEMS
@@ -534,13 +667,18 @@
return term_char;
if (num_term <=0) num_term = (int)elem_len;
for (num=0; ; num++) {
- for (i=0; i<(unsigned)num_term && *strv==term_char; i++,strv++);
+ for (i=0; i<(unsigned)num_term && *strv==term_char; i++,strv++){;}
if (i==(unsigned)num_term) break;
else strv += elem_len-i;
}
+if (0) { /* to prevent not used warnings in gcc (added by ROOT) */
+ c2fstrv(0, 0, 0, 0); f2cstrv(0, 0, 0, 0); kill_trailing(0, 0);
+ vkill_trailing(0, 0, 0, 0); num_elem(0, 0, 0, 0);
+}
return (int)num;
}
-#endif
+/* #endif removed 2/10/98 (CFITSIO) */
+
/*-------------------------------------------------------------------------*/
/* UTILITIES FOR C TO USE STRINGS IN FORTRAN COMMON BLOCKS */
@@ -1318,6 +1456,7 @@
#define INTVVVVVVV_cfTYPE int
#define LOGICALVVVVVVV_cfTYPE int
#define LONGVVVVVVV_cfTYPE long
+#define LONGLONGVVVVVVV_cfTYPE LONGLONG /* added by MR December 2005 */
#define SHORTVVVVVVV_cfTYPE short
#define PBYTE_cfTYPE INTEGER_BYTE
#define PDOUBLE_cfTYPE DOUBLE_PRECISION
@@ -1325,6 +1464,7 @@
#define PINT_cfTYPE int
#define PLOGICAL_cfTYPE int
#define PLONG_cfTYPE long
+#define PLONGLONG_cfTYPE LONGLONG /* added by MR December 2005 */
#define PSHORT_cfTYPE short
#define CFARGS0(A,T,V,W,X,Y,Z) _3(T,_cf,A)
@@ -1342,6 +1482,7 @@
#define INT_cfINT(N,A,B,X,Y,Z) DOUBLE_cfINT(N,A,B,X,Y,Z)
#define LOGICAL_cfINT(N,A,B,X,Y,Z) DOUBLE_cfINT(N,A,B,X,Y,Z)
#define LONG_cfINT(N,A,B,X,Y,Z) DOUBLE_cfINT(N,A,B,X,Y,Z)
+#define LONGLONG_cfINT(N,A,B,X,Y,Z) DOUBLE_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
#define SHORT_cfINT(N,A,B,X,Y,Z) DOUBLE_cfINT(N,A,B,X,Y,Z)
#define PBYTE_cfINT(N,A,B,X,Y,Z) PDOUBLE_cfINT(N,A,B,X,Y,Z)
#define PDOUBLE_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,PINT,B,X,Y,Z,0)
@@ -1349,6 +1490,7 @@
#define PINT_cfINT(N,A,B,X,Y,Z) PDOUBLE_cfINT(N,A,B,X,Y,Z)
#define PLOGICAL_cfINT(N,A,B,X,Y,Z) PDOUBLE_cfINT(N,A,B,X,Y,Z)
#define PLONG_cfINT(N,A,B,X,Y,Z) PDOUBLE_cfINT(N,A,B,X,Y,Z)
+#define PLONGLONG_cfINT(N,A,B,X,Y,Z) PDOUBLE_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
#define PSHORT_cfINT(N,A,B,X,Y,Z) PDOUBLE_cfINT(N,A,B,X,Y,Z)
#define BYTEV_cfINT(N,A,B,X,Y,Z) DOUBLEV_cfINT(N,A,B,X,Y,Z)
#define BYTEVV_cfINT(N,A,B,X,Y,Z) DOUBLEVV_cfINT(N,A,B,X,Y,Z)
@@ -1392,6 +1534,13 @@
#define LONGVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z)
#define LONGVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z)
#define LONGVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define LONGLONGV_cfINT(N,A,B,X,Y,Z) DOUBLEV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define LONGLONGVV_cfINT(N,A,B,X,Y,Z) DOUBLEVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define LONGLONGVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define LONGLONGVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define LONGLONGVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define LONGLONGVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define LONGLONGVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
#define SHORTV_cfINT(N,A,B,X,Y,Z) DOUBLEV_cfINT(N,A,B,X,Y,Z)
#define SHORTVV_cfINT(N,A,B,X,Y,Z) DOUBLEVV_cfINT(N,A,B,X,Y,Z)
#define SHORTVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVV_cfINT(N,A,B,X,Y,Z)
@@ -1451,7 +1600,12 @@
#define BYTE_cfPU(A) CFextern INTEGER_BYTE FCALLSC_QUALIFIER A
#define DOUBLE_cfPU(A) CFextern DOUBLE_PRECISION FCALLSC_QUALIFIER A
#if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define FLOAT_cfPU(A) CFextern DOUBLE_PRECISION FCALLSC_QUALIFIER A
+#else
#define FLOAT_cfPU(A) CFextern FORTRAN_REAL FCALLSC_QUALIFIER A
+#endif
#else
#define FLOAT_cfPU(A) CFextern FLOATFUNCTIONTYPE FCALLSC_QUALIFIER A
#endif
@@ -1589,6 +1743,7 @@
#define INT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
#define LOGICAL_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,LOGICAL,A,B,C,D,E)
#define LONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LONGLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
#define SHORT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
#define BYTEV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
#define BYTEVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
@@ -1632,6 +1787,13 @@
#define LONGVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
#define LONGVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
#define LONGVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LONGLONGV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define LONGLONGVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define LONGLONGVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define LONGLONGVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define LONGLONGVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define LONGLONGVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define LONGLONGVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
#define SHORTV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
#define SHORTVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
#define SHORTVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
@@ -1645,6 +1807,7 @@
#define PINT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
#define PLOGICAL_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PLOGICAL,A,B,C,D,E)
#define PLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define PLONGLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
#define PSHORT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
#define STRING_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,STRING,A,B,C,D,E)
#define PSTRING_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PSTRING,A,B,C,D,E)
@@ -1957,6 +2120,7 @@
#define INT_cfT(M,I,A,B,D) *A
#define LOGICAL_cfT(M,I,A,B,D) F2CLOGICAL(*A)
#define LONG_cfT(M,I,A,B,D) *A
+#define LONGLONG_cfT(M,I,A,B,D) *A /* added by MR December 2005 */
#define SHORT_cfT(M,I,A,B,D) *A
#define BYTEV_cfT(M,I,A,B,D) A
#define DOUBLEV_cfT(M,I,A,B,D) A
@@ -1964,6 +2128,7 @@
#define INTV_cfT(M,I,A,B,D) A
#define LOGICALV_cfT(M,I,A,B,D) A
#define LONGV_cfT(M,I,A,B,D) A
+#define LONGLONGV_cfT(M,I,A,B,D) A /* added by MR December 2005 */
#define SHORTV_cfT(M,I,A,B,D) A
#define BYTEVV_cfT(M,I,A,B,D) (void *)A /* We have to cast to void *,*/
#define BYTEVVV_cfT(M,I,A,B,D) (void *)A /* since we don't know the */
@@ -2001,6 +2166,12 @@
#define LONGVVVVV_cfT(M,I,A,B,D) (void *)A
#define LONGVVVVVV_cfT(M,I,A,B,D) (void *)A
#define LONGVVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define LONGLONGVV_cfT(M,I,A,B,D) (void *)A /* added by MR December 2005 */
+#define LONGLONGVVV_cfT(M,I,A,B,D) (void *)A /* added by MR December 2005 */
+#define LONGLONGVVVV_cfT(M,I,A,B,D) (void *)A /* added by MR December 2005 */
+#define LONGLONGVVVVV_cfT(M,I,A,B,D) (void *)A /* added by MR December 2005 */
+#define LONGLONGVVVVVV_cfT(M,I,A,B,D) (void *)A /* added by MR December 2005 */
+#define LONGLONGVVVVVVV_cfT(M,I,A,B,D) (void *)A /* added by MR December 2005 */
#define SHORTVV_cfT(M,I,A,B,D) (void *)A
#define SHORTVVV_cfT(M,I,A,B,D) (void *)A
#define SHORTVVVV_cfT(M,I,A,B,D) (void *)A
@@ -2013,6 +2184,7 @@
#define PINT_cfT(M,I,A,B,D) A
#define PLOGICAL_cfT(M,I,A,B,D) ((*A=F2CLOGICAL(*A)),A)
#define PLONG_cfT(M,I,A,B,D) A
+#define PLONGLONG_cfT(M,I,A,B,D) A /* added by MR December 2005 */
#define PSHORT_cfT(M,I,A,B,D) A
#define PVOID_cfT(M,I,A,B,D) A
#if defined(apolloFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran)
@@ -2083,12 +2255,18 @@
#define INT_cfFZ(UN,LN) int FCALLSC_QUALIFIER fcallsc(UN,LN)(
#define LOGICAL_cfFZ(UN,LN) int FCALLSC_QUALIFIER fcallsc(UN,LN)(
#define LONG_cfFZ(UN,LN) long FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#define LONGLONG_cfFZ(UN,LN) LONGLONG FCALLSC_QUALIFIER fcallsc(UN,LN)( /* added by MR December 2005 */
#define SHORT_cfFZ(UN,LN) short FCALLSC_QUALIFIER fcallsc(UN,LN)(
#define VOID_cfFZ(UN,LN) void FCALLSC_QUALIFIER fcallsc(UN,LN)(
#ifndef __CF__KnR
/* The void is req'd by the Apollo, to make this an ANSI function declaration.
The Apollo promotes K&R float functions to double. */
-#define FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define FLOAT_cfFZ(UN,LN) DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#else
+#define FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#endif
#ifdef vmsFortran
#define STRING_cfFZ(UN,LN) void FCALLSC_QUALIFIER fcallsc(UN,LN)(fstring *AS
#else
@@ -2104,7 +2282,12 @@
#endif
#else
#if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define FLOAT_cfFZ(UN,LN) DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#else
#define FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#endif
#else
#define FLOAT_cfFZ(UN,LN) FLOATFUNCTIONTYPE FCALLSC_QUALIFIER fcallsc(UN,LN)(
#endif
@@ -2118,13 +2301,19 @@
#define BYTE_cfF(UN,LN) BYTE_cfFZ(UN,LN)
#define DOUBLE_cfF(UN,LN) DOUBLE_cfFZ(UN,LN)
#ifndef __CF_KnR
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define FLOAT_cfF(UN,LN) DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#else
#define FLOAT_cfF(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#endif
#else
#define FLOAT_cfF(UN,LN) FLOAT_cfFZ(UN,LN)
#endif
#define INT_cfF(UN,LN) INT_cfFZ(UN,LN)
#define LOGICAL_cfF(UN,LN) LOGICAL_cfFZ(UN,LN)
#define LONG_cfF(UN,LN) LONG_cfFZ(UN,LN)
+#define LONGLONG_cfF(UN,LN) LONGLONG_cfFZ(UN,LN) /* added by MR December 2005 */
#define SHORT_cfF(UN,LN) SHORT_cfFZ(UN,LN)
#define VOID_cfF(UN,LN) VOID_cfFZ(UN,LN)
#define STRING_cfF(UN,LN) STRING_cfFZ(UN,LN),
@@ -2187,6 +2376,7 @@
#define LOGICAL_cfI return C2FLOGICAL(A0);
#endif
#define LONG_cfI return A0;
+#define LONGLONG_cfI return A0; /* added by MR December 2005 */
#define SHORT_cfI return A0;
#define STRING_cfI return ;
#define VOID_cfI return ;
--- cfortran-4.4.orig/index.htm
+++ cfortran-4.4/index.htm
@@ -22,7 +22,8 @@
Burkhard D. Burow. "Mixed Language Programming",
In Computing in High Energy Physics (CHEP'95), Rio de Janeiro, Brazil,
Sept. 1995, editors R. Shellard and T.Nguyen, World Scientific, pp. 610-614.
-Here is the paper and the slides of the presentation.
+Here is the paper
+and the slides of the presentation.
It introduces cfortran.h and alternative methods for mixed language programming
and thus can help you decide if cfortran.h can be of use to you.
@@ -33,21 +34,23 @@
then cfortran.h has a few thousand users. You easily can find users in a www search.
-The cfortran.h software consists of the single C header file cfortran.h.
+The cfortran.h software consists of the single C header file cfortran.h.
The documentation is the single file cfortran.html.
The documentation also is available at its original location http://wwwinfo.cern.ch/asd/cernlib/cfortran.html.
-The documentation also is available as the original ASCII file cfortran.doc.
+The documentation also is available as the gzipped ASCII file cfortran.doc.gz.
A variety of small independent applications are available to test and demonstrate cfortran.h.
-All the applications are contained in a compressed tar file cfortran.examples.tar.gz.
+All the applications are contained in
+
+the examples directory.
Though NOT recommended for most purposes,
-the above applications also are available in a single C file cfortest.c
-and a single Fortran file cfortex.f.
+the above applications also are available in a single C file cfortest.c
+and a single Fortran file cfortex.f.
If cfortran.h has served you well, you may want to look at the recent instance of graph reduction
--- cfortran-4.4.orig/cfortran.doc
+++ cfortran-4.4/cfortran.doc
@@ -195,13 +195,13 @@
HP9000> f77 -c cfortex.f
HP9000> CC -o cfortest cfortest.c cfortex.o -lI77 -lF77 && cfortest
-HP0000> # If old-style f77 +800 compiled objects are required:
+HP9000> # If old-style f77 +800 compiled objects are required:
HP9000> # #define hpuxFortran800
HP9000> cc -c -Aa -DhpuxFortran800 cfortest.c
HP9000> f77 +800 -o cfortest cfortest.o cfortex.f
f2c> # In the following, 'CC' is any C compiler.
-f2c> f2c -R cfortex.f
+f2c> f2c cfortex.f
f2c> CC -o cfortest -Df2cFortran cfortest.c cfortex.c -lf2c && cfortest
Portland Group $ # Presumably other C compilers also work.
@@ -533,9 +533,10 @@
FORTRAN_REAL thus corresponds to FORTRAN's REAL on all machines, including t3e.
-o f2c
- f2c, by default promotes REAL functions to double. cfortran.h does not (yet)
-support this, so the f2c -R option must be used to turn this promotion off.
+o f2c / g77
+ f2c and g77 by default promote REAL functions to double. As of December 9,
+2005, the Debian package of cfortran supports this behavior, so the f2c -R
+option must *NOT* be used to turn this promotion off.
o f2c
[Thanks to Dario Autiero for pointing out the following.]
@@ -573,6 +574,11 @@
#endif
/* Last three lines are a work-around for the strange f2c naming feature. */
+o gfortran
+ gfortran behaves similarly to f2c and g77, EXCEPT that it does NOT by default
+promote REAL functions to double. Therefore you should use -DgFortran instead
+of -Dg77Fortran or -Df2cFortran to let cfortran.h know about this difference.
+
o NAG f90
The Fortran 77 subset of Fortran 90 is supported. Extending cfortran.h to
interface C with all of Fortran 90 has not yet been examined.
@@ -643,7 +649,7 @@
[For an ancient math.h on a 386 or sparc, get similar from a new math.h.]
#ifdef mc68000 /* 5 lines Copyright (c) 1988 by Sun Microsystems, Inc. */
#define FLOATFUNCTIONTYPE int
- #define RETURNFLOAT(x) return (*(int *)(&(x)))
+ #define RETURNFLOAT(x) return (*(int *)(&(x)))
#define ASSIGNFLOAT(x,y) *(int *)(&x) = y
#endif
@@ -874,7 +880,7 @@
works everywhere and would seem to be an obvious choice.
-3.