1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
#include "f2c.h"
#include "fio.h"
#include "fmt.h"
#include "lio.h"
#ifdef __cplusplus
extern "C" {
#endif
ftnint L_len;
int f__Aquote;
static VOID
donewrec(Void)
{
if (f__recpos)
(*f__donewrec)();
}
static VOID
#ifdef KR_headers
lwrt_I(n) longint n;
#else
lwrt_I(longint n)
#endif
{
char *p;
int ndigit, sign;
p = f__icvt(n, &ndigit, &sign, 10);
if(f__recpos + ndigit >= L_len)
donewrec();
PUT(' ');
if (sign)
PUT('-');
while(*p)
PUT(*p++);
}
static VOID
#ifdef KR_headers
lwrt_L(n, len) ftnint n; ftnlen len;
#else
lwrt_L(ftnint n, ftnlen len)
#endif
{
if(f__recpos+LLOGW>=L_len)
donewrec();
wrt_L((Uint *)&n,LLOGW, len);
}
static VOID
#ifdef KR_headers
lwrt_A(p,len) char *p; ftnlen len;
#else
lwrt_A(char *p, ftnlen len)
#endif
{
int a;
char *p1, *pe;
a = 0;
pe = p + len;
if (f__Aquote) {
a = 3;
if (len > 1 && p[len-1] == ' ') {
while(--len > 1 && p[len-1] == ' ');
pe = p + len;
}
p1 = p;
while(p1 < pe)
if (*p1++ == '\'')
a++;
}
if(f__recpos+len+a >= L_len)
donewrec();
if (a
#ifndef OMIT_BLANK_CC
|| !f__recpos
#endif
)
PUT(' ');
if (a) {
PUT('\'');
while(p < pe) {
if (*p == '\'')
PUT('\'');
PUT(*p++);
}
PUT('\'');
}
else
while(p < pe)
PUT(*p++);
}
static int
#ifdef KR_headers
l_g(buf, n) char *buf; double n;
#else
l_g(char *buf, double n)
#endif
{
#ifdef Old_list_output
doublereal absn;
char *fmt;
absn = n;
if (absn < 0)
absn = -absn;
fmt = LLOW <= absn && absn < LHIGH ? LFFMT : LEFMT;
#ifdef USE_STRLEN
sprintf(buf, fmt, n);
return strlen(buf);
#else
return sprintf(buf, fmt, n);
#endif
#else
register char *b, c, c1;
b = buf;
*b++ = ' ';
if (n < 0) {
*b++ = '-';
n = -n;
}
else
*b++ = ' ';
if (n == 0) {
#ifdef SIGNED_ZEROS
if (signbit_f2c(&n))
*b++ = '-';
#endif
*b++ = '0';
*b++ = '.';
*b = 0;
goto f__ret;
}
sprintf(b, LGFMT, n);
switch(*b) {
#ifndef WANT_LEAD_0
case '0':
while(b[0] = b[1])
b++;
break;
#endif
case 'i':
case 'I':
/* Infinity */
case 'n':
case 'N':
/* NaN */
while(*++b);
break;
default:
/* Fortran 77 insists on having a decimal point... */
for(;; b++)
switch(*b) {
case 0:
*b++ = '.';
*b = 0;
goto f__ret;
case '.':
while(*++b);
goto f__ret;
case 'E':
for(c1 = '.', c = 'E'; *b = c1;
c1 = c, c = *++b);
goto f__ret;
}
}
f__ret:
return b - buf;
#endif
}
static VOID
#ifdef KR_headers
l_put(s) register char *s;
#else
l_put(register char *s)
#endif
{
#ifdef KR_headers
register void (*pn)() = f__putn;
#else
register void (*pn)(int) = f__putn;
#endif
register int c;
while(c = *s++)
(*pn)(c);
}
static VOID
#ifdef KR_headers
lwrt_F(n) double n;
#else
lwrt_F(double n)
#endif
{
char buf[LEFBL];
if(f__recpos + l_g(buf,n) >= L_len)
donewrec();
l_put(buf);
}
static VOID
#ifdef KR_headers
lwrt_C(a,b) double a,b;
#else
lwrt_C(double a, double b)
#endif
{
char *ba, *bb, bufa[LEFBL], bufb[LEFBL];
int al, bl;
al = l_g(bufa, a);
for(ba = bufa; *ba == ' '; ba++)
--al;
bl = l_g(bufb, b) + 1; /* intentionally high by 1 */
for(bb = bufb; *bb == ' '; bb++)
--bl;
if(f__recpos + al + bl + 3 >= L_len)
donewrec();
#ifdef OMIT_BLANK_CC
else
#endif
PUT(' ');
PUT('(');
l_put(ba);
PUT(',');
if (f__recpos + bl >= L_len) {
(*f__donewrec)();
#ifndef OMIT_BLANK_CC
PUT(' ');
#endif
}
l_put(bb);
PUT(')');
}
int
#ifdef KR_headers
l_write(number,ptr,len,type) ftnint *number,type; char *ptr; ftnlen len;
#else
l_write(ftnint *number, char *ptr, ftnlen len, ftnint type)
#endif
{
#define Ptr ((flex *)ptr)
int i;
longint x;
double y,z;
real *xx;
doublereal *yy;
for(i=0;i< *number; i++)
{
switch((int)type)
{
default: f__fatal(117,"unknown type in lio");
case TYINT1:
x = Ptr->flchar;
goto xint;
case TYSHORT:
x=Ptr->flshort;
goto xint;
#ifdef Allow_TYQUAD
case TYQUAD:
x = Ptr->fllongint;
goto xint;
#endif
case TYLONG:
x=Ptr->flint;
xint: lwrt_I(x);
break;
case TYREAL:
y=Ptr->flreal;
goto xfloat;
case TYDREAL:
y=Ptr->fldouble;
xfloat: lwrt_F(y);
break;
case TYCOMPLEX:
xx= &Ptr->flreal;
y = *xx++;
z = *xx;
goto xcomplex;
case TYDCOMPLEX:
yy = &Ptr->fldouble;
y= *yy++;
z = *yy;
xcomplex:
lwrt_C(y,z);
break;
case TYLOGICAL1:
x = Ptr->flchar;
goto xlog;
case TYLOGICAL2:
x = Ptr->flshort;
goto xlog;
case TYLOGICAL:
x = Ptr->flint;
xlog: lwrt_L(Ptr->flint, len);
break;
case TYCHAR:
lwrt_A(ptr,len);
break;
}
ptr += len;
}
return(0);
}
#ifdef __cplusplus
}
#endif
|