7
#define GRIB_MISSVAL -9.E33
10
#define LTYPE_SURFACE 1
12
#define LTYPE_ISOBARIC 100
13
#define LTYPE_MEANSEA 102
14
#define LTYPE_ALTITUDE 103
15
#define LTYPE_HEIGHT 105
16
#define LTYPE_SIGMA 107
17
#define LTYPE_HYBRID 109
18
#define LTYPE_HYBRID_LAYER 110
19
#define LTYPE_LANDDEPTH 111
20
#define LTYPE_LANDDEPTH_LAYER 112
21
#define LTYPE_ISENTROPIC 113
22
#define LTYPE_SEADEPTH 160
23
#define LTYPE_99_MARGIN 1000
26
* Data representation type (Grid Type) [Table 6]
28
#define GTYPE_LATLON 0 /* latitude/longitude */
29
#define GTYPE_LATLON_ROT 10 /* rotated latitude/longitude */
30
#define GTYPE_LATLON_STR 20 /* stretched latitude/longitude */
31
#define GTYPE_LATLON_ROTSTR 30 /* rotated and stretched latitude/longitude */
32
#define GTYPE_GAUSSIAN 4 /* gaussian grid */
33
#define GTYPE_GAUSSIAN_ROT 14 /* rotated gaussian grid */
34
#define GTYPE_GAUSSIAN_STR 24 /* stretched gaussian grid */
35
#define GTYPE_GAUSSIAN_ROTSTR 34 /* rotated and stretched gaussian grid */
36
#define GTYPE_LCC 3 /* Lambert conformal */
37
#define GTYPE_SPECTRAL 50 /* spherical harmonics */
38
#define GTYPE_GME 192 /* hexagonal GME grid */
41
* Macros for the indicator section ( Section 0 )
43
#define ISEC0_GRIB_Len (isec0[ 0]) /* Number of octets in the GRIB message */
44
#define ISEC0_GRIB_Version (isec0[ 1]) /* GRIB edition number */
48
* Macros for the product definition section ( Section 1 )
50
#define ISEC1_TABLE4_MINUTE 0
51
#define ISEC1_TABLE4_HOUR 1
52
#define ISEC1_TABLE4_DAY 2
53
#define ISEC1_TABLE4_3HOURS 10
54
#define ISEC1_TABLE4_6HOURS 11
55
#define ISEC1_TABLE4_12HOURS 12
56
#define ISEC1_TABLE4_QUARTER 13
59
#define ISEC1_CodeTable (isec1[ 0]) /* Version number of code table */
60
#define ISEC1_CenterID (isec1[ 1]) /* Identification of centre */
61
#define ISEC1_ModelID (isec1[ 2]) /* Identification of model */
62
#define ISEC1_GridDefinition (isec1[ 3]) /* Grid definition */
63
#define ISEC1_Sec2Or3Flag (isec1[ 4]) /* Section 2 or 3 included */
64
#define ISEC1_Parameter (isec1[ 5]) /* Parameter indicator */
65
#define ISEC1_LevelType (isec1[ 6]) /* Type of level indicator */
66
#define ISEC1_Level1 (isec1[ 7]) /* Level 1 */
67
#define ISEC1_Level2 (isec1[ 8]) /* Level 2 */
68
#define ISEC1_Year (isec1[ 9]) /* Year of century (YY) */
69
#define ISEC1_Month (isec1[10]) /* Month (MM) */
70
#define ISEC1_Day (isec1[11]) /* Day (DD) */
71
#define ISEC1_Hour (isec1[12]) /* Hour (HH) */
72
#define ISEC1_Minute (isec1[13]) /* Minute (MM) */
73
#define ISEC1_TimeUnit (isec1[14]) /* Time unit indicator */
74
#define ISEC1_TimePeriod1 (isec1[15]) /* P1 Time period */
75
#define ISEC1_TimePeriod2 (isec1[16]) /* P2 Time period */
76
#define ISEC1_TimeRange (isec1[17]) /* Time range indicator */
77
#define ISEC1_AvgNum (isec1[18]) /* Number of products included in an average */
78
#define ISEC1_AvgMiss (isec1[19]) /* Number of products missing from an average */
79
#define ISEC1_Century (isec1[20]) /* Century */
80
#define ISEC1_SubCenterID (isec1[21]) /* Subcenter identifier */
81
#define ISEC1_DecScaleFactor (isec1[22]) /* Decimal scale factor */
82
#define ISEC1_LocalFLag (isec1[23]) /* Flag field to indicate local use in isec1 */
84
#define ISEC1_ECMWF_LocalExtension (isec1[36])
85
#define ISEC1_ECMWF_Class (isec1[37])
89
* Macros for the grid definition section ( Section 2 )
91
#define ISEC2_GridType (isec2[ 0]) /* Data representation type */
93
/* Triangular grids */
95
#define ISEC2_GME_NI2 (isec2[ 1]) /* Number of factor 2 in factorisation of Ni */
96
#define ISEC2_GME_NI3 (isec2[ 2]) /* Number of factor 3 in factorisation of Ni */
97
#define ISEC2_GME_ND (isec2[ 3]) /* Nubmer of diamonds */
98
#define ISEC2_GME_NI (isec2[ 4]) /* Number of tri. subdiv. of the icosahedron */
99
#define ISEC2_GME_AFlag (isec2[ 5]) /* Flag for orientation of diamonds (Table A) */
100
#define ISEC2_GME_LatPP (isec2[ 6]) /* Latitude of pole point */
101
#define ISEC2_GME_LonPP (isec2[ 7]) /* Longitude of pole point */
102
#define ISEC2_GME_LonMPL (isec2[ 8]) /* Longitude of the first diamond */
103
#define ISEC2_GME_BFlag (isec2[ 9]) /* Flag for storage sequence (Table B) */
105
/* Spherical harmonic coeficients */
107
#define ISEC2_PentaJ (isec2[ 1]) /* J pentagonal resolution parameter */
108
#define ISEC2_PentaK (isec2[ 2]) /* K pentagonal resolution parameter */
109
#define ISEC2_PentaM (isec2[ 3]) /* M pentagonal resolution parameter */
110
#define ISEC2_RepType (isec2[ 4]) /* Representation type */
111
#define ISEC2_RepMode (isec2[ 5]) /* Representation mode */
115
#define ISEC2_NumLon (isec2[ 1]) /* Number of points along a parallel (Ni) */
116
#define ISEC2_NumLat (isec2[ 2]) /* Number of points along a meridian (Nj) */
117
#define ISEC2_FirstLat (isec2[ 3]) /* Latitude of the first grid point */
118
#define ISEC2_FirstLon (isec2[ 4]) /* Longitude of the first grid point */
119
#define ISEC2_ResFlag (isec2[ 5]) /* Resolution flag: 128 regular grid */
120
#define ISEC2_LastLat (isec2[ 6]) /* Latitude of the last grid point */
121
#define ISEC2_LastLon (isec2[ 7]) /* Longitude of the last grid point */
122
#define ISEC2_LonIncr (isec2[ 8]) /* i direction increment */
123
#define ISEC2_LatIncr (isec2[ 9]) /* j direction increment */
124
#define ISEC2_NumPar (isec2[ 9]) /* Number of parallels between a pole and the E.*/
125
#define ISEC2_ScanFlag (isec2[10]) /* Scanning mode flags */
126
#define ISEC2_NumVCP (isec2[11]) /* Number of vertical coordinate parameters */
129
#define ISEC2_Lambert_Lov (isec2[ 6]) /* Orientation of the grid */
130
#define ISEC2_Lambert_dx (isec2[ 8]) /* X-direction grid length */
131
#define ISEC2_Lambert_dy (isec2[ 9]) /* Y-direction grid length */
132
#define ISEC2_Lambert_ProjFlag (isec2[12]) /* Projection centre flag */
133
#define ISEC2_Lambert_LatS1 (isec2[13]) /* First lat at which the secant cone cuts the sphere */
134
#define ISEC2_Lambert_LatS2 (isec2[14]) /* Second lat at which the secant cone cuts the sphere */
135
#define ISEC2_Lambert_LatSP (isec2[19]) /* Latitude of the southern pole */
136
#define ISEC2_Lambert_LonSP (isec2[20]) /* Longitude of the southern pole */
139
#define ISEC2_Reduced (isec2[16]) /* 0: regular, 1: reduced grid */
141
#define ISEC2_RowLonPtr (&isec2[22])
142
#define ISEC2_RowLon(i) (isec2[22+i]) /* Number of points along each parallel */
146
#define ISEC2_LatSP (isec2[12]) /* Latitude of the southern pole of rotation */
147
#define ISEC2_LonSP (isec2[13]) /* Longitude of the southern pole of rotation */
149
#define FSEC2_RotAngle (fsec2[ 0]) /* Angle of rotation */
150
#define FSEC2_StrFact (fsec2[ 1]) /* Stretching factor */
153
* Macros for the bit map section ( Section 3 )
155
#define ISEC3_PredefBitmap (isec3[ 0]) /* Predefined bitmap */
156
#define ISEC3_MissVal (isec3[ 1]) /* Missing data value for integers */
157
#define FSEC3_MissVal (fsec3[ 1]) /* Missing data value for floats */
160
* Macros for the binary data section ( Section 4 )
162
#define ISEC4_NumValues (isec4[ 0]) /* Number of data values for encode/decode */
163
#define ISEC4_NumBits (isec4[ 1]) /* Number of bits used for each encoded value */
164
#define ISEC4_NumNonMissValues (isec4[20]) /* Number of non-missing values */
169
void gribFixZSE(int flag); /* 1: Fix ZeroShiftError of simple packed spherical harmonics */
170
void gribSetConst(int flag); /* 1: Don't pack constant fields on regular grids */
171
void gribSetDebug(int debug); /* 1: Debugging */
172
void gribSetRound(int round);
173
void gribSetRefDP(double refval);
174
void gribSetRefSP(float refval);
175
void gribSetValueCheck(int vcheck);
178
void gribExSP(int *isec0, int *isec1, int *isec2, float *fsec2, int *isec3,
179
float *fsec3, int *isec4, float *fsec4, int klenp, int *kgrib,
180
int kleng, int *kword, char *hoper, int *kret);
182
void gribExDP(int *isec0, int *isec1, int *isec2, double *fsec2, int *isec3,
183
double *fsec3, int *isec4, double *fsec4, int klenp, int *kgrib,
184
int kleng, int *kword, char *hoper, int *kret);
187
const char *cgribexLibraryVersion(void);
189
void gribDebug(int debug);
190
void gribSetCalendar(int calendar);
192
void gribDateTime(int *isec1, int *date, int *time);
193
int gribRefDate(int *isec1);
194
int gribRefTime(int *isec1);
195
int gribTimeIsFC(int *isec1);
197
void gribPrintSec0(int *isec0);
198
void gribPrintSec1(int *isec0, int *isec1);
199
void gribPrintSec2DP(int *isec0, int *isec2, double *fsec2);
200
void gribPrintSec2SP(int *isec0, int *isec2, float *fsec2);
201
void gribPrintSec3DP(int *isec0, int *isec3, double *fsec3);
202
void gribPrintSec3SP(int *isec0, int *isec3, float *fsec3);
203
void gribPrintSec4DP(int *isec0, int *isec4, double *fsec4);
204
void gribPrintSec4SP(int *isec0, int *isec4, float *fsec4);
205
void gribPrintSec4Wave(int *isec4);
207
void gribPrintALL(int nrec, long offset, long recpos, long recsize, unsigned char *gribbuffer);
208
void gribPrintPDS(int nrec, long recpos, long recsize, unsigned char *gribbuffer);
209
void gribPrintGDS(int nrec, long recpos, long recsize, unsigned char *gribbuffer);
210
void gribPrintBMS(int nrec, long recpos, long recsize, unsigned char *gribbuffer);
211
void gribPrintBDS(int nrec, long recpos, long recsize, unsigned char *gribbuffer);
212
void gribCheck1(int nrec, long recpos, long recsize, unsigned char *gribbuffer);
213
void gribRepair1(int nrec, long recpos, long recsize, unsigned char *gribbuffer);
215
int grib1Sections(unsigned char *gribbuffer, long recsize, unsigned char **pdsp,
216
unsigned char **gdsp, unsigned char **bmsp, unsigned char **bdsp);
217
int grib2Sections(unsigned char *gribbuffer, long recsize, unsigned char **idsp,
218
unsigned char **lusp, unsigned char **gdsp, unsigned char **pdsp,
219
unsigned char **drsp, unsigned char **bmsp, unsigned char **bdsp);
221
int gribGetZip(long recsize, unsigned char *gribbuffer, long *urecsize);
223
int gribBzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufsize);
224
int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufsize);
225
int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufsize);
227
int gribOpen(const char *filename, const char *mode);
228
void gribClose(int fileID);
230
int gribRead(int fileID, unsigned char *buffer, size_t *buffersize);
231
int gribWrite(int fileID, unsigned char *buffer, size_t buffersize);
232
off_t gribGetPos(int fileID);
233
int gribGetSize(int fileID);
234
int gribCheckSeek(int fileID, long *offset, int *version);
235
int gribFileSeek(int fileID, long *offset);
236
int gribReadSize(int fileID);
237
int gribVersion(unsigned char *buffer, size_t buffersize);
239
int gribGinfo(long recpos, long recsize, unsigned char *gribbuffer, int *intnum, float *fltnum);
241
double calculate_pfactor(const double* spectralField, long fieldTruncation, long subsetTruncation);
243
#endif /* _CGRIBEX_H */