1 |
< |
/* Copyright (c) 1992 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1993 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
18 |
|
|
19 |
|
#include "data.h" |
20 |
|
|
21 |
+ |
/* picture memory usage before warning */ |
22 |
+ |
#ifndef PSIZWARN |
23 |
+ |
#ifdef BIGMEM |
24 |
+ |
#define PSIZWARN 3000000 |
25 |
+ |
#else |
26 |
+ |
#define PSIZWARN 1000000 |
27 |
+ |
#endif |
28 |
+ |
#endif |
29 |
|
|
30 |
+ |
#ifndef TABSIZ |
31 |
|
#define TABSIZ 97 /* table size (prime) */ |
32 |
+ |
#endif |
33 |
|
|
34 |
|
#define hash(s) (shash(s)%TABSIZ) |
35 |
|
|
36 |
|
|
37 |
|
extern char *fgetword(); |
38 |
|
|
39 |
< |
extern char *libpath; /* library search path */ |
39 |
> |
extern char *getlibpath(); /* library search path */ |
40 |
|
|
41 |
|
static DATARRAY *dtab[TABSIZ]; /* data array list */ |
42 |
|
|
78 |
|
* 0 0 ni p0i p1i .. pni |
79 |
|
*/ |
80 |
|
|
81 |
< |
if ((dfname = getpath(dname, libpath, R_OK)) == NULL) { |
81 |
> |
if ((dfname = getpath(dname, getlibpath(), R_OK)) == NULL) { |
82 |
|
sprintf(errmsg, "cannot find data file \"%s\"", dname); |
83 |
|
error(USER, errmsg); |
84 |
|
} |
169 |
|
getpict(pname) /* get picture pname */ |
170 |
|
char *pname; |
171 |
|
{ |
162 |
– |
extern char *libpath; |
172 |
|
double inpaspect; |
173 |
|
char *pfname; |
174 |
|
FILE *fp; |
184 |
|
if (!strcmp(pname, pp->name)) |
185 |
|
return(pp); /* found! */ |
186 |
|
|
187 |
< |
if ((pfname = getpath(pname, libpath, R_OK)) == NULL) { |
187 |
> |
if ((pfname = getpath(pname, getlibpath(), R_OK)) == NULL) { |
188 |
|
sprintf(errmsg, "cannot find picture file \"%s\"", pname); |
189 |
|
error(USER, errmsg); |
190 |
|
} |
207 |
|
getheader(fp, headaspect, &inpaspect); |
208 |
|
if (!fgetsresolu(&inpres, fp)) |
209 |
|
goto readerr; |
210 |
+ |
#if PSIZWARN |
211 |
+ |
/* check memory usage */ |
212 |
+ |
i = 3*sizeof(DATATYPE)*inpres.xr*inpres.yr; |
213 |
+ |
if (i > PSIZWARN) { |
214 |
+ |
sprintf(errmsg, "picture file \"%s\" using %d bytes of memory", |
215 |
+ |
pname, i); |
216 |
+ |
error(WARNING, errmsg); |
217 |
+ |
} |
218 |
+ |
#endif |
219 |
|
for (i = 0; i < 3; i++) { |
220 |
|
pp[i].nd = 2; |
221 |
|
pp[i].dim[0].ne = inpres.yr; |
341 |
|
int asize; |
342 |
|
int lower, upper; |
343 |
|
register int i; |
344 |
< |
double x, y, y0, y1; |
344 |
> |
double x, y0, y1; |
345 |
|
/* set up dimensions for recursion */ |
346 |
|
sd.nd = dp->nd - 1; |
347 |
|
asize = 1; |
354 |
|
/* get independent variable */ |
355 |
|
if (dp->dim[0].p == NULL) { /* evenly spaced points */ |
356 |
|
x = (pt[0] - dp->dim[0].org)/dp->dim[0].siz; |
357 |
< |
x = x * (dp->dim[0].ne - 1); |
357 |
> |
x *= (double)(dp->dim[0].ne - 1); |
358 |
|
i = x; |
359 |
|
if (i < 0) |
360 |
|
i = 0; |
395 |
|
* taper off harmonically to zero. |
396 |
|
*/ |
397 |
|
if (x > i+2) |
398 |
< |
y = (2*y1-y0)/(x-i-1); |
381 |
< |
else if (x < i-1) |
382 |
< |
y = (2*y0-y1)/(i-x); |
383 |
< |
else |
384 |
< |
y = y0*((i+1)-x) + y1*(x-i); |
398 |
> |
return( (2*y1-y0)/(x-(i-1)) ); |
399 |
|
|
400 |
< |
return(y); |
400 |
> |
if (x < i-1) |
401 |
> |
return( (2*y0-y1)/(i-x) ); |
402 |
> |
|
403 |
> |
return( y0*((i+1)-x) + y1*(x-i) ); |
404 |
|
} |