38 void fdebufr_f(
char *ofile,
int lenof,
char *tbldir,
int lentd,
char *tblfil,
int lentf,
char *prmstg,
int lenps,
39 char basic,
char forcemt,
char cfms );
49 printf(
"\nUSAGE:\n" );
50 printf(
" %s [-v] [-h] [-b] [-c] [-m] [-o outfile] [-t tabledir] [-f tablefil] [-p prmstg] bufrfile\n\n", prgnam );
51 printf(
"\nWHERE:\n" );
52 printf(
" -v prints program version information and exits\n\n" );
53 printf(
" -h prints program help and usage information and exits\n\n" );
54 printf(
" -b specifies the \"basic\" option, meaning that only the\n" );
55 printf(
" information in Sections 0-3 will be decoded from each\n" );
56 printf(
" BUFR message in the bufrfile, and no attempt will be\n" );
57 printf(
" made to decode the data in Section 4\n\n" );
58 printf(
" -c specifies that code and flag table meanings should not\n" );
59 printf(
" be read from master BUFR tables and included in the output;\n" );
60 printf(
" otherwise this feature is enabled by default\n\n" );
61 printf(
" -m specifies that master BUFR tables will be used to\n" );
62 printf(
" decode the data messages in the file, regardless of\n" );
63 printf(
" whether it contains any embedded DX BUFR table messages.\n" );
64 printf(
" This option can be used to view the actual contents of\n" );
65 printf(
" DX BUFR table messages, which otherwise would not be\n" );
66 printf(
" printed in the output listing.\n\n" );
67 printf(
" outfile [path/]name of file to contain verbose output listing.\n" );
68 printf(
" The default is \"bufrfilename.debufr.out\" in the current\n" );
69 printf(
" working directory, where bufrfilename is the basename of\n" );
70 printf(
" the bufrfile (i.e. bufrfile with any preceding [path/]\n" );
71 printf(
" removed).\n\n" );
72 printf(
" tabledir [path/]name of directory containing tables to be used\n" );
73 printf(
" for decoding. This directory contains the DX BUFR tables\n" );
74 printf(
" file to be used (if one was specified via the -f option),\n" );
75 printf(
" or it may contain all of the master BUFR tables when these\n" );
76 printf(
" are being used to decode a file. If unspecified, the\n" );
77 printf(
" default directory location is\n" );
78 printf(
" \"/home/runner/work/NCEPLIBS-bufr/NCEPLIBS-bufr/bufr/build/install/tables\"\n\n" );
79 printf(
" tablefil file within tabledir containing DX BUFR tables to be used\n" );
80 printf(
" for decoding.\n\n" );
81 printf(
" prmstg string of comma-separated PARAMETER=VALUE pairs, up to a\n" );
82 printf(
" maximum of 20. For each pair, the dynamic allocation\n" );
83 printf(
" PARAMETER will be set to VALUE within the underlying\n" );
84 printf(
" NCEPLIBS-bufr software, overriding the default value that would\n" );
85 printf(
" otherwise be used. A complete list of parameters that can\n" );
86 printf(
" be dynamically sized is included within the documentation\n" );
87 printf(
" for NCEPLIBS-bufr function isetprm.\n\n" );
88 printf(
" bufrfile [path/]name of BUFR file to be decoded\n\n" );
167 int main(
int argc,
char *argv[ ] ) {
175 char tbldir_default[500] =
176 "/home/runner/work/NCEPLIBS-bufr/NCEPLIBS-bufr/bufr/build/ins"
186 char *bcopy, *bname, *dcopy, *dname;
188 int lenof, lentd, lentf, lenps;
193 while ( ( ch = getopt ( argc, argv,
"vhbcmo:t:f:p:" ) ) != EOF ) {
197 printf(
"This is debufr v4.0.0, built with NCEPLIBS-bufr v%s\n", bvstr );
200 printf(
"\nPROGRAM %s\n", argv[0] );
201 printf(
"\nABSTRACT: This program decodes a BUFR file and generates a verbose\n" );
202 printf(
" listing of the contents. If a DX BUFR tables file is specified\n" );
203 printf(
" (using the -f option) or if the specified BUFR file contains an\n" );
204 printf(
" embedded DX BUFR tables message as the first message in the file,\n" );
205 printf(
" then this DX BUFR tables information is used to decode the data\n" );
206 printf(
" messages in the file. Otherwise, or whenever the -m option is\n" );
207 printf(
" specified, master BUFR tables are read and used to decode the\n" );
208 printf(
" data messages in the file.\n" );
222 if ( ( ofile = malloc( strlen( optarg ) + 1 ) ) == NULL ) {
223 printf(
"\nERROR: Could not allocate memory for output file name!\n" );
226 strcpy ( ofile, optarg );
229 if ( ( tbldir = malloc( strlen( optarg ) + 1 ) ) == NULL ) {
230 printf(
"\nERROR: Could not allocate memory for tables directory!\n" );
233 strcpy ( tbldir, optarg );
236 if ( ( wkstr = malloc( strlen( optarg ) + 1 ) ) == NULL ) {
237 printf(
"\nERROR: Could not allocate memory for DX BUFR tables file!\n" );
240 strcpy ( wkstr, optarg );
243 if ( ( prmstg = malloc( strlen( optarg ) + 1 ) ) == NULL ) {
244 printf(
"\nERROR: Could not allocate memory for PARAMETER(S)=VALUE(S) string!\n" );
247 strcpy ( prmstg, optarg );
256 if ( (optind+1) != argc ) {
257 printf(
"\nERROR: You must specify an input BUFR file to be decoded!\n" );
265 cobfl( argv[optind], io );
270 if ( prmstg == NULL ) {
271 if ( ( prmstg = malloc( 9 ) ) == NULL ) {
272 printf(
"\nERROR: Could not allocate memory for PARAMETER(S)=VALUE(S) string!\n" );
275 strcpy( prmstg,
"NULLPSTG" );
281 if ( tbldir == NULL ) {
282 if ( ( tbldir = malloc( strlen( tbldir_default ) + 1 ) ) == NULL ) {
283 printf(
"\nERROR: Could not allocate memory for tables directory!\n" );
286 strcpy( tbldir, tbldir_default );
292 if ( wkstr == NULL ) {
293 if ( ( tblfil = malloc( 9 ) ) == NULL ) {
294 printf(
"\nERROR: Could not allocate memory for DX BUFR tables file!\n" );
297 strcpy( tblfil,
"NULLFILE" );
300 if ( ( tblfil = malloc( strlen( tbldir ) + strlen( wkstr ) + 2 ) ) == NULL ) {
301 printf(
"\nERROR: Could not allocate memory for DX BUFR tables file!\n" );
304 sprintf( tblfil,
"%s%c%s", tbldir,
'/', wkstr );
313 if ( ofile == NULL ) {
314 bcopy = strdup( argv[optind] );
315 bname = basename( bcopy );
316 if ( ( ofile = malloc( strlen( bname ) + 15 ) ) == NULL ) {
317 printf(
"\nERROR: Could not allocate memory for output file name!\n" );
320 strcpy( ofile, bname );
321 strcat( ofile,
".debufr.out" );
328 dcopy = strdup( ofile );
329 dname = dirname( dcopy );
330 if ( access( dname, W_OK ) != 0 ) {
331 printf(
"\nERROR: Cannot write output file to %s\n",
332 ( strcmp( dname,
"." ) == 0 ?
"current working directory" : dname ) );
341 lenof = strlen( ofile );
342 lentd = strlen( tbldir );
343 lentf = strlen( tblfil );
344 lenps = strlen( prmstg );
345 fdebufr_f( ofile, lenof, tbldir, lentd, tblfil, lentf, prmstg, lenps, basic, forcemt, cfms );
Enable a number of NCEPLIBS-bufr subprograms to be called from within C and C++ application programs.
void cobfl(char *bfl, char io)
Open a new file for reading or writing BUFR messages via a C language interface.
void ccbfl(void)
Close all files that were opened via previous calls to function cobfl().
void bvers_f(char *cverstr, int cverstr_len)
Get the version number of the NCEPLIBS-bufr software.
Enable a number of NCEPLIBS-bufr subprograms to be called from within the C part of the library.
#define VERS_STR_LEN
Size of a character string needed to store a library version number.
int main(int argc, char *argv[])
This program decodes a BUFR file and generates a verbose listing of the contents.
void prtusage(char *prgnam)
This function prints program usage information to standard output.
void fdebufr_f(char *ofile, int lenof, char *tbldir, int lentd, char *tblfil, int lentf, char *prmstg, int lenps, char basic, char forcemt, char cfms)
Read, decode, and print a verbose output listing of the contents of a BUFR file.