NCEPLIBS-g2c  1.8.0
g2cinq.c File Reference

Inquiry functions. More...

#include "grib2_int.h"
#include <stdarg.h>

Go to the source code of this file.

Functions

 EXTERN_MUTEX (m)
 If pthreads are enabled, use externally-defined mutex for thread-safety. More...
 
int g2c_inq (int g2cid, int *num_msg)
 Learn about a GRIB2 file. More...
 
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. More...
 
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. More...
 
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. More...
 
int g2c_inq_prod (int g2cid, int msg_num, int prod_num, int *pds_template_len, int *pds_template, int *gds_template_len, int *gds_template, int *drs_template_len, int *drs_template)
 Inquire about a product. More...
 

Variables

G2C_FILE_INFO_T g2c_file [G2C_MAX_FILES+1]
 Global file information. More...
 

Detailed Description

Inquiry functions.

Author
Ed Hartnett
Date
10/21/22

Definition in file g2cinq.c.

Function Documentation

◆ EXTERN_MUTEX()

EXTERN_MUTEX ( )

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

◆ g2c_inq()

int g2c_inq ( int  g2cid,
int *  num_msg 
)

Learn about a GRIB2 file.

Parameters
g2cidID of the opened file, as from g2c_open().
num_msgPointer that gets the number of messages in the file. Ignored if NULL.
Returns
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.

◆ g2c_inq_dim()

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.

Parameters
g2cidID of the opened file, as from g2c_open().
msg_numNumber of the message in the file, starting with the first message as 0.
prod_numProduct number.
dim_numDimension number, with the first dimension as 0.
lenPointer that gets the length of this dimension. Ignored if NULL.
namePointer that gets the name of this dimension. Must have memory of size G2C_MAX_NAME. Ignored if NULL.
valPointer that gets array of dimension values, of length len. Ignored if NULL.
Returns
Author
Ed Hartnett
Date
10/21/22

Definition at line 328 of file g2cinq.c.

References G2C_EBADID, 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, 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.

◆ g2c_inq_msg()

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
g2cidID of the opened file, as from g2c_open().
msg_numNumber of the message in the file, starting with the first message as 0.
disciplinePointer that gets the discipline from the message. Ignored if NULL.
num_fieldsPointer that gets the number of fields in the message. Ignored if NULL.
num_localPointer that gets the number of local sections in the message. Ignored if NULL.
centerPointer that gets the code for the producing center from the message. Ignored if NULL.
subcenterPointer that gets the code for the producing subcenter from the message. Ignored if NULL.
master_versionPointer that gets the master version from the message. Ignored if NULL.
local_versionPointer that gets the local version from the message. Ignored if NULL.
Returns
Author
Ed Hartnett
Date
10/21/22

Definition at line 86 of file g2cinq.c.

References g2c_message_info::center, g2c_message_info::discipline, G2C_EBADID, G2C_ENOMSG, g2c_file, G2C_MAX_FILES, G2C_NOERROR, g2c_message_info::local_version, g2c_message_info::master_version, g2c_message_info::msg_num, g2c_message_info::next, g2c_message_info::num_fields, g2c_message_info::num_local, and g2c_message_info::subcenter.

◆ g2c_inq_msg_time()

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
g2cidID of the opened file, as from g2c_open().
msg_numNumber of the message in the file, starting with the first message as 0.
sig_ref_timePointer that gets Significane of reference time value from the message. Ignored if NULL.
yearPointer that gets the year from the message. Ignored if NULL.
monthPointer that gets the month from the message. Ignored if NULL.
dayPointer that gets the day from the message. Ignored if NULL.
hourPointer that gets the hour from the message. Ignored if NULL.
minutePointer that gets the minute from the message. Ignored if NULL.
secondPointer that gets the seconds from the message. Ignored if NULL.
Returns
Author
Ed Hartnett
Date
10/22/22

Definition at line 149 of file g2cinq.c.

References g2c_message_info::day, G2C_EBADID, 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, g2c_message_info::next, g2c_message_info::second, g2c_message_info::sig_ref_time, and g2c_message_info::year.

◆ g2c_inq_prod()

int g2c_inq_prod ( int  g2cid,
int  msg_num,
int  prod_num,
int *  pds_template_len,
int *  pds_template,
int *  gds_template_len,
int *  gds_template,
int *  drs_template_len,
int *  drs_template 
)

Inquire about a product.

Parameters
g2cidFile ID.
msg_numMessage number.
prod_numProduct number.
pds_template_lenPDS template length. Ignored if NULL.
pds_templateThe PDS template. Ignored if NULL.
gds_template_lenGDS template length. Ignored if NULL.
gds_templateThe GDS template. Ignored if NULL.
drs_template_lenThe DRS template length. Ignored if NULL.
drs_templateThe DRS template. Ignored if NULL.
Returns
Author
Ed Hartnett
Date
10/21/22

Definition at line 207 of file g2cinq.c.

References G2C_EBADID, 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

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().