1 /*
2 
3     Copyright (C) 2014, The University of Texas at Austin
4 
5     This file is part of libflame and is available under the 3-Clause
6     BSD license, which can be found in the LICENSE file at the top-level
7     directory, or at http://opensource.org/licenses/BSD-3-Clause
8 
9 */
10 // f2c.h  --  Standard Fortran to C header file
11 //  barf  [ba:rf]  2.  "He suggested using FORTRAN, and everybody barfed."
12 //  - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition)
13 
14 #include <stdio.h>
15 #include <string.h>
16 #include <stdlib.h>
17 #include <math.h>
18 #include <complex.h>
19 #undef complex
20 
21 #ifndef F2C_INCLUDE
22 #define F2C_INCLUDE
23 
24 /* typedef long int integer; */
25 typedef int integer;
26 
27 typedef unsigned long int uinteger;
28 typedef char *address;
29 typedef short int shortint;
30 typedef float real;
31 typedef double doublereal;
32 typedef struct { real r, i; } complex;
33 typedef struct { doublereal r, i; } doublecomplex;
34 
35 /* typedef long int logical; */
36 typedef int logical;
37 
38 typedef short int shortlogical;
39 typedef char logical1;
40 typedef char integer1;
41 #ifdef INTEGER_STAR_8	/* Adjust for integer*8. */
42 typedef long long longint;		/* system-dependent */
43 typedef unsigned long long ulongint;	/* system-dependent */
44 #define qbit_clear(a,b)	((a) & ~((ulongint)1 << (b)))
45 #define qbit_set(a,b)	((a) |  ((ulongint)1 << (b)))
46 #endif
47 
48 #define TRUE_ (1)
49 #define FALSE_ (0)
50 
51 /* Extern is for use with -E */
52 #ifndef Extern
53 #define Extern extern
54 #endif
55 
56 /* I/O stuff */
57 
58 #ifdef f2c_i2
59 /* for -i2 */
60 typedef short flag;
61 typedef short ftnlen;
62 typedef short ftnint;
63 #else
64 typedef long int flag;
65 typedef long int ftnlen;
66 typedef long int ftnint;
67 #endif
68 
69 /*external read, write*/
70 typedef struct
71 {	flag cierr;
72 	ftnint ciunit;
73 	flag ciend;
74 	char *cifmt;
75 	ftnint cirec;
76 } cilist;
77 
78 /*internal read, write*/
79 typedef struct
80 {	flag icierr;
81 	char *iciunit;
82 	flag iciend;
83 	char *icifmt;
84 	ftnint icirlen;
85 	ftnint icirnum;
86 } icilist;
87 
88 /*open*/
89 typedef struct
90 {	flag oerr;
91 	ftnint ounit;
92 	char *ofnm;
93 	ftnlen ofnmlen;
94 	char *osta;
95 	char *oacc;
96 	char *ofm;
97 	ftnint orl;
98 	char *oblnk;
99 } olist;
100 
101 /*close*/
102 typedef struct
103 {	flag cerr;
104 	ftnint cunit;
105 	char *csta;
106 } cllist;
107 
108 /*rewind, backspace, endfile*/
109 typedef struct
110 {	flag aerr;
111 	ftnint aunit;
112 } alist;
113 
114 /* inquire */
115 typedef struct
116 {	flag inerr;
117 	ftnint inunit;
118 	char *infile;
119 	ftnlen infilen;
120 	ftnint	*inex;	/*parameters in standard's order*/
121 	ftnint	*inopen;
122 	ftnint	*innum;
123 	ftnint	*innamed;
124 	char	*inname;
125 	ftnlen	innamlen;
126 	char	*inacc;
127 	ftnlen	inacclen;
128 	char	*inseq;
129 	ftnlen	inseqlen;
130 	char 	*indir;
131 	ftnlen	indirlen;
132 	char	*infmt;
133 	ftnlen	infmtlen;
134 	char	*inform;
135 	ftnint	informlen;
136 	char	*inunf;
137 	ftnlen	inunflen;
138 	ftnint	*inrecl;
139 	ftnint	*innrec;
140 	char	*inblank;
141 	ftnlen	inblanklen;
142 } inlist;
143 
144 #define VOID void
145 
146 union Multitype {	/* for multiple entry points */
147 	integer1 g;
148 	shortint h;
149 	integer i;
150 	/* longint j; */
151 	real r;
152 	doublereal d;
153 	complex c;
154 	doublecomplex z;
155 	};
156 
157 typedef union Multitype Multitype;
158 
159 /*typedef long int Long;*/	/* No longer used; formerly in Namelist */
160 
161 struct Vardesc {	/* for Namelist */
162 	char *name;
163 	char *addr;
164 	ftnlen *dims;
165 	int  type;
166 	};
167 typedef struct Vardesc Vardesc;
168 
169 struct Namelist {
170 	char *name;
171 	Vardesc **vars;
172 	int nvars;
173 	};
174 typedef struct Namelist Namelist;
175 
176 #ifndef f2c_abs
177   #define f2c_abs(x) ((x) >= 0 ? (x) : -(x))
178 #endif
179 #ifndef f2c_dabs
180   #define f2c_dabs(x) (doublereal)f2c_abs(x)
181 #endif
182 #ifndef min
183   #define min(a,b) ((a) <= (b) ? (a) : (b))
184 #endif
185 #ifndef max
186   #define max(a,b) ((a) >= (b) ? (a) : (b))
187 #endif
188 #ifndef dmin
189   #define dmin(a,b) (doublereal)min(a,b)
190 #endif
191 #ifndef dmax
192   #define dmax(a,b) (doublereal)max(a,b)
193 #endif
194 
195 #define bit_test(a,b)	((a) >> (b) & 1)
196 #define bit_clear(a,b)	((a) & ~((uinteger)1 << (b)))
197 #define bit_set(a,b)	((a) |  ((uinteger)1 << (b)))
198 
199 /* procedure parameter types for -A and -C++ */
200 
201 #define F2C_proc_par_types 1
202 #ifdef __cplusplus
203 typedef int /* Unknown procedure type */ (*U_fp)(...);
204 typedef shortint (*J_fp)(...);
205 typedef integer (*I_fp)(...);
206 typedef real (*R_fp)(...);
207 typedef doublereal (*D_fp)(...);
208 typedef doublereal (*E_fp)(...);
209 typedef /* Complex */ VOID (*C_fp)(...);
210 typedef /* Double Complex */ VOID (*Z_fp)(...);
211 typedef logical (*L_fp)(...);
212 typedef shortlogical (*K_fp)(...);
213 typedef /* Character */ VOID (*H_fp)(...);
214 typedef /* Subroutine */ int (*S_fp)(...);
215 #else
216 typedef int /* Unknown procedure type */ (*U_fp)();
217 typedef shortint (*J_fp)();
218 typedef integer (*I_fp)();
219 typedef real (*R_fp)();
220 typedef doublereal (*D_fp)();
221 typedef doublereal (*E_fp)();
222 typedef /* Complex */ VOID (*C_fp)();
223 typedef /* Double Complex */ VOID (*Z_fp)();
224 typedef logical (*L_fp)();
225 typedef shortlogical (*K_fp)();
226 typedef /* Character */ VOID (*H_fp)();
227 typedef /* Subroutine */ int (*S_fp)();
228 #endif
229 /* E_fp is for real functions when -R is not specified */
230 typedef VOID C_f;	/* complex function */
231 typedef VOID H_f;	/* character function */
232 typedef VOID Z_f;	/* double complex function */
233 typedef doublereal E_f;	/* real function with -R not specified */
234 
235 /* undef any lower-case symbols that your C compiler predefines, e.g.: */
236 
237 #ifndef Skip_f2c_Undefs
238 #undef cray
239 #undef gcos
240 #undef mc68010
241 #undef mc68020
242 #undef mips
243 #undef pdp11
244 #undef sgi
245 #undef sparc
246 #undef sun
247 #undef sun2
248 #undef sun3
249 #undef sun4
250 #undef u370
251 #undef u3b
252 #undef u3b2
253 #undef u3b5
254 #undef unix
255 #undef vax
256 #endif
257 #endif
258