vlist.h 5.47 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
3
#ifndef _VLIST_H
#define _VLIST_H

Thomas Jahns's avatar
Thomas Jahns committed
4
5
6
7
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

8
9
#include <stddef.h>  /* size_t */

Uwe Schulzweida's avatar
Uwe Schulzweida committed
10
11
12
13
#ifndef _CDI_LIMITS_H
#  include "cdi_limits.h"
#endif

Deike Kleberg's avatar
Deike Kleberg committed
14
#define VALIDMISS 1.e+303
Uwe Schulzweida's avatar
Uwe Schulzweida committed
15

16
17
18
19
/*
 * CDI attribute
 */
typedef struct {
20
21
22
23
24
25
26
27
28
29
30
  size_t    xsz;	  /* amount of space at xvalue                      */
  size_t    namesz;       /* size of name                                   */
  char     *name;         /* attribute name                                 */
  int       indtype;	  /* internal data type of xvalue (INT, FLT or TXT) */
  int       exdtype;      /* external data type                             */
                          /* indtype    exdtype                             */
                          /* TXT        TXT                                 */
                          /* INT        INT16, INT32                        */
                          /* FLT        FLT32, FLT64                        */
  size_t    nelems;    	  /* number of elements                             */
  void     *xvalue;       /* the actual data                                */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
31
} cdi_att_t;
32
33
34


typedef struct {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
35
36
37
38
  size_t     nalloc;		/* number allocated >= nelems */
  size_t     nelems;		/* length of the array */
  cdi_att_t  value[MAX_ATTRIBUTES];
} cdi_atts_t;
39
40


Uwe Schulzweida's avatar
Uwe Schulzweida committed
41
42
43
44
typedef struct
{
  int      flag;
  int      index;
45
  int      mlevelID;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
46
47
  int      flevelID;
}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
48
levinfo_t;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
49

50
51
52
#define DEFAULT_LEVINFO(levID) \
  (levinfo_t){ 0, -1, levID, levID}
/*
53
54
#define DEFAULT_LEVINFO(levID) \
  (levinfo_t){ .flag = 0, .index = -1, .flevelID = levID, .mlevelID = levID}
55
*/
56
57
58
59
60
61
62
63
typedef struct
{
  int ens_index;
  int ens_count;
  int forecast_init_type;
}
ensinfo_t;

64
65
66
67
68
69
70
/* ---------------------------------- */
/* Local change: 2013-01-28, FP (DWD) */
/* ---------------------------------- */

/* Length of optional keyword/value pair list */
#define MAX_OPT_GRIB_ENTRIES 50

Deike Kleberg's avatar
Deike Kleberg committed
71

Uwe Schulzweida's avatar
Uwe Schulzweida committed
72
73
typedef struct
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
74
75
76
77
78
79
80
  int         flag;
  int         isUsed;
  int         mvarID;
  int         fvarID;
  int         param;
  int         gridID;
  int         zaxisID;
81
  int         tsteptype; /* TSTEP_* */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
82
83
84
85
86
87
  int         datatype;  /* DATATYPE_PACKX for GRIB data, else DATATYPE_FLT32 or DATATYPE_FLT64 */
  int         instID;
  int         modelID;
  int         tableID;
  int         timave;
  int         timaccu;
88
  int         typeOfGeneratingProcess;
89
  int         productDefinitionTemplate;
90
  int         chunktype;
91
  int         xyz;
92
  int         missvalused; /* TRUE if missval is defined */
Deike Kleberg's avatar
Deike Kleberg committed
93
  int         lvalidrange;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
94
95
96
97
  char       *name;
  char       *longname;
  char       *stdname;
  char       *units;
98
  char       *extra;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
99
100
101
  double      missval;
  double      scalefactor;
  double      addoffset;
Deike Kleberg's avatar
Deike Kleberg committed
102
  double      validrange[2];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
103
  levinfo_t  *levinfo;
Deike Kleberg's avatar
Deike Kleberg committed
104
105
  int         comptype;     // compression type
  int         complevel;    // compression level
106
  ensinfo_t  *ensdata;      /* Ensemble information */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
107
  cdi_atts_t  atts;
Deike Kleberg's avatar
Deike Kleberg committed
108
  int         iorank;
109
#if  defined  (HAVE_LIBGRIB_API)
110
111
112
113
114
115
116
  /* ---------------------------------- */
  /* Local change: 2013-01-28, FP (DWD) */
  /* ---------------------------------- */

  /* (Optional) list of keyword/double value pairs */
  int    opt_grib_dbl_nentries;
  char*  opt_grib_dbl_keyword[MAX_OPT_GRIB_ENTRIES];
117
  int    opt_grib_dbl_update[MAX_OPT_GRIB_ENTRIES];
118
119
120
121
  double opt_grib_dbl_val[MAX_OPT_GRIB_ENTRIES];
  /* (Optional) list of keyword/integer value pairs */
  int    opt_grib_int_nentries;
  char*  opt_grib_int_keyword[MAX_OPT_GRIB_ENTRIES];
122
  int    opt_grib_int_update[MAX_OPT_GRIB_ENTRIES];
123
  int    opt_grib_int_val[MAX_OPT_GRIB_ENTRIES];
124
#endif
Uwe Schulzweida's avatar
Uwe Schulzweida committed
125
}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
126
var_t;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
127

Uwe Schulzweida's avatar
Uwe Schulzweida committed
128

Uwe Schulzweida's avatar
Uwe Schulzweida committed
129
130
typedef struct
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
131
132
133
134
135
136
137
138
139
140
141
  int         self;
  int         nvars;        /* number of variables                */
  int         ngrids;
  int         nzaxis;
  int         ntsteps;
  int         taxisID;
  int         tableID;
  int         instID;
  int         modelID;
  int         varsAllocated;
  int         gridIDs[MAX_GRIDS_PS];
142
  int         zaxisIDs[MAX_ZAXES_PS];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
143
144
  var_t      *vars;
  cdi_atts_t  atts;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
145
}
146
147
148
149
vlist_t;


vlist_t *vlist_to_pointer(int vlistID);
150
151
152
153
const char *vlistInqVarNamePtr(int vlistID, int varID);
const char *vlistInqVarLongnamePtr(int vlistID, int varID);
const char *vlistInqVarStdnamePtr(int vlistID, int varID);
const char *vlistInqVarUnitsPtr(int vlistID, int varID);
154
155
156
void     vlistDestroyVarName(int vlistID, int varID);
void     vlistDestroyVarLongname(int vlistID, int varID);
void     vlistDestroyVarUnits(int vlistID, int varID);
157
void     vlistDefVarTsteptype(int vlistID, int varID, int tsteptype);
158
159
160
161
162
int      vlistInqVarMissvalUsed(int vlistID, int varID);
int      vlistHasTime(int vlistID);

int      vlistDelAtts(int vlistID, int varID);
int      vlistCopyVarAtts(int vlistID1, int varID_1, int vlistID2, int varID_2);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
163

164
165
void     vlistUnpack(char * buffer, int bufferSize, int * pos,
                     int originNamespace, void *context, int force_id);
Thomas Jahns's avatar
Thomas Jahns committed
166

Deike Kleberg's avatar
Deike Kleberg committed
167
168
169
170
171
172
/*      vlistDefVarValidrange: Define the valid range of a Variable */
void    vlistDefVarValidrange(int vlistID, int varID, const double *validrange);

/*      vlistInqVarValidrange: Get the valid range of a Variable */
int     vlistInqVarValidrange(int vlistID, int varID, double *validrange);

Thomas Jahns's avatar
Thomas Jahns committed
173
174
175
int vlist_att_compare(vlist_t *a, int varIDA, vlist_t *b, int varIDB,
                      int attnum);

176
177
178
179
180
#if  defined  (HAVE_LIBGRIB_API)
extern int   cdiNAdditionalGRIBKeys;
extern char* cdiAdditionalGRIBKeys[];
#endif

Uwe Schulzweida's avatar
Uwe Schulzweida committed
181
#endif  /* _VLIST_H */
182
183
184
185
186
187
188
189
190
/*
 * Local Variables:
 * c-file-style: "Java"
 * c-basic-offset: 2
 * indent-tabs-mode: nil
 * show-trailing-whitespace: t
 * require-trailing-newline: t
 * End:
 */