NCEPLIBS-g2c  1.8.0
g2cdegrib2.c File Reference

Write summary output to a file, as is done by utility grb2index. More...

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

Go to the source code of this file.

Macros

#define G2C_DATE_TIME_LEN   25
 Size of the date/time string. More...
 
#define G2C_MAX_TYPE_OF_FIXED_SURFACE_LEN   40
 Maximum length of "Type of first fixed surface" string. More...
 

Functions

static int format_level (char *cbuf, int ival, int scale)
 Format the level string for degrib2 output. More...
 
int g2c_degrib2 (int g2cid, const char *fileout)
 Write a summary file like the degrib2 utility. More...
 
int g2c_get_datetime (int ipdtn, long long int *ipdtmpl, short year, unsigned char month, unsigned char day, unsigned char hour, unsigned char minute, unsigned char second, char *tabbrev)
 Convert date and time from GRIB2 info to string output. More...
 
int g2c_get_level_desc (int ipdtn, long long int *ipdtmpl, char *level_desc)
 Determine the string that describes the level information, given the GRIB2 Product Definition Template information. More...
 

Variables

G2C_FILE_INFO_T g2c_file [G2C_MAX_FILES+1]
 Global file information. More...
 
G2C_CODE_TABLE_Tg2c_table
 Pointer to the list of code tables. More...
 

Detailed Description

Write summary output to a file, as is done by utility grb2index.

Author
Ed Hartnett
Date
Sep 17, 2022

Definition in file g2cdegrib2.c.

Macro Definition Documentation

◆ G2C_DATE_TIME_LEN

#define G2C_DATE_TIME_LEN   25

Size of the date/time string.

Definition at line 21 of file g2cdegrib2.c.

◆ G2C_MAX_TYPE_OF_FIXED_SURFACE_LEN

#define G2C_MAX_TYPE_OF_FIXED_SURFACE_LEN   40

Maximum length of "Type of first fixed surface" string.

Definition at line 19 of file g2cdegrib2.c.

Function Documentation

◆ format_level()

static int format_level ( char *  cbuf,
int  ival,
int  scale 
)
static

Format the level string for degrib2 output.

Parameters
cbufCharacter buffer of length 11 which will get the formatted level description.
ivalInteger value which may need scaling.
scaleScaling factor information.
Returns
Author
Ed Hartnett
Date
11/16/22

Definition at line 256 of file g2cdegrib2.c.

References G2C_NOERROR.

Referenced by g2c_get_level_desc().

◆ g2c_degrib2()

int g2c_degrib2 ( int  g2cid,
const char *  fileout 
)

Write a summary file like the degrib2 utility.

Parameters
g2cidIndentifier for the file, returned by g2c_open() or g2c_create().
fileoutPath of output file. Any existing file of this name will be overwritten.
Returns
Author
Ed Hartnett
Date
Sep 17, 2022

Definition at line 637 of file g2cdegrib2.c.

References g2c_message_info::bytes_in_msg, g2c_message_info::bytes_to_msg, g2c_message_info::center, g2c_section5_info::data_def, g2c_message_info::day, g2c_message_info::discipline, G2C_EBADID, G2C_EFILE, G2C_EINVAL, G2C_ENOSECTION, G2C_ERROR, g2c_file, g2c_get_datetime(), g2c_get_level_desc(), g2c_get_prod(), G2C_MAX_FILES, G2C_MAX_NOAA_ABBREV_LEN, G2C_MAX_TYPE_OF_FIXED_SURFACE_LEN, G2C_NOERROR, g2c_param_abbrev(), g2c_section3_info::grid_def, g2c_message_info::hour, g2c_section6_info::indicator, g2c_section3_info::interp_list, g2c_message_info::local_version, LOG, g2c_message_info::master_version, g2c_message_info::minute, g2c_message_info::month, g2c_section_info::msg, g2c_message_info::msg_num, g2c_message_info::next, g2c_section_info::next, g2c_section4_info::num_coord, g2c_section3_info::num_data_points, g2c_section5_info::num_data_points, g2c_message_info::num_fields, g2c_message_info::num_local, g2c_section3_info::num_opt, g2c_section3_info::optional, g2c_section_info::prev, g2c_section4_info::prod_def, g2c_message_info::sec, g2c_section_info::sec_info, g2c_section_info::sec_len, g2c_section_info::sec_num, g2c_message_info::second, g2c_message_info::sig_ref_time, g2c_section3_info::source_grid_def, g2c_message_info::status, g2c_message_info::subcenter, g2c_section_info::template, g2c_section_info::template_len, g2c_message_info::type, and g2c_message_info::year.

Referenced by main().

◆ g2c_get_datetime()

int g2c_get_datetime ( int  ipdtn,
long long int *  ipdtmpl,
short  year,
unsigned char  month,
unsigned char  day,
unsigned char  hour,
unsigned char  minute,
unsigned char  second,
char *  tabbrev 
)

Convert date and time from GRIB2 info to string output.

Note
This function is based on the prvtime() function in NCEPLIBS-grib_utils.
Parameters
[in]ipdtnProduct Definition Template Number (Code Table 4.0).
ipdtmplArray of data values for the Product Definition Template specified by ipdtn.
yearyear
monthmonth
dayday
hourhour
minuteminute
secondsecond
tabbrevCharacter array that will get the date and time string. Must be of length 100.
Returns
Author
Ed Hartnett
Date
Sep 28, 2022

Definition at line 49 of file g2cdegrib2.c.

References G2C_DATE_TIME_LEN, and G2C_NOERROR.

Referenced by g2c_degrib2().

◆ g2c_get_level_desc()

int g2c_get_level_desc ( int  ipdtn,
long long int *  ipdtmpl,
char *  level_desc 
)

Determine the string that describes the level information, given the GRIB2 Product Definition Template information.

This subroutine finds the "Type of first fixed surface" (see [Code table 4.5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-0.shtml)) using the product definition template value and product template array. The location in the template array varies depending on the template number.

Parameters
ipdtnProduct Definition Template Number (Code Table 4.0).
ipdtmplArray of data values for the Product Definition Template specified by ipdtn.
level_descCharacter array which gets the string describing the level. Must be of length 40.
Returns
Author
Ed Hartnett
Date
Sep 28, 2022

Definition at line 312 of file g2cdegrib2.c.

References format_level(), and G2C_NOERROR.

Referenced by g2c_degrib2().

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

◆ g2c_table

G2C_CODE_TABLE_T* g2c_table
extern

Pointer to the list of code tables.

Definition at line 15 of file g2cxml.c.