NCEPLIBS-g2  3.4.7
getgb2p.F90 File Reference

Find and extract a GRIB2 message from a file. More...

Go to the source code of this file.

Functions/Subroutines

subroutine getgb2p (lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, extract, k, gribm, leng, iret)
 Find and extract a GRIB2 message from a file. More...
 

Detailed Description

Find and extract a GRIB2 message from a file.

Author
Mark Iredell
Date
1994-04-01

Definition in file getgb2p.F90.

Function/Subroutine Documentation

◆ getgb2p()

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 
)

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().

Note
Specifing an index file may increase speed. Do not engage the same logical unit from more than one processor.
Parameters
[in]lugbUnit of the unblocked GRIB data file. The file must have been opened with baopen() or baopenr() before calling this routine.
[in]lugiUnit 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]jNumber of fields to skip (set to 0 to search from beginning).
[in]jdiscGRIB2 discipline number of requested field. See GRIB2 - TABLE 0.0 - DISCIPLINE. Use -1 to accept any discipline.
[in]jidsArray of values in the identification section. (Set to -9999 for wildcard.)
[in]jpdtnProduct Definition Template (PDT) number (n) (if = -1, don't bother matching PDT - accept any)
[in]jpdtArray of values defining the Product Definition Template of the field for which to search (=-9999 for wildcard).
[in]jgdtnGrid Definition Template (GDT) number (if = -1, don't bother matching GDT - accept any).
[in]jgdtarray of values defining the Grid Definition Template of the field for which to search (=-9999 for wildcard).
[in]extractvalue indicating whether to return a GRIB2 message with just the requested field, or the entire GRIB2 message containing the requested field.
  • .true. return GRIB2 message containing only the requested field.
  • .false. return entire GRIB2 message containing the requested field.
[out]kfield number unpacked.
[out]gribmreturned GRIB message.
[out]lenglength of returned GRIB message in bytes.
[out]iretinteger return code
  • 0 No error.
  • 96 Error reading index.
  • 97 Error reading GRIB file.
  • 99 Request not found.
Author
Mark Iredell
Date
1994-04-01

Definition at line 92 of file getgb2p.F90.

References getg2i(), getg2ir(), getgb2rp(), getgb2s(), and gf_free().