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);
|
||||
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_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 */
|
||||
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)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < NUMBER(table) ; i++)
|
||||
if(strcmp(op,table[i].type) == 0)
|
||||
{
|
||||
grib_dumper_class* c = *(table[i].cclass);
|
||||
grib_dumper* d = (grib_dumper*) grib_context_malloc_clear(h->context,c->size);
|
||||
d->depth = 0;
|
||||
d->handle = h;
|
||||
d->cclass = c;
|
||||
d->option_flags = option_flags;
|
||||
d->arg = arg;
|
||||
d->out = out;
|
||||
grib_init_dumper(d);
|
||||
grib_context_log(h->context,GRIB_LOG_DEBUG,"Creating dumper of type : %s ", op);
|
||||
return d;
|
||||
}
|
||||
grib_context_log(h->context,GRIB_LOG_ERROR,"Unknown type : %s for dumper", op);
|
||||
return NULL;
|
||||
int i;
|
||||
for(i = 0; i < NUMBER(table) ; i++)
|
||||
if(strcmp(op,table[i].type) == 0)
|
||||
{
|
||||
grib_dumper_class* c = *(table[i].cclass);
|
||||
grib_dumper* d = (grib_dumper*) grib_context_malloc_clear(h->context,c->size);
|
||||
d->depth = 0;
|
||||
d->handle = h;
|
||||
d->cclass = c;
|
||||
d->option_flags = option_flags;
|
||||
d->arg = arg;
|
||||
d->out = out;
|
||||
grib_init_dumper(d);
|
||||
grib_context_log(h->context,GRIB_LOG_DEBUG,"Creating dumper of type : %s ", op);
|
||||
return d;
|
||||
}
|
||||
grib_context_log(h->context,GRIB_LOG_ERROR,"Unknown type : %s for dumper", op);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void grib_dump_accessors_block(grib_dumper* dumper,grib_block_of_accessors* block)
|
||||
{
|
||||
grib_accessor* a = block->first;
|
||||
while(a)
|
||||
{
|
||||
grib_accessor_dump(a,dumper);
|
||||
a = a->next;
|
||||
}
|
||||
grib_accessor* a = block->first;
|
||||
while(a)
|
||||
{
|
||||
grib_accessor_dump(a,dumper);
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
|
||||
void grib_dump_accessors_list(grib_dumper* dumper,grib_accessors_list* al)
|
||||
{
|
||||
grib_accessors_list* cur=al;
|
||||
grib_accessors_list* next=al->next;
|
||||
|
||||
while(next) {
|
||||
grib_accessor_dump(cur->accessor,dumper);
|
||||
cur=next;
|
||||
next=cur->next;
|
||||
}
|
||||
grib_accessors_list* cur=al;
|
||||
grib_accessors_list* next=al->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);
|
||||
|
||||
if(act){
|
||||
grib_accessor_dump(act, d );
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
return GRIB_NOT_FOUND;
|
||||
grib_accessor* act = grib_find_accessor(h, name);
|
||||
if(act){
|
||||
grib_accessor_dump(act, d );
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
return GRIB_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
void grib_dump_content(grib_handle* h, FILE* f,const char* mode,unsigned long option_flags,void *data)
|
||||
{
|
||||
grib_dumper *dumper;
|
||||
dumper = grib_dumper_factory(mode?mode:"serialize",h,f,option_flags,data);
|
||||
grib_dump_header(dumper,h);
|
||||
grib_dump_accessors_block(dumper,h->root->block);
|
||||
grib_dump_footer(dumper,h);
|
||||
grib_dumper_delete(dumper);
|
||||
grib_dumper *dumper;
|
||||
dumper = grib_dumper_factory(mode?mode:"serialize",h,f,option_flags,data);
|
||||
grib_dump_header(dumper,h);
|
||||
grib_dump_accessors_block(dumper,h->root->block);
|
||||
grib_dump_footer(dumper,h);
|
||||
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;
|
||||
dumper = grib_dumper_factory(mode?mode:"serialize",h,f,option_flags,data);
|
||||
grib_dump_header(dumper,h);
|
||||
grib_dump_accessors_list(dumper,al);
|
||||
grib_dump_footer(dumper,h);
|
||||
grib_dumper_delete(dumper);
|
||||
grib_dumper* dumper = NULL;
|
||||
Assert(h->product_kind == PRODUCT_BUFR);
|
||||
dumper = grib_dumper_factory(mode?mode:"serialize",h,f,option_flags,data);
|
||||
grib_dump_header(dumper,h);
|
||||
grib_dump_accessors_list(dumper,al);
|
||||
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"},
|
||||
{"S",0,0,1,0,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},
|
||||
{"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},
|
||||
{"f",0,0,0,1,0},
|
||||
{"H",0,0,0,1,0},
|
||||
{"a",0,0,0,1,0},
|
||||
{"w:",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"},
|
||||
{"7",0,0,0,1,0},
|
||||
{"V",0,0,0,1,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.";
|
||||
|
@ -49,8 +49,8 @@ static int first_handle=1;
|
|||
int grib_options_count=sizeof(grib_options)/sizeof(grib_option);
|
||||
|
||||
/**
|
||||
*grib_dump
|
||||
*Dump the content of a BUFR file
|
||||
* bufr_dump
|
||||
* Dump the content of a BUFR file
|
||||
*
|
||||
*/
|
||||
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 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";
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -101,11 +101,12 @@ int grib_tool_init(grib_runtime_options* options)
|
|||
| GRIB_DUMP_FLAG_READ_ONLY;
|
||||
}
|
||||
|
||||
/* See ECC-215
|
||||
if (grib_options_on("D")) {
|
||||
options->dump_mode = "debug";
|
||||
options->dump_flags = GRIB_DUMP_FLAG_VALUES
|
||||
| GRIB_DUMP_FLAG_READ_ONLY;
|
||||
}
|
||||
} */
|
||||
|
||||
if (grib_options_on("a"))
|
||||
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"))
|
||||
options->dump_flags |= GRIB_DUMP_FLAG_ALL_DATA;
|
||||
|
||||
|
||||
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");
|
||||
al=accessor_bufr_data_array_get_dataAccessors(a);
|
||||
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;
|
||||
case 's':
|
||||
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) {
|
||||
if (json ){
|
||||
if (first_handle) {
|
||||
fprintf(dump_file,"{ \"messages\" : [ \n");
|
||||
first_handle=0;
|
||||
} else {
|
||||
fprintf(dump_file,",\n");
|
||||
if (json ){
|
||||
if (first_handle) {
|
||||
fprintf(dump_file,"{ \"messages\" : [ \n");
|
||||
first_handle=0;
|
||||
} else {
|
||||
fprintf(dump_file,",\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(dump_file,"\"ERROR: unreadable message\"\n");
|
||||
return 0;
|
||||
fprintf(dump_file,"\"ERROR: unreadable message\"\n");
|
||||
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;
|
||||
|
||||
if (grib_options_on("V")) {
|
||||
printf("\neccodes Version ");
|
||||
printf("\necCodes Version ");
|
||||
grib_print_api_version(stdout);
|
||||
printf("\n\n");
|
||||
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);
|
||||
|
||||
if (grib_options_on("V")) {
|
||||
printf("\neccodes Version ");
|
||||
printf("\necCodes Version ");
|
||||
grib_print_api_version(stdout);
|
||||
printf("\n\n");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue