Go to the documentation of this file.
22 #define G2_VERSION "1.7.0"
24 #define G2_PNG_ENABLED 1
25 #define G2_JPEG2000_ENABLED 1
28 typedef int64_t g2int;
222 unsigned char **csec2);
226 g2int *mappdslen,
float **coordlist,
g2int *numcoord);
255 unsigned char *cpack,
g2int *lcpack);
259 unsigned char *cpack,
g2int *lcpack);
263 unsigned char *cpack,
g2int *lcpack);
267 unsigned char *cpack,
g2int *lcpack);
275 #define G2_NO_ERROR 0
276 #define G2_CREATE_GRIB_VERSION -1
277 #define G2_INFO_NO_GRIB 1
278 #define G2_INFO_GRIB_VERSION 2
279 #define G2_INFO_NO_SEC1 3
280 #define G2_INFO_WRONG_END 4
281 #define G2_INFO_BAD_END 5
282 #define G2_INFO_INVAL_SEC 6
283 #define G2_GETFLD_NO_GRIB 1
284 #define G2_GETFLD_GRIB_VERSION 2
285 #define G2_GETFLD_INVAL 3
286 #define G2_GETFLD_WRONG_END 4
287 #define G2_GETFLD_WRONG_NFLDS 6
288 #define G2_GETFLD_BAD_END 7
289 #define G2_GETFLD_INVAL_SEC 8
290 #define G2_GETFLD_NO_DRT 9
291 #define G2_GETFLD_BAD_SEC1 15
292 #define G2_GETFLD_BAD_SEC2 16
293 #define G2_GETFLD_BAD_SEC3 10
294 #define G2_GETFLD_BAD_SEC4 11
295 #define G2_GETFLD_BAD_SEC5 12
296 #define G2_GETFLD_BAD_SEC6 13
297 #define G2_GETFLD_BAD_SEC7 14
298 #define G2_GETFLD_NO_BITMAP 17
299 #define G2_GRIBEND_MSG_INIT -1
300 #define G2_BAD_SEC -4
301 #define G2_UNPACK_BAD_SEC 2
302 #define G2_UNPACK_NO_MEM 6
303 #define G2_UNPACK3_BAD_GDT 5
304 #define G2_UNPACK4_BAD_PDT 5
305 #define G2_UNPACK5_BAD_DRT 7
306 #define G2_UNPACK6_BAD_BITMAP 4
307 #define G2_UNPACK7_CORRUPT_SEC 7
308 #define G2_UNPACK7_WRONG_GDT 5
309 #define G2_UNPACK7_BAD_DRT 4
310 #define G2_ADD_MSG_INIT -1
311 #define G2_ADD_MSG_COMPLETE -2
312 #define G2_BAD_SEC_COUNTS -3
313 #define G2_ADDFIELD_BAD_PDT -5
314 #define G2_ADDFIELD_BAD_GDS -6
315 #define G2_ADDFIELD_BAD_DRT -7
316 #define G2_ADDFIELD_BAD_BITMAP -8
317 #define G2_ADDFIELD_BAD_GDT -9
318 #define G2_ADDFIELD_ERR -10
319 #define G2_ADDGRID_BAD_GDT -5
320 #define G2_JPCUNPACK_MEM 1
321 #define G2_SPECUNPACK_TYPE -3
322 #define G2_JASPER_INIT -2
323 #define G2_JASPER_ENCODE -3
324 #define G2_JASPER_DECODE -3
325 #define G2_JASPER_DECODE_COLOR -5
328 #define G2C_NO_ERROR 0
329 #define G2C_NOT_GRIB -50
330 #define G2C_MSG_COMPLETE -51
g2int g2_unpack1(unsigned char *cgrib, g2int *iofst, g2int **ids, g2int *idslen)
This subroutine unpacks Section 1 - Identification Section as defined in GRIB Edition 2.
g2int g2_create(unsigned char *cgrib, g2int *listsec0, g2int *listsec1)
This routine initializes a new GRIB2 message and packs GRIB2 Section 0 (Indicator Section) and Sectio...
g2int * igdtmpl
Contains the data values for the Grid Definition Template specified by igdtnum.
g2int pngunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts, float *fld)
This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB...
g2int g2_unpack5(unsigned char *cgrib, g2int *iofst, g2int *ndpts, g2int *idrsnum, g2int **idrstmpl, g2int *mapdrslen)
This subroutine unpacks Section 5 (Data Representation Section) as defined in GRIB Edition 2.
void jpcpackd(double *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a data field into a JPEG2000 code stream.
g2int g2_unpack7(unsigned char *cgrib, g2int *iofst, g2int igdsnum, g2int *igdstmpl, g2int idrsnum, g2int *idrstmpl, g2int ndpts, float **fld)
This subroutine unpacks Section 7 (Data Section) as defined in GRIB Edition 2.
g2int ngrdpts
Number of grid points in the defined grid.
g2int unpacked
Logical value indicating whether the bitmap and data values were unpacked.
void g2_free(gribfield *gfld)
This routine frees up memory that was allocated for struct gribfield.
g2int ifldnum
Field number within GRIB message.
g2int g2_addgrid(unsigned char *cgrib, g2int *igds, g2int *igdstmpl, g2int *ideflist, g2int idefnum)
This routine packs up a Grid Definition Section (Section 3) and adds it to a GRIB2 message.
g2int idrtlen
Number of elements in idrtmpl.
g2int ibmap
Bitmap indicator (see Table 6.0).
g2int griddef
Source of grid definition (see Table 3.0).
g2int g2_unpack4(unsigned char *cgrib, g2int *iofst, g2int *ipdsnum, g2int **ipdstmpl, g2int *mappdslen, float **coordlist, g2int *numcoord)
This subroutine unpacks Section 4 (Product Definition Section) as defined in GRIB Edition 2.
void seekgb(FILE *lugb, g2int iseek, g2int mseek, g2int *lskip, g2int *lgrib)
This subprogram searches a file for the next GRIB Message.
g2int numoct_opt
Number of octets needed for each additional grid points definition.
g2int g2_addfield(unsigned char *cgrib, g2int ipdsnum, g2int *ipdstmpl, float *coordlist, g2int numcoord, g2int idrsnum, g2int *idrstmpl, float *fld, g2int ngrdpts, g2int ibmap, g2int *bmap)
This routine packs up Sections 4 through 7 for a given field and adds them to a GRIB2 message.
g2int pngunpackd(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts, double *fld)
This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB...
g2int g2_info(unsigned char *cgrib, g2int *listsec0, g2int *listsec1, g2int *numfields, g2int *numlocal)
This subroutine searches through a GRIB2 message and returns the number of gridded fields found in th...
g2int * idsect
Contains the entries in the Identification Section (Section 1).
g2int g2_unpack6(unsigned char *cgrib, g2int *iofst, g2int ngpts, g2int *ibmap, g2int **bmap)
This subroutine unpacks Section 6 (Bit-Map Section) as defined in GRIB Edition 2.
int g2c_set_log_level(int new_level)
Use this to set the global log level.
g2int g2_gribend(unsigned char *cgrib)
This routine finalizes a GRIB2 message after all grids and fields have been added.
g2int g2_getfld(unsigned char *cgrib, g2int ifldnum, g2int unpack, g2int expand, gribfield **gfld)
This subroutine returns all the metadata, template values, bit-map (if applicable),...
void pngpack(float *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a float data field into PNG image format.
g2int * idrtmpl
Contains the data values for the Data Representation Template specified by idrtnum.
g2int jpcunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts, float *fld)
Unpack JPEG2000 compressed data into an array of floats, using info from the GRIB2 Data Representatio...
g2int interp_opt
Interpretation of list for optional points definition.
g2int ipdtlen
Number of elements in ipdtmpl - i.e.
g2int g2_unpack2(unsigned char *cgrib, g2int *iofst, g2int *lencsec2, unsigned char **csec2)
This subroutine unpacks Section 2 (Local Use Section) as defined in GRIB Edition 2.
void pngpackd(double *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a double data field into PNG image format.
g2int discipline
Message Discipline (see Table 0.0).
g2int num_opt
(Used if numoct_opt .ne.
float * coord_list
Array containing floating point values intended to document the vertical discretisation associated to...
g2int ipdtnum
Product Definition Template Number (see Table 4.0).
int64_t g2int
Long integer type.
g2int g2_unpack3(unsigned char *cgrib, g2int *iofst, g2int **igds, g2int **igdstmpl, g2int *mapgridlen, g2int **ideflist, g2int *idefnum)
This routine unpacks Section 3 (Grid Definition Section) as defined in GRIB Edition 2.
float * fld
Array of ndpts unpacked data points.
unsigned char * local
Pointer to character array containing contents of Local Section 2, if included.
g2int idrtnum
Data Representation Template Number (see Table 5.0).
g2int num_coord
Number of values in array coord_list.
g2int expanded
Logical value indicating whether the data field was expanded to the grid in the case where a bit-map ...
g2int version
GRIB edition number (2).
g2int locallen
Length of array local.
g2int ndpts
Number of data points unpacked and returned.
g2int igdtlen
Number of elements in igdtmpl - i.e.
g2int * list_opt
(Used if numoct_opt .ne.
g2int g2_addlocal(unsigned char *cgrib, unsigned char *csec2, g2int lcsec2)
This routine adds a Local Use Section (Section 2) to a GRIB2 message.
g2int igdtnum
Grid Definition Template Number (See Table 3.1).
void jpcpack(float *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a data field into a JPEG2000 code stream.
g2int * bmap
Integer array containing decoded bitmap, if ibmap=0 or ibap=254.
g2int * ipdtmpl
Contains the data values for the Product Definition Template specified by ipdtnum.
g2int idsectlen
Number of elements in idsect.
uint64_t g2intu
Unsigned long integer type.
g2int jpcunpackd(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts, double *fld)
Unpack JPEG2000 compressed data into an array of doubles, using info from the GRIB2 Data Representati...