Man page - extern_mutex(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
g2cindex.c
NAMESYNOPSIS
Macros
Functions
Variables
Detailed Description
Macro Definition Documentation
#define G2C_INDEX_BASENAME_LEN 40
#define G2C_INDEX_BITMAP_BYTES 6
#define G2C_INDEX_DATE_STR_LEN 10
#define G2C_INDEX_FIXED_LEN 44
#define G2C_INDEX_FIXED_LEN_2 48
#define G2C_INDEX_HEADER_LEN 81
#define G2C_INDEX_STR1_LEN 7
#define G2C_INDEX_TIME_STR_LEN 8
Function Documentation
EXTERN_MUTEX (m)
int g2c_get_prod_sections (G2C_MESSAGE_INFO_T * msg, int fieldnum,G2C_SECTION_INFO_T ** sec3, G2C_SECTION_INFO_T ** sec4,G2C_SECTION_INFO_T ** sec5, G2C_SECTION_INFO_T ** sec6,G2C_SECTION_INFO_T ** sec7)
int g2c_open_index (const char * data_file, const char * index_file, intmode, int * g2cid)
int g2c_open_index1 (const char * index_file)
int g2c_start_index1_record (FILE * f, int rw_flag, unsigned int * b2_msg,unsigned int * b2_pds, unsigned int * b2_gds, unsigned int * b2_bms,unsigned int * b2_bds, unsigned int * msglen, unsigned char * version,unsigned char * pds_val, unsigned char * gds_val, unsigned char *bms_val, unsigned char * bds_val, unsigned char * pds_val2, unsignedchar * pds_val3, unsigned char * gds_val2)
int g2c_start_index_record (FILE * f, int rw_flag, int * reclen, int * msg,int * local, int * gds, int * pds, int * drs, int * bms, int * data,size_t * msglen, unsigned char * version, unsigned char * discipline,short * fieldnum)
int g2c_start_index_record_lf (FILE * f, int rw_flag, int * reclen, size_t* msg, size_t * local, size_t * gds, size_t * pds, size_t * drs, size_t* bms, size_t * data, size_t * msglen, unsigned char * version,unsigned char * discipline, short * fieldnum)
int g2c_write_index (int g2cid, int mode, const char * index_file)
static int read_hdr_rec1 (FILE * f, int * ip, int * jp, int * kp, char *date_str, char * time_str) [static]
static int read_hdr_rec2 (FILE * f, int * skipp, int * total_lenp, int *num_recp, char * basename, int * index_version) [static]
Variable Documentation
G2C_FILE_INFO_T g2c_file[G2C_MAX_FILES+1] [extern]
Author
NAME
g2cindex.c - Write summary output to an index file, as is done by utility grb2index.
SYNOPSIS
#include
βgrib2_int.hβ
#include <libgen.h>
#include <stdarg.h>
#include <time.h>
Macros
#define
G2C_INDEX_BASENAME_LEN
40
Length of the basename in header record 2.
#define
G2C_INDEX_BITMAP_BYTES
6
Length of bitmap section included in the index record.
#define
G2C_INDEX_DATE_STR_LEN
10
Length of date string in index record.
#define
G2C_INDEX_FIXED_LEN
44
Length of beginning of index record.
#define
G2C_INDEX_FIXED_LEN_2
48
Length of beginning of index record for large files.
#define
G2C_INDEX_HEADER_LEN
81
Length of the two header lines at the top of the index file.
#define
G2C_INDEX_STR1_LEN
7
Length of str1 string in index record.
#define
G2C_INDEX_TIME_STR_LEN
8
Length of time string in index record.
Functions
EXTERN_MUTEX
(m)
Use externally-defined mutex for thread-safety.
int
g2c_get_prod_sections
(
G2C_MESSAGE_INFO_T
*msg, int fieldnum,
G2C_SECTION_INFO_T
**sec3,
G2C_SECTION_INFO_T
**sec4,
G2C_SECTION_INFO_T
**sec5,
G2C_SECTION_INFO_T
**sec6,
G2C_SECTION_INFO_T
**sec7)
Given a pointer to a message, and a field number, return
pointers to all relevent section structs for that product.
int
g2c_open_index
(const char *data_file, const char
*index_file, int mode, int *g2cid)
Open a GRIB2 file with the help of an index file.
int
g2c_open_index1
(const char *index_file)
Open a GRIB1 index file and read the contents.
int
g2c_start_index1_record
(FILE *f, int rw_flag,
unsigned int *b2_msg, unsigned int *b2_pds, unsigned int
*b2_gds, unsigned int *b2_bms, unsigned int *b2_bds,
unsigned int *msglen, unsigned char *version, unsigned char
*pds_val, unsigned char *gds_val, unsigned char *bms_val,
unsigned char *bds_val, unsigned char *pds_val2, unsigned
char *pds_val3, unsigned char *gds_val2)
Read or write the start of a version 1 index record.
int
g2c_start_index_record
(FILE *f, int rw_flag, int
*reclen, int *msg, int *local, int *gds, int *pds, int *drs,
int *bms, int *data, size_t *msglen, unsigned char *version,
unsigned char *discipline, short *fieldnum)
Read or write the start of a version 2 index record.
int
g2c_start_index_record_lf
(FILE *f, int rw_flag,
int *reclen, size_t *msg, size_t *local, size_t *gds, size_t
*pds, size_t *drs, size_t *bms, size_t *data, size_t
*msglen, unsigned char *version, unsigned char *discipline,
short *fieldnum)
Read or write the start of a version 2 index record.
int
g2c_write_index
(int g2cid, int mode, const char
*index_file)
Create an index file from a GRIB2 file, just like those
created by the grb2index utility.
static int
read_hdr_rec1
(FILE *f, int *ip, int *jp,
int *kp, char *date_str, char *time_str)
Read the header record apparently named after Steve Lord.
static int
read_hdr_rec2
(FILE *f, int *skipp, int
*total_lenp, int *num_recp, char *basename, int
*index_version)
Read the second header record of an index file.
Variables
G2C_FILE_INFO_T
g2c_file
[
G2C_MAX_FILES
+1]
Global file information.
Detailed Description
Write summary output to an index file, as is done by utility grb2index.
Author
Ed Hartnett
Date
10/12/22
Definition in file g2cindex.c .
Macro Definition Documentation
#define G2C_INDEX_BASENAME_LEN 40
Length of the basename in header record 2.
Definition at line 20 of file g2cindex.c .
#define G2C_INDEX_BITMAP_BYTES 6
Length of bitmap section included in the index record.
Definition at line 23 of file g2cindex.c .
#define G2C_INDEX_DATE_STR_LEN 10
Length of date string in index record.
Definition at line 32 of file g2cindex.c .
#define G2C_INDEX_FIXED_LEN 44
Length of beginning of index record.
Definition at line 26 of file g2cindex.c .
#define G2C_INDEX_FIXED_LEN_2 48
Length of beginning of index record for large files.
Definition at line 29 of file g2cindex.c .
#define G2C_INDEX_HEADER_LEN 81
Length of the two header lines at the top of the index file.
Definition at line 17 of file g2cindex.c .
#define G2C_INDEX_STR1_LEN 7
Length of str1 string in index record.
Definition at line 38 of file g2cindex.c .
#define G2C_INDEX_TIME_STR_LEN 8
Length of time string in index record.
Definition at line 35 of file g2cindex.c .
Function Documentation
EXTERN_MUTEX (m)
Use externally-defined mutex for thread-safety.
int g2c_get_prod_sections (G2C_MESSAGE_INFO_T * msg, int fieldnum,G2C_SECTION_INFO_T ** sec3, G2C_SECTION_INFO_T ** sec4,G2C_SECTION_INFO_T ** sec5, G2C_SECTION_INFO_T ** sec6,G2C_SECTION_INFO_T ** sec7)
Given a pointer to a message, and a field number, return pointers to all relevent section structs for that product. Each product is defined in a section 4, and has an associated section 3, 5, 6, and 7.
Parameters
msg
Pointer to a
G2C_MESSAGE_INFO_T with information about the message.
fieldnum
The field number (first field in message is 0).
sec3
Pointer that gets a pointer to the
G2C_SECTION_INFO_T struct for the section 3 associated with
this product.
sec4
Pointer that gets a pointer to the
G2C_SECTION_INFO_T struct for the section 4 associated with
this product.
sec5
Pointer that gets a pointer to the
G2C_SECTION_INFO_T struct for the section 5 associated with
this product.
sec6
Pointer that gets a pointer to the
G2C_SECTION_INFO_T struct for the section 6 associated with
this product. NULL is returned if there is no section 6.
sec7
Pointer that gets a pointer to the
G2C_SECTION_INFO_T struct for the section 7 associated with
this product.
Note
This is an internal function and should not be called by users.
Returns
|
β’ |
G2C_NOERROR No error. |
|||
|
β’ |
G2C_EINVAL Invalid input. |
|||
|
β’ |
G2C_ENOSECTION Section not found. |
Author
Ed Hartnett
Date
10/27/22
Definition at line 317 of file g2cindex.c .
References G2C_EINVAL , G2C_ENOSECTION , G2C_NOERROR , g2c_section_info::next , g2c_section_info::prev , g2c_message_info::sec , g2c_section_info::sec_info , and g2c_section_info::sec_num .
Referenced by g2c_write_index() .
int g2c_open_index (const char * data_file, const char * index_file, intmode, int * g2cid)
Open a GRIB2 file with the help of an index file. The index file, generated by the grb2index utility, of the g2c_write_index() function, contains the byte offsets for the sections of each message in the GRIB2 file. When a GRIB2 file is opened with an index file, the library does not have to scan the file to locate all metadata.
Parameters
data_file
The name of
the data file to which the index applies.
index_file
The name that will be given to the index
file. An existing file will be overwritten.
mode
Open mode flags.
g2cid
Pointer that gets the g2cid for this file. Ignored
if NULL.
Returns
|
β’ |
G2C_NOERROR No error. |
Author
Ed Hartnett
Date
10/12/22
Definition at line 914 of file g2cindex.c .
References add_msg() , add_section() , g2c_message_info::bytes_to_bms , g2c_message_info::bytes_to_data , g2c_message_info::bytes_to_local , g2c_message_info::bytes_to_msg , g2c_message_info::discipline , g2c_add_file() , G2C_EBADSECTION , G2C_EFILE , G2C_EINVAL , G2C_ENAMETOOLONG , g2c_file , g2c_file_io_ubyte() , g2c_file_io_uint() , G2C_FILE_READ , G2C_INDEX_BASENAME_LEN , G2C_INDEX_DATE_STR_LEN , G2C_INDEX_HEADER_LEN , G2C_INDEX_STR1_LEN , G2C_INDEX_TIME_STR_LEN , g2c_log_section1() , G2C_MAX_NAME , G2C_NOERROR , g2c_rw_section1_metadata() , g2c_start_index_record() , g2c_start_index_record_lf() , LOG , g2c_message_info::master_version , MUTEX_LOCK , and MUTEX_UNLOCK .
Referenced by main() .
int g2c_open_index1 (const char * index_file)
Open a GRIB1 index file and read the contents. This function opens the GRIB2 index file and reads its metadata, and opens the accompanying GRIB2 file.
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
index_file The name that will be given to the index file. An existing file will be overwritten.
Returns
|
β’ |
G2C_NOERROR No error. |
Author
Ed Hartnett
Date
10/12/22
Definition at line 812 of file g2cindex.c .
References G2C_EFILE , G2C_EINVAL , G2C_FILE_READ , G2C_INDEX1_BDS_VAL_LEN , G2C_INDEX1_BMS_VAL_LEN , G2C_INDEX1_GDS_VAL_LEN , G2C_INDEX1_PDS_VAL_LEN , G2C_INDEX_BASENAME_LEN , G2C_INDEX_DATE_STR_LEN , G2C_INDEX_HEADER_LEN , G2C_INDEX_TIME_STR_LEN , G2C_NOERROR , g2c_start_index1_record() , LOG , MUTEX_LOCK , MUTEX_UNLOCK , read_hdr_rec1() , and read_hdr_rec2() .
int g2c_start_index1_record (FILE * f, int rw_flag, unsigned int * b2_msg,unsigned int * b2_pds, unsigned int * b2_gds, unsigned int * b2_bms,unsigned int * b2_bds, unsigned int * msglen, unsigned char * version,unsigned char * pds_val, unsigned char * gds_val, unsigned char *bms_val, unsigned char * bds_val, unsigned char * pds_val2, unsignedchar * pds_val3, unsigned char * gds_val2)
Read or write the start of a version 1 index record. For more detail on version 1 of the index format, see the grbindex documentation in the NCEPLIBS-grib_util .
Parameters
f
FILE * to open index
file.
rw_flag
True if function should write, false if it
should read.
b2_msg
Pointer that gets the bytes to skip in file
before msg.
b2_pds
Pointer that gets bytes to skip in message before
pds.
b2_gds
Pointer that gets bytes to skip in message before
gds (0 if no gds).
b2_bms
Pointer that gets bytes to skip in message before
bms (0 if no bms).
b2_bds
Pointer that gets bytes to skip in message before
bds.
msglen
Pointer that gets bytes total in the message.
version
Pointer that gets grib version number (always 1
for this function).
pds_val
Pointer that gets an arry of 27 bytes of the
product definition section (pds).
gds_val
Pointer that gets an arry of 41 bytes of the
gds.
bms_val
Pointer that gets an arry of 5 bytes of the bms.
bds_val
Pointer that gets an arry of 10 bytes, bytes
41-100 of the bds.
pds_val2
Pointer that gets an arry of 59 bytes 41-100 of
the pds. Ignored if null.
pds_val3
Pointer that gets an arry of 11 bytes 29-40 of
the pds. Ignored if null.
gds_val2
Pointer that gets an arry of 135 bytes 43-178
of the gds. Ignored if null.
Returns
|
β’ |
G2C_NOERROR No error. |
|||
|
β’ |
G2C_EINVAL Invalid input. |
|||
|
β’ |
G2C_EFILE File I/O error. |
Author
Ed Hartnett 9/11/23
Definition at line 238 of file g2cindex.c .
References G2C_EFILE , G2C_EINVAL , g2c_file_io_ubyte() , g2c_file_io_uint() , G2C_INDEX1_BDS_VAL_LEN , G2C_INDEX1_BMS_VAL_LEN , G2C_INDEX1_GDS_VAL_LEN , G2C_INDEX1_PDS_VAL_LEN , and G2C_NOERROR .
Referenced by g2c_open_index1() .
int g2c_start_index_record (FILE * f, int rw_flag, int * reclen, int * msg,int * local, int * gds, int * pds, int * drs, int * bms, int * data,size_t * msglen, unsigned char * version, unsigned char * discipline,short * fieldnum)
Read or write the start of a version 2 index record.
Parameters
f
FILE * to open index
file.
rw_flag
True if function should write, false if it
should read.
reclen
Pointer to reclen.
msg
Pointer to msg.
local
Pointer to local.
gds
Pointer to gds.
pds
Pointer to pds.
drs
Pointer to drs.
bms
Pointer to bms.
data
Pointer to data.
msglen
Pointer to msglen.
version
Pointer to version.
discipline
Pointer to discipline.
fieldnum
Pointer to fieldnum, 0- based. (It is 1-based
in the index file.)
Returns
|
β’ |
G2C_NOERROR No error. |
|||
|
β’ |
G2C_EINVAL Invalid input. |
|||
|
β’ |
G2C_EFILE File I/O error. |
Author
Ed Hartnett 10/26/22
Definition at line 70 of file g2cindex.c .
References G2C_EINVAL , g2c_file_io_short() , g2c_file_io_ubyte() , g2c_file_io_uint() , g2c_file_io_ulonglong() , G2C_NOERROR , and LOG .
Referenced by g2c_open_index() , and g2c_write_index() .
int g2c_start_index_record_lf (FILE * f, int rw_flag, int * reclen, size_t* msg, size_t * local, size_t * gds, size_t * pds, size_t * drs, size_t* bms, size_t * data, size_t * msglen, unsigned char * version,unsigned char * discipline, short * fieldnum)
Read or write the start of a version 2 index record.
Parameters
f
FILE pointer to open
index file.
rw_flag
True if function should write, false if it
should read.
reclen
Pointer to reclen, the length of the index record
in bytes.
msg
Pointer to bytes to skip in file to reach msg.
local
Pointer to bytes to skip in message to reach
local.
gds
Pointer to bytes to skip in message to reach gds.
pds
Pointer to bytes to skip in message to reach pds.
drs
Pointer to bytes to skip in message to reach drs.
bms
Pointer to bytes to skip in message to reach bms.
data
Pointer to bytes to skip in message to reach data.
msglen
Pointer to msglen.
version
Pointer to version.
discipline
Pointer to discipline.
fieldnum
Pointer to fieldnum, 0- based. (It is 1-based
in the index file.)
Returns
|
β’ |
G2C_NOERROR No error. |
|||
|
β’ |
G2C_EINVAL Invalid input. |
|||
|
β’ |
G2C_EFILE File I/O error. |
Author
Ed Hartnett 10/26/22
Definition at line 151 of file g2cindex.c .
References G2C_EINVAL , g2c_file_io_short() , g2c_file_io_ubyte() , g2c_file_io_uint() , g2c_file_io_ulonglong() , G2C_NOERROR , and LOG .
Referenced by g2c_open_index() , and g2c_write_index() .
int g2c_write_index (int g2cid, int mode, const char * index_file)
Create an index file from a GRIB2 file, just like those created by the grb2index utility. The index file starts with two header records:
|
1. |
81-byte header with βgb2ix1β in columns 42-47. |
||
|
2. |
81-byte header with number of bytes to skip before index records, total length in bytes of the index records, number of index records, and grib file basename written in format (βix1form:β,3i10,2x,a40). |
Each following index record corresponds to a grib message and has the internal format:
|
β’ |
byte 001 - 004 length of index record |
||
|
β’ |
byte 005 - 008 bytes to skip in data file before grib message |
||
|
β’ |
byte 009 - 012 bytes to skip in message before lus (local use) (0, if none). |
||
|
β’ |
byte 013 - 016 bytes to skip in message before gds |
||
|
β’ |
byte 017 - 020 bytes to skip in message before pds |
||
|
β’ |
byte 021 - 024 bytes to skip in message before drs |
||
|
β’ |
byte 025 - 028 bytes to skip in message before bms |
||
|
β’ |
byte 029 - 032 bytes to skip in message before data section |
||
|
β’ |
byte 033 - 040 bytes total in the message |
||
|
β’ |
byte 041 - 041 grib version number (currently 2) |
||
|
β’ |
byte 042 - 042 message discipline |
||
|
β’ |
byte 043 - 044 field number within grib2 message (1-based) |
||
|
β’ |
byte 045 - ii identification section (ids) |
||
|
β’ |
byte ii+1- jj grid definition section (gds) |
||
|
β’ |
byte jj+1- kk product definition section (pds) |
||
|
β’ |
byte kk+1- ll the data representation section (drs) |
||
|
β’ |
byte ll+1-ll+6 first 6 bytes of the bit map section (bms) |
Parameters
g2cid
File it for an
open GRIB2 file, as returned by
g2c_open()
.
mode
Mode flags. Set
G2C_NOCLOBBER
to avoid
overwriting and existing file.
index_file
The name that will be given to the index
file. An existing file will be overwritten.
Returns
|
β’ |
G2C_NOERROR No error. |
Author
Ed Hartnett
Date
10/12/22
Definition at line 431 of file g2cindex.c .
References g2c_message_info::bytes_in_msg , g2c_message_info::bytes_to_local , g2c_message_info::bytes_to_msg , g2c_section_info::bytes_to_sec , g2c_message_info::discipline , g2c_file_info::f , g2c_message_info::file , G2C_EBADID , G2C_EFILE , G2C_EINVAL , g2c_file , g2c_file_io_ubyte() , g2c_file_io_uint() , G2C_FILE_WRITE , g2c_get_prod_sections() , G2C_INDEX_BASENAME_LEN , G2C_INDEX_BITMAP_BYTES , G2C_INDEX_FIXED_LEN , G2C_INDEX_FIXED_LEN_2 , G2C_INDEX_HEADER_LEN , G2C_LARGE_FILE_INDEX , G2C_MAX_FILES , G2C_NOCLOBBER , G2C_NOERROR , g2c_rw_section1_metadata() , g2c_rw_section3_metadata() , g2c_rw_section4_metadata() , g2c_rw_section5_metadata() , g2c_start_index_record() , g2c_start_index_record_lf() , LOG , g2c_message_info::master_version , MUTEX_LOCK , MUTEX_UNLOCK , g2c_message_info::next , g2c_message_info::num_fields , ONE_BYTE , g2c_message_info::sec1_len , and g2c_section_info::sec_len .
Referenced by main() .
static int read_hdr_rec1 (FILE * f, int * ip, int * jp, int * kp, char *date_str, char * time_str) [static]
Read the header record apparently named after Steve Lord. This function reads the first of two 81-byte header records of an index file.
Parameters
f
Pointer to open FILE.
ip
Pointer that gets i value. Ignored if NULL.
jp
Pointer that gets j value. Ignored if NULL.
kp
Pointer that gets k value. Ignored if NULL.
date_str
Pointer to char array of size
G2C_INDEX_DATE_STR_LEN
+ 1 which will get the date
string from the header. Ignored if NULL.
time_str
Pointer to char array of size
G2C_INDEX_TIME_STR_LEN
+ 1 which will get the time
string from the header. Ignored if NULL.
Returns
0 for success, error code otherwise.
Author
Edward Hartnett
Date
9/10/23
Definition at line 684 of file g2cindex.c .
References G2C_EFILE , G2C_INDEX_DATE_STR_LEN , G2C_INDEX_HEADER_LEN , G2C_INDEX_STR1_LEN , G2C_INDEX_TIME_STR_LEN , G2C_NOERROR , and LOG .
Referenced by g2c_open_index1() .
static int read_hdr_rec2 (FILE * f, int * skipp, int * total_lenp, int *num_recp, char * basename, int * index_version) [static]
Read the second header record of an index file. This function reads the second of two 81-byte header records of an index file.
Parameters
f
Pointer to open FILE.
skipp
Pointer that gets number of bytes to skip before
index records. Ignored if NULL.
total_lenp
Pointer that gets number of bytes in each
index record. Ignored if NULL.
num_recp
Pointer that gets number of index records in
the file. Ignored if NULL.
basename
Pointer to char array of size
G2C_INDEX_BASENAME_LEN
+ 1 which will get the
basename string from the second header record. Ignored if
NULL.
index_version
The version of the index, 1 for legacy, 2
to allow for > 2 GB GRIB2 files.
Returns
0 for success, error code otherwise.
Author
Edward Hartnett
Date
9/10/23
Definition at line 753 of file g2cindex.c .
References G2C_EFILE , G2C_INDEX_BASENAME_LEN , G2C_INDEX_HEADER_LEN , and G2C_NOERROR .
Referenced by g2c_open_index1() .
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_open_index() , and g2c_write_index() .
Author
Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.