---
name: "g2_unpack3.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_unpack3.c"
---

# g2\_unpack3.c(3)

Unpack Section 3 (Grid Definition Section) of a GRIB2 message.

## NAME

g2\_unpack3.c - Unpack Section 3 (Grid Definition Section) of a GRIB2 message.

## SYNOPSIS

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

### Functions

**g2int** **g2\_unpack3** (unsigned char \*cgrib, **g2int** \*iofst, **g2int** \*\*igds, **g2int** \*\*igdstmpl, **g2int** \*mapgridlen, **g2int** \*\*ideflist, **g2int** \*idefnum)\
 Unpack `Section 3 (Grid Definition Section)` of a GRIB2 message.

## Detailed Description

Unpack Section 3 (Grid Definition Section) of a GRIB2 message.

**Author**

Stephen Gilbert

**Date**

2002-10-31

Definition in file **g2\_unpack3.c**.

## Function Documentation

### g2int g2\_unpack3 (unsigned char \* cgrib, g2int \* iofst, g2int \*\* igds, g2int \*\* igdstmpl, g2int \* mapgridlen, g2int \*\* ideflist, g2int \* idefnum)

Unpack `Section 3 (Grid Definition Section)` of a GRIB2 message.

### Program History Log

Date   Programmer   Comments    2002-10-31   Gilbert   Initial    2009-01-14   Vuong   Changed structure name template to gtemplate

**Parameters**

*cgrib* Char array ontaining Section 3 of the GRIB2 message. \
 *iofst* Pointer to g2int which contains the bit offset for the beginning of Section 3 in cgrib. \
 *igds* Pointer to a pointer which will get a pointer to memory allocated for the GDS array, of length 5. The array will contain information read from the appropriate GRIB Grid Definition Section 3 for the field being returned.

- •

  igds\[0\] Source of grid definition (see `Table 3.0`).

- •

  igds\[1\] Number of grid points in the defined grid.

- •

  igds\[2\] Number of octets needed for each additional grid points definition. Used to define number of points in each row (or column) for non-regular grids. = 0, if using regular grid.

- •

  igds\[3\] Interpretation of list for optional points definition. (See `Table 3.11`)

- •

  igds\[4\] Grid Definition Template Number (see `Table 3.1`).

*igdstmpl* Pointer a pointer to g2int, which will get a pointer to an allocated array that contians containing the data values from the Grid Definition Template specified by igds\[4\]. \
 *mapgridlen* A pointer tat gets the number of elements in igdstmpl. i.e. number of entries in Grid Defintion Template specified by igds\[4\]. \
 *ideflist* (Used if igds\[2\] .ne. 0) Pointer to integer array containing the number of grid points contained in each row (or column). \
 *idefnum* (Used if igds\[2\] != 0.) A pointer that gets the number of entries in array ideflist - i.e. number of rows (or columns) for which optional grid points are defined.

**Returns**

- •

  **G2\_NO\_ERROR** No error.

- •

  **G2\_UNPACK\_BAD\_SEC** Array passed had incorrect section number.

- •

  **G2\_UNPACK3\_BAD\_GDT** message contains an undefined Grid Definition Template.

- •

  **G2\_UNPACK\_NO\_MEM** Memory allocation error.

**Author**

Stephen Gilbert

**Date**

2002-10-31

Definition at line **62** of file **g2\_unpack3.c**.

References **gtemplate::ext**, **extgridtemplate()**, **gtemplate::extlen**, **G2\_NO\_ERROR**, **G2\_UNPACK3\_BAD\_GDT**, **G2\_UNPACK\_BAD\_SEC**, **G2\_UNPACK\_NO\_MEM**, **gbit()**, **gbits()**, **getgridtemplate()**, **gtemplate::map**, **gtemplate::maplen**, and **gtemplate::needext**.

Referenced by **g2\_getfld()**, **getdim()**, and **getpoly()**.

## Author

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