grid.h 4.64 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
3
#ifndef _GRID_H
#define _GRID_H

4
5
#include "cdi.h"

Uwe Schulzweida's avatar
Uwe Schulzweida committed
6
typedef unsigned char mask_t;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
7

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
typedef struct grid_t grid_t;

struct gridVirtTable
{
  void (*destroy)(grid_t *gridptr);
  void (*duplicateData)(grid_t *gridptrOrig, grid_t *gridptrDup);
  void (*defXVals)(grid_t *gridptr, const double *xvals);
  void (*defYVals)(grid_t *gridptr, const double *yvals);
  void (*defMask)(grid_t *gridptr, const int *mask);
  void (*defMaskGME)(grid_t *gridptr, const int *mask);
  void (*defXBounds)(grid_t *gridptr, const double *xbounds);
  void (*defYBounds)(grid_t *gridptr, const double *ybounds);
  void (*defArea)(grid_t *gridptr, const double *area);
  double (*inqXVal)(grid_t *gridptr, int index);
  double (*inqYVal)(grid_t *gridptr, int index);
  int (*inqXVals)(grid_t *gridptr, double *xvals);
  int (*inqYVals)(grid_t *gridptr, double *yvals);
  const double *(*inqXValsPtr)(grid_t *gridptr);
  const double *(*inqYValsPtr)(grid_t *gridptr);
  void (*inqArea)(grid_t *gridptr, double *area);
28
  const double *(*inqAreaPtr)(grid_t *gridptr);
29
30
31
32
33
34
35
36
37
  int (*inqMask)(grid_t *gridptr, int *mask);
  int (*inqMaskGME)(grid_t *gridptr, int *mask_gme);
  int (*inqXBounds)(grid_t *gridptr, double *xbounds);
  int (*inqYBounds)(grid_t *gridptr, double *ybounds);
  const double *(*inqXBoundsPtr)(grid_t *gridptr);
  const double *(*inqYBoundsPtr)(grid_t *gridptr);
};

struct grid_t {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
38
39
40
  int     self;
  int     type;                   /* grid type                      */
  int     prec;                   /* grid precision                 */
41
  int     proj;                   /* grid projection                */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
42
43
  mask_t *mask;
  mask_t *mask_gme;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
44
45
46
47
48
49
50
51
  double *xvals;
  double *yvals;
  double *area;
  double *xbounds;
  double *ybounds;
  double  xfirst, yfirst;
  double  xlast, ylast;
  double  xinc, yinc;
52
  double  lcc_originLon;          /* Lambert Conformal Conic        */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
53
54
55
56
57
58
  double  lcc_originLat;
  double  lcc_lonParY;
  double  lcc_lat1;
  double  lcc_lat2;
  double  lcc_xinc;
  double  lcc_yinc;
59
60
  int     lcc_projflag;
  int     lcc_scanflag;
61
62
63
  short   lcc_defined;
  short   lcc2_defined;
  int     laea_defined;
64
65
66
67
68
  double  lcc2_lon_0;             /* Lambert Conformal Conic 2      */
  double  lcc2_lat_0;
  double  lcc2_lat_1;
  double  lcc2_lat_2;
  double  lcc2_a;
69
70
71
  double  laea_lon_0;             /* Lambert Azimuthal Equal Area   */
  double  laea_lat_0;
  double  laea_a;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
72
  double  xpole, ypole, angle;    /* rotated north pole             */
73
74
75
76
  short   isCyclic;               /* TRUE for global cyclic grids   */
  short   isRotated;              /* TRUE for rotated grids         */
  short   xdef;                   /* 0: undefined 1:xvals 2:x0+xinc */
  short   ydef;                   /* 0: undefined 1:yvals 2:y0+yinc */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
77
  int     nd, ni, ni2, ni3;       /* parameter for GRID_GME         */
78
  int     number, position;       /* parameter for GRID_REFERENCE   */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
79
80
  int     trunc;                  /* parameter for GRID_SPECTEAL    */
  int     nvertex;
81
82
  char   *reference;
  unsigned char uuid[CDI_UUID_SIZE]; /* uuid for grid reference        */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
83
84
85
  int    *rowlon;
  int     nrowlon;
  int     size;
86
87
88
  int     xsize;                  /* number of values along X */
  int     ysize;                  /* number of values along Y */
  int     np;                     /* number of parallels between a pole and the equator */
89
  int     lcomplex;
90
  int     hasdims;
91
92
  const char *xstdname;
  const char *ystdname;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
93
94
95
96
97
98
  char    xname[CDI_MAX_NAME];
  char    yname[CDI_MAX_NAME];
  char    xlongname[CDI_MAX_NAME];
  char    ylongname[CDI_MAX_NAME];
  char    xunits[CDI_MAX_NAME];
  char    yunits[CDI_MAX_NAME];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
99
  char   *name;
100
101
102
  const struct gridVirtTable *vtable;
  void *extraData;
};
Uwe Schulzweida's avatar
Uwe Schulzweida committed
103
104


Uwe Schulzweida's avatar
Uwe Schulzweida committed
105
void grid_init(grid_t *gridptr);
106
107
void
cdiGridTypeInit(grid_t *gridptr, int gridtype, int size);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
108
void grid_free(grid_t *gridptr);
109
grid_t *gridID2Ptr(int gridID);
110
extern const struct gridVirtTable cdiGridVtable;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
111

Thomas Jahns's avatar
Thomas Jahns committed
112
unsigned cdiGridCount(void);
113

Uwe Schulzweida's avatar
Uwe Schulzweida committed
114
115
116
const double *gridInqXvalsPtr(int gridID);
const double *gridInqYvalsPtr(int gridID);

117
118
const double *gridInqXboundsPtr(int gridID);
const double *gridInqYboundsPtr(int gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
119
120
const double *gridInqAreaPtr(int gridID);

121
122
int gridCompare(int gridID, const grid_t *grid);
int gridGenerate(const grid_t *grid);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
123

Thomas Jahns's avatar
Thomas Jahns committed
124
void cdiGridGetIndexList(unsigned, int * );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
125

126
127
void
gridUnpack(char * unpackBuffer, int unpackBufferSize,
128
           int * unpackBufferPos, int originNamespace, void *context,
129
130
           int force_id);

131
132
133
134
135
136
137
struct addIffNewRes
{
  int Id;
  int isNew;
};

struct addIffNewRes cdiVlistAddGridIfNew(int vlistID, grid_t *grid, int mode);
138

Uwe Schulzweida's avatar
Uwe Schulzweida committed
139
#endif
140
141
142
143
144
145
146
147
148
/*
 * Local Variables:
 * c-file-style: "Java"
 * c-basic-offset: 2
 * indent-tabs-mode: nil
 * show-trailing-whitespace: t
 * require-trailing-newline: t
 * End:
 */