|
NCEPLIBS-g2
3.4.7
|
Find and unpack a GRIB2 message in a file. More...
Go to the source code of this file.
Functions/Subroutines | |
| subroutine | getgb2 (LUGB, LUGI, J, JDISC, JIDS, JPDTN, JPDT, JGDTN, JGDT, UNPACK, K, GFLD, IRET) |
| Find and unpack a GRIB2 message in a file. More... | |
| subroutine getgb2 | ( | integer, intent(in) | LUGB, |
| integer, intent(in) | LUGI, | ||
| integer, intent(in) | J, | ||
| integer, intent(in) | JDISC, | ||
| integer, dimension(*) | JIDS, | ||
| integer, intent(in) | JPDTN, | ||
| integer, dimension(*) | JPDT, | ||
| integer, intent(in) | JGDTN, | ||
| integer, dimension(*) | JGDT, | ||
| logical, intent(in) | UNPACK, | ||
| integer, intent(out) | K, | ||
| type(gribfield), intent(out) | GFLD, | ||
| integer, intent(out) | IRET | ||
| ) |
Find and unpack a GRIB2 message in a file.
It reads a GRIB index file (or optionally the GRIB file itself) to get the index buffer (i.e. table of contents) for the GRIB file.
Find in the index buffer a reference to the GRIB field requested.
The GRIB field request specifies the number of fields to skip and the unpacked identification section, grid definition template and product defintion section parameters. (A requested parameter of -9999 means to allow any value of this parameter to be found.)
If the requested GRIB field is found, then it is read from the GRIB file and unpacked. Its number is returned along with the associated unpacked parameters. the bitmap (if any); the data values are unpacked only if argument unpack is set to true. If the GRIB field is not found, then the return code will be nonzero.
The decoded information for the selected GRIB field is returned in a derived type variable, gfld, which is of type grib_mod::gribfield. Users of this routine will need to include the line "use grib_mod" in their calling routine.
Derived type grib_mod::gribfield contains pointers to many arrays of data. Users must free this memory by calling gf_free().
This subroutine calls getidx(), which allocates memory and stores the resulting pointers in an array that is a Fortran "save" variable. The result is that the memory will not be freed by the library and cannot be reached by the caller. To free this memory call gf_finalize() after all library operations are complete.
| [in] | LUGB | integer unit of the unblocked grib data file. File must be opened with baopen() or baopenr() before calling this routine. |
| [in] | LUGI | integer unit of the unblocked grib index file. If nonzero, file must be opened with baopen() or baopenr() before calling this routine.
|
| [in] | J | integer number of fields to skip (=0 to search from beginning) |
| [in] | JDISC | grib2 discipline number of requested field (if = -1, accept any discipline see code table 0.0)
|
| [in] | JIDS | integer array of values in the identification section (=-9999 for wildcard)
|
| [in] | JPDTN | integer product definition template number (n) (if = -1, don't bother matching pdt - accept any) |
| [in] | JPDT | integer array of values defining the product definition template 4.n of the field for which to search (=-9999 for wildcard) |
| [in] | JGDTN | integer grid definition template number (m) (if = -1, don't bother matching gdt - accept any ) |
| [in] | JGDT | integer array of values defining the grid definition template 3.m of the field for which to search (=-9999 for wildcard) |
| [in] | UNPACK | logical value indicating whether to unpack bitmap/data
|
| [out] | K | integer field number unpacked |
| [out] | GFLD | derived type grib_mod::gribfield. |
| [out] | IRET | integer return code
|
Definition at line 112 of file getgb2.F90.
References getgb2l(), getgb2r(), getgb2s(), getidx(), and gf_free().