NCEPLIBS-g2  3.4.5
getgb2p.f File Reference

This subroutine find and extracts a grib 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)
 This subroutine find and extracts a grib message from a file. More...
 

Detailed Description

This subroutine find and extracts a grib message from a file.

Author
Mark Iredell
Date
1994-04-01

Definition in file getgb2p.f.

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 
)

This subroutine find and extracts a grib message from 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. If the grib field is not found, then the return code will be nonzero.

PROGRAM HISTORY LOG:

  • 1994-04-01 Mark Iredell
  • 1995-10-31 Mark Iredell modularized portions of code into subprograms and allowed for unspecified index file
  • 2002-01-11 Stephen Gilbert modified from getgb and getgbm to work with grib2
  • 2003-12-17 Stephen Gilbert modified from getgb2 to return packed grib2 message
    Parameters
    [in]LUGBinteger unit of the unblocked grib data file. file must be opened with baopen or baopenr before calling this routine.
    [in]LUGIinteger unit of the unblocked grib index file. if nonzero, file must be opened with baopen baopenr before calling this routine. (=0 to get index buffer from the grib file)
    [in]Jinteger number of fields to skip (=0 to search from beginning)
    [in]JDISCgrib2 discipline number of requested field (if = -1, accept any discipline see code table 0.0)
  • 0 meteorological products
  • 1 hydrological products
  • 2 land surface products
  • 3 space products
  • 10 oceanographic products
    Parameters
    [in]JIDSinteger array of values in the identification section (=-9999 for wildcard)
  • JIDS(1) identification of originating centre (see common code table c-1)
  • JIDS(2) identification of originating sub-centre
  • JIDS(3) grib master tables version number (see code table 1.0) 0 experimental;1 initial operational version number.
  • JIDS(4) grib local tables version number (see code table 1.1) 0 local tables not used; 1-254 number of local tables version used.
  • JIDS(5) significance of reference time (code table 1.2) 0 analysis; 1 start of forecast; 2 verifying time of forecast; 3 observation time
  • JIDS(6) year (4 digits)
  • JIDS(7) month
  • JIDS(8) day
  • JIDS(9) hour
  • JIDS(10) minute
  • JIDS(11) second
  • JIDS(12) production status of processed data (see code table 1.3) 0 operational products; 1 operational test products; 2 research products; 3 re-analysis products.
  • JIDS(13) type of processed data (see code table 1.4) 0 analysis products; 1 forecast products; 2 analysis and forecast products; 3 control forecast products; 4 perturbed forecast products; 5 control and perturbed forecast products; 6 processed satellite observations; 7 processed radar observations.
    Parameters
    [in]JPDTNinteger product definition template number (n) (if = -1, don't bother matching pdt - accept any)
    [in]JPDTinteger array of values defining the product definition template 4.n of the field for which to search (=-9999 for wildcard)
    [in]JGDTNinteger grid definition template number (m) (if = -1, don't bother matching gdt - accept any )
    [in]JGDTinteger array of values defining the grid definition template 3.m of the field for which to search (=-9999 for wildcard)
    [in]EXTRACTlogical value 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.
    Parameters
    [out]Kinteger field number unpacked.
    [out]GRIBMreturned grib message.
    [out]LENGlength of returned grib message in bytes.
    [out]IRETinteger return code
  • 0 all ok
  • 96 error reading index
  • 97 error reading grib file
  • 99 request not found
    Note
    specify an index file if feasible to increase speed. do not engage the same logical unit from more than one processor. Note that derived type gribfield contains pointers to many arrays of data. The memory for these arrays is allocated when the values in the arrays are set, to help minimize problems with array overloading. Because of this users are encouraged to free up this memory, when it is no longer needed, by an explicit call to subroutine gf_free.
    Author
    Mark Iredell
    Date
    1994-04-01

Definition at line 100 of file getgb2p.f.