---
name: "g2_addlocal.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_addlocal.c"
---

# g2\_addlocal.c(3)

Add a Local Use Section (Section 2) to a GRIB2 message.

## NAME

g2\_addlocal.c - Add a Local Use Section (Section 2) to a GRIB2 message.

## SYNOPSIS

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

### Functions

**g2int** **g2\_addlocal** (unsigned char \*cgrib, unsigned char \*csec2, **g2int** lcsec2)\
 Adds a `Local Use Section (Section 2)` to a GRIB2 message.

## Detailed Description

Add a Local Use Section (Section 2) to a GRIB2 message.

**Author**

Stephen Gilbeert

**Date**

2002-11-01

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

## Function Documentation

### g2int g2\_addlocal (unsigned char \* cgrib, unsigned char \* csec2, g2int lcsec2)

Adds a `Local Use Section (Section 2)` to a GRIB2 message. This function is used with routines **g2\_create()**, **g2\_addgrid()**, **g2\_addfield()**, and **g2\_gribend()** to create a complete GRIB2 message.

**Parameters**

*cgrib* Char array that contains the GRIB2 message to which section 2 should be added. Must be allocated large enough to store the entire GRIB2 message. \
 *csec2* Character array containing information to be added in Section 2. \
 *lcsec2* Number of bytes of character array csec2 to be added to Section 2.

**Returns**

\> 0 = Current size of updated GRIB2 message.

- •

  **G2\_ADD\_MSG\_INIT** GRIB message was not initialized. Need to call routine gribcreate first.

- •

  **G2\_ADD\_MSG\_COMPLETE** GRIB message already complete. Cannot add new section.

- •

  **G2\_BAD\_SEC\_COUNTS** Sum of Section byte counts doesn't add to total byte count.

- •

  **G2\_BAD\_SEC** Previous Section was not 1 or 7.

**Note**

The Local Use Section (Section 2) can only follow Section 1 or Section 7 in a GRIB2 message.

**Author**

Stephen Gilbeert

**Date**

2002-11-01

Definition at line **41** of file **g2\_addlocal.c**.

References **G2\_ADD\_MSG\_COMPLETE**, **G2\_ADD\_MSG\_INIT**, **G2\_BAD\_SEC**, **G2\_BAD\_SEC\_COUNTS**, **g2c\_check\_msg()**, **G2C\_EMSGCOMPLETE**, **G2C\_ENOTGRIB**, **gbit()**, and **sbit()**.

## Author

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