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

# g2cinq.c(3)

Inquiry functions.

## NAME

g2cinq.c - Inquiry functions.

## SYNOPSIS

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

### Functions

**EXTERN\_MUTEX** (m)\
 If pthreads are enabled, use externally-defined mutex for thread-safety.  int **g2c\_inq** (int g2cid, int \*num\_msg)\
 Learn about a GRIB2 file.  int **g2c\_inq\_dim** (int g2cid, int msg\_num, int prod\_num, int dim\_num, size\_t \*len, char \*name, float \*val)\
 Learn about the one of the dimensions of a GRIB2 product.  int **g2c\_inq\_dim\_info** (int g2cid, int msg\_num, int prod\_num, int dim\_num, size\_t \*len, char \*name)\
 Learn about the one of the dimensions of a GRIB2 product.  int **g2c\_inq\_msg** (int g2cid, int msg\_num, unsigned char \*discipline, int \*num\_fields, int \*num\_local, short \*center, short \*subcenter, unsigned char \*master\_version, unsigned char \*local\_version)\
 Learn about a GRIB2 message.  int **g2c\_inq\_msg\_time** (int g2cid, int msg\_num, unsigned char \*sig\_ref\_time, short \*year, unsigned char \*month, unsigned char \*day, unsigned char \*hour, unsigned char \*minute, unsigned char \*second)\
 Learn about the date/time information in a GRIB2 message.  int **g2c\_inq\_prod** (int g2cid, int msg\_num, int prod\_num, int \*pds\_template\_len, long long int \*pds\_template, int \*gds\_template\_len, long long int \*gds\_template, int \*drs\_template\_len, long long int \*drs\_template)\
 Inquire about a product.

### Variables

**G2C\_FILE\_INFO\_T** **g2c\_file** \[**G2C\_MAX\_FILES**+1\]\
 Global file information.

## Detailed Description

Inquiry functions.

**Author**

Ed Hartnett

**Date**

10/21/22

Definition in file **g2cinq.c**.

## Function Documentation

### EXTERN\_MUTEX (m)

If pthreads are enabled, use externally-defined mutex for thread-safety.

### int g2c\_inq (int g2cid, int \* num\_msg)

Learn about a GRIB2 file.

**Parameters**

*g2cid* ID of the opened file, as from **g2c\_open()**. \
 *num\_msg* Pointer that gets the number of messages in the file. Ignored if NULL.

**Returns**

- •

  **G2C\_NOERROR** No error.

- •

  **G2C\_EBADID** File ID not found.

**Author**

Ed Hartnett

**Date**

10/21/22

Definition at line **31** of file **g2cinq.c**.

References **G2C\_EBADID**, **g2c\_file**, **G2C\_MAX\_FILES**, **G2C\_NOERROR**, **MUTEX\_LOCK**, **MUTEX\_UNLOCK**, and **g2c\_file\_info::num\_messages**.

### int g2c\_inq\_dim (int g2cid, int msg\_num, int prod\_num, int dim\_num, size\_t \* len, char \* name, float \* val)

Learn about the one of the dimensions of a GRIB2 product. This function will return the size, name, and values along the dimension.

**Parameters**

*g2cid* ID of the opened file, as from **g2c\_open()**. \
 *msg\_num* Number of the message in the file, starting with the first message as 0. \
 *prod\_num* Product number. \
 *dim\_num* Dimension number, with the first dimension as 0. \
 *len* Pointer that gets the length of this dimension. Ignored if NULL. \
 *name* Pointer that gets the name of this dimension. Must have memory of size G2C\_MAX\_NAME. Ignored if NULL. \
 *val* Pointer that gets array of dimension values, of length len. Ignored if NULL.

**Returns**

- •

  **G2C\_NOERROR** No error.

- •

  **G2C\_EBADID** File ID not found.

- •

  **G2C\_ENOMSG** Message not found.

- •

  **G2C\_ENOPRODUCT** Product not found.

- •

  **G2C\_ENOSECTION** GDS not found.

**Author**

Ed Hartnett

**Date**

10/21/22

Definition at line **372** of file **g2cinq.c**.

References **G2C\_EBADID**, **G2C\_EINVAL**, **G2C\_ENOMSG**, **G2C\_ENOPRODUCT**, **G2C\_ENOSECTION**, **g2c\_file**, **G2C\_MAX\_FILES**, **G2C\_MAX\_NAME**, **G2C\_NOERROR**, **g2c\_dim\_info::len**, **g2c\_message\_info::msg\_num**, **MUTEX\_LOCK**, **MUTEX\_UNLOCK**, **g2c\_dim\_info::name**, **g2c\_message\_info::next**, **g2c\_section\_info::next**, **g2c\_section\_info::prev**, **g2c\_message\_info::sec**, **g2c\_section\_info::sec\_info**, **g2c\_section\_info::sec\_num**, and **g2c\_dim\_info::value**.

Referenced by **g2c\_inq\_dim\_info()**.

### int g2c\_inq\_dim\_info (int g2cid, int msg\_num, int prod\_num, int dim\_num, size\_t \* len, char \* name)

Learn about the one of the dimensions of a GRIB2 product. This function will return the size and name of the dimension.

**Parameters**

*g2cid* ID of the opened file, as from **g2c\_open()**. \
 *msg\_num* Number of the message in the file, starting with the first message as 0. \
 *prod\_num* Product number. \
 *dim\_num* Dimension number, with the first dimension as 0. \
 *len* Pointer that gets the length of this dimension. Ignored if NULL. \
 *name* Pointer that gets the name of this dimension. Must have memory of size G2C\_MAX\_NAME. Ignored if NULL.

**Returns**

- •

  **G2C\_NOERROR** No error.

- •

  **G2C\_EBADID** File ID not found.

- •

  **G2C\_ENOMSG** Message not found.

- •

  **G2C\_ENOPRODUCT** Product not found.

- •

  **G2C\_ENOSECTION** GDS not found.

**Author**

Ed Hartnett

**Date**

10/21/22

Definition at line **468** of file **g2cinq.c**.

References **g2c\_inq\_dim()**.

### int g2c\_inq\_msg (int g2cid, int msg\_num, unsigned char \* discipline, int \* num\_fields, int \* num\_local, short \* center, short \* subcenter, unsigned char \* master\_version, unsigned char \* local\_version)

Learn about a GRIB2 message.

**Parameters**

*g2cid* ID of the opened file, as from **g2c\_open()**. \
 *msg\_num* Number of the message in the file, starting with the first message as 0. \
 *discipline* Pointer that gets the discipline from the message. Ignored if NULL. \
 *num\_fields* Pointer that gets the number of fields in the message. Ignored if NULL. \
 *num\_local* Pointer that gets the number of local sections in the message. Ignored if NULL. \
 *center* Pointer that gets the code for the producing center from the message. Ignored if NULL. \
 *subcenter* Pointer that gets the code for the producing subcenter from the message. Ignored if NULL. \
 *master\_version* Pointer that gets the master version from the message. Ignored if NULL. \
 *local\_version* Pointer that gets the local version from the message. Ignored if NULL.

**Returns**

- •

  **G2C\_NOERROR** No error.

- •

  **G2C\_EBADID** File ID not found.

- •

  **G2C\_ENOMSG** Message not found.

**Author**

Ed Hartnett

**Date**

10/21/22

Definition at line **87** of file **g2cinq.c**.

References **g2c\_message\_info::center**, **g2c\_message\_info::discipline**, **G2C\_EBADID**, **G2C\_EINVAL**, **G2C\_ENOMSG**, **g2c\_file**, **G2C\_MAX\_FILES**, **G2C\_NOERROR**, **g2c\_message\_info::local\_version**, **g2c\_message\_info::master\_version**, **g2c\_message\_info::msg\_num**, **MUTEX\_LOCK**, **MUTEX\_UNLOCK**, **g2c\_message\_info::next**, **g2c\_message\_info::num\_fields**, **g2c\_message\_info::num\_local**, and **g2c\_message\_info::subcenter**.

### int g2c\_inq\_msg\_time (int g2cid, int msg\_num, unsigned char \* sig\_ref\_time, short \* year, unsigned char \* month, unsigned char \* day, unsigned char \* hour, unsigned char \* minute, unsigned char \* second)

Learn about the date/time information in a GRIB2 message.

**Parameters**

*g2cid* ID of the opened file, as from **g2c\_open()**. \
 *msg\_num* Number of the message in the file, starting with the first message as 0. \
 *sig\_ref\_time* Pointer that gets Significane of reference time value from the message. Ignored if NULL. \
 *year* Pointer that gets the year from the message. Ignored if NULL. \
 *month* Pointer that gets the month from the message. Ignored if NULL. \
 *day* Pointer that gets the day from the message. Ignored if NULL. \
 *hour* Pointer that gets the hour from the message. Ignored if NULL. \
 *minute* Pointer that gets the minute from the message. Ignored if NULL. \
 *second* Pointer that gets the seconds from the message. Ignored if NULL.

**Returns**

- •

  **G2C\_NOERROR** No error.

- •

  **G2C\_EBADID** File ID not found.

- •

  **G2C\_ENOMSG** Message not found.

**Author**

Ed Hartnett

**Date**

10/22/22

Definition at line **170** of file **g2cinq.c**.

References **g2c\_message\_info::day**, **G2C\_EBADID**, **G2C\_EINVAL**, **G2C\_ENOMSG**, **g2c\_file**, **G2C\_MAX\_FILES**, **G2C\_NOERROR**, **g2c\_message\_info::hour**, **g2c\_message\_info::minute**, **g2c\_message\_info::month**, **g2c\_message\_info::msg\_num**, **MUTEX\_LOCK**, **MUTEX\_UNLOCK**, **g2c\_message\_info::next**, **g2c\_message\_info::second**, **g2c\_message\_info::sig\_ref\_time**, and **g2c\_message\_info::year**.

### int g2c\_inq\_prod (int g2cid, int msg\_num, int prod\_num, int \* pds\_template\_len, long long int \* pds\_template, int \* gds\_template\_len, long long int \* gds\_template, int \* drs\_template\_len, long long int \* drs\_template)

Inquire about a product.

**Parameters**

*g2cid* File ID. \
 *msg\_num* Message number. \
 *prod\_num* Product number. \
 *pds\_template\_len* PDS template length. Ignored if NULL. \
 *pds\_template* Pointer that gets the PDS template. Ignored if NULL. \
 *gds\_template\_len* GDS template length. Ignored if NULL. \
 *gds\_template* Pointer that gets the GDS template. Ignored if NULL. \
 *drs\_template\_len* The DRS template length. Ignored if NULL. \
 *drs\_template* Pointer that gets the DRS template. Ignored if NULL.

**Returns**

- •

  **G2C\_NOERROR** No error.

- •

  **G2C\_EBADID** File ID not found.

- •

  **G2C\_ENOMSG** Message not found.

- •

  **G2C\_ENOPRODUCT** Product not found.

- •

  **G2C\_ENOSECTION** Section not found.

**Author**

Ed Hartnett

**Date**

10/21/22

Definition at line **247** of file **g2cinq.c**.

References **G2C\_EBADID**, **G2C\_EINVAL**, **G2C\_ENOMSG**, **G2C\_ENOPRODUCT**, **G2C\_ENOSECTION**, **g2c\_file**, **G2C\_MAX\_FILES**, **G2C\_NOERROR**, **g2c\_message\_info::msg\_num**, **MUTEX\_LOCK**, **MUTEX\_UNLOCK**, **g2c\_message\_info::next**, **g2c\_section\_info::next**, **g2c\_section\_info::prev**, **g2c\_message\_info::sec**, **g2c\_section\_info::sec\_info**, **g2c\_section\_info::sec\_num**, **g2c\_section\_info::template**, and **g2c\_section\_info::template\_len**.

## Variable Documentation

### G2C\_FILE\_INFO\_T g2c\_file\[G2C\_MAX\_FILES+1\]` [extern]`

Global file information.

Definition at line **10** of file **g2cfile.c**.

Referenced by **g2c\_inq()**, **g2c\_inq\_dim()**, **g2c\_inq\_msg()**, **g2c\_inq\_msg\_time()**, and **g2c\_inq\_prod()**.

## Author

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