NCEPLIBS-g2c  1.8.0
g2_info.c File Reference

Search through a GRIB2 message and returns the number of gridded fields found in the message and the number (and maximum size) of Local Use Sections. More...

#include <stdio.h>
#include <stdlib.h>
#include "grib2_int.h"

Go to the source code of this file.

Functions

g2int g2_info (unsigned char *cgrib, g2int *listsec0, g2int *listsec1, g2int *numfields, g2int *numlocal)
 This subroutine searches through a GRIB2 message and returns the number of gridded fields found in the message and the number (and maximum size) of Local Use Sections. More...
 

Detailed Description

Search through a GRIB2 message and returns the number of gridded fields found in the message and the number (and maximum size) of Local Use Sections.

Author
Stephen Gilbeert
Date
2002-10-28

Definition in file g2_info.c.

Function Documentation

◆ g2_info()

g2int g2_info ( unsigned char *  cgrib,
g2int listsec0,
g2int listsec1,
g2int numfields,
g2int numlocal 
)

This subroutine searches through a GRIB2 message and returns the number of gridded fields found in the message and the number (and maximum size) of Local Use Sections.

Also various checks are performed to see if the message is a valid GRIB2 message.

Parameters
cgribPointer to a buffer containing the GRIB2 message.
listsec0Pointer to an array that gets the information decoded from GRIB Indicator Section 0. Must be allocated with >= 3 elements (see G2C_SECTION0_LEN).
  • listsec0(0) Discipline-GRIB Master Table Number (Code Table 0.0).
  • listsec0[1] GRIB Edition Number (currently 2).
  • listsec0[2] Length of GRIB message.
listsec1Pointer to an array that gets the information read from GRIB Identification Section 1. Must be allocated with >= 13 elements (see G2C_SECTION1_LEN).
  • listsec1[0] Id of orginating centre (Table 0).
  • listsec1[1] Id of orginating sub-centre (Table C).
  • listsec1[2] GRIB Master Tables Version Number (Table 1.0).
  • listsec1[3] GRIB Local Tables Version Number (Table 1.1).
  • listsec1[4] Significance of Reference Time (Table 1.2)
  • listsec1[5] Reference Time - Year (4 digits)
  • listsec1[6] Reference Time - Month
  • listsec1[7] Reference Time - Day
  • listsec1[8] Reference Time - Hour
  • listsec1[9] Reference Time - Minute
  • listsec1[10] Reference Time - Second
  • listsec1[11] Production status of data (Table 1.3).
  • listsec1[12] Type of processed data (Table 1.4).
numfieldsA pointer that gets the number of gridded fields found in the GRIB message. That is, the number of occurences of Sections 4 - 7.
numlocalA pointer that gets the number of Local Use Sections (section 2) found in the GRIB message.
Returns
0 for success, otherwise:
Author
Stephen Gilbeert
Date
2002-10-28

Definition at line 68 of file g2_info.c.

References G2_INFO_BAD_END, G2_INFO_GRIB_VERSION, G2_INFO_INVAL_SEC, G2_INFO_NO_GRIB, G2_INFO_NO_SEC1, G2_INFO_WRONG_END, gbit(), and LOG.