root/cdat/trunk/libcdms/include/grads.h
Revision 2109, 42.6 kB (checked in by dubois, 7 years ago) |
---|
Line | |
---|---|
1 | /* Copyright (c) 1988-1995 by Brian Doty |
2 | See file COPYRIGHT for complete rights and liability information. */ |
3 | |
4 | /* Handling of missing data values. If SETMISS is 0, it is assumed |
5 | that missing data values will exactly match the value parsed from |
6 | the data description file (true on many machines). If SETMISS is 1, |
7 | a test is done for a small range (+-value/EPSILON) and if true the |
8 | value is set to exactly the missing data value when read. */ |
9 | |
10 | #include <stdio.h> |
11 | |
12 | #define SETMISS 1 |
13 | #define EPSILON 1e5 |
14 | #define FUZZ_SCALE 1e-5 |
15 | |
16 | /* RPTNUM: Number of garpt blocks to allocate per memory block |
17 | BLKNUM: Max number of memory requests |
18 | A max of RPTNUM*BLKNUM stations can be held per request */ |
19 | |
20 | #define RPTNUM 200 |
21 | #define BLKNUM 500 |
22 | |
23 | #if GRADS_CRAY == 1 |
24 | #define CPULIMSIG SIGCPULIM |
25 | #else |
26 | #define CPULIMSIG SIGXCPU |
27 | #endif |
28 | |
29 | /*******************\ |
30 | * Data Structures * |
31 | \*******************/ |
32 | |
33 | /* Pointer to data object */ |
34 | |
35 | union gadata { |
36 | struct gagrid *pgr; |
37 | struct gastn *stn; |
38 | }; |
39 | |
40 | /* Date/time structure. */ |
41 | |
42 | struct dt { |
43 | int yr; |
44 | int mo; |
45 | int dy; |
46 | int hr; |
47 | int mn; |
48 | }; |
49 | |
50 | /* Collection structure */ |
51 | |
52 | struct gaclct { |
53 | struct gaclct *forw; /* Forward Pointer */ |
54 | struct gastn *stn; /* Pointer to station data */ |
55 | struct gastn *stn2; /* Pointer to station data */ |
56 | }; |
57 | |
58 | /* info for LATS */ |
59 | |
60 | struct galats { |
61 | |
62 | /*=== lats_parmtab ===*/ |
63 | char ptname[256]; /* parameter file name */ |
64 | |
65 | /*=== lats_create ===*/ |
66 | int convention; /* data convention (enum) */ |
67 | int frequency; /* data frequency (enum) e.g., hourly */ |
68 | int calendar; /* calendar of the time model (enum) e.g., standard */ |
69 | int deltat; /* number of time units between outputs, e.g., 12 for every 12 h */ |
70 | char model[256]; /* model COMMENT */ |
71 | char center[32]; /* data source which is the GRIB PROCESS ! NOT the GRIB CENTER */ |
72 | char comment[256]; /* comment on data set which will go into the title of the .ctl file */ |
73 | char oname[256]; /* name of the output file (dset) */ |
74 | |
75 | /*=== lats_basetime ===*/ |
76 | int lyr; /* lats basetime year */ |
77 | int lmo; /* lats basetime month */ |
78 | int lda; /* lats basetime day */ |
79 | int lhr; /* lats basetime hour */ |
80 | |
81 | /*=== lats_vertdim ===*/ |
82 | char vertdimname[32]; /* name of the vertial dimension */ |
83 | double levels[128]; /* vertical levels MAX IS 128!!!*/ |
84 | int nlev; /* number of levels */ |
85 | |
86 | /*=== lats_grid ===*/ |
87 | int gridtype; /* grid type (enum), calculated in GrADS except when LATS_GAUSSIAN */ |
88 | char gridname[32]; /* name of the vertial dimension */ |
89 | int ilinear; /* linearity of the grid in x */ |
90 | int jlinear; /* linearity of the grid in y */ |
91 | int nlon; /* # of points in x */ |
92 | int nlat; /* # of points in y */ |
93 | float lon_1; /* starting longitide */ |
94 | float lat_1; /* starting latitude */ |
95 | float lon_nlon; /* ending longitude */ |
96 | float lat_nlat; /* ending latitude */ |
97 | |
98 | /*=== lats_var ===*/ |
99 | char var[32]; /* variable name */ |
100 | char var_comment[256]; /* variable name */ |
101 | int timestat; /* variable time statistic (enum) */ |
102 | |
103 | /*=== lats_write ===*/ |
104 | double varlev; /* level value of the variable for lats_write*/ |
105 | |
106 | /*--- time options ---*/ |
107 | int time_opt; /* 0 - grid relative ; 1 - dimension environment relative ; 2 - set time using baset time ; 3 - forecast hourly */ |
108 | int fhour; /* forecast hour if using lats forecast_hourly */ |
109 | |
110 | /*--- internal id's to pass to the lats routines ---*/ |
111 | int id_file; |
112 | int id_lev; |
113 | int id_grid; |
114 | int id_var; |
115 | |
116 | int id_user_file; |
117 | int id_user_var; |
118 | int id_user_grid; |
119 | int id_user_lev; |
120 | int id_user_write; |
121 | |
122 | }; |
123 | |
124 | |
125 | /*mf 9612105 Contains global information for Mike Fiorino mf*/ |
126 | |
127 | struct gamfcmn { |
128 | int cal365 ; /* 365 (no leap year) calendar */ |
129 | int fullyear ; /* 1 - must specify full year 0 old default */ |
130 | int warnflg; /* warning level flag for messages */ |
131 | }; |
132 | |
133 | /* Contains information about the user interface and graphics output. */ |
134 | struct gacmn { |
135 | |
136 | int pass; /* Number of passes since last clear */ |
137 | int gpass[10]; /* Number of passes for each gx type */ |
138 | int loopdim; /* Looping dimension */ |
139 | int loopflg; /* Looping on or off */ |
140 | float loopincr; /* Looping increment */ |
141 | |
142 | struct gafile *pfi1; /* Pointer to first gafile in chain */ |
143 | struct gafile *pfid; /* Pointer to default gafile */ |
144 | int fnum; /* File count */ |
145 | int dfnum; /* Default file number */ |
146 | |
147 | struct gadefn *pdf1; /* Pointer to first define block */ |
148 | |
149 | float dmin[3],dmax[3]; /* Current absolute coordinate limits */ |
150 | struct dt tmin,tmax; |
151 | int vdim[4]; /* Which dimensions vary? */ |
152 | |
153 | float pxsize,pysize; /* Physical page size in inches */ |
154 | int orient; /* Page orientation */ |
155 | int vpflag; /* If 1, virtual page being used */ |
156 | float xsiz,xsiz1,xsiz2; /* Physical plotting size in X direction */ |
157 | float ysiz,ysiz1,ysiz2; /* Physical plotting size in Y direction */ |
158 | int paflg; /* User has specified plotting area */ |
159 | float pxmin,pxmax; /* User specified plotting area */ |
160 | float pymin,pymax; |
161 | float aspect; /* User specified aspect ratio */ |
162 | |
163 | int clab; /* control contour labels. */ |
164 | int clskip; /* Contour label skipping */ |
165 | char *clstr; /* Contour label template */ |
166 | float rainmn,rainmx; /* control rainbow colors */ |
167 | int rbflg; /* User rainbow colors specified */ |
168 | int rbcols[100]; /* User rainbow colors */ |
169 | |
170 | float cmin,cmax,cint; /* User specified contour limits */ |
171 | int cflag; /* If true, user specifies contour levels*/ |
172 | float clevs[100]; /* User specified contour levels */ |
173 | int ccflg; /* If true, user specifies contour colors*/ |
174 | int ccols[100]; /* User specified contour colors */ |
175 | int shdcls[120]; /* Shade colors after shading */ |
176 | float shdlvs[120]; /* Shade levels */ |
177 | int shdcnt; /* Number of shdlvs, shdcls */ |
178 | int ccolor,cstyle; /* User contour/line appearance */ |
179 | int cthick; /* User gx display line thickness */ |
180 | int cmark; /* Line marker type */ |
181 | int csmth; /* Contour smoothing on or off */ |
182 | int cterp; /* Spline fit on or off */ |
183 | float rmin,rmax,rint; /* Axis limits for 1-D plots */ |
184 | float rmin2,rmax2,rint2; /* Axis limits for 1-D plots */ |
185 | int aflag,aflag2; /* Keep 1D axis limits fixed */ |
186 | int grflag,grstyl,grcolr; /* Grid flag, linestyle, color */ |
187 | int dignum; /* grid value plot control (gxout=grid) */ |
188 | float digsiz; |
189 | int arrflg; /* Use already set arrow scaling */ |
190 | float arrsiz; /* Arrow size in inches */ |
191 | int arlflg; /* Arrow label flag */ |
192 | float arrmag; /* Vector magnitude producing arrsiz arrw*/ |
193 | float ahdsiz; /* Arrow head size. */ |
194 | int miconn; /* Connect line graph accross missing */ |
195 | int strmden; /* Streamline density indicator */ |
196 | int mdlblnk,mdldig3; /* Station model plot opts */ |
197 | |
198 | int fgvals[50]; /* Values for grid fill */ |
199 | int fgcols[50]; |
200 | int fgcnt; |
201 | |
202 | int stidflg; /* Plot station ids with values */ |
203 | |
204 | float axmin,axmax,axint; /* Overrides for X-axis labels */ |
205 | float aymin,aymax,ayint; /* Overrides for Y-axis labels */ |
206 | int axflg, ayflg; /* Is override in effect for the axis? */ |
207 | int frame; /* Display frame? */ |
208 | |
209 | int rotate; /* Rotate plot from default orientation */ |
210 | int xflip, yflip; /* Flip X or Y axes */ |
211 | int zlog; /* Z coordinate in log scale */ |
212 | |
213 | int mproj; /* Map projection -- used for X,Y plot */ |
214 | /* only. 0 = no map. */ |
215 | int mpdraw; /* Draw map outline - 0=no */ |
216 | float mpvals[10]; /* Map projection option values. */ |
217 | int mpflg; /* Map projection option values are set. */ |
218 | char *mpdset[8]; /* Map data set names. */ |
219 | int mpcols[256]; /* Map Color array */ |
220 | int mpstls[256]; /* Map line styles array */ |
221 | int mpthks[256]; /* Map line widths array */ |
222 | int mapcol,mapstl,mapthk; /* Default map color, style, thickness */ |
223 | |
224 | int gout0; /* Graphics output type for stat. */ |
225 | int gout1; /* Graphics output type for 1-D. */ |
226 | int gout2a; /* Graphics output type for 2-D. */ |
227 | int gout2b; /* Graphics output type for 2-D. */ |
228 | int goutstn; /* Graphics output type for stns */ |
229 | |
230 | int blkflg; /* Leave certain values black when shadng*/ |
231 | float blkmin, blkmax; /* Black range */ |
232 | |
233 | int reccol,recthk; /* Draw Rectangle color, brdr thickness */ |
234 | int lincol,linstl,linthk; /* Draw line color, style, thickness */ |
235 | int mcolor; /* auto color (orange or grey) */ |
236 | int strcol,strthk,strjst; /* Draw string color, thckns, justifictn */ |
237 | float strrot; /* Draw string rotation */ |
238 | float strhsz,strvsz; /* Draw string hor. size, vert. size */ |
239 | int anncol,annthk; /* Draw title color, thickness */ |
240 | int grflg; /* Grey Scale flag */ |
241 | int devbck; /* Device background */ |
242 | int xlcol,xlthck,ylcol,ylthck,clcol,clthck; /* color, thickness */ |
243 | int xlside,ylside,ylpflg; |
244 | float xlsiz,ylsiz,clsiz,xlpos,ylpos,yllow; /* Axis lable size */ |
245 | float xlevs[50],ylevs[50]; /* User specified x/y axis labels */ |
246 | int xlflg,ylflg; /* Number of user specified labels */ |
247 | int xtick,ytick; /* Number of extra tick marks */ |
248 | float xlint,ylint; /* User specified label increment */ |
249 | char *xlstr, *ylstr; /* user substitution string for labels */ |
250 | int xlab,ylab; /* Axis label options */ |
251 | char *xlabs, *ylabs; /* User specifies all labels */ |
252 | int ixlabs, iylabs; /* Count of user labels */ |
253 | int lfc1,lfc2; /* Linefill colors */ |
254 | int wxcols[5]; /* wx symbol colors */ |
255 | int wxopt; /* wx options */ |
256 | int tser; /* station time series type */ |
257 | |
258 | int bargap; /* Bar Gap in percent */ |
259 | int barolin; /* Bar outline flag */ |
260 | float barbase; /* Bar Base Value */ |
261 | int barflg; /* Bar flag: 1, use base value */ |
262 | /* 0, draw from plot base */ |
263 | /* -1, draw from plot top */ |
264 | |
265 | int btnfc,btnbc,btnoc,btnoc2; /* Current button attributes */ |
266 | int btnftc,btnbtc,btnotc,btnotc2; |
267 | int btnthk; |
268 | |
269 | int drvals[15]; /* Attributes for drop menus */ |
270 | |
271 | FILE *ffile; /* grads.fwrite file handle */ |
272 | char *fwname; /* fwrite file name */ |
273 | |
274 | int grdsflg; /* Indicate whether to put grads atrib. */ |
275 | |
276 | int timelabflg; /* Indicate whether to put cur time atrib. */ |
277 | |
278 | int dbflg; /* Double buffer mode flag */ |
279 | |
280 | int batflg; /* Batch mode */ |
281 | |
282 | int numgrd,relnum; /* Number of data objects held */ |
283 | int type[16]; /* Data type of each data object */ |
284 | union gadata result[16]; /* Pointers to held data objects */ |
285 | struct gaclct *clct[32]; /* Anchor for collection */ |
286 | int clctnm[32]; /* Number of items collected */ |
287 | int clcttp[32]; /* Varying dimension of collection */ |
288 | |
289 | int lastgx; /* Last gx plotted */ |
290 | int xdim, ydim; /* Which dimensions on X and Y axis */ |
291 | /* Grid-to-world conversion info follows */ |
292 | |
293 | float (*xgr2ab) (float *, float); |
294 | float (*ygr2ab) (float *, float); |
295 | float (*xab2gr) (float *, float); |
296 | float (*yab2gr) (float *, float); |
297 | float *xgrval; |
298 | float *ygrval; |
299 | float *xabval; |
300 | float *yabval; |
301 | |
302 | int impflg; /* Implied run flag */ |
303 | char *impnam; /* Implided run script name */ |
304 | |
305 | int impcmd; /* Implicit run */ |
306 | |
307 | int sig; /* User has signalled */ |
308 | |
309 | int ptflg; /* Pattern fill flag */ |
310 | int ptopt; /* Pattern option: */ |
311 | /* 0, open */ |
312 | /* 1, solid */ |
313 | /* 2, dot */ |
314 | /* 3, line */ |
315 | int ptden; /* Dot or line pattern density */ |
316 | int ptang; /* Line pattern angle */ |
317 | |
318 | struct galats glats ; /* LATS option struct */ |
319 | |
320 | }; |
321 | |
322 | |
323 | |
324 | /* GA status structure. Contains necessary info about the scaling |
325 | and file structure in force. */ |
326 | |
327 | struct gastat { |
328 | |
329 | struct gafile *pfi1; /* Pointer to first gafile in chain */ |
330 | |
331 | struct gafile *pfid; /* Pointer to default gafile */ |
332 | |
333 | int fnum; /* Default file number */ |
334 | |
335 | struct gadefn *pdf1; /* Pointer to first define block */ |
336 | |
337 | struct gaclct **pclct; /* Pointer to the collection pointers */ |
338 | |
339 | union gadata result; /* Result goes here */ |
340 | |
341 | int type; /* Result type (grid or stn) */ |
342 | |
343 | int idim,jdim; /* Varying dimensions */ |
344 | |
345 | float dmin[3],dmax[3]; /* Range of absolute dimensions */ |
346 | struct dt tmin,tmax; |
347 | |
348 | }; |
349 | |
350 | /* Description of a data file. */ |
351 | |
352 | /* This is to define the pointer added at the end of the gafile structure */ |
353 | /* -hoop, 95/07/10 and 95/11/10 */ |
354 | #if USESDF == 1 |
355 | #include "gasdf.h" |
356 | #endif |
357 | |
358 | struct gafile { |
359 | |
360 | struct gafile *pforw; /* Forward pointer to next gafile block. |
361 | List is anchored within gastat. */ |
362 | |
363 | char name[256]; /* File name. */ |
364 | |
365 | char *tempname; /* File name of open file (different with templates) */ |
366 | |
367 | char dnam[256]; /* Descriptor file name */ |
368 | |
369 | char *mnam; /* Map(index) file name */ |
370 | |
371 | FILE *infile; /* File pointer. */ |
372 | |
373 | int type; /* Type of file: 1 = grid |
374 | 2 = simple station |
375 | 3 = mapped station |
376 | 4 = defined grid */ |
377 | |
378 | char title[80]; /* Title -- describes the file. */ |
379 | float undef; /* Global undefined value for this file */ |
380 | float ulow,uhi; /* Undefined limits for SETMISS test */ |
381 | |
382 | float *rbuf; /* Buffer for file I/O equal in length |
383 | to one grid row in the file, or equal |
384 | in length to the size needed to hold |
385 | the largest station report */ |
386 | char *pbuf; /* Same as rbuf, for unpacking */ |
387 | char *bbuf; /* Same as rbuf, for bit map I/O */ |
388 | |
389 | int bswap; /* Byte swapping needed */ |
390 | |
391 | int mtype; /* Stn map file type */ |
392 | int *tstrt; /* Pointer to list length dnum[3] of |
393 | start points of times in the file */ |
394 | int *tcnt; /* Count of stns for assctd time */ |
395 | int stcnt; /* Count of mapped stids when stn data |
396 | and map file is type stidmap. */ |
397 | int stpos; /* Position in map file of start of |
398 | stid info for map file type stidmap. */ |
399 | FILE *mfile; /* File pointer to stidmap file */ |
400 | |
401 | int dnum[4]; /* Dimension sizes for this file. */ |
402 | |
403 | int tlpflg; /* Circular file flag */ |
404 | |
405 | int tlpst; /* Start time offset in circular file */ |
406 | |
407 | int vnum; /* Number of variables. */ |
408 | |
409 | int ivnum; /* Number of level independent variables |
410 | for station data file */ |
411 | |
412 | int lvnum; /* Number of level dependent variables |
413 | for station data file */ |
414 | |
415 | struct gavar *pvar1; /* Pointer to an array of structures. |
416 | Each structure in the array has info |
417 | about the specific variable. */ |
418 | |
419 | int gsiz; /* Number of elements in a grid (x*y) */ |
420 | /* This is for actual grid on disk, |
421 | not psuedo grid (when pp in force) */ |
422 | |
423 | int tsiz; /* Number of elements in an entire time |
424 | group (all variables at all levels |
425 | for one time). */ |
426 | int trecs; /* Number of records (XY grids) per time |
427 | group. */ |
428 | int fhdr; /* Number of bytes to ignore at file head*/ |
429 | |
430 | int wrap; /* The grid globally 'wraps' in X */ |
431 | |
432 | int seqflg, yrflg, zrflg; /* Format flags */ |
433 | |
434 | int ppflag; /* Pre-projection type. |
435 | 0 = none |
436 | 1 = polar stereo |
437 | 2 = lambert conformal */ |
438 | |
439 | int ppwrot; /* Pre-projection wind rotation flag */ |
440 | |
441 | int ppisiz, ppjsiz; /* Actual size of preprojected grid */ |
442 | |
443 | float ppvals[20]; /* Projection constants for pre-projected |
444 | grids. Values depend on projection. */ |
445 | |
446 | int *ppi[8]; /* Pointers to offsets for pre-projected |
447 | grid interpolation */ |
448 | |
449 | float *ppf[8]; /* Pointers to interpolation constants |
450 | for pre-projected grids */ |
451 | |
452 | float *ppw; /* Pointer to wind rotation array */ |
453 | |
454 | float (*gr2ab[3]) (float *, float); |
455 | /* Addresses of routines to do conversion |
456 | from grid coordinates to absolute |
457 | coordinates for X, Y, Z. All Date/time |
458 | conversions handled by gr2t. */ |
459 | |
460 | float (*ab2gr[3]) (float *, float); |
461 | /* Addresses of routines to do conversion |
462 | from absolute coordinates to grid |
463 | coordinates for X,Y,Z. All date/time |
464 | conversions handled by t2gr. */ |
465 | |
466 | float *grvals[4]; /* Pointers to conversion information for |
467 | grid-to-absolute conversion routines. */ |
468 | |
469 | float *abvals[4]; /* Pointers to conversion information for |
470 | absolute-to-grid conversion routines. */ |
471 | |
472 | int linear[4]; /* Indicates if a dimension has a linear |
473 | grid/absolute coord transformation |
474 | (Time coordinate always linear). */ |
475 | |
476 | int dimoff[4]; /* Dimension offsets for defined grids */ |
477 | int climo; /* Climatological Flag (defined grids) */ |
478 | int cysiz; /* Cycle size for climo grids */ |
479 | |
480 | int idxflg; /* File records are indexed */ |
481 | int grbgrd; /* GRIB Grid type */ |
482 | struct gaindx *pindx; /* Index Strucure if indexed file */ |
483 | |
484 | int tmplat; /* File name template */ |
485 | int *fnums; /* File number for each time */ |
486 | int fnumc; /* Current file number that is open */ |
487 | |
488 | int errcnt; /* Current error count */ |
489 | int errflg; /* Current error flag */ |
490 | |
491 | /*mf mf*/ |
492 | int xyhdr; /* Number of bytes to ignore at head of xy grids*/ |
493 | int thdr; /* Number of bytes to ignore at head of time chunk*/ |
494 | int calendar; /* Support for 365-day calendars */ |
495 | int cray_ieee; /* Support 32-bit IEEE data on cray */ |
496 | /*mf mf*/ |
497 | |
498 | |
499 | /* Use of this with the ifdef has implications for checkpoint/restart, */ |
500 | /* as it changes the size of the gafile structure. -hoop 95/07/10 */ |
501 | #if USESDF == 1 |
502 | IO_STD *sdf_ptr ; /* Pointer to SDF file structure */ |
503 | #endif |
504 | |
505 | }; |
506 | |
507 | |
508 | /* Structure that describes a grid (requestor or descriptor block). */ |
509 | |
510 | struct gagrid { |
511 | |
512 | float *grid; /* Address of the grid. */ |
513 | |
514 | struct gafile *pfile; /* Address of the associated gafile |
515 | structure to get the data from |
516 | (requestor block only) */ |
517 | |
518 | float undef; /* Undefined value for this grid. */ |
519 | |
520 | float rmin,rmax; /* Minimum/Maximum grid value |
521 | (rmin is set to the grid value when |
522 | isiz=jsiz=1. *grid points to here.) */ |
523 | |
524 | int isiz,jsiz; /* isiz = number of elements per row. |
525 | jsiz = number of rows. */ |
526 | |
527 | int idim,jdim; /* Dimension of rows and columns. |
528 | -1 = This dimension does not vary |
529 | 1 = X dimension (usually longitude) |
530 | 2 = Y dimension (usually lattitude) |
531 | 3 = Z dimension (usually pressure) |
532 | 4 = Time |
533 | |
534 | If both dimensions are -1, then the |
535 | grid has one value, which will be |
536 | placed in rmin. */ |
537 | |
538 | int iwrld, jwrld; /* World coordinates valid? */ |
539 | |
540 | int dimmin[4],dimmax[4]; /* Dimension limits for each dimension |
541 | (X,Y,Z,T) in grid units. */ |
542 | |
543 | struct gavar *pvar; /* Pointer to the structure with info |
544 | on this particular variable. If |
545 | NULL, this grid is the result of |
546 | an expression evaluation where the |
547 | variable type is unkown. */ |
548 | |
549 | char *exprsn; /* If grid is a 'final' result, this |
550 | will point to a character string that |
551 | contains the original expression. */ |
552 | |
553 | int alocf; /* Scaling info allocated for us only */ |
554 | |
555 | float (*igrab) (float *, float); |
556 | float (*jgrab) (float *, float); |
557 | /* Addresses of routines to perform |
558 | grid-to-absolute coordinate |
559 | transforms for this grid's i and j |
560 | dimensions (unless i or j = 3). */ |
561 | |
562 | float (*iabgr) (float *, float); |
563 | float (*jabgr) (float *, float); |
564 | /* Absolute to grid conversion routines */ |
565 | |
566 | float *ivals, *jvals; /* Pointers to conversion info for the |
567 | grid to abs conversion routines */ |
568 | float *iavals, *javals; /* Conversion info for abs to grid */ |
569 | |
570 | int ilinr,jlinr; /* Indicates if linear transformation */ |
571 | |
572 | |
573 | }; |
574 | |
575 | /* Structure that describes a report header in a stn file */ |
576 | |
577 | struct rpthdr { |
578 | char id[8]; /* Character station id */ |
579 | float lat; /* Latitude of report */ |
580 | float lon; /* Longitude of report */ |
581 | float t; /* Time in relative grid units */ |
582 | int nlev; /* Number of levels following */ |
583 | int flag; /* Level independent var set flag */ |
584 | }; |
585 | |
586 | /* Structure that describes a stid info block within a stidmap file */ |
587 | |
588 | struct stninf { |
589 | char stid[8]; |
590 | int offset; |
591 | int rcnt; |
592 | }; |
593 | |
594 | /* Structure that describes a single report */ |
595 | |
596 | struct garpt { |
597 | |
598 | struct garpt *rpt; /* Address of next report */ |
599 | |
600 | char stid[8]; /* Station id */ |
601 | |
602 | float lat,lon,lev,tim; /* Location of station */ |
603 | |
604 | int work; /* Work area */ |
605 | |
606 | float val; /* Value of variable */ |
607 | |
608 | }; |
609 | |
610 | /* Structure that describes a collection of station reports. */ |
611 | |
612 | struct gastn { |
613 | |
614 | struct garpt *rpt; /* Address of start of link list */ |
615 | |
616 | int rnum; /* Number of reports. */ |
617 | |
618 | struct garpt *blks[BLKNUM]; /* ptrs to memory holding rpts */ |
619 | |
620 | struct gafile *pfi; /* Address of the associated gafile |
621 | structure to get the data from |
622 | (requestor block only) */ |
623 | |
624 | float undef; /* Undefined value for this data. */ |
625 | |
626 | int idim,jdim; /* Varying dimensions for this data |
627 | -1 = This dimension does not vary |
628 | 1 = X dimension (longitude) |
629 | 2 = Y dimension (lattitude) |
630 | 3 = Z dimension (pressure) |
631 | 4 = Time */ |
632 | |
633 | float dmin[3],dmax[3]; /* Dimension limits for each dimension |
634 | (X,Y,Z) in world coords. |
635 | Non-varying dimensions can have |
636 | limits in this structure. */ |
637 | |
638 | int rflag; /* Get stations within specified radius in |
639 | degrees of fixed lat and lon */ |
640 | float radius; /* Radius */ |
641 | |
642 | int sflag; /* Get specific station */ |
643 | char stid[8]; /* Station id to get */ |
644 | |
645 | int tmin,tmax; /* Grid limits of time */ |
646 | |
647 | float *tvals; /* Pointer to conversion info for the |
648 | time conversion routines. */ |
649 | |
650 | struct gavar *pvar; /* Pointer to the structure with info |
651 | on this particular variable. If |
652 | NULL, this grid is the result of |
653 | an expression evaluation where the |
654 | variable type is unkown. */ |
655 | |
656 | struct garpt **prev; /* Used for allocating rpt structures */ |
657 | struct garpt *crpt; |
658 | int rptcnt,blkcnt; |
659 | |
660 | }; |
661 | |
662 | /* Structure that describes a variable in a file. These structures |
663 | are built in arrays that are hung off of gafile structures. */ |
664 | |
665 | |
666 | struct gavar { |
667 | |
668 | char varnm[128]; /* Variable name. */ |
669 | |
670 | char abbrv[16]; /* Variable abbreviation. */ |
671 | |
672 | int units[4]; /* Units indicator. */ |
673 | |
674 | int offset; /* Offset in grid elements of the start |
675 | of this variable within a time group |
676 | within this file. */ |
677 | |
678 | int recoff; /* Record (XY grid) offset of the start |
679 | of this variable within a time group */ |
680 | |
681 | int levels; /* Number of levels for this variable. |
682 | 0 is special and indiates one grid is |
683 | available for the surface only. */ |
684 | /*mf |
685 | |
686 | new variable attribute to handles: |
687 | |
688 | dfrm: |
689 | |
690 | 1-byte |
691 | int dat |
692 | |
693 | var_t: variable t transform |
694 | var_z: variable z transform |
695 | y_x : x-y transform |
696 | |
697 | mf*/ |
698 | |
699 | int dfrm; /* format type indicator |
700 | 1 - unsigned char |
701 | 4 - int |
702 | */ |
703 | |
704 | int var_t ; |
705 | int var_z ; |
706 | int y_x ; |
707 | |
708 | }; |
709 | |
710 | /* Structure that describes a function call. */ |
711 | |
712 | struct gafunc { |
713 | |
714 | int argnum; /* Number of arguments found by fncprs */ |
715 | |
716 | char *argpnt[20]; /* Pointers to the argument strings */ |
717 | |
718 | char buff[1000]; /* Argument string buffer */ |
719 | |
720 | }; |
721 | |
722 | /* Structure that describes a user defined function */ |
723 | |
724 | struct gaufb { |
725 | struct gaufb *ufb; /* Forward pointer */ |
726 | char name[8]; /* Function name */ |
727 | int alo,ahi; /* Limits on number of args */ |
728 | int atype[8]; /* Types of args. 0=expr,1=float,2=int,3=char */ |
729 | int sflg; /* Sequential or direct */ |
730 | char *fname; /* Name of user executable */ |
731 | char *oname; /* File name for data transfer to user */ |
732 | char *iname; /* File name for data transfer from user */ |
733 | }; |
734 | |
735 | /* Structure that describes a defined grid */ |
736 | |
737 | struct gadefn { |
738 | |
739 | struct gadefn *pforw; /* Linked list pointer */ |
740 | |
741 | struct gafile *pfi; /* File Structure containing the data */ |
742 | |
743 | char abbrv[20]; /* Abbreviation assigned to this */ |
744 | |
745 | }; |
746 | |
747 | /* Stack to evaluate the expression. The stack consists of an |
748 | array of structures. */ |
749 | |
750 | struct smem { |
751 | int type; /* Entry type: -2 stn,-1 grid,1=op,2='(',3=')' */ |
752 | union sobj { |
753 | int op; /* Operator: 0=*, 1=/, 2=+ */ |
754 | struct gagrid *pgr; /* Operand (grid or stn) */ |
755 | struct gastn *stn; |
756 | } obj; |
757 | }; |
758 | |
759 | /* Index structure, for when the records in a data file are indexed. |
760 | The indexing file will contain this structure at the front, followed |
761 | by the specified number of header and indexing values. These |
762 | header and indexing values are file format specific. */ |
763 | |
764 | struct gaindx { |
765 | int type; /* Indexing file type */ |
766 | int hinum; /* Number of ints in header */ |
767 | int hfnum; /* Number of floats in header */ |
768 | int intnum; /* Number of index ints (long) */ |
769 | int fltnum; /* Number of index floats */ |
770 | int *hipnt; /* Pointer to header int values */ |
771 | float *hfpnt; /* Pointer to header float values */ |
772 | int *intpnt; /* Pointer to int index values */ |
773 | float *fltpnt; /* Pointer to float index values */ |
774 | } ; |
775 | |
776 | |
777 | /***********************\ |
778 | * Function Prototypes * |
779 | \***********************/ |
780 | |
781 | /* Functions in GRADS.C */ |
782 | |
783 | void gasig (int); |
784 | int gaqsig (void); |
785 | |
786 | /* Functions in GAUSER: |
787 | gacmd: Process a user command |
788 | gacln: Reset variables |
789 | gaenab: Process an enable command |
790 | gadraw: Process a draw command |
791 | gadef: Process a define command |
792 | gaudef: Process undefine command |
793 | gamodf: Modify defined grid |
794 | gaqury: Process a query command |
795 | gahelp: Process a help command |
796 | gaset: Process the SET command |
797 | gadspl: Process a display command |
798 | gapars: Parse a compound expression for gadspl |
799 | gagrel: Release all held grids |
800 | gaopen: Open a data file from a descriptor file |
801 | cleanup: Clean up an input record |
802 | gaprnt: Process output messages |
803 | gagsdo: Execute command for a script |
804 | getpst: Allocate and initialize a gastat block */ |
805 | |
806 | void gainit (void); |
807 | |
808 | int gacmd (char *, struct gacmn *, int); |
809 | void gacln (struct gacmn *,int); |
810 | int gaenab (char *, struct gacmn *); |
811 | int gadraw (char *, struct gacmn *); |
812 | int gardrw (char *, struct gacmn *); |
813 | int gaexec (char *, struct gacmn *); |
814 | char *gagsdo (char *, int *); |
815 | int gadef (char *, struct gacmn *, int); |
816 | int gaudef (char *, struct gacmn *); |
817 | int gamodf (char *, struct gacmn *); |
818 | int gaqdef (char *, struct gacmn *, int); |
819 | int gaqury (char *, char *, struct gacmn *); |
820 | int gahelp (char *, struct gacmn *); |
821 | int gaset (char *, char *, struct gacmn *); |
822 | int gacoll (char *, struct gacmn *); |
823 | int gadspl (char *, struct gacmn *); |
824 | int gaspcl (char *, struct gacmn *); |
825 | int gapars (char *, struct gastat *, struct gacmn *) ; |
826 | void gagrel (struct gacmn *); |
827 | int gaopen (char *, struct gacmn *); |
828 | void cleanup (char *); |
829 | struct gastat *getpst (struct gacmn *); |
830 | void gaprnt (int, char *); |
831 | |
832 | int gaddes (char *, struct gafile *, int); |
833 | int deflin (char *, struct gafile *, int, int); |
834 | int deflev (char *, char *, struct gafile *, int); |
835 | struct gafile *getpfi (void); |
836 | |
837 | /* Functions in GAEXPR: |
838 | gaexpr: Evaluate an expression by creating a stack |
839 | eval: Process the expression stack |
840 | gaoper: Perforam operation between two operands |
841 | gagrop: Perform a grid operation |
842 | gastop: Perform a station operation |
843 | gascop: Perform an op between a constant and stations |
844 | gagrvl: Put a constant in grid format |
845 | varprs: Parse a variable in the expression |
846 | getdfn: Search defined grid chain for a predifined grid |
847 | gagchk: Check validity of operation between two grids |
848 | stnvar: Handle specialized parsing of stn variable */ |
849 | |
850 | int gaexpr (char *, struct gastat *) ; |
851 | int eval (int, struct smem *, int *); |
852 | int gaoper (struct smem *, int, int, int, int); |
853 | struct gagrid *gagrop (struct gagrid *, struct gagrid *, int, int); |
854 | struct gastn *gastop (struct gastn *, struct gastn *, int, int); |
855 | struct gastn *gascop (struct gastn *, float, int, int); |
856 | struct gagrid *gagrvl (float); |
857 | char *varprs (char *, struct gastat *) ; |
858 | int gagchk (struct gagrid *, struct gagrid *, int); |
859 | struct gafile *getdfn (char *, struct gastat *); |
860 | char *stnvar (char *, char *, struct gafile *, struct gavar *, |
861 | struct gastat *); |
862 | |
863 | /* Functions in GAFUNC: |
864 | rtnprs: Parse and execute a function call |
865 | gafopr: Perform opration for two-op function call |
866 | gafdef: Read user function definition table |
867 | */ |
868 | |
869 | char *rtnprs (char *, char *, struct gastat *) ; |
870 | int gafopr (struct gastat *, struct gastat *, int ); |
871 | void gafdef (void); |
872 | |
873 | /* Functions in GAIO: |
874 | gaggrd: Get a grid from a data file |
875 | gagrow: Get a row of data, possibly wrapped, from the file |
876 | gafcyx: Calculate file position of an item of data with x-y transposed |
877 | gafcor: Calculate file position of an item of data |
878 | garrow: Get an item or items from the data file |
879 | gagstn: Get a collection of stations |
880 | garead: |
881 | gardyx: garead for x-y transposed |
882 | gaglvs: Get appropriate var and levs from rpt |
883 | gaarpt: Allocate report block |
884 | gasstn: Seek to location in station file |
885 | garstn: Read station data |
886 | gacstn: Cache a station report |
887 | gagdef: Get grid from defined variable |
888 | clicyc: Adjust for cyclic climatological defined variable |
889 | gagpre: Predefined variable access */ |
890 | |
891 | int gaggrd (struct gagrid *); |
892 | int gagrow (float *, int *); |
893 | int gafcor (int, int, int, int); |
894 | int gafcyx (int, int, int, int); |
895 | int garrow (int, int, int, int, int, float *); |
896 | int garead (int, int, float *); |
897 | int gardyx (int, int, float *); |
898 | int gagstn (struct gastn *); |
899 | int gaglvs (int, struct rpthdr *, struct gastn *); |
900 | struct garpt *gaarpt (struct gastn *); |
901 | int gasstn (int); |
902 | int garstn (int, char *, int); |
903 | void gacstn (char *, char *, int, int); |
904 | void gagcst (int, char *); |
905 | int gagdef (void); |
906 | void clicyc(int *); |
907 | int gagpre (void); |
908 | int gairow (int, int, int, int, int, int, float *); |
909 | int gaird (int, int, int, int, int, int); |
910 | int gaprow (int, int, int, int, int, int, float *); |
911 | int gaopfn (int,int *); |
912 | int gappcn (struct gafile *, int, int); |
913 | void w3fb04 (float, float, float, float, float *, float *); |
914 | void ll2lc (float *, float, float, float *, float *); |
915 | void gaiomg (void); |
916 | |
917 | /* Functions in GAGX: |
918 | gagx: Initialize graphics interface |
919 | gaplot: Generalized graphics output routine |
920 | gas1d: Set up scaling for a 1-D grid |
921 | gas2d: Set up scaling for a 2-D grid |
922 | gagrph: Plot line graph |
923 | gacntr: Plot contour plot |
924 | gastrm: Plot streamline plot |
925 | gafgrd: Fill grid boxes |
926 | gashad: Plot shaded plot |
927 | gavect: Plot vector feild |
928 | gascat: Plot scatter plot from two grids |
929 | gaarrw: Plot individual arrow |
930 | gaplvl: Plot grid values |
931 | gawmap: Plot appropriate map |
932 | gacsel: Select a contour interval |
933 | gaaxis: Generate proper axis labels for axes |
934 | galnch: Convert a longitude value to character form |
935 | galtch: Convert a latitude value to character form |
936 | gaconv: Perform grid level scaling |
937 | gatinc: Get date/time increment for time axis |
938 | gasfil: Shade fill a grid sqaure |
939 | trfill: Fill half a grid square (triangle) |
940 | gagfil: Fill grids with shaded ranges |
941 | */ |
942 | void gagx (struct gacmn *); |
943 | void gaplot (struct gacmn *); |
944 | void gas1d (struct gacmn *, float, float, int, int, struct gagrid *, |
945 | struct gastn *); |
946 | void gas2d (struct gacmn *, struct gagrid *, int); |
947 | void gagrph (struct gacmn *,int); |
948 | void gastts (struct gacmn *); |
949 | void galfil (struct gacmn *); |
950 | void lfint (float, float, float, float, float *, float *); |
951 | void lfout (float *, float *, float *, float *, int, int); |
952 | void gacntr (struct gacmn *, int); |
953 | void gastrm (struct gacmn *); |
954 | void gashad (struct gacmn *); |
955 | void gavect (struct gacmn *, int); |
956 | void gascat (struct gacmn *); |
957 | void gafgrd (struct gacmn *); |
958 | void gafwrt (struct gacmn *); |
959 | int galats (struct gacmn *, int, int); /*mf --- GrADS-lats interface mf*/ |
960 | void gaarrw (float, float, float, float, float); |
961 | void gaplvl (struct gacmn *); |
962 | void gamscl (struct gacmn *); |
963 | void gawmap (struct gacmn *, int); |
964 | void gacsel (float, float, float *, float *, float *); |
965 | void gaaxis (int, struct gacmn *, int); |
966 | int galnch (float, char *); |
967 | int galtch (float, char *); |
968 | void gaconv (float, float, float *, float *); |
969 | void gagexp (float *, int, int, float *, int, int, float); |
970 | void gaglin (float *, int, int, float *, int, int, float); |
971 | struct gagrid *gaflip (struct gagrid *, struct gacmn *); |
972 | int gatinc (struct gacmn *, struct dt *, struct dt *); |
973 | void gasfil (int, int, float, float, float, float, float, float, float, float); |
974 | void trfill (float, float, float, float, float, float, float, float, |
975 | float, int, int); |
976 | void gafstn (struct gacmn *); |
977 | void gapstn (struct gacmn *); |
978 | void gawsym (struct gacmn *); |
979 | void gabarb (float, float, float, float, float, float, float, int); |
980 | void gapmdl (struct gacmn *); |
981 | void gasmdl (struct gacmn *, struct garpt *, float *, float *); |
982 | float wndexit (float, float, float, float, float, float *, |
983 | float *, float *, float *); |
984 | void gapprf (struct gacmn *); |
985 | void gatser (struct gacmn *); |
986 | void gampax (struct gacmn *); |
987 | void wxsym (int, float, float, float, int, int *); |
988 | void wxprim (int, float, float, float); |
989 | void gagsav (int, struct gacmn *, struct gagrid *); |
990 | void galnx (float, float, float *, float *); |
991 | void galny (float, float, float *, float *); |
992 | void gaalnx (float, float, float *, float *); |
993 | void gaalny (float, float, float *, float *); |
994 | void gagfil ( float *, int, int, float *, int *, int, float); |
995 | void gafram (struct gacmn *); |
996 | void gaaxpl (struct gacmn *, int, int); |
997 | void gaselc (struct gacmn *, float, float); |
998 | int gashdc (struct gacmn *, float); |
999 | |
1000 | /* Functions in GAUTIL: |
1001 | nxtcmd: Get next command from the user |
1002 | timadd: Add an increment to a time |
1003 | timsub: Subtract an increment from a time |
1004 | t2gr: Convert an absolute time to a grid value |
1005 | gr2t: Convert a grid value to an absolute time |
1006 | timdif: Calculate difference between two times |
1007 | qleap: Determine if a year is a leap year |
1008 | adtprs: Parse an absolute date/time expression |
1009 | rdtprs: Parse a relative date/time expression |
1010 | gaedit: Convert from float to character |
1011 | cmpwrd: Compare two character strings |
1012 | nxtwrd: Point to the next blank delimited word in a string |
1013 | liconv: Linear conversion routine |
1014 | gr2lev: Discrete level scaling routine |
1015 | lev2gr: Discrete level scaling routine |
1016 | intprs: Parse an integer expression |
1017 | valprs: Parse a floating number expression |
1018 | dimprs: Parse a dimension expression |
1019 | lowcas: Convert a string to lower case |
1020 | uppcas: Convert a string to upper case |
1021 | getstr: Move part of a string to another string |
1022 | getwrd: Get next word in a string as a string |
1023 | gamnmx: Get minimum and maximum grid value |
1024 | garemb: Remove blanks from and terminate a string |
1025 | gagaus: Set up scaling for gaussian grid (R40) |
1026 | gags30: Set up scaling for gaussian grid (R30) |
1027 | gags20: Set up scaling for gaussian grid (R20) |
1028 | gags15: Set up scaling for Ocean Grid (MOM32) |
1029 | gamo32: Set up scaling for gaussian grid (R15) |
1030 | gat2ch: Date/Time to character form |
1031 | cmpch: Compare two strings of specified length |
1032 | gafree: Free stuff hung off pst block |
1033 | gagfre: Free gagrid block and associated data |
1034 | gasfre: Free gastn block and associated data |
1035 | gagbb: Unpack bit value |
1036 | gagby: Unpack byte value |
1037 | gabswp: Byte swap data values |
1038 | gahswp: Byte swap report header |
1039 | flt2ibm: convert float to ibm float (ebisuzaki) |
1040 | ibm2flt: convert ibm float to float (ebisuzaki) |
1041 | */ |
1042 | |
1043 | int nxtcmd (char *, char *); |
1044 | void timadd (struct dt *, struct dt *); |
1045 | void timsub (struct dt *, struct dt *); |
1046 | float t2gr (float *, struct dt *); |
1047 | void gr2t (float *, float, struct dt *); |
1048 | int timdif (struct dt *, struct dt *); |
1049 | int qleap (int); |
1050 | char *adtprs (char *, struct dt *, struct dt *); |
1051 | char *rdtprs (char *, struct dt *); |
1052 | int gaedit (float, char *, int); |
1053 | int cmpwrd (char *, char *); |
1054 | char *nxtwrd (char *); |
1055 | float liconv (float *, float); |
1056 | float gr2lev (float *, float); |
1057 | float lev2gr (float *, float); |
1058 | char *intprs (char *, int *); |
1059 | char *valprs (char *, float *); |
1060 | char *dimprs (char *, struct gastat *, struct gafile *, |
1061 | int *, float *, int, int *); |
1062 | void lowcas (char *); |
1063 | void uppcas (char *); |
1064 | void getstr (char *, char *, int); |
1065 | void getwrd (char *, char *, int); |
1066 | void gamnmx (struct gagrid *); |
1067 | int garemb (char *); |
1068 | float *gagaus(int,int); |
1069 | float *gags30(int,int); |
1070 | float *gags20(int,int); |
1071 | float *gags15(int,int); |
1072 | float *gamo32(int,int); |
1073 | int gat2ch (struct dt *, int, char *); |
1074 | int cmpch (char *, char *, int); |
1075 | void gafree (struct gastat *); |
1076 | void gagfre (struct gagrid *); |
1077 | void gasfre (struct gastn *); |
1078 | void fnmexp (char *, char *, char *); |
1079 | int gagbb (char *, int, int); |
1080 | int gagby (char *, int, int); |
1081 | char *gafndt (char *, struct dt *, struct dt *, float *); |
1082 | void gabswp (float *, int); |
1083 | void gahswp (struct rpthdr *); |
1084 | int dayweek (struct dt *); |
1085 | |
1086 | /*mf -- Wesley Ebisuzaki routines -- mf*/ |
1087 | |
1088 | int flt2ibm(float x, unsigned char *ibm); |
1089 | float ibm2flt(unsigned char *ibm); |
1090 | float ieee2flt(unsigned char *); |
1091 | int flt2ieee(float , unsigned char *); |
1092 | int be_int2int(unsigned char *) ; |
1093 | |
1094 | |
1095 | |
1096 | /* Functions in GASRCP: |
1097 | gsfile: run a script file used in gauser.c |
1098 | */ |
1099 | |
1100 | char *gsfile (char *, int *, int); |
Note: See TracBrowser for help on using the browser.