---
name: "g2_info.c"
section: "3"
platform: "linux"
package: "libg2c-dev"
version: "2.1.0-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/g2_info.c"
---

# g2\_info.c(3)

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.

## NAME

g2\_info.c - 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.

## SYNOPSIS

`#include 'grib2_int.h'`\
 `#include <stdio.h>`\
 `#include <stdlib.h>`\

### Functions

**g2int** **g2\_info** (unsigned char \*cgrib, **g2int** \*listsec0, **g2int** \*listsec1, **g2int** \*numfields, **g2int** \*numlocal)\
 Search through a GRIB2 message and return the number of gridded fields found in the message and the number (and maximum size) of Local Use Sections.

## 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

### g2int g2\_info (unsigned char \* cgrib, g2int \* listsec0, g2int \* listsec1, g2int \* numfields, g2int \* numlocal)

Search through a GRIB2 message and return the number of gridded fields found in the message and the number (and maximum size) of Local Use Sections. Other checks are performed to see if the message is a valid GRIB2 message.

**Parameters**

*cgrib* Pointer to a buffer containing the GRIB2 message. \
 *listsec0* Pointer 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\] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2\_doc/grib2\_table0-0.shtml)).

- •

  listsec0\[1\] GRIB Edition Number (currently 2).

- •

  listsec0\[2\] Length of GRIB message.

*listsec1* Pointer 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\] (https://www.nco.ncep.noaa.gov/pmb/docs/on388/table0.html)).

- •

  listsec1\[1\] Id of orginating sub-centre (\[Table C\] (https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablec.html)).

- •

  listsec1\[2\] GRIB Master Tables Version Number (\[Table 1.0\] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2\_doc/grib2\_table1-0.shtml)).

- •

  listsec1\[3\] GRIB Local Tables Version Number (\[Table 1.1\] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2\_doc/grib2\_table1-1.shtml)).

- •

  listsec1\[4\] Significance of Reference Time (\[Table 1.2\] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2\_doc/grib2\_table1-1.shtml))

- •

  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\] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2\_doc/grib2\_table1-3.shtml)).

- •

  listsec1\[12\] Type of processed data (\[Table 1.4\] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2\_doc/grib2\_table1-4.shtml)).

*numfields* A pointer that gets the number of gridded fields found in the GRIB message. That is, the number of occurences of Sections 4 - 7. \
 *numlocal* A pointer that gets the number of Local Use Sections (section 2) found in the GRIB message.

**Returns**

0 for success, otherwise:

- •

  **G2\_INFO\_NO\_GRIB** Beginning characters 'GRIB' not found.

- •

  **G2\_INFO\_GRIB\_VERSION** GRIB message is not Edition 2.

- •

  **G2\_INFO\_NO\_SEC1** Could not find Section 1, where expected.

- •

  **G2\_INFO\_WRONG\_END** End string '7777' found, but not where expected.

- •

  **G2\_INFO\_BAD\_END** End string '7777' not found at end of message.

- •

  **G2\_INFO\_INVAL\_SEC** Invalid section number found.

**Author**

Stephen Gilbeert

**Date**

2002-10-28

Definition at line **70** 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**.

## Author

Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.
