NCEPLIBS-g2tmpl
1.12.0
|
4dot2 More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
Go to the source code of this file.
Macros | |
#define | MXFNLEN 120 |
Max fn length. More... | |
#define | MXFNLEN 120 |
Max fn length. More... | |
#define | MXG2MNEM 16 |
Define the maximum length of a mnemonic in GRIB2 Code Table 4.2. More... | |
#define | MXG2MNEMP4 ( MXG2MNEM + 4) |
Define the maximum length of a mnemonic in GRIB2 Code Table 4.2. More... | |
#define | NUMALLOC 2500 |
Allocate internal memory for table entries in chunks of 25000. More... | |
Typedefs | |
typedef int | f77int |
On certain operating systems, the FORTRAN compiler appends an underscore to subprogram names in its object namespace. More... | |
Functions | |
void | close_4dot2 (f77int *iret) |
This subroutine should be called one time at the end of the application program in order to free all allocated memory. More... | |
int | compar (const struct TableEntry *pte1, const struct TableEntry *pte2) |
Define the internal comparison function for use with qsort and bsearch. More... | |
void | open_and_read_4dot2 (char *filename, f77int *iret) |
Opens and reads the GRIB2 Code Table 4.2 into an internal memory structure. More... | |
void | search_for_4dot2_entry (char nemo[MXG2MNEM], f77int *locflg, f77int *disc, f77int *catg, f77int *parm, f77int *iret) |
Searches for a specified mnemonic within the previously-opened GRIB2 Code Table 4.2 and returns the corresponding product discipline, parameter category and parameter number. More... | |
void | sort_and_write_4dot2 (char *filename, f77int *iret) |
Sorts the contents of GRIB2 Code Table 4.2 within the internal memory structure and writes the output to the file specified by filename. More... | |
Variables | |
size_t | nentry = 0 |
Number of entries. More... | |
struct TableEntry * | pe0 = NULL |
Table entry. More... | |
#define MXFNLEN 120 |
Max fn length.
Definition at line 23 of file process_4dot2.c.
#define MXFNLEN 120 |
Max fn length.
Definition at line 23 of file process_4dot2.c.
#define MXG2MNEM 16 |
Define the maximum length of a mnemonic in GRIB2 Code Table 4.2.
Definition at line 13 of file process_4dot2.c.
#define MXG2MNEMP4 ( MXG2MNEM + 4) |
Define the maximum length of a mnemonic in GRIB2 Code Table 4.2.
Definition at line 17 of file process_4dot2.c.
#define NUMALLOC 2500 |
Allocate internal memory for table entries in chunks of 25000.
Definition at line 20 of file process_4dot2.c.
typedef int f77int |
On certain operating systems, the FORTRAN compiler appends an underscore to subprogram names in its object namespace.
Therefore, on such systems, a matching underscore must be appended to any C language references to the same subprogram names so that the linker can correctly resolve such references across the C <-> FORTRAN interface at link time. In order to ensure that the C <-> FORTRAN interface works properly (and portably!), the default size of an "INTEGER" declared in FORTRAN must be identical to that of an "int" declared in C. If this is not the case (e.g. some FORTRAN compilers, most notably AIX via the -qintsize= option, allow the sizes of INTEGERs to be definitively prescribed outside of the source code itself!), then the following conditional directive (or a variant of it) can be used to ensure that the size of an "int" in C remains identical to that of an "INTEGER" in FORTRAN.
Definition at line 50 of file process_4dot2.c.
void close_4dot2 | ( | f77int * | iret | ) |
This subroutine should be called one time at the end of the application program in order to free all allocated memory.
iret | Return code: 0 = normal return. |
Definition at line 342 of file process_4dot2.c.
References pe0.
int compar | ( | const struct TableEntry * | pte1, |
const struct TableEntry * | pte2 | ||
) |
Define the internal comparison function for use with qsort and bsearch.
pte1 | TableEntry1 |
pte2 | TableEntry2 |
Definition at line 84 of file process_4dot2.c.
Referenced by search_for_4dot2_entry(), and sort_and_write_4dot2().
void open_and_read_4dot2 | ( | char * | filename, |
f77int * | iret | ||
) |
Opens and reads the GRIB2 Code Table 4.2 into an internal memory structure.
In order for the search_for_4dot2_entry() function to be used, the table must be in sorted order with respect to the mnemonic and according to the criteria of the compar() function. If this has not already been done, it can be done by calling the sort_and_write_4dot2() function prior to calling the search_for_4dot2_entry() function.
filename | Location of table file on filesystem; directory prefixes or other local filesystem notation is allowed up to 120 total characters. |
iret | Return code:
|
Definition at line 113 of file process_4dot2.c.
References MXFNLEN, nentry, NUMALLOC, and pe0.
Referenced by sort_params_grib2_tbl().
void search_for_4dot2_entry | ( | char | nemo[MXG2MNEM], |
f77int * | locflg, | ||
f77int * | disc, | ||
f77int * | catg, | ||
f77int * | parm, | ||
f77int * | iret | ||
) |
Searches for a specified mnemonic within the previously-opened GRIB2 Code Table 4.2 and returns the corresponding product discipline, parameter category and parameter number.
A binary search algorithm is used.
In order for this function to be used, the table must already be in sorted order with respect to the mnemonic and according to the criteria of the compar() function. If this has not already been done, it can be done by calling the sort_and_write_4dot2() function prior to calling this function.
nemo | Mnemonic (of up to 16 characters in length) to search for within table. |
locflg | Version of mnemonic to be returned, in case of duplication within table:
|
disc | Product discipline |
catg | Parameter category |
parm | Parameter number |
iret | Return code:
|
Definition at line 284 of file process_4dot2.c.
void sort_and_write_4dot2 | ( | char * | filename, |
f77int * | iret | ||
) |
Sorts the contents of GRIB2 Code Table 4.2 within the internal memory structure and writes the output to the file specified by filename.
The output file will be in a format suitable for subsequent reading via the open_and_read_4dot2() function, so that this function does not need to be called again prior to calling search_for_4dot2_entry().
filename | Filename to which to write the sorted output. Directory prefixes or other local filesystem notation is allowed up to 120 total characters. |
iret | Return code:
|
Definition at line 199 of file process_4dot2.c.
References compar(), MXFNLEN, MXG2MNEMP4, nentry, and pe0.
Referenced by sort_params_grib2_tbl().
size_t nentry = 0 |
Number of entries.
Definition at line 65 of file process_4dot2.c.
Referenced by open_and_read_4dot2(), search_for_4dot2_entry(), and sort_and_write_4dot2().
struct TableEntry* pe0 = NULL |
Table entry.
Definition at line 62 of file process_4dot2.c.
Referenced by close_4dot2(), open_and_read_4dot2(), search_for_4dot2_entry(), and sort_and_write_4dot2().