mirror of https://github.com/ecmwf/eccodes.git
ECC-215: Remove the -D option from bufr_dump
This commit is contained in:
parent
1ceda96076
commit
ba4cb052da
|
@ -904,7 +904,7 @@ void grib_dump_accessors_block(grib_dumper *dumper, grib_block_of_accessors *blo
|
||||||
void grib_dump_accessors_list(grib_dumper *dumper, grib_accessors_list *al);
|
void grib_dump_accessors_list(grib_dumper *dumper, grib_accessors_list *al);
|
||||||
int grib_print(grib_handle *h, const char *name, grib_dumper *d);
|
int grib_print(grib_handle *h, const char *name, grib_dumper *d);
|
||||||
void grib_dump_content(grib_handle *h, FILE *f, const char *mode, unsigned long option_flags, void *data);
|
void grib_dump_content(grib_handle *h, FILE *f, const char *mode, unsigned long option_flags, void *data);
|
||||||
void grib_dump_bufr_flat(grib_accessors_list *al, grib_handle *h, FILE *f, const char *mode, unsigned long option_flags, void *data);
|
void codes_dump_bufr_flat(grib_accessors_list *al, grib_handle *h, FILE *f, const char *mode, unsigned long option_flags, void *data);
|
||||||
|
|
||||||
/* grib_context.c */
|
/* grib_context.c */
|
||||||
size_t grib_context_read(const grib_context *c, void *ptr, size_t size, void *stream);
|
size_t grib_context_read(const grib_context *c, void *ptr, size_t size, void *stream);
|
||||||
|
|
|
@ -31,77 +31,75 @@ static struct table_entry table[] =
|
||||||
|
|
||||||
grib_dumper* grib_dumper_factory(const char* op, grib_handle* h, FILE* out, unsigned long option_flags,void* arg)
|
grib_dumper* grib_dumper_factory(const char* op, grib_handle* h, FILE* out, unsigned long option_flags,void* arg)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < NUMBER(table) ; i++)
|
for(i = 0; i < NUMBER(table) ; i++)
|
||||||
if(strcmp(op,table[i].type) == 0)
|
if(strcmp(op,table[i].type) == 0)
|
||||||
{
|
{
|
||||||
grib_dumper_class* c = *(table[i].cclass);
|
grib_dumper_class* c = *(table[i].cclass);
|
||||||
grib_dumper* d = (grib_dumper*) grib_context_malloc_clear(h->context,c->size);
|
grib_dumper* d = (grib_dumper*) grib_context_malloc_clear(h->context,c->size);
|
||||||
d->depth = 0;
|
d->depth = 0;
|
||||||
d->handle = h;
|
d->handle = h;
|
||||||
d->cclass = c;
|
d->cclass = c;
|
||||||
d->option_flags = option_flags;
|
d->option_flags = option_flags;
|
||||||
d->arg = arg;
|
d->arg = arg;
|
||||||
d->out = out;
|
d->out = out;
|
||||||
grib_init_dumper(d);
|
grib_init_dumper(d);
|
||||||
grib_context_log(h->context,GRIB_LOG_DEBUG,"Creating dumper of type : %s ", op);
|
grib_context_log(h->context,GRIB_LOG_DEBUG,"Creating dumper of type : %s ", op);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
grib_context_log(h->context,GRIB_LOG_ERROR,"Unknown type : %s for dumper", op);
|
grib_context_log(h->context,GRIB_LOG_ERROR,"Unknown type : %s for dumper", op);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void grib_dump_accessors_block(grib_dumper* dumper,grib_block_of_accessors* block)
|
void grib_dump_accessors_block(grib_dumper* dumper,grib_block_of_accessors* block)
|
||||||
{
|
{
|
||||||
grib_accessor* a = block->first;
|
grib_accessor* a = block->first;
|
||||||
while(a)
|
while(a)
|
||||||
{
|
{
|
||||||
grib_accessor_dump(a,dumper);
|
grib_accessor_dump(a,dumper);
|
||||||
a = a->next;
|
a = a->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void grib_dump_accessors_list(grib_dumper* dumper,grib_accessors_list* al)
|
void grib_dump_accessors_list(grib_dumper* dumper,grib_accessors_list* al)
|
||||||
{
|
{
|
||||||
grib_accessors_list* cur=al;
|
grib_accessors_list* cur=al;
|
||||||
grib_accessors_list* next=al->next;
|
grib_accessors_list* next=al->next;
|
||||||
|
|
||||||
while(next) {
|
|
||||||
grib_accessor_dump(cur->accessor,dumper);
|
|
||||||
cur=next;
|
|
||||||
next=cur->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
while(next) {
|
||||||
|
grib_accessor_dump(cur->accessor,dumper);
|
||||||
|
cur=next;
|
||||||
|
next=cur->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int grib_print (grib_handle* h, const char* name, grib_dumper *d ){
|
int grib_print(grib_handle* h, const char* name, grib_dumper *d ){
|
||||||
|
|
||||||
grib_accessor* act = grib_find_accessor(h, name);
|
grib_accessor* act = grib_find_accessor(h, name);
|
||||||
|
if(act){
|
||||||
if(act){
|
grib_accessor_dump(act, d );
|
||||||
grib_accessor_dump(act, d );
|
return GRIB_SUCCESS;
|
||||||
return GRIB_SUCCESS;
|
}
|
||||||
}
|
return GRIB_NOT_FOUND;
|
||||||
return GRIB_NOT_FOUND;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void grib_dump_content(grib_handle* h, FILE* f,const char* mode,unsigned long option_flags,void *data)
|
void grib_dump_content(grib_handle* h, FILE* f,const char* mode,unsigned long option_flags,void *data)
|
||||||
{
|
{
|
||||||
grib_dumper *dumper;
|
grib_dumper *dumper;
|
||||||
dumper = grib_dumper_factory(mode?mode:"serialize",h,f,option_flags,data);
|
dumper = grib_dumper_factory(mode?mode:"serialize",h,f,option_flags,data);
|
||||||
grib_dump_header(dumper,h);
|
grib_dump_header(dumper,h);
|
||||||
grib_dump_accessors_block(dumper,h->root->block);
|
grib_dump_accessors_block(dumper,h->root->block);
|
||||||
grib_dump_footer(dumper,h);
|
grib_dump_footer(dumper,h);
|
||||||
grib_dumper_delete(dumper);
|
grib_dumper_delete(dumper);
|
||||||
}
|
}
|
||||||
|
|
||||||
void grib_dump_bufr_flat(grib_accessors_list* al,grib_handle* h, FILE* f,const char* mode,unsigned long option_flags,void *data)
|
void codes_dump_bufr_flat(grib_accessors_list* al,grib_handle* h, FILE* f,const char* mode,unsigned long option_flags,void *data)
|
||||||
{
|
{
|
||||||
grib_dumper *dumper;
|
grib_dumper* dumper = NULL;
|
||||||
dumper = grib_dumper_factory(mode?mode:"serialize",h,f,option_flags,data);
|
Assert(h->product_kind == PRODUCT_BUFR);
|
||||||
grib_dump_header(dumper,h);
|
dumper = grib_dumper_factory(mode?mode:"serialize",h,f,option_flags,data);
|
||||||
grib_dump_accessors_list(dumper,al);
|
grib_dump_header(dumper,h);
|
||||||
grib_dump_footer(dumper,h);
|
grib_dump_accessors_list(dumper,al);
|
||||||
grib_dumper_delete(dumper);
|
grib_dump_footer(dumper,h);
|
||||||
|
grib_dumper_delete(dumper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,22 +21,22 @@ grib_option grib_options[]={
|
||||||
"\n\t\tOptions: s->structure, f->flat (only data), a->all attributes\n",1,1,"s"},
|
"\n\t\tOptions: s->structure, f->flat (only data), a->all attributes\n",1,1,"s"},
|
||||||
{"S",0,0,1,0,0},
|
{"S",0,0,1,0,0},
|
||||||
{"O",0,"Octet mode. WMO documentation style dump.\n",0,1,0},
|
{"O",0,"Octet mode. WMO documentation style dump.\n",0,1,0},
|
||||||
{"D",0,0,0,1,0},
|
/* {"D",0,0,0,1,0}, */ /* See ECC-215 */
|
||||||
{"d",0,"Print all data values.\n",1,1,0},
|
{"d",0,"Print all data values.\n",1,1,0},
|
||||||
{"u",0,"Print only some values.\n",0,1,0},
|
{"u",0,"Print only some values.\n",0,1,0},
|
||||||
/* {"C",0,0,0,1,0}, */
|
/* {"C",0,0,0,1,0}, */
|
||||||
{"t",0,0,0,1,0},
|
{"t",0,0,0,1,0},
|
||||||
{"f",0,0,0,1,0},
|
{"f",0,0,0,1,0},
|
||||||
{"H",0,0,0,1,0},
|
{"H",0,0,0,1,0},
|
||||||
{"a",0,0,0,1,0},
|
{"a",0,0,0,1,0},
|
||||||
{"w:",0,0,0,1,0},
|
{"w:",0,0,0,1,0},
|
||||||
{"s:",0,0,0,1,0},
|
{"s:",0,0,0,1,0},
|
||||||
/* {"M",0,0,0,1,0}, */
|
/* {"M",0,0,0,1,0}, */
|
||||||
{"T:",0,0,1,0,"B"},
|
{"T:",0,0,1,0,"B"},
|
||||||
{"7",0,0,0,1,0},
|
{"7",0,0,0,1,0},
|
||||||
{"V",0,0,0,1,0},
|
{"V",0,0,0,1,0},
|
||||||
{"q",0,0,1,0,0}
|
{"q",0,0,1,0,0}
|
||||||
/* {"x",0,0,0,1,0} */
|
/* {"x",0,0,0,1,0} */
|
||||||
};
|
};
|
||||||
|
|
||||||
char* grib_tool_description="Dump the content of a BUFR file in different formats.";
|
char* grib_tool_description="Dump the content of a BUFR file in different formats.";
|
||||||
|
@ -49,8 +49,8 @@ static int first_handle=1;
|
||||||
int grib_options_count=sizeof(grib_options)/sizeof(grib_option);
|
int grib_options_count=sizeof(grib_options)/sizeof(grib_option);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*grib_dump
|
* bufr_dump
|
||||||
*Dump the content of a BUFR file
|
* Dump the content of a BUFR file
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -65,12 +65,12 @@ int grib_tool_before_getopt(grib_runtime_options* options)
|
||||||
|
|
||||||
int grib_tool_init(grib_runtime_options* options)
|
int grib_tool_init(grib_runtime_options* options)
|
||||||
{
|
{
|
||||||
int opt=grib_options_on("C")+grib_options_on("O")+grib_options_on("D");
|
int opt=grib_options_on("C")+grib_options_on("O");
|
||||||
|
|
||||||
options->dump_mode = "default";
|
options->dump_mode = "default";
|
||||||
|
|
||||||
if (opt > 1) {
|
if (opt > 1) {
|
||||||
printf("%s: simultaneous j/C/O/D options not allowed\n",grib_tool_name);
|
printf("%s: simultaneous j/C/O options not allowed\n",grib_tool_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,11 +101,12 @@ int grib_tool_init(grib_runtime_options* options)
|
||||||
| GRIB_DUMP_FLAG_READ_ONLY;
|
| GRIB_DUMP_FLAG_READ_ONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See ECC-215
|
||||||
if (grib_options_on("D")) {
|
if (grib_options_on("D")) {
|
||||||
options->dump_mode = "debug";
|
options->dump_mode = "debug";
|
||||||
options->dump_flags = GRIB_DUMP_FLAG_VALUES
|
options->dump_flags = GRIB_DUMP_FLAG_VALUES
|
||||||
| GRIB_DUMP_FLAG_READ_ONLY;
|
| GRIB_DUMP_FLAG_READ_ONLY;
|
||||||
}
|
} */
|
||||||
|
|
||||||
if (grib_options_on("a"))
|
if (grib_options_on("a"))
|
||||||
options->dump_flags |= GRIB_DUMP_FLAG_ALIASES;
|
options->dump_flags |= GRIB_DUMP_FLAG_ALIASES;
|
||||||
|
@ -119,7 +120,6 @@ int grib_tool_init(grib_runtime_options* options)
|
||||||
if (grib_options_on("d") && !grib_options_on("u"))
|
if (grib_options_on("d") && !grib_options_on("u"))
|
||||||
options->dump_flags |= GRIB_DUMP_FLAG_ALL_DATA;
|
options->dump_flags |= GRIB_DUMP_FLAG_ALL_DATA;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
|
||||||
a=grib_find_accessor(h,"numericValues");
|
a=grib_find_accessor(h,"numericValues");
|
||||||
al=accessor_bufr_data_array_get_dataAccessors(a);
|
al=accessor_bufr_data_array_get_dataAccessors(a);
|
||||||
options->dump_flags=GRIB_DUMP_FLAG_ALL_ATTRIBUTES;
|
options->dump_flags=GRIB_DUMP_FLAG_ALL_ATTRIBUTES;
|
||||||
grib_dump_bufr_flat(al,h,stdout,options->dump_mode,options->dump_flags,0);
|
codes_dump_bufr_flat(al,h,stdout,options->dump_mode,options->dump_flags,0);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
err=grib_set_long(h,"unpack",1);
|
err=grib_set_long(h,"unpack",1);
|
||||||
|
@ -233,15 +233,14 @@ int grib_tool_finalise_action(grib_runtime_options* options)
|
||||||
}
|
}
|
||||||
|
|
||||||
int grib_no_handle_action(int err) {
|
int grib_no_handle_action(int err) {
|
||||||
if (json ){
|
if (json ){
|
||||||
if (first_handle) {
|
if (first_handle) {
|
||||||
fprintf(dump_file,"{ \"messages\" : [ \n");
|
fprintf(dump_file,"{ \"messages\" : [ \n");
|
||||||
first_handle=0;
|
first_handle=0;
|
||||||
} else {
|
} else {
|
||||||
fprintf(dump_file,",\n");
|
fprintf(dump_file,",\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
fprintf(dump_file,"\"ERROR: unreadable message\"\n");
|
||||||
fprintf(dump_file,"\"ERROR: unreadable message\"\n");
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ int grib_process_runtime_options(grib_context* context,int argc,char** argv,grib
|
||||||
char *karg=NULL,*warg=NULL,*sarg=NULL,*barg=NULL;
|
char *karg=NULL,*warg=NULL,*sarg=NULL,*barg=NULL;
|
||||||
|
|
||||||
if (grib_options_on("V")) {
|
if (grib_options_on("V")) {
|
||||||
printf("\neccodes Version ");
|
printf("\necCodes Version ");
|
||||||
grib_print_api_version(stdout);
|
grib_print_api_version(stdout);
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -312,7 +312,7 @@ int grib_process_runtime_options(grib_context* context,int argc,char** argv,grib
|
||||||
else grib_gts_header_off(context);
|
else grib_gts_header_off(context);
|
||||||
|
|
||||||
if (grib_options_on("V")) {
|
if (grib_options_on("V")) {
|
||||||
printf("\neccodes Version ");
|
printf("\necCodes Version ");
|
||||||
grib_print_api_version(stdout);
|
grib_print_api_version(stdout);
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue