File: grid.h

package info (click to toggle)
vis5d 4.3-5
  • links: PTS
  • area: main
  • in suites: slink
  • size: 16,856 kB
  • ctags: 6,127
  • sloc: ansic: 66,158; fortran: 4,470; makefile: 1,683; tcl: 414; sh: 69
file content (208 lines) | stat: -rw-r--r-- 6,076 bytes parent folder | download | duplicates (3)
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
/* grid.h */

/*
 * Generic grid structure, lists of grids, and functions
 */



#ifndef GRID_H
#define GRID_H


/*#include "v5d.h"*/


/*
 * Limits for v5dimport, limits for the output v5d file are probably
 * smaller and found in v5d.h
 */
#define IMAXVARS     70
#define IMAXTIMES  1000
#define IMAXPROJ    100



/* Map projections:  (Must agree w/ projections used in v5d files!!) */
#define PROJ_GENERIC   0  /* No specific units */
#define PROJ_LINEAR    1  /* Cylindrical-Equidistant (old vis5d) */
#define PROJ_LAMBERT   2  /* Lambert conformal */
#define PROJ_STEREO    3  /* Stereographic */
#define PROJ_ROTATED   4  /* Rotated equidistant */
#define PROJ_EPA      10  /* EPA RADM/MM4 system */


/* Vertical coordinate sytems:  (Must agree w/ vcs used in v5d files!!) */
#define VERT_GENERIC      0  /* No specific units */
#define VERT_EQUAL_KM     1  /* Equally spaced in kilometers */
#define VERT_UNEQUAL_KM   2  /* Non-equally spaced in kilometers */
#define VERT_UNEQUAL_MB   3  /* Non-equally spaced in millibars */
#define VERT_EPA         10  /* EPA RADM/MM4 system */



/*
 * Describes a map projection:
 */
struct projection {
   int Nr, Nc;             /* number of rows and columns */
   int Kind;               /* Kind of projection, one of PROJ_* */
   float *Args;            /* Array of projection parameters */
   float *AuxArgs;         /* Array of auxillary projection parameters */
};



/*
 * Describes a vertical coordinate system (VCS):
 */
struct vcs {
   int Nl;                 /* Number of levels */
   int Kind;               /* Kind of vcs, one of VERT_* */
   float *Args;            /* Array of vcs parameters */
   int LowLev;             /* Location of bottom-most grid level w.r.t. VCS */
};




/* Grid selection bits: */
#define TIME_BIT  1
#define VAR_BIT   2
#define PROJ_BIT  4
#define VCS_BIT   8
#define ALL_BITS  0xf



/*
 * Description of a single 3-D grid:
 */
struct grid_info {
        char *FileName;                  /* File name */
        int Format;                      /* Which file format (see file.h) */
        int TimeStep, VarNum, Position;  /* Location of grid within file */
        int FileNumber;                  /* For McIDAS GRID files */

        int Nr, Nc, Nl;                  /* Size of grid */
        int DateStamp;                   /* Date in YYDDD */
        int TimeStamp;                   /* Time in HHMMSS */
        char *VarName;                   /* Name of variable */
        char *Units;                     /* Physical units string or NULL */

        /* Map / Vert. Coord. Sys. arguments as used by v5dCreate functions */
        struct projection *Proj;         /* Map projection info */
        struct vcs *Vcs;                 /* Vert Coord Sys info */

        int byteswapped;                /* byteswapped flag for GRADS file */
        float MissingValue;             /* The missing data value */

        float *Data;                    /* Nr*Nc*Nl array of data or NULL */

        int SelectBits;                 /* Selection bits, OR of *_BIT flags */
        int NewSelState;                /* Set when GUI must be updated */

        struct grid_info *Next;         /* Next node in linked list */
        struct grid_info *Sibling;      /* Used by the table data structure */
};



/*
 * This "data base" structure bundles up all the grid information.
 */
struct grid_db {

   /*
    * Initially, we scan all the input files to build this linked list
    * of information about every 3-D grid:
    */
   int NumGrids;                   /* Number of grids in linked list */
   struct grid_info *FirstGrid;    /* Pointer to first grid */
   struct grid_info *LastGrid;     /* Pointer to last grid */

   /*
    * Next, we analysis the list of grids to get the following information:
    */
   int NumTimes;                  /* Number of distinct timesteps */
   int DateStamp[IMAXTIMES];      /* Array of dates in YYDDD format */
   int TimeStamp[IMAXTIMES];      /* Array of times in HHMMSS format */

   int NumVars;                   /* Number of distinct variables */
   char *VarNames[IMAXVARS];      /* Array of pointers to the variable names */
   char *Units[IMAXVARS];         /* Array of units strings, may be NULL */

   int NumProj;                           /* Number of map projections */
   struct projection *ProjList[IMAXPROJ]; /* Array of map projections */

   int NumVcs;                            /* Number of VCSs */
   struct vcs *VcsList[IMAXPROJ];         /* Array of VCSs */

   /*
    * We also organize the grids into a 2-D matrix indexed by timestep
    * and variable number:
    */
   struct grid_info *Matrix[IMAXTIMES][IMAXVARS];

   /*
    * Using the GUI, or text interface, the user can select which grids are
    * to be included in the output file according to timestep, variable,
    * map projection, or VCS.  These flag arrays indicate what's currently
    * selected:
    */
   int VarSelected[IMAXVARS];        /* Array of variable selection flags */
   int TimeSelected[IMAXTIMES];      /* Array of timestep selection flags */
   int ProjSelected[IMAXPROJ];       /* Array of projection selection flags */
   int VcsSelected[IMAXPROJ];        /* Array of vcs selection flags */

   /*
    * Misc.
    */
   int Sorted;
};




/*
 * A linked list of grids:
 */
#ifdef JUNK
struct grid_list {
        int NumGrids;                    /* Number of grids */
        struct grid_info *First, *Last;  /* Pointers to first and last grids */
};
#endif


extern struct grid_info *alloc_grid_info( void );


extern void free_grid_info( struct grid_info *info );


extern struct grid_db *alloc_grid_db( void );


extern void free_grid_db( struct grid_db *db );


extern void append_grid( struct grid_info *grid, struct grid_db *db );


extern int remove_grid( struct grid_info *grid, struct grid_db *db );


extern void free_all_grids( struct grid_db *db );


extern void print_grid_list( struct grid_db *db );


extern char **sprint_grid_list( struct grid_db *db );


extern int find_max_levels( struct grid_db *db );


#endif