NCEPLIBS-g2
3.5.0
|
The getgb2 subroutines 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) |
This is a legacy version of getgb2i2(). More... | |
subroutine | getgb2i2 (lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, unpack, idxver, k, gfld, iret) |
Find and unpack a GRIB2 message in a file, using an version 1 or 2 index record which is either found in memory, read from an index file, or generated. More... | |
subroutine | getgb2l (lugb, cindex, gfld, iret) |
Read and unpack a local use section from a GRIB2 index record (index format 1) and GRIB2 file. More... | |
subroutine | getgb2l2 (lugb, idxver, cindex, gfld, iret) |
Read and unpack a local use section from a GRIB2 index record (index format 1 or 2) and GRIB2 file. More... | |
subroutine | getgb2p (lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, extract, k, gribm, leng, iret) |
Legacy subroutine to find and extract a GRIB2 message from a file. More... | |
subroutine | getgb2p2 (lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, extract, idxver, k, gribm, leng8, iret) |
Find and extract a GRIB2 message from a file. More... | |
subroutine | getgb2r (lugb, cindex, gfld, iret) |
Read and unpack sections 6 and 7 from a GRIB2 message using a version 1 index record. More... | |
subroutine | getgb2r2 (lugb, idxver, cindex, gfld, iret) |
Read and unpack sections 6 and 7 from a GRIB2 message using a version 1 or version 2 index record. More... | |
subroutine | getgb2rp (lugb, cindex, extract, gribm, leng, iret) |
Extract a grib message from a file given the index (index format 1) of the requested field. More... | |
subroutine | getgb2rp2 (lugb, idxver, cindex, extract, gribm, leng8, iret) |
Extract a grib message from a file given the version 1 or 2 index of the requested field. More... | |
The getgb2 subroutines find and unpack a GRIB2 message in a file.
Definition in file g2getgb2.F90.
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 | ||
) |
This is a legacy version of getgb2i2().
It finds and unpacks a GRIB2 message in a file, using an version 1 index record which is either found in memory, read from an index file, or generated.
Users of this routine must:
For more details, see getgb2i2().
[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. lugi may be:
|
[in] | j | integer number of fields to skip (0 to search from beginning). |
[in] | jdisc | GRIB2 discipline number of requested field: –1 accept any discipline
|
[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 62 of file g2getgb2.F90.
References getgb2i2().
subroutine getgb2i2 | ( | 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(in) | idxver, | ||
integer, intent(out) | k, | ||
type(gribfield), intent(out) | gfld, | ||
integer, intent(out) | iret | ||
) |
Find and unpack a GRIB2 message in a file, using an version 1 or 2 index record which is either found in memory, read from an index file, or generated.
This subroutine is similar to getgb2(), but allows the caller to specify the index version of the generated index (if one is generated). Use index version 2 for all new code, as it handles all GRIB2 files, including files > 2 GB. Use index version 1 for backward compatibility, but it does not work past the first 2 GB of the file.
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 getidx2(), 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. lugi may be:
|
[in] | j | integer number of fields to skip (0 to search from beginning). |
[in] | jdisc | GRIB2 discipline number of requested field: –1 accept any discipline
|
[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
|
[in] | idxver | Index version of the cindex buffer. |
[out] | k | integer field number unpacked |
[out] | gfld | derived type grib_mod::gribfield. |
[out] | iret | integer return code
|
Definition at line 191 of file g2getgb2.F90.
References g2logging::g2_log(), g2logging::g2_log_msg, getgb2l2(), getgb2r2(), getgb2s2(), getidx2(), and gf_free().
Referenced by getgb2().
subroutine getgb2l | ( | integer, intent(in) | lugb, |
character(len = 1), dimension(*), intent(in) | cindex, | ||
type(gribfield) | gfld, | ||
integer, intent(out) | iret | ||
) |
Read and unpack a local use section from a GRIB2 index record (index format 1) and GRIB2 file.
This subprogram is intended for private use by getgb2() routine only.
Note that derived type gribfield contains pointers to many arrays of data. Users must free this memory with gf_free().
This subroutine supports only index format 1, which will not work for files > 2 GB. New code should use getgb2l2().
[in] | lugb | integer unit of the unblocked grib data file. |
[in] | cindex | index record of the grib field (see ix2gb2() for description of an index record.) |
[out] | gfld | derived type gribfield grib_mod::gribfield. |
[out] | iret | integer return code
|
Definition at line 309 of file g2getgb2.F90.
References getgb2l2().
subroutine getgb2l2 | ( | integer, intent(in) | lugb, |
integer, intent(in) | idxver, | ||
character(len = 1), dimension(*), intent(in) | cindex, | ||
type(gribfield) | gfld, | ||
integer, intent(out) | iret | ||
) |
Read and unpack a local use section from a GRIB2 index record (index format 1 or 2) and GRIB2 file.
This subroutine decodes information for the selected GRIB2 field and returns it in a derived type variable, gfld. gfld is of type grib_mod::gribfield. Users of this routine will need to include the line "use grib_mod" in their calling routine.
This subprogram is intended for private use by getgb2() routine only.
Note that derived type gribfield contains pointers to many arrays of data. Users must free this memory with gf_free().
[in] | lugb | integer unit of the unblocked grib data file. |
[in] | idxver | Index version of the cindex buffer. |
[in] | cindex | index record of the grib field (see ix2gb2() for description of an index record.) |
[out] | gfld | derived type gribfield grib_mod::gribfield. |
[out] | iret | integer return code
|
Definition at line 357 of file g2getgb2.F90.
References g2_gbytec1(), g2_gbytec81(), g2logging::g2_log(), g2logging::g2_log_msg, and gf_unpack2().
Referenced by getgb2i2(), and getgb2l().
subroutine getgb2p | ( | 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) | extract, | ||
integer, intent(out) | k, | ||
character(len = 1), dimension(:), pointer | gribm, | ||
integer, intent(out) | leng, | ||
integer, intent(out) | iret | ||
) |
Legacy subroutine to find and extract a GRIB2 message from a file.
Use getgb2p2() for new code.
This subroutine 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. It finds 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. If the GRIB field is not found, then the return code will be nonzero.
The derived type grib_mod::gribfield contains allocated memory that must be freed by the caller with subroutine gf_free().
[in] | lugb | Unit of the unblocked GRIB data file. The file must have been opened with baopen() or baopenr() before calling this routine. |
[in] | lugi | Unit of the unblocked GRIB index file. If nonzero, file must have been opened with baopen() or baopenr() before calling this subroutine. Set to 0 to get index buffer from the GRIB file. |
[in] | j | Number of fields to skip (set to 0 to search from beginning). |
[in] | jdisc | GRIB2 discipline number of requested field. See GRIB2 - TABLE 0.0 - DISCIPLINE. Use -1 to accept any discipline. |
[in] | jids | Array of values in the identification section. (Set to -9999 for wildcard.) |
[in] | jpdtn | Product Definition Template (PDT) number (n) (if = -1, don't bother matching PDT - accept any) |
[in] | jpdt | Array of values defining the Product Definition Template of the field for which to search (=-9999 for wildcard). |
[in] | jgdtn | Grid Definition Template (GDT) number (if = -1, don't bother matching GDT - accept any). |
[in] | jgdt | array of values defining the Grid Definition Template of the field for which to search (=-9999 for wildcard). |
[in] | extract | value indicating whether to return a GRIB2 message with just the requested field, or the entire GRIB2 message containing the requested field.
|
[out] | k | field number unpacked. |
[out] | gribm | returned GRIB message. |
[out] | leng | length of returned GRIB message in bytes. |
[out] | iret | integer return code
|
Definition at line 520 of file g2getgb2.F90.
References getgb2p2().
subroutine getgb2p2 | ( | 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) | extract, | ||
integer, intent(inout) | idxver, | ||
integer, intent(out) | k, | ||
character(len = 1), dimension(:), pointer | gribm, | ||
integer (kind = 8), intent(out) | leng8, | ||
integer, intent(out) | iret | ||
) |
Find and extract a GRIB2 message from a file.
This subroutine 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. It finds 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. If the GRIB field is not found, then the return code will be nonzero.
The derived type grib_mod::gribfield contains allocated memory that must be freed by the caller with subroutine gf_free().
[in] | lugb | Unit of the unblocked GRIB data file. The file must have been opened with baopen() or baopenr() before calling this routine. |
[in] | lugi | Unit of the unblocked GRIB index file. If nonzero, file must have been opened with baopen() or baopenr() before calling this subroutine. Set to 0 to get index buffer from the GRIB file. |
[in] | j | Number of fields to skip (set to 0 to search from beginning). |
[in] | jdisc | GRIB2 discipline number of requested field. See GRIB2 - TABLE 0.0 - DISCIPLINE. Use -1 to accept any discipline. |
[in] | jids | Array of values in the identification section. (Set to -9999 for wildcard.)
|
[in] | jpdtn | Product Definition Template (PDT) number (n) (if = -1, don't bother matching PDT - accept any) |
[in] | jpdt | Array of values defining the Product Definition Template of the field for which to search (=-9999 for wildcard). |
[in] | jgdtn | Grid Definition Template (GDT) number (if = -1, don't bother matching GDT - accept any). |
[in] | jgdt | array of values defining the Grid Definition Template of the field for which to search (=-9999 for wildcard). |
[in] | extract | value indicating whether to return a GRIB2 message with just the requested field, or the entire GRIB2 message containing the requested field.
|
[in] | idxver | The index version, use 2 for new code, 1 for legacy index files. |
[out] | k | field number unpacked. |
[out] | gribm | returned GRIB message. |
[out] | leng8 | length of returned GRIB message in bytes. |
[out] | iret | integer return code
|
Definition at line 654 of file g2getgb2.F90.
References getg2i2(), getg2i2r(), getgb2rp2(), getgb2s2(), and gf_free().
Referenced by getgb2p().
subroutine getgb2r | ( | integer, intent(in) | lugb, |
character(len=1), dimension(*), intent(in) | cindex, | ||
type(gribfield) | gfld, | ||
integer, intent(out) | iret | ||
) |
Read and unpack sections 6 and 7 from a GRIB2 message using a version 1 index record.
This function is maintained for backward compatibility. New code should use getgb2r2(), which can handle both version 1 and version 2 index records.
Metadata for the field must already exists in derived type grib_mod::gribfield. Specifically, it requires gfld%ibmap, gfld%ngrdpts, gfld%idrtnum, gfld%idrtmpl, and gfld%ndpts.
The field data is returned in derived type variable, gfld, of type grib_mod::gribfield. Users of this routine will need to include the line "use grib_mod" in their calling routine.
This subprogram is intended for private use by getgb2() routines only.
Derived type gribfield contains pointers to many arrays of data. Users must free this memory by calling gf_free().
[in] | lugb | integer unit of the unblocked grib data file. File must be opened with baopen() or baopenr() before calling this routine. |
[in] | cindex | version 1 index record of the field (see subroutine ix2gb2() for description of an index record.) |
[out] | gfld | derived type grib_mod::gribfield. |
[out] | iret | Return code:
|
Definition at line 797 of file g2getgb2.F90.
References getgb2r2().
subroutine getgb2r2 | ( | integer, intent(in) | lugb, |
integer, intent(in) | idxver, | ||
character(len=1), dimension(*), intent(in) | cindex, | ||
type(gribfield) | gfld, | ||
integer, intent(out) | iret | ||
) |
Read and unpack sections 6 and 7 from a GRIB2 message using a version 1 or version 2 index record.
Metadata for the field must already exists in derived type grib_mod::gribfield. Specifically, it requires gfld%ibmap, gfld%ngrdpts, gfld%idrtnum, gfld%idrtmpl, and gfld%ndpts.
The field data is returned in derived type variable, gfld, of type grib_mod::gribfield. Users of this routine will need to include the line "use grib_mod" in their calling routine.
This subprogram is intended for private use by getgb2() routines only.
Derived type gribfield contains pointers to many arrays of data. Users must free this memory by calling gf_free().
[in] | lugb | integer unit of the unblocked grib data file. File must be opened with baopen() or baopenr() before calling this routine. |
[in] | idxver | Index version, 1 for legacy, 2 if file may be > 2 GB. |
[in] | cindex | version 1 or 2 index record of the grib field (see subroutine ixgb2() for description of an index record.) |
[out] | gfld | derived type grib_mod::gribfield. |
[out] | iret | Return code:
|
Definition at line 856 of file g2getgb2.F90.
References g2_gbytec1(), g2_gbytec81(), g2logging::g2_log(), g2logging::g2_log_msg, gf_unpack6(), and gf_unpack7().
Referenced by getgb2i2(), and getgb2r().
subroutine getgb2rp | ( | integer, intent(in) | lugb, |
character(len = 1), dimension(*), intent(in) | cindex, | ||
logical, intent(in) | extract, | ||
character(len = 1), dimension(:), pointer | gribm, | ||
integer, intent(out) | leng, | ||
integer, intent(out) | iret | ||
) |
Extract a grib message from a file given the index (index format 1) of the requested field.
This subroutine is maintained for backward compatibility. New code should use getgb2rp2().
The GRIB message returned can contain only the requested field (extract=.true.), or the complete GRIB message originally containing the desired field can be returned (extract=.false.) even if other fields were included in the GRIB message.
If the GRIB field is not found, then the return code will be nonzero.
[in] | lugb | integer unit of the unblocked grib data file. file must be opened with baopen() or baopenr() before calling this routine. |
[in] | cindex | Index record of the grib field (see docunentation of subroutine ix2gb2() for description of an index record.) |
[in] | extract | Logical value indicating whether to return a GRIB2 message with just the requested field, or the entire GRIB2 message containing the requested field.
|
[out] | gribm | Returned grib message. |
[out] | leng | Length of returned grib message in bytes. |
[out] | iret | Return code:
|
Definition at line 1084 of file g2getgb2.F90.
References getgb2rp2().
subroutine getgb2rp2 | ( | integer, intent(in) | lugb, |
integer, intent(inout) | idxver, | ||
character(len = 1), dimension(*), intent(in) | cindex, | ||
logical, intent(in) | extract, | ||
character(len = 1), dimension(:), pointer | gribm, | ||
integer (kind = 8), intent(out) | leng8, | ||
integer, intent(out) | iret | ||
) |
Extract a grib message from a file given the version 1 or 2 index of the requested field.
The GRIB message returned can contain only the requested field (extract=.true.), or the complete GRIB message originally containing the desired field can be returned (extract=.false.) even if other fields were included in the GRIB message.
If the GRIB field is not found, then the return code will be nonzero.
[in] | lugb | integer unit of the unblocked grib data file. file must be opened with baopen() or baopenr() before calling this routine. |
[in] | idxver | Version of index, use 1 for legacy, 2 if files may be > 2 GB. |
[in] | cindex | Index record of the grib field (see docunentation of subroutine ixgb2() for description of an index record.) |
[in] | extract | Logical value indicating whether to return a GRIB2 message with just the requested field, or the entire GRIB2 message containing the requested field.
|
[out] | gribm | Returned grib message. |
[out] | leng8 | Length of returned grib message in bytes. |
[out] | iret | Return code:
|
Definition at line 1147 of file g2getgb2.F90.
References g2_gbytec1(), g2_gbytec8(), g2_gbytec81(), g2logging::g2_log(), g2logging::g2_log_msg, and g2_sbytec81().
Referenced by getgb2p2(), and getgb2rp().