NCEPLIBS-g2c  1.6.4
grib2.h
Go to the documentation of this file.
1 
13 #ifndef _grib2_H
14 #define _grib2_H
15 #include <stdio.h>
16 #include <stdint.h>
17 
18 #define G2_VERSION "g2clib-1.6.4"
20 typedef int64_t g2int;
21 typedef uint64_t g2intu;
22 typedef float g2float;
27 struct gtemplate
28 {
34 
39 
43 
46 
49 
53 };
54 
55 typedef struct gtemplate gtemplate;
60 struct gribfield
61 {
64 
68 
116 
119 
122  unsigned char *local;
123 
126 
129 
136 
139 
144 
149 
155 
160 
164 
168 
172 
176 
180 
184 
187 
192 
195 
199 
202 
206 
210 
219 
227 
231 
234 };
235 
236 typedef struct gribfield gribfield;
238 /* Prototypes for unpacking sections API */
239 g2int g2_unpack1(unsigned char *,g2int *,g2int **,g2int *);
240 g2int g2_unpack3(unsigned char *,g2int *,g2int **,g2int **,g2int *,g2int **,g2int *);
241 g2int g2_unpack4(unsigned char *,g2int *,g2int *,g2int **,g2int *,g2float **,g2int *);
242 g2int g2_unpack5(unsigned char *,g2int *,g2int *,g2int *,g2int **,g2int *);
243 g2int g2_unpack6(unsigned char *,g2int *,g2int ,g2int *,g2int **);
244 g2int g2_unpack7(unsigned char *,g2int *,g2int ,g2int *,g2int ,g2int *,g2int ,g2float **);
245 
246 /* Prototypes for unpacking API */
247 void seekgb(FILE *,g2int ,g2int ,g2int *,g2int *);
248 g2int g2_info(unsigned char *,g2int *,g2int *,g2int *,g2int *);
249 g2int g2_getfld(unsigned char *,g2int ,g2int ,g2int ,gribfield **);
250 void g2_free(gribfield *);
251 
252 /* Prototypes for packing API */
253 g2int g2_create(unsigned char *,g2int *,g2int *);
254 g2int g2_addlocal(unsigned char *,unsigned char *,g2int );
255 g2int g2_addgrid(unsigned char *,g2int *,g2int *,g2int *,g2int );
256 g2int g2_addfield(unsigned char *,g2int ,g2int *,
257  g2float *,g2int ,g2int ,g2int *,
258  g2float *,g2int ,g2int ,g2int *);
259 g2int g2_gribend(unsigned char *);
260 
261 /* Prototypes for supporting routines */
262 extern double int_power(double, g2int );
263 extern void mkieee(g2float *,g2int *,g2int);
264 void rdieee(g2int *,g2float *,g2int );
271 extern void simpack(g2float *,g2int,g2int *,unsigned char *,g2int *);
272 extern void compack(g2float *,g2int,g2int,g2int *,unsigned char *,g2int *);
273 void misspack(g2float *,g2int ,g2int ,g2int *, unsigned char *, g2int *);
274 void gbit(unsigned char *,g2int *,g2int ,g2int );
275 void sbit(unsigned char *,g2int *,g2int ,g2int );
276 void gbits(unsigned char *,g2int *,g2int ,g2int ,g2int ,g2int );
277 void sbits(unsigned char *,g2int *,g2int ,g2int ,g2int ,g2int );
278 
279 int pack_gp(g2int *, g2int *, g2int *,
280  g2int *, g2int *, g2int *, g2int *, g2int *,
281  g2int *, g2int *, g2int *, g2int *,
282  g2int *, g2int *, g2int *, g2int *, g2int *,
283  g2int *, g2int *, g2int *);
284 
285 #endif /* _grib2_H */
g2int igdtnum
Grid Definition Template Number (See Table 3.1).
Definition: grib2.h:163
void mkieee(g2float *, g2int *, g2int)
This subroutine stores a list of real values in 32-bit IEEE floating point format.
Definition: mkieee.c:21
g2int locallen
Length of array local.
Definition: grib2.h:125
g2int ibmap
Bitmap indicator (see Table 6.0).
Definition: grib2.h:226
g2int g2_unpack7(unsigned char *, g2int *, g2int, g2int *, g2int, g2int *, g2int, g2float **)
This subroutine unpacks Section 7 (Data Section) as defined in GRIB Edition 2.
Definition: g2_unpack7.c:65
gtemplate * getpdstemplate(g2int)
This subroutine returns PDS template information for a specified Product Definition Template.
Definition: pdstemplates.c:73
g2int interp_opt
Interpretation of list for optional points definition.
Definition: grib2.h:148
g2int ngrdpts
Number of grid points in the defined grid.
Definition: grib2.h:138
g2int g2_addgrid(unsigned char *, g2int *, g2int *, g2int *, g2int)
This routine packs up a Grid Definition Section (Section 3) and adds it to a GRIB2 message.
Definition: g2_addgrid.c:66
g2int g2_unpack6(unsigned char *, g2int *, g2int, g2int *, g2int **)
This subroutine unpacks Section 6 (Bit-Map Section) as defined in GRIB Edition 2.
Definition: g2_unpack6.c:33
g2int ifldnum
Field number within GRIB message.
Definition: grib2.h:128
g2float * coord_list
Array containing floating point values intended to document the vertical discretisation associated to...
Definition: grib2.h:191
float g2float
Float type.
Definition: grib2.h:22
g2int * ext
Number of octets of each entry in the extension part of the template.
Definition: grib2.h:52
double int_power(double, g2int)
Function similar to C pow() power function.
Definition: int_power.c:17
g2int g2_unpack1(unsigned char *, g2int *, g2int **, g2int *)
This subroutine unpacks Section 1 - Identification Section as defined in GRIB Edition 2.
Definition: g2_unpack1.c:55
g2int g2_unpack5(unsigned char *, g2int *, g2int *, g2int *, g2int **, g2int *)
This subroutine unpacks Section 5 (Data Representation Section) as defined in GRIB Edition 2.
Definition: g2_unpack5.c:42
gtemplate * extdrstemplate(g2int, g2int *)
This subroutine generates the remaining octet map for a given Data Representation Template,...
Definition: drstemplates.c:110
g2int griddef
Source of grid definition (see Table 3.0).
Definition: grib2.h:135
void gbits(unsigned char *, g2int *, g2int, g2int, g2int, g2int)
Get bits - unpack bits: Extract arbitrary size values from a packed bit string, right justifying each...
Definition: gbits.c:57
g2int ipdtnum
Product Definition Template Number (see Table 4.0).
Definition: grib2.h:175
g2int * ipdtmpl
Contains the data values for the Product Definition Template specified by ipdtnum.
Definition: grib2.h:183
g2int discipline
Message Discipline (see Table 0.0).
Definition: grib2.h:67
g2int g2_getfld(unsigned char *, g2int, g2int, g2int, gribfield **)
This subroutine returns all the metadata, template values, bit-map (if applicable),...
Definition: g2_getfld.c:102
g2int numoct_opt
Number of octets needed for each additional grid points definition.
Definition: grib2.h:143
void sbit(unsigned char *, g2int *, g2int, g2int)
Store bits - put arbitrary size values into a packed bit string, taking the low order bits from each ...
Definition: gbits.c:38
g2int g2_gribend(unsigned char *)
This routine finalizes a GRIB2 message after all grids and fields have been added.
Definition: g2_gribend.c:35
void misspack(g2float *, g2int, g2int, g2int *, unsigned char *, g2int *)
This subroutine packs up a data field using a complex packing algorithm as defined in the GRIB2 docum...
Definition: misspack.c:43
g2int idrtlen
Number of elements in idrtmpl.
Definition: grib2.h:201
g2int extlen
Number of entries in the template extension.
Definition: grib2.h:48
g2int unpacked
Logical value indicating whether the bitmap and data values were unpacked.
Definition: grib2.h:209
g2int g2_unpack3(unsigned char *, g2int *, g2int **, g2int **, g2int *, g2int **, g2int *)
This routine unpacks Section 3 (Grid Definition Section) as defined in GRIB Edition 2.
Definition: g2_unpack3.c:57
gtemplate * getdrstemplate(g2int)
This subroutine returns DRS template information for a specified Data Representation Template.
Definition: drstemplates.c:64
int pack_gp(g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *, g2int *)
Determines groups of variable size, but at least of size minpk, the associated max (jmax( )) and min ...
Definition: pack_gp.c:256
g2int * map
Number of octets of each entry in the static part of the template.
Definition: grib2.h:42
g2int idsectlen
Number of elements in idsect.
Definition: grib2.h:118
g2int g2_info(unsigned char *, g2int *, g2int *, g2int *, g2int *)
This subroutine searches through a GRIB2 message and returns the number of gridded fields found in th...
Definition: g2_info.c:67
g2int ipdtlen
Number of elements in ipdtmpl - i.e.
Definition: grib2.h:179
g2int needext
Indicates whether or not the template needs to be extended.
Definition: grib2.h:45
g2int g2_unpack4(unsigned char *, g2int *, g2int *, g2int **, g2int *, g2float **, g2int *)
This subroutine unpacks Section 4 (Product Definition Section) as defined in GRIB Edition 2.
Definition: g2_unpack4.c:45
gtemplate * getgridtemplate(g2int)
This subroutine returns grid template information for a specified Grid Definition Template for [Secti...
Definition: gridtemplates.c:75
uint64_t g2intu
Unsigned long integer type.
Definition: grib2.h:21
g2int num
The template number.
Definition: grib2.h:35
g2int * igdtmpl
Contains the data values for the Grid Definition Template specified by igdtnum.
Definition: grib2.h:171
g2int idrtnum
Data Representation Template Number (see Table 5.0).
Definition: grib2.h:198
g2int ndpts
Number of data points unpacked and returned.
Definition: grib2.h:194
g2int g2_create(unsigned char *, g2int *, g2int *)
This routine initializes a new GRIB2 message and packs GRIB2 sections 0 (Indicator Section) and 1 (Id...
Definition: g2_create.c:63
g2int * idrtmpl
Contains the data values for the Data Representation Template specified by idrtnum.
Definition: grib2.h:205
g2int g2_addlocal(unsigned char *, unsigned char *, g2int)
This routine adds a Local Use Section (Section 2) to a GRIB2 message.
Definition: g2_addlocal.c:37
g2int * list_opt
(Used if numoct_opt .ne.
Definition: grib2.h:159
gtemplate * extpdstemplate(g2int, g2int *)
This subroutine generates the remaining octet map for a given Product Definition Template,...
Definition: pdstemplates.c:121
g2int version
GRIB edition number (2).
Definition: grib2.h:63
void gbit(unsigned char *, g2int *, g2int, g2int)
Get bits - unpack bits: Extract arbitrary size values from a packed bit string, right justifying each...
Definition: gbits.c:20
g2int g2_addfield(unsigned char *, g2int, g2int *, g2float *, g2int, g2int, g2int *, g2float *, g2int, g2int, g2int *)
This routine packs up Sections 4 through 7 for a given field and adds them to a GRIB2 message.
Definition: g2_addfield.c:106
g2int type
The template type: 3 Grid Defintion Template.
Definition: grib2.h:33
void simpack(g2float *, g2int, g2int *, unsigned char *, g2int *)
This subroutine packs up a data field using the simple packing algorithm as defined in the GRIB2 docu...
Definition: simpack.c:34
g2int * idsect
Contains the entries in the Identification Section (Section 1).
Definition: grib2.h:115
void g2_free(gribfield *)
This routine frees up memory that was allocated for struct gribfield.
Definition: g2_free.c:24
g2float * fld
Array of ndpts unpacked data points.
Definition: grib2.h:233
g2int num_coord
Number of values in array coord_list.
Definition: grib2.h:186
void seekgb(FILE *, g2int, g2int, g2int *, g2int *)
This subprogram searches a file for the next GRIB Message.
Definition: seekgb.c:32
unsigned char * local
Pointer to character array containing contents of Local Section 2, if included.
Definition: grib2.h:122
g2int expanded
Logical value indicating whether the data field was expanded to the grid in the case where a bit-map ...
Definition: grib2.h:218
g2int num_opt
(Used if numoct_opt .ne.
Definition: grib2.h:154
g2int igdtlen
Number of elements in igdtmpl - i.e.
Definition: grib2.h:167
gtemplate * extgridtemplate(g2int, g2int *)
This subroutine generates the remaining octet map for a given Grid Definition Template,...
g2int maplen
Number of entries in the static part of the template.
Definition: grib2.h:38
g2int * bmap
Integer array containing decoded bitmap, if ibmap=0 or ibap=254.
Definition: grib2.h:230
int64_t g2int
Long integer type.
Definition: grib2.h:20
void sbits(unsigned char *, g2int *, g2int, g2int, g2int, g2int)
Store bits - put arbitrary size values into a packed bit string, taking the low order bits from each ...
Definition: gbits.c:114
void compack(g2float *, g2int, g2int, g2int *, unsigned char *, g2int *)
This subroutine packs up a data field using a complex packing algorithm as defined in the GRIB2 docum...
Definition: compack.c:42
void rdieee(g2int *, g2float *, g2int)
This subroutine reads a list of real values in 32-bit IEEE floating point format.
Definition: rdieee.c:20
Struct for GRIB field.
Definition: grib2.h:61
Struct for GRIB template.
Definition: grib2.h:28