1 /* gasdf.h - header info for SDF functionality */
2 /* id: netcdf_io.h,v 1.2 1995/05/31 23:53:44 jac (Julia Collins) */
3 /* Revision 1.3 1997/07/21 09:51:00 hoop */
4 /* added gasdfparms struct */
5 /* Revision 1.2  1995/05/31  23:53:44  jac  */
6 /* add missing definition */
7 /*  */
8 /* Revision 1.1  1995/05/02  20:23:12  jac */
9 /* Initial revision */
10 /* */
11 
12 typedef struct {
13     int xsrch, ysrch, zsrch, tsrch ; /* if these need to be searched for */
14     int dvsrch, isxdf ; /* do data var names need to be searched, is it xdf */
15     int xsetup, ysetup, zsetup, tsetup ; /* if these need setting up */
16     int needtitle, needundef ;
17     char *xdimname, *ydimname, *zdimname, *tdimname ;
18     int dvcount ; /* number of data variables */
19     char **dvncnames, **dvganames ; /* netCDF datavar names, GrADS abbrevs */
20     int *dvsetup ; /* does this var yet need its levelcnt and longname? */
21     int hasDDFundef ;
22 } GASDFPARMS ;
23 
24 #define CALENDAR "calendar"
25 #define CAL365 "365_day_year"
26 #define ALTCAL365 "noleap"
27 
28 /*	=== Header file for File I/O ===	*/
29 
30 #include "netcdf.h"
31 #include "udunits.h"
32 
33 #define MISSING		-1
34 
35 /* Missing data definitions  */
36 #define BFILL		FILL_BYTE
37 #define BMISS		-BFILL
38 #define SFILL		FILL_SHORT
39 #define SMISS		-SFILL
40 #define LFILL		FILL_LONG
41 #define LMISS		-LFILL
42 #define FFILL		FILL_FLOAT
43 #define FMISS		-FFILL
44 #define DFILL		FILL_DOUBLE
45 #define DMISS		-DFILL
46 
47 /* temporary flags to read time according to new or old standards */
48 #define CDC			0
49 #define COOP			1
50 
51 /* default scale and offset values for unpacked files */
52 #define B_SCALE		(char) 	 1
53 #define S_SCALE		(short)  1
54 #define L_SCALE		(long) 	 1
55 #define F_SCALE		(float)  1.0
56 #define D_SCALE		(double) 1.0
57 #define B_OFFSET	(char) 	 0
58 #define S_OFFSET	(short)  0
59 #define L_OFFSET	(long) 	 0
60 #define F_OFFSET	(float)  0.0
61 #define D_OFFSET	(double) 0.0
62 
63 /* Missing data definitions  */
64 #define BFILL		FILL_BYTE
65 #define BMISS		-BFILL
66 #define SFILL		FILL_SHORT
67 #define SMISS		-SFILL
68 #define LFILL		FILL_LONG
69 #define LMISS		-LFILL
70 #define FFILL		FILL_FLOAT
71 #define FMISS		-FFILL
72 #define DFILL		FILL_DOUBLE
73 #define DMISS		-DFILL
74 
75 /* structure to store data values */
76 union att_val {
77   signed char  bval;
78   short sval;
79   long lval;
80   float fval;
81   double dval;
82 };
83 
84 /* Attribute list. */
85 struct attrib_list {
86 	struct attrib_list *next;	/* pointer to next entry */
87 	char *name;			/* name of this attribute */
88 	nc_type type;			/* data type of this attribute */
89 	int len;			/* length of this attribute */
90 	void *data;			/* the data for this attribute */
91 };
92 
93 /* generic structures for storing netcdf data.  	  */
94 typedef struct varinfo VAR_INFO;
95 struct varinfo
96 {
97 	VAR_INFO *next;	    		/* next variable structure, if       */
98 				    	/* >1 variable in the file.          */
99 	int varid;			/* Variable i.d. 		     */
100 	char varnam[MAX_NC_NAME + 1];	/* variable name 		     */
101 	char gradsabbr[16] ;            /* GrADS abbrev; comes in on i/o reqs*/
102 	nc_type vartype;		/* Variable data type. 		     */
103 	int nvardims;		    	/* Number of variable dimensions     */
104 	int vardimid[MAX_VAR_DIMS];	/* Variable dimension IDs. 	     */
105 					/* assumptions: the time dimension   */
106 					/* (if it exists) is first.  The     */
107 					/* dimension IDs may be used to index*/
108 					/* the IO_STD dimension arrays.      */
109 	int dimmap[4];/*-1s if not datavar; T{,Z},Y,X pos'ns (0..(nvardims-1))*/
110         int dimidmap[4];/* see above, but dimids, not pos'ns */
111 	int nvatts;			/* Number of variable attributes     */
112 	struct attrib_list *first_vattr;/* First variable attribute. 	     */
113 	void *data;			/* actual data to be read from 	     */
114 					/* or written to the netCDF file     */
115         union att_val missing_value ;   /* value of missing_value attribute */
116 };
117 
118 typedef struct
119 {
120 	int time_type;		/* temporary flag for time handling 	     */
121 	int cdfid;		/* netCDF File ID 	    	      	     */
122 	int ndims;		/* Number of dimensions in input file. 	     */
123 	int nvars;		/* Number of variables in input file. 	     */
124 	int ngatts;		/* Number of global attributes in input file.*/
125 	int dimids[MAX_NC_DIMS];/* list of all dimension IDs	 	     */
126 				/* dimension assumptions: if there is a time */
127 				/* dimension (which there should be, since   */
128 				/* the standard requires it :-) ), it is the */
129 				/* first dimension.  This array is redundant */
130 				/* since the dimensions are numbered sequen- */
131 				/* tially beginning with 0; thus the dimids  */
132 				/* ARE the array indices into this and the   */
133 				/* following two arrays.		     */
134 	char dimnam[MAX_NC_DIMS][MAX_NC_NAME + 1]; /* dimension names */
135 	long dimsiz[MAX_NC_DIMS]; /* dimension sizes		*/
136 	int recdim;		/* Unlimited (record) dimension */
137 	struct attrib_list *first_gattr;	/* First global attribute. */
138 	VAR_INFO *var;		/* variable information			*/
139         int hasDDFundef ;       /* in DDF for xdfopen, UNDEF stmt occurred */
140 } IO_STD;
141