NCEPLIBS-g2  3.4.7
ixgb2.F90 File Reference

Generate an index record for each field in a GRIB2 message. More...

Go to the source code of this file.

Functions/Subroutines

subroutine ixgb2 (LUGB, LSKIP, LGRIB, CBUF, NUMFLD, MLEN, IRET)
 Generate an index record for each field in a GRIB2 message. More...
 

Detailed Description

Generate an index record for each field in a GRIB2 message.

Author
Mark Iredell
Date
1995-10-31

Definition in file ixgb2.F90.

Function/Subroutine Documentation

◆ ixgb2()

subroutine ixgb2 ( integer  LUGB,
integer  LSKIP,
integer  LGRIB,
character(len = 1), dimension(:), pointer  CBUF,
integer  NUMFLD,
integer  MLEN,
integer  IRET 
)

Generate an index record for each field in a GRIB2 message.

The index records are written to index buffer pointed to by cbuf. All integers in the index are in big-endian format.

This subroutine is called by getg2ir(), which packages the index records into an index file.

The index buffer returned contains index records with the format:

  • byte 001 - 004 length of index record
  • byte 005 - 008 bytes to skip in data file before GRIB message
  • byte 009 - 012 bytes to skip in message before lus (local use) set = 0, if no local section.
  • byte 013 - 016 bytes to skip in message before gds
  • byte 017 - 020 bytes to skip in message before pds
  • byte 021 - 024 bytes to skip in message before drs
  • byte 025 - 028 bytes to skip in message before bms
  • byte 029 - 032 bytes to skip in message before data section
  • byte 033 - 040 bytes total in the message
  • byte 041 - 041 GRIB version number (2)
  • byte 042 - 042 message discipline
  • byte 043 - 044 field number within GRIB2 message
  • byte 045 - ii identification section (ids)
  • byte ii + 1- jj grid definition section (gds)
  • byte jj + 1- kk product definition section (pds)
  • byte kk + 1- ll the data representation section (drs)
  • byte ll + 1-ll + 6 first 6 bytes of the bit map section (bms)
Parameters
[in]lugbUnit of the unblocked GRIB file. Must be opened by baopen() or baopenr().
[in]lskipNumber of bytes to skip before GRIB message.
[in]lgribNumber of bytes in GRIB message. When subroutine is called, this must be set to the size of the cbuf buffer.
[out]cbufPointer to a buffer that will get the index records. If any memory is associated with cbuf when this subroutine is called, cbuf will be nullified in the subroutine. Initially cbuf will get an allocation of 5000 bytes. realloc() will be used to increase the size if necessary. Users must free memory that cbuf points to when cbuf is no longer needed.
[out]numfldNumber of index records created.
[out]mlenTotal length of all index records.
[out]iretReturn code
  • 0 No error
  • 1 Not enough memory available to hold full index buffer.
  • 2 I/O error in read.
  • 3 GRIB message is not edition 2.
  • 4 Not enough memory to allocate extent to index buffer.
  • 5 Unidentified GRIB section encountered.
Author
Mark Iredell
Date
1995-10-31

Definition at line 55 of file ixgb2.F90.

References g2_gbytec(), and g2_sbytec().

Referenced by getg2ir().