libflame  revision_anchor
FLA_f2c.h
Go to the documentation of this file.
00001 /*
00002 
00003     Copyright (C) 2014, The University of Texas at Austin
00004 
00005     This file is part of libflame and is available under the 3-Clause
00006     BSD license, which can be found in the LICENSE file at the top-level
00007     directory, or at http://opensource.org/licenses/BSD-3-Clause
00008 
00009 */
00010 // f2c.h  --  Standard Fortran to C header file
00011 //  barf  [ba:rf]  2.  "He suggested using FORTRAN, and everybody barfed."
00012 //  - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition)
00013 
00014 #include <stdio.h>
00015 #include <string.h>
00016 #include <stdlib.h> 
00017 #include <math.h>
00018 #include <complex.h>
00019 #undef complex
00020 
00021 #ifndef F2C_INCLUDE
00022 #define F2C_INCLUDE
00023 
00024 /* typedef long int integer; */
00025 typedef int integer; 
00026 
00027 typedef unsigned long int uinteger;
00028 typedef char *address;
00029 typedef short int shortint;
00030 typedef float real;
00031 typedef double doublereal;
00032 typedef struct { real r, i; } complex;
00033 typedef struct { doublereal r, i; } doublecomplex;
00034 
00035 /* typedef long int logical; */
00036 typedef int logical; 
00037 
00038 typedef short int shortlogical;
00039 typedef char logical1;
00040 typedef char integer1;
00041 #ifdef INTEGER_STAR_8   /* Adjust for integer*8. */
00042 typedef long long longint;      /* system-dependent */
00043 typedef unsigned long long ulongint;    /* system-dependent */
00044 #define qbit_clear(a,b) ((a) & ~((ulongint)1 << (b)))
00045 #define qbit_set(a,b)   ((a) |  ((ulongint)1 << (b)))
00046 #endif
00047 
00048 #define TRUE_ (1)
00049 #define FALSE_ (0)
00050 
00051 /* Extern is for use with -E */
00052 #ifndef Extern
00053 #define Extern extern
00054 #endif
00055 
00056 /* I/O stuff */
00057 
00058 #ifdef f2c_i2
00059 /* for -i2 */
00060 typedef short flag;
00061 typedef short ftnlen;
00062 typedef short ftnint;
00063 #else
00064 typedef long int flag;
00065 typedef long int ftnlen;
00066 typedef long int ftnint;
00067 #endif
00068 
00069 /*external read, write*/
00070 typedef struct
00071 {   flag cierr;
00072     ftnint ciunit;
00073     flag ciend;
00074     char *cifmt;
00075     ftnint cirec;
00076 } cilist;
00077 
00078 /*internal read, write*/
00079 typedef struct
00080 {   flag icierr;
00081     char *iciunit;
00082     flag iciend;
00083     char *icifmt;
00084     ftnint icirlen;
00085     ftnint icirnum;
00086 } icilist;
00087 
00088 /*open*/
00089 typedef struct
00090 {   flag oerr;
00091     ftnint ounit;
00092     char *ofnm;
00093     ftnlen ofnmlen;
00094     char *osta;
00095     char *oacc;
00096     char *ofm;
00097     ftnint orl;
00098     char *oblnk;
00099 } olist;
00100 
00101 /*close*/
00102 typedef struct
00103 {   flag cerr;
00104     ftnint cunit;
00105     char *csta;
00106 } cllist;
00107 
00108 /*rewind, backspace, endfile*/
00109 typedef struct
00110 {   flag aerr;
00111     ftnint aunit;
00112 } alist;
00113 
00114 /* inquire */
00115 typedef struct
00116 {   flag inerr;
00117     ftnint inunit;
00118     char *infile;
00119     ftnlen infilen;
00120     ftnint  *inex;  /*parameters in standard's order*/
00121     ftnint  *inopen;
00122     ftnint  *innum;
00123     ftnint  *innamed;
00124     char    *inname;
00125     ftnlen  innamlen;
00126     char    *inacc;
00127     ftnlen  inacclen;
00128     char    *inseq;
00129     ftnlen  inseqlen;
00130     char    *indir;
00131     ftnlen  indirlen;
00132     char    *infmt;
00133     ftnlen  infmtlen;
00134     char    *inform;
00135     ftnint  informlen;
00136     char    *inunf;
00137     ftnlen  inunflen;
00138     ftnint  *inrecl;
00139     ftnint  *innrec;
00140     char    *inblank;
00141     ftnlen  inblanklen;
00142 } inlist;
00143 
00144 #define VOID void
00145 
00146 union Multitype {   /* for multiple entry points */
00147     integer1 g;
00148     shortint h;
00149     integer i;
00150     /* longint j; */
00151     real r;
00152     doublereal d;
00153     complex c;
00154     doublecomplex z;
00155     };
00156 
00157 typedef union Multitype Multitype;
00158 
00159 /*typedef long int Long;*/  /* No longer used; formerly in Namelist */
00160 
00161 struct Vardesc {    /* for Namelist */
00162     char *name;
00163     char *addr;
00164     ftnlen *dims;
00165     int  type;
00166     };
00167 typedef struct Vardesc Vardesc;
00168 
00169 struct Namelist {
00170     char *name;
00171     Vardesc **vars;
00172     int nvars;
00173     };
00174 typedef struct Namelist Namelist;
00175 
00176 #ifndef abs
00177   #define abs(x) ((x) >= 0 ? (x) : -(x))
00178 #endif
00179 #ifndef dabs
00180   #define dabs(x) (doublereal)abs(x)
00181 #endif
00182 #ifndef min
00183   #define min(a,b) ((a) <= (b) ? (a) : (b))
00184 #endif
00185 #ifndef max
00186   #define max(a,b) ((a) >= (b) ? (a) : (b))
00187 #endif
00188 #ifndef dmin
00189   #define dmin(a,b) (doublereal)min(a,b)
00190 #endif
00191 #ifndef dmax
00192   #define dmax(a,b) (doublereal)max(a,b)
00193 #endif
00194 
00195 #define bit_test(a,b)   ((a) >> (b) & 1)
00196 #define bit_clear(a,b)  ((a) & ~((uinteger)1 << (b)))
00197 #define bit_set(a,b)    ((a) |  ((uinteger)1 << (b)))
00198 
00199 /* procedure parameter types for -A and -C++ */
00200 
00201 #define F2C_proc_par_types 1
00202 #ifdef __cplusplus
00203 typedef int /* Unknown procedure type */ (*U_fp)(...);
00204 typedef shortint (*J_fp)(...);
00205 typedef integer (*I_fp)(...);
00206 typedef real (*R_fp)(...);
00207 typedef doublereal (*D_fp)(...);
00208 typedef doublereal (*E_fp)(...);
00209 typedef /* Complex */ VOID (*C_fp)(...);
00210 typedef /* Double Complex */ VOID (*Z_fp)(...);
00211 typedef logical (*L_fp)(...);
00212 typedef shortlogical (*K_fp)(...);
00213 typedef /* Character */ VOID (*H_fp)(...);
00214 typedef /* Subroutine */ int (*S_fp)(...);
00215 #else
00216 typedef int /* Unknown procedure type */ (*U_fp)();
00217 typedef shortint (*J_fp)();
00218 typedef integer (*I_fp)();
00219 typedef real (*R_fp)();
00220 typedef doublereal (*D_fp)();
00221 typedef doublereal (*E_fp)();
00222 typedef /* Complex */ VOID (*C_fp)();
00223 typedef /* Double Complex */ VOID (*Z_fp)();
00224 typedef logical (*L_fp)();
00225 typedef shortlogical (*K_fp)();
00226 typedef /* Character */ VOID (*H_fp)();
00227 typedef /* Subroutine */ int (*S_fp)();
00228 #endif
00229 /* E_fp is for real functions when -R is not specified */
00230 typedef VOID C_f;   /* complex function */
00231 typedef VOID H_f;   /* character function */
00232 typedef VOID Z_f;   /* double complex function */
00233 typedef doublereal E_f; /* real function with -R not specified */
00234 
00235 /* undef any lower-case symbols that your C compiler predefines, e.g.: */
00236 
00237 #ifndef Skip_f2c_Undefs
00238 #undef cray
00239 #undef gcos
00240 #undef mc68010
00241 #undef mc68020
00242 #undef mips
00243 #undef pdp11
00244 #undef sgi
00245 #undef sparc
00246 #undef sun
00247 #undef sun2
00248 #undef sun3
00249 #undef sun4
00250 #undef u370
00251 #undef u3b
00252 #undef u3b2
00253 #undef u3b5
00254 #undef unix
00255 #undef vax
00256 #endif
00257 #endif