Man page - add_msg(3)
Packages contains this manual
- g2c_get_drs_template(3)
- sbits(3)
- cmplxpack(3)
- g2_unpack4.c(3)
- g2_info.c(3)
- reduce(3)
- g2c_get_msg(3)
- specpack(3)
- g2intu(3)
- int_power.c(3)
- bytes_to_bms(3)
- g2c_file_io_byte(3)
- dimid(3)
- idrtnum(3)
- g2ccsv.c(3)
- g2c_pngpackd(3)
- g2c_file_io(3)
- decenc_png.c(3)
- g2_miss.c(3)
- file(3)
- g2c_open_index1(3)
- g2_unpack2(3)
- g2int(3)
- pngunpack(3)
- specpack.c(3)
- g2cutil.c(3)
- g2c_rw_section6_metadata(3)
- g2_addgrid(3)
- g2c_next_g2cid(3)
- sec_len(3)
- g2c_inq_dim(3)
- jpcunpack.c(3)
- png_stream(3)
- maplen(3)
- minute(3)
- subcenter(3)
- g2c_inq(3)
- g2_unpack5.c(3)
- g2c_file_io_template(3)
- dec_aec(3)
- griddef(3)
- num_opt(3)
- g2num(3)
- decenc_openjpeg.c(3)
- g2c_file_io_ubyte(3)
- map(3)
- bytes_to_msg(3)
- g1num(3)
- jpcunpack_int(3)
- g2c_aecunpackd(3)
- num_local(3)
- pngpack_int(3)
- read_hdr_rec2(3)
- g2_addfield(3)
- aecpack.c(3)
- section_number(3)
- status(3)
- bytes_to_sec(3)
- g2_addfield.c(3)
- drstemplates.c(3)
- year(3)
- g2c_degrib2(3)
- g2_create.c(3)
- misspack(3)
- version(3)
- enc_aec(3)
- g2c_dec_jpeg2000(3)
- g2c_enc_jpeg2000(3)
- extgridtemplate(3)
- next(3)
- section_offset(3)
- g2c_open(3)
- read_msg_metadata(3)
- num_data_points(3)
- unpacked(3)
- jpcpack(3)
- igdtnum(3)
- g2_gribend(3)
- bytes_in_msg(3)
- g2c_file_io_ulonglong(3)
- discipline(3)
- dim(3)
- g2c_rw_section1_metadata(3)
- g2_create(3)
- free_metadata(3)
- g2c_open_index(3)
- g2c_find_table(3)
- g2_unpack7.c(3)
- g2c_csv_init(3)
- templatesgrid(3)
- g2c_log_section(3)
- g2c_csv_strsep(3)
- main(3)
- g2c_param_all(3)
- data_def(3)
- g2c_log_section1(3)
- aecunpack_int(3)
- g2_getfld(3)
- reduce.c(3)
- pack_gp(3)
- g2c_gbit_int(3)
- extpdstemplate(3)
- g2cio.c(3)
- g2c_inq_prod(3)
- sec1_len(3)
- g2c_file(3)
- g2c_start_index_record_lf(3)
- int_dec_jpeg2000(3)
- g2c_seekmsg(3)
- g2_addlocal(3)
- g2c_set_log_level(3)
- g2cat(3)
- gbits.c(3)
- g2c_get_pds_template(3)
- numoct_opt(3)
- g2c_aecpackd(3)
- simunpack.c(3)
- igdtlen(3)
- grib2.h(3)
- g2c_table(3)
- g2c_jpcunpackf(3)
- num(3)
- expanded(3)
- getgridtemplate(3)
- g2c_file_io_longlong(3)
- gbit(3)
- g2c_rw_section5_metadata(3)
- sig_ref_time(3)
- g2c_find_desc(3)
- g2c_write_index(3)
- month(3)
- g2_unpack1.c(3)
- idrtlen(3)
- g2c_free_tables(3)
- g2_getfld.c(3)
- decenc_aec.c(3)
- g2c_start_index1_record(3)
- fld(3)
- g2cinq.c(3)
- g2c_pngunpackd(3)
- g2c_file_io_uint(3)
- num_fields(3)
- g2cdegrib2.c(3)
- format_level(3)
- gtemplate(3)
- decenc_jpeg2000.c(3)
- g2c_add_file(3)
- f(3)
- source_grid_def(3)
- g2c_compare(3)
- g2_unpack6(3)
- msg(3)
- g2_unpack1(3)
- compack(3)
- g2c_start_index_record(3)
- g2c_file_io_short(3)
- g2c_inq_dim_info(3)
- bmap(3)
- len(3)
- g2c_get_datetime(3)
- g2_unpack4(3)
- master_version(3)
- ndpts(3)
- abbrev(3)
- igdtmpl(3)
- prod_def(3)
- comunpack(3)
- center(3)
- pdstemplates.c(3)
- hton64(3)
- field_num(3)
- simpack.c(3)
- g2_gribend.c(3)
- ipdtnum(3)
- g2c_jpcunpackd(3)
- type(3)
- title(3)
- rdieee(3)
- getdrstemplate(3)
- bytes_to_data(3)
- code(3)
- add_section(3)
- g2c_rw_section3_metadata(3)
- g2c_unpack7_int(3)
- extdrstemplate(3)
- dec_png(3)
- getpoly.c(3)
- specunpack(3)
- entry(3)
- num_messages(3)
- g2c_log_file(3)
- g2c_file_io_int(3)
- mkieee(3)
- cmplxpack.c(3)
- dec_jpeg2000(3)
- g2_addgrid.c(3)
- num_sections(3)
- getpoly(3)
- g2c_dec_png(3)
- g1ver(3)
- ibmap(3)
- sec(3)
- user_flush_data(3)
- g2c_jpcpackd(3)
- jpcpack_int(3)
- template_len(3)
- g2float(3)
- g2c_rw_section4_metadata(3)
- local_version(3)
- indicator(3)
- compack.c(3)
- g2c_get_pds_template_extension(3)
- seekgb(3)
- g2c_get_level_desc(3)
- g2c_enc_png(3)
- gbits(3)
- pngunpack.c(3)
- msg_num(3)
- bytes_to_local(3)
- pngpack.c(3)
- user_read_data(3)
- g2cprod.c(3)
- local(3)
- specunpack.c(3)
- jpcpack.c(3)
- day(3)
- g2c_close(3)
- add_msg(3)
- aecpack(3)
- ngrdpts(3)
- g2cparams.c(3)
- g2_unpack3(3)
- list_opt(3)
- template(3)
- pngpack(3)
- g2c_inq_msg(3)
- g2cid(3)
- mkieee.c(3)
- g2c_aecunpackf(3)
- g2cfile.c(3)
- value(3)
- g2_free.c(3)
- ipdtlen(3)
- g2_free(3)
- g2_info(3)
- g2_addlocal.c(3)
- idsectlen(3)
- g2c_get_prod(3)
- g2c_gbits_int(3)
- simunpack(3)
- int_power(3)
- enc_png(3)
- section1(3)
- idsect(3)
- g2c_strerror(3)
- g2c_pngunpackf(3)
- ntoh64(3)
- templatespds(3)
- g2disc(3)
- coord_list(3)
- idrtmpl(3)
- grib2_int.h(3)
- user_write_data(3)
- rdieee.c(3)
- aecunpack(3)
- g2c_file_io_ushort(3)
- g2_unpack2.c(3)
- hour(3)
- gridtemplates.c(3)
- find_available_g2cid(3)
- interp_list(3)
- getdim(3)
- g2c_param_g2tog1(3)
- getgridindex(3)
- g2c_jpcpackf(3)
- g2_unpack6.c(3)
- comunpack.c(3)
- g2c_find_msg2(3)
- getpdstemplate(3)
- g2c_get_prod_sections(3)
- g2c_degrib2.c(3)
- g2_unpack7(3)
- extlen(3)
- aecunpack.c(3)
- param(3)
- seekgb.c(3)
- g2c_find_desc_str(3)
- misspack.c(3)
- optional(3)
- g2_unpack3.c(3)
- doc(3)
- g2ccompare.c(3)
- g2c_get_grid_template(3)
- g2c_param_g1tog2(3)
- g2c_unpack7(3)
- templatesdrs(3)
- g2c_get_grid_template_extension(3)
- path(3)
- grid_def(3)
- needext(3)
- prev(3)
- sec_info(3)
- ext(3)
- g2c_inq_msg_time(3)
- g2c_aecpackf(3)
- pngunpack_int(3)
- g2c_compare.c(3)
- g2c_param_abbrev(3)
- name(3)
- g2c_find_entry(3)
- sbit(3)
- read_hdr_rec1(3)
- gribfield(3)
- sec_num(3)
- g2cindex.c(3)
- locallen(3)
- sec_id(3)
- pack_gp.c(3)
- g2_miss(3)
- getdim.c(3)
- jpcunpack(3)
- g2_unpack5(3)
- g2c_pngpackf(3)
- read_metadata(3)
- g2c_check_msg(3)
- util.c(3)
- num_coord(3)
- desc(3)
- getpdsindex(3)
- interp_opt(3)
- getdrsindex(3)
- g2c_print_tables(3)
- enc_jpeg2000(3)
- ipdtmpl(3)
- aecpack_int(3)
- g2c_index.c(3)
- simpack(3)
- determine_dims(3)
- ifldnum(3)
apt-get install libg2c-dev
Manual
g2cfile.c
NAMESYNOPSIS
Macros
Functions
Variables
Detailed Description
Macro Definition Documentation
#define BYTES_TO_DISCIPLINE 6
#define G2C_SEEKMSG_BUFSIZE 4092
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define READ_BUF_SIZE 4092
Function Documentation
int add_msg (G2C_FILE_INFO_T * file, int msg_num, size_t bytes_to_msg,size_t bytes_in_msg, int read_file, G2C_MESSAGE_INFO_T ** msg)
int add_section (FILE * f, G2C_MESSAGE_INFO_T * msg, int sec_id, unsignedint sec_len, size_t bytes_to_sec, unsigned char sec_num)
static int determine_dims (G2C_SECTION_INFO_T * sec) [static]
static int find_available_g2cid (int * g2cid) [static]
static int free_metadata (int g2cid) [static]
int g2c_add_file (const char * path, int mode, int * g2cid)
int g2c_close (int g2cid)
int g2c_find_msg2 (int g2cid, size_t skip_bytes, size_t max_bytes, size_t *bytes_to_msg, size_t * bytes_in_msg)
int g2c_get_msg (int g2cid, size_t skip_bytes, size_t max_bytes, size_t *bytes_to_msg, size_t * bytes_in_msg, unsigned char ** cbuf)
int g2c_open (const char * path, int mode, int * g2cid)
int g2c_rw_section1_metadata (FILE * f, int rw_flag, G2C_MESSAGE_INFO_T *msg)
int g2c_rw_section3_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
int g2c_rw_section4_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
int g2c_rw_section5_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
int g2c_rw_section6_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
int g2c_seekmsg (int g2cid, size_t skip, size_t * offset, size_t * msglen)
MUTEX (m)
static int read_metadata (int g2cid) [static]
static int read_msg_metadata (G2C_MESSAGE_INFO_T * msg) [static]
Variable Documentation
G2C_FILE_INFO_T g2c_file[G2C_MAX_FILES+1]
int g2c_next_g2cid = 1
Author
NAME
g2cfile.c - File functions for the g2c library.
SYNOPSIS
#include ’grib2_int.h’
Macros
#define
BYTES_TO_DISCIPLINE
6
Number of bytes to discipline field in GRIB2 message.
#define
G2C_SEEKMSG_BUFSIZE
4092
Size of buffer used in
g2c_seekmsg()
.
#define
MIN
(a, b) ((a) < (b) ? (a) : (b))
Find a minimum.
#define
READ_BUF_SIZE
4092
Default size of read-buffer.
Functions
int
add_msg
(
G2C_FILE_INFO_T
*file, int msg_num,
size_t bytes_to_msg, size_t bytes_in_msg, int read_file,
G2C_MESSAGE_INFO_T
**msg)
Add new message to linked list.
int
add_section
(FILE *f,
G2C_MESSAGE_INFO_T
*msg, int sec_id, unsigned int sec_len, size_t bytes_to_sec,
unsigned char sec_num)
Add metadata about a new section 3, 4, 5, 6, or 7.
static int
determine_dims
(
G2C_SECTION_INFO_T
*sec)
Determine the dimension information from the section 3
metadata.
static int
find_available_g2cid
(int *g2cid)
Find a g2cid to use for a newly opened or created file.
static int
free_metadata
(int g2cid)
Free resources holding the file metadata.
int
g2c_add_file
(const char *path, int mode, int
*g2cid)
Open a GRIB2 file and add it to the list of open files.
int
g2c_close
(int g2cid)
Close a GRIB2 file, freeing resources.
int
g2c_find_msg2
(int g2cid, size_t skip_bytes,
size_t max_bytes, size_t *bytes_to_msg, size_t
*bytes_in_msg)
Search a file for the next GRIB1 or GRIB2 message.
int
g2c_get_msg
(int g2cid, size_t skip_bytes, size_t
max_bytes, size_t *bytes_to_msg, size_t *bytes_in_msg,
unsigned char **cbuf)
Search a file for the next GRIB1 or GRIB2 message, and read
it, allocating space in memory to hold the message.
int
g2c_open
(const char *path, int mode, int *g2cid)
Open an existing GRIB2 file.
int
g2c_rw_section1_metadata
(FILE *f, int rw_flag,
G2C_MESSAGE_INFO_T
*msg)
Read Section 1.
int
g2c_rw_section3_metadata
(FILE *f, int rw_flag,
G2C_SECTION_INFO_T
*sec)
Read the metadata from section 3 (Grid Definition Section)
of a GRIB2 message.
int
g2c_rw_section4_metadata
(FILE *f, int rw_flag,
G2C_SECTION_INFO_T
*sec)
Read or write the metadata from section 4 (Product
Definition Section) of a GRIB2 message.
int
g2c_rw_section5_metadata
(FILE *f, int rw_flag,
G2C_SECTION_INFO_T
*sec)
Read or write the metadata from section 5 (Data
Representation Section) of a GRIB2 message.
int
g2c_rw_section6_metadata
(FILE *f, int rw_flag,
G2C_SECTION_INFO_T
*sec)
Read or write the metadata from section 6 (Data
Representation Section) of a GRIB2 message.
int
g2c_seekmsg
(int g2cid, size_t skip, size_t
*offset, size_t *msglen)
Search a file for the next GRIB2 Message.
MUTEX
(m)
Define mutex for thread-safety.
static int
read_metadata
(int g2cid)
Read metadata from a GRIB2 file being opened with
g2c_open()
.
static int
read_msg_metadata
(
G2C_MESSAGE_INFO_T
*msg)
Read the file to get metadata about a message.
Variables
G2C_FILE_INFO_T
g2c_file
[
G2C_MAX_FILES
+1]
Global file information.
int
g2c_next_g2cid
= 1
Next g2cid file ID - used when opening or creating a
file.
Detailed Description
File functions for the g2c library.
Author
Ed Hartnett
Date
Aug 16, 2022
Definition in file g2cfile.c .
Macro Definition Documentation
#define BYTES_TO_DISCIPLINE 6
Number of bytes to discipline field in GRIB2 message.
Definition at line 22 of file g2cfile.c .
#define G2C_SEEKMSG_BUFSIZE 4092
Size of buffer used in g2c_seekmsg() .
Definition at line 27 of file g2cfile.c .
#define MIN(a, b) ((a) < (b) ? (a) : (b))
Find a minimum.
Definition at line 16 of file g2cfile.c .
#define READ_BUF_SIZE 4092
Default size of read-buffer.
Definition at line 19 of file g2cfile.c .
Function Documentation
int add_msg (G2C_FILE_INFO_T * file, int msg_num, size_t bytes_to_msg,size_t bytes_in_msg, int read_file, G2C_MESSAGE_INFO_T ** msg)
Add new message to linked list.
Parameters
file
Pointer to the
G2C_FILE_INFO_T for this file.
msg_num
Number of the message in file (0-based).
bytes_to_msg
Number of bytes to the start of the message
in the file.
bytes_in_msg
Length of message in bytes.
read_file
Set to true to cause metadata to be read from
a GRIB2 data file.
msg
Pointer to a pointer that will get the location of
the newly created
G2C_MESSAGE_INFO_T
object. Ignored
if NULL.
Returns
|
• |
G2C_NOERROR - No error. |
Author
Ed Hartnett
Date
Sep 12, 2022
Definition at line 1017 of file g2cfile.c .
References g2c_message_info::bytes_in_msg , g2c_message_info::bytes_to_msg , g2c_message_info::file , G2C_ENOMEM , G2C_NOERROR , LOG , g2c_file_info::msg , g2c_message_info::msg_num , g2c_message_info::next , g2c_file_info::num_messages , and read_msg_metadata() .
Referenced by g2c_open_index() , and read_metadata() .
int add_section (FILE * f, G2C_MESSAGE_INFO_T * msg, int sec_id, unsignedint sec_len, size_t bytes_to_sec, unsigned char sec_num)
Add metadata about a new section 3, 4, 5, 6, or 7.
Parameters
f
FILE pointer to open
GRIB2 file.
msg
Pointer to the G2C_MESSAGE_INFO_T struct.
sec_id
0-based section ID.
sec_len
Length of section.
bytes_to_sec
Number of bytes from start of message to
this section.
sec_num
Section number.
Returns
|
• |
G2C_NOERROR - No error. |
Author
Ed Hartnett
Date
Sep 12, 2022
Definition at line 794 of file g2cfile.c .
References g2c_section_info::bytes_to_sec , G2C_EBADSECTION , G2C_ENOMEM , G2C_FILE_READ , G2C_NOERROR , g2c_rw_section3_metadata() , g2c_rw_section4_metadata() , g2c_rw_section5_metadata() , g2c_rw_section6_metadata() , LOG , g2c_section_info::msg , g2c_section_info::next , g2c_message_info::num_local , g2c_section_info::prev , g2c_message_info::sec , g2c_section_info::sec_id , g2c_section_info::sec_len , and g2c_section_info::sec_num .
Referenced by g2c_open_index() , and read_msg_metadata() .
static int determine_dims (G2C_SECTION_INFO_T * sec) [static]
Determine the dimension information from the section 3 metadata. See (GRIB2 - SECTION 3 GRID DEFINITION SECTION)[https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml].
For a list of grid definitions see [GRIB2 - TABLE 3.1 Grid Definition Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-1.shtml).
Parameters
sec G2C_SECTION3_INFO_T struct.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOMEM Out of memory. |
Author
Ed Hartnett
Date
Sep 15, 2022
Definition at line 415 of file g2cfile.c .
References g2c_section3_info::dim , G2C_ENOMEM , G2C_MAX_NAME , G2C_NOERROR , g2c_section3_info::grid_def , LATITUDE , g2c_dim_info::len , LOG , LONGITUDE , g2c_dim_info::name , g2c_section_info::sec_info , g2c_section_info::template , and g2c_dim_info::value .
Referenced by g2c_rw_section3_metadata() .
static int find_available_g2cid (int * g2cid) [static]
Find a g2cid to use for a newly opened or created file.
Parameters
g2cid Pointer that gets the next available g2cid.
Returns
|
• |
G2C_NOERROR - No error. |
||
|
• |
G2C_EINVAL - Invalid input. |
||
|
• |
G2C_ETOOMANYFILES - Trying to open too many files at the same time. ’ |
Author
Ed Hartnett 8/18/22
Definition at line 363 of file g2cfile.c .
References G2C_EINVAL , G2C_ETOOMANYFILES , g2c_file , G2C_MAX_FILES , g2c_next_g2cid , and G2C_NOERROR .
Referenced by g2c_add_file() .
static int free_metadata (int g2cid) [static]
Free resources holding the file metadata.
Parameters
g2cid Indentifier for the file.
Returns
|
• |
G2C_NOERROR - No error. |
|||
|
• |
G2C_EBADID - Bad file ID. |
Author
Ed Hartnett
Date
Aug 16, 2022
Definition at line 1304 of file g2cfile.c .
References G2C_EBADID , g2c_file , G2C_MAX_FILES , G2C_NOERROR , LOG , g2c_file_info::msg , g2c_message_info::next , g2c_section_info::next , g2c_message_info::sec , g2c_section_info::sec_info , g2c_section_info::sec_num , and g2c_section_info::template .
Referenced by g2c_close() .
int g2c_add_file (const char * path, int mode, int * g2cid)
Open a GRIB2 file and add it to the list of open files.
Parameters
path
Path of the file.
mode
Open mode flags.
g2cid
Pointer that gets an indentifier for the file.
Returns
|
• |
G2C_NOERROR - No error. |
||
|
• |
G2C_EINVAL - Invalid input. |
||
|
• |
G2C_ETOOMANYFILES - Trying to open too many files at the same time. |
Author
Ed Hartnett
Date
Aug 16, 2022
Definition at line 1143 of file g2cfile.c .
References find_available_g2cid() , G2C_EFILE , G2C_EINVAL , G2C_ENAMETOOLONG , g2c_file , G2C_MAX_NAME , G2C_NOERROR , G2C_WRITE , g2c_file_info::g2cid , LOG , g2c_file_info::msg , and g2c_file_info::num_messages .
Referenced by g2c_open() , and g2c_open_index() .
int g2c_close (int g2cid)
Close a GRIB2 file, freeing resources.
Parameters
g2cid Indentifier for the file.
Returns
|
• |
G2C_NOERROR - No error. |
|||
|
• |
G2C_EBADID - Bad file ID. |
Author
Ed Hartnett
Date
Aug 16, 2022
Definition at line 1367 of file g2cfile.c .
References g2c_file_info::f , free_metadata() , G2C_EBADID , G2C_EFILE , g2c_file , G2C_MAX_FILES , G2C_NOERROR , g2c_file_info::g2cid , LOG , MUTEX_LOCK , MUTEX_UNLOCK , g2c_file_info::num_messages , and g2c_file_info::path .
Referenced by main() .
int g2c_find_msg2 (int g2cid, size_t skip_bytes, size_t max_bytes, size_t *bytes_to_msg, size_t * bytes_in_msg)
Search a file for the next GRIB1 or GRIB2 message. A grib message is identified by its indicator section, i.e. an 8-byte sequence with ’GRIB’ in bytes 1-4 and a ’1’ or ’2’ in byte 8. If found, the length of the message is decoded from bytes 5-7. The search is done over a given section of the file. The search is terminated if an eof or i/o error is encountered.
Parameters
g2cid
ID of the opened
grib file, returned by
g2c_open()
.
skip_bytes
Number of bytes to skip before search.
max_bytes
Maximum number of bytes to search.
bytes_to_msg
Pointer that gets the number of bytes to
skip before message.
bytes_in_msg
Pointer that gets the number of bytes in
message (or 0 if no message found)
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID g2cid not found. |
|||
|
• |
G2C_EFILE File error. |
|||
|
• |
G2C_EINVAL Invalid input. |
Author
Ed Hartnett
Date
2022-08-19
Definition at line 164 of file g2cfile.c .
References G2C_EBADID , G2C_EFILE , G2C_EINVAL , G2C_EMSG , G2C_ENOMEM , G2C_ERROR , g2c_file , G2C_MAGIC_HEADER_LEN , G2C_NOERROR , LOG , MIN , and READ_BUF_SIZE .
int g2c_get_msg (int g2cid, size_t skip_bytes, size_t max_bytes, size_t *bytes_to_msg, size_t * bytes_in_msg, unsigned char ** cbuf)
Search a file for the next GRIB1 or GRIB2 message, and read it, allocating space in memory to hold the message. A grib message is identified by its indicator section, i.e. an 8-byte sequence with ’GRIB’ in bytes 1-4 and a ’1’ or ’2’ in byte 8. If found, the length of the message is decoded from bytes 5-7. The search is done over a given section of the file. The search is terminated if an EOF or I/O error is encountered.
Parameters
g2cid
ID of the opened
grib file, returned by
g2c_open()
.
skip_bytes
The number of bytes to skip before search.
max_bytes
The maximum number of bytes to search. Must be
at least 16.
bytes_to_msg
A pointer that gets the number of bytes to
skip before message.
bytes_in_msg
A pointer that gets the number of bytes in
message (or 0 if no message found)
cbuf
A pointer that gets allocation of memory, into
which the message is copied. This memory must be freed by
the caller.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID g2cid not found. |
|||
|
• |
G2C_EFILE File error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOMEM Out of memory. |
|||
|
• |
G2C_ENOMSG No GRIB message found. |
Author
Ed Hartnett
Date
2022-08-20
Definition at line 291 of file g2cfile.c .
References G2C_EBADID , G2C_EFILE , G2C_EINVAL , G2C_ENOMEM , G2C_ENOMSG , G2C_ERROR , g2c_file , G2C_MIN_MAX_BYTES , G2C_NOERROR , LOG , and seekgb() .
int g2c_open (const char * path, int mode, int * g2cid)
Open an existing GRIB2 file. This function opens the GRIB2 file and reads its metadata.
GRIB2 messages in the file are assigned a message ID, starting with 0 for the first message in the file.
Each product within a message is assigned a product ID, starting with 0 for the first product in the message.
Files opened with this function should be closed with a call g2c_close() to release resources.
Parameters
path
Path of the file.
mode
Open mode flags.
g2cid
Pointer that gets an indentifier for the file.
Returns
|
• |
G2C_NOERROR - No error. |
||
|
• |
G2C_EINVAL - Invalid input. |
||
|
• |
G2C_ETOOMANYFILES - Trying to open too many files at the same time. |
Author
Ed Hartnett
Date
Aug 16, 2022
Definition at line 1201 of file g2cfile.c .
References g2c_add_file() , LOG , MUTEX_LOCK , MUTEX_UNLOCK , and read_metadata() .
Referenced by main() .
int g2c_rw_section1_metadata (FILE * f, int rw_flag, G2C_MESSAGE_INFO_T *msg)
Read Section 1.
Parameters
f
Pointer to open file.
rw_flag
G2C_FILE_WRITE
if function should write,
G2C_FILE_READ
if it should read.
msg
Pointer to G2C_MESSAGE_INFO_T which will be
populated with the values of section 0.
Returns
-G2C_NOERROR No error.
Author
Ed Hartnett
Date
10/16/22
Definition at line 874 of file g2cfile.c .
References g2c_message_info::center , g2c_message_info::day , G2C_ENOSECTION , g2c_file_io_short() , g2c_file_io_ubyte() , g2c_file_io_uint() , G2C_NOERROR , G2C_SECTION1_BYTES , g2c_message_info::hour , g2c_message_info::local_version , LOG , g2c_message_info::master_version , g2c_message_info::minute , g2c_message_info::month , g2c_message_info::sec1_len , g2c_message_info::second , g2c_message_info::sig_ref_time , g2c_message_info::status , g2c_message_info::subcenter , g2c_message_info::type , and g2c_message_info::year .
Referenced by g2c_open_index() , g2c_write_index() , and read_msg_metadata() .
int g2c_rw_section3_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
Read the metadata from section 3 (Grid Definition Section) of a GRIB2 message. When this function is called, the file cursor is positioned just after the section number field in the section. The size of the section, and the section number, have already been read when this function is called.
Parameters
f
FILE pointer to open
GRIB2 file.
rw_flag
G2C_FILE_WRITE
if function should write,
G2C_FILE_READ
(0) if it should read.
sec
Pointer to the G2C_SECTION_INFO_T struct.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOMEM Out of memory. |
|||
|
• |
G2C_ENOTEMPLATE Can’t find template. |
Author
Ed Hartnett
Date
Sep 15, 2022
Definition at line 478 of file g2cfile.c .
References determine_dims() , G2C_EINVAL , G2C_ENOMEM , g2c_file_io_template() , g2c_file_io_ubyte() , g2c_file_io_uint() , g2c_file_io_ushort() , g2c_get_grid_template() , G2C_MAX_GDS_TEMPLATE_MAPLEN , G2C_NOERROR , g2c_section3_info::grid_def , g2c_section3_info::interp_list , LOG , g2c_section3_info::num_data_points , g2c_section3_info::num_opt , g2c_section_info::sec_info , g2c_section_info::sec_num , g2c_section3_info::source_grid_def , g2c_section_info::template , and g2c_section_info::template_len .
Referenced by add_section() , and g2c_write_index() .
int g2c_rw_section4_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
Read or write the metadata from section 4 (Product Definition Section) of a GRIB2 message. When this function is called, the file cursor is positioned just after the section number field in the section. The size of the section, and the section number, have already been read/written when this function is called.
Parameters
f
FILE pointer to open
GRIB2 file.
rw_flag
G2C_FILE_WRITE
if function should write,
G2C_FILE_READ
if it should read.
sec
Pointer to the G2C_SECTION_INFO_T struct.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOMEM Out of memory. |
|||
|
• |
G2C_ENOTEMPLATE Can’t find template. |
Author
Ed Hartnett
Date
Sep 16, 2022
Definition at line 574 of file g2cfile.c .
References G2C_EINVAL , G2C_ENOMEM , g2c_file_io_template() , g2c_file_io_ushort() , g2c_get_pds_template() , G2C_MAX_PDS_TEMPLATE_MAPLEN , G2C_NOERROR , LOG , g2c_section_info::msg , g2c_section4_info::num_coord , g2c_message_info::num_fields , g2c_section4_info::prod_def , g2c_section_info::sec_info , g2c_section_info::sec_num , g2c_section_info::template , and g2c_section_info::template_len .
Referenced by add_section() , and g2c_write_index() .
int g2c_rw_section5_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
Read or write the metadata from section 5 (Data Representation Section) of a GRIB2 message. When this function is called, the file cursor is positioned just after the section number field in the section. The size of the section, and the section number, have already been read when this function is called.
Parameters
f
FILE pointer to open
GRIB2 file.
rw_flag
G2C_FILE_WRITE
if function should write,
G2C_FILE_READ
if it should read.
sec
Pointer to the G2C_SECTION_INFO_T struct.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOMEM Out of memory. |
|||
|
• |
G2C_ENOTEMPLATE Can’t find template. |
Author
Ed Hartnett
Date
Sep 16, 2022
Definition at line 663 of file g2cfile.c .
References g2c_section5_info::data_def , G2C_EINVAL , G2C_ENOMEM , g2c_file_io_template() , g2c_file_io_uint() , g2c_file_io_ushort() , g2c_get_drs_template() , G2C_MAX_PDS_TEMPLATE_MAPLEN , G2C_NOERROR , LOG , g2c_section5_info::num_data_points , g2c_section_info::sec_info , g2c_section_info::template , and g2c_section_info::template_len .
Referenced by add_section() , and g2c_write_index() .
int g2c_rw_section6_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
Read or write the metadata from section 6 (Data Representation Section) of a GRIB2 message. When this function is called, the file cursor is positioned just after the section number field in the section. The size of the section, and the section number, have already been read when this function is called.
Parameters
f
FILE pointer to open
GRIB2 file.
rw_flag
G2C_FILE_WRITE
if function should write,
G2C_FILE_READ
if it should read.
sec
Pointer to the G2C_SECTION_INFO_T struct.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOMEM Out of memory. |
|||
|
• |
G2C_ENOTEMPLATE Can’t find template. |
Author
Ed Hartnett
Date
Sep 16, 2022
Definition at line 745 of file g2cfile.c .
References G2C_EINVAL , G2C_ENOMEM , g2c_file_io_ubyte() , G2C_NOERROR , g2c_section6_info::indicator , LOG , and g2c_section_info::sec_info .
Referenced by add_section() .
int g2c_seekmsg (int g2cid, size_t skip, size_t * offset, size_t * msglen)
Search a file for the next GRIB2 Message. The search is terminated when a GRIB2 message is found, or the end of the file is reached.
Parameters
g2cid
ID of an open
GRIB2 file, returned from
g2c_open()
/g2c_create().
skip
The number of bytes in the file to skip before
starting the search.
offset
Pointer that gets the number of bytes to skip
from the beggining of the file to where the GRIB message
starts. Ignored if NULL.
msglen
Pointer that gets the number of bytes in message
(set to 0, if no message found). Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID Bad g2cid. |
|||
|
• |
G2C_ENOMEM Out of memory. |
Author
Ed Hartnett
Date
2022-09-11
Definition at line 56 of file g2cfile.c .
References G2C_EBADID , G2C_EFILE , G2C_ENOMEM , g2c_file , G2C_MAGIC_HEADER , G2C_NOERROR , G2C_SEEKMSG_BUFSIZE , hton64 , and LOG .
Referenced by read_metadata() .
MUTEX (m)
Define mutex for thread-safety.
static int read_metadata (int g2cid) [static]
Read metadata from a GRIB2 file being opened with g2c_open() .
Parameters
g2cid The indentifier for the file.
Returns
|
• |
G2C_NOERROR - No error. |
|||
|
• |
G2C_EBADID g2cid not found. |
|||
|
• |
G2C_EFILE File error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOMEM Out of memory. |
|||
|
• |
G2C_ENOMSG No GRIB message found. |
Author
Ed Hartnett
Date
Aug 22, 2022
Definition at line 1079 of file g2cfile.c .
References add_msg() , G2C_EBADID , G2C_ENOMSG , g2c_file , g2c_log_file() , G2C_NOERROR , g2c_seekmsg() , and LOG .
Referenced by g2c_open() .
static int read_msg_metadata (G2C_MESSAGE_INFO_T * msg) [static]
Read the file to get metadata about a message.
Parameters
msg Pointer to the G2C_MESSAGE_INFO_T struct for this message.
Returns
|
• |
G2C_NOERROR - No error. |
Author
Ed Hartnett
Date
Sep 12, 2022
Definition at line 937 of file g2cfile.c .
References add_section() , BYTES_TO_DISCIPLINE , g2c_message_info::bytes_to_msg , g2c_message_info::discipline , g2c_file_info::f , g2c_message_info::file , FOUR_BYTES , G2C_EBADSECTION , G2C_EFILE , g2c_file_io_ubyte() , g2c_file_io_uint() , G2C_FILE_READ , G2C_NOERROR , g2c_rw_section1_metadata() , G2C_SECTION0_BYTES , LOG , ONE_BYTE , and g2c_message_info::sec1_len .
Referenced by add_msg() .
Variable Documentation
G2C_FILE_INFO_T g2c_file[G2C_MAX_FILES+1]
Global file information.
Definition at line 10 of file g2cfile.c .
Referenced by find_available_g2cid() , free_metadata() , g2c_add_file() , g2c_close() , g2c_compare() , g2c_degrib2() , g2c_find_msg2() , g2c_get_msg() , g2c_get_prod() , g2c_inq() , g2c_inq_dim() , g2c_inq_msg() , g2c_inq_msg_time() , g2c_inq_prod() , g2c_log_file() , g2c_open_index() , g2c_seekmsg() , g2c_write_index() , and read_metadata() .
int g2c_next_g2cid = 1
Next g2cid file ID - used when opening or creating a file.
Definition at line 13 of file g2cfile.c .
Referenced by find_available_g2cid() .
Author
Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.