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

# simpack.c(3)

Pack a data field using the simple packing algorithm.

## NAME

simpack.c - Pack a data field using the simple packing algorithm.

## SYNOPSIS

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

### Functions

void **simpack** (float \*fld, **g2int** ndpts, **g2int** \*idrstmpl, unsigned char \*cpack, **g2int** \*lcpack)\
 Packs a data field using the simple packing algorithm.

## Detailed Description

Pack a data field using the simple packing algorithm.

**Author**

Stephen Gilbert

**Date**

2002-11-06

Definition in file **simpack.c**.

## Function Documentation

### void simpack (float \* fld, g2int ndpts, g2int \* idrstmpl, unsigned char \* cpack, g2int \* lcpack)

Packs a data field using the simple packing algorithm. This function also fills in GRIB2 Data Representation Template 5.0 with the appropriate values.

**Parameters**

*fld* Contains the data values to pack. \
 *ndpts* The number of data values in array fld. \
 *idrstmpl* Contains the array of values for \[Data Representation Template 5.0\](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2\_doc/grib2\_temp5-0.shtml).

- •

  0 Reference value - ignored on input - set by simpack routine.

- •

  1 Binary Scale Factor - unchanged from input.

- •

  2 Decimal Scale Factor - unchanged from input.

- •

  3 Number of bits used to pack data, if value is \> 0 and \<= 31. If this input value is 0 or outside above range then the num of bits is calculated based on given data and scale factors.

- •

  4 Original field type - currently ignored on input. Data values assumed to be reals. Set to 0 by simpack routine.

*cpack* The packed data field \
 *lcpack* length of packed field starting at cpack.

**Author**

Stephen Gilbert

**Date**

2002-11-06

Definition at line **36** of file **simpack.c**.

References **ALOG2**, **int\_power()**, **LOG**, **mkieee()**, **sbit()**, and **sbits()**.

Referenced by **g2\_addfield()**, and **specpack()**.

## Author

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