mirror of https://github.com/ecmwf/eccodes.git
ECC-1699: Dump
This commit is contained in:
parent
3cb61d994f
commit
161a048488
|
@ -1134,3 +1134,11 @@ int codes_bufr_key_is_coordinate(const grib_handle* h, const char* key, int* err
|
|||
*err = GRIB_SUCCESS;
|
||||
return ((acc->flags & GRIB_ACCESSOR_FLAG_BUFR_COORD) != 0);
|
||||
}
|
||||
|
||||
int codes_bufr_key_exclude_from_dump(const char* key)
|
||||
{
|
||||
if (strstr(key, "percentConfidence->percentConfidence->percentConfidence->percentConfidence->percentConfidence")) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1382,6 +1382,7 @@ int codes_bufr_extract_headers_malloc(grib_context* c, const char* filename, cod
|
|||
int codes_bufr_header_get_string(codes_bufr_header* bh, const char* key, char* val, size_t* len);
|
||||
int codes_bufr_key_is_header(const grib_handle* h, const char* key, int* err);
|
||||
int codes_bufr_key_is_coordinate(const grib_handle* h, const char* key, int* err);
|
||||
int codes_bufr_key_exclude_from_dump(const char* key);
|
||||
|
||||
/* string_util.cc*/
|
||||
int strcmp_nocase(const char* s1, const char* s2);
|
||||
|
|
|
@ -326,11 +326,13 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
|
|||
}
|
||||
else {
|
||||
r = compute_bufr_key_rank(h, self->keys, a->name);
|
||||
if (!grib_is_missing_long(a, value)) {
|
||||
if (r != 0)
|
||||
fprintf(self->dumper.out, " CODES_CHECK(codes_get_long(h, \"#%d#%s\", &iVal), 0);\n", r, a->name);
|
||||
else
|
||||
fprintf(self->dumper.out, " CODES_CHECK(codes_get_long(h, \"%s\", &iVal), 0);\n", a->name);
|
||||
if (!codes_bufr_key_exclude_from_dump(a->name)) {
|
||||
if (!grib_is_missing_long(a, value)) {
|
||||
if (r != 0)
|
||||
fprintf(self->dumper.out, " CODES_CHECK(codes_get_long(h, \"#%d#%s\", &iVal), 0);\n", r, a->name);
|
||||
else
|
||||
fprintf(self->dumper.out, " CODES_CHECK(codes_get_long(h, \"%s\", &iVal), 0);\n", a->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,8 +390,10 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
|
|||
}
|
||||
else {
|
||||
/* int r=compute_bufr_key_rank(h,self->keys,a->name); */
|
||||
if (!grib_is_missing_long(a, value)) {
|
||||
fprintf(self->dumper.out, " CODES_CHECK(codes_get_long(h, \"%s->%s\", &iVal), 0);\n", prefix, a->name);
|
||||
if (!codes_bufr_key_exclude_from_dump(prefix)) {
|
||||
if (!grib_is_missing_long(a, value)) {
|
||||
fprintf(self->dumper.out, " CODES_CHECK(codes_get_long(h, \"%s->%s\", &iVal), 0);\n", prefix, a->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -322,8 +322,9 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
|
|||
return;
|
||||
|
||||
self->empty = 0;
|
||||
fprintf(self->dumper.out, "print \"%s->%s = [%s->%s]\";\n", prefix, a->name, prefix, a->name);
|
||||
|
||||
if (!codes_bufr_key_exclude_from_dump(prefix)) {
|
||||
fprintf(self->dumper.out, "print \"%s->%s = [%s->%s]\";\n", prefix, a->name, prefix, a->name);
|
||||
}
|
||||
if (self->isLeaf == 0) {
|
||||
char* prefix1 = (char*)grib_context_malloc_clear(c, sizeof(char) * (strlen(a->name) + strlen(prefix) + 5));
|
||||
snprintf(prefix1, 1024, "%s->%s", prefix, a->name);
|
||||
|
|
|
@ -347,8 +347,10 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
|
|||
fprintf(self->dumper.out, " call codes_get(ibufr, '%s->%s', iValues)\n", prefix, a->name);
|
||||
}
|
||||
else {
|
||||
if (!grib_is_missing_long(a, value)) {
|
||||
fprintf(self->dumper.out, " call codes_get(ibufr, '%s->%s', iVal)\n", prefix, a->name);
|
||||
if (!codes_bufr_key_exclude_from_dump(prefix)) {
|
||||
if (!grib_is_missing_long(a, value)) {
|
||||
fprintf(self->dumper.out, " call codes_get(ibufr, '%s->%s', iVal)\n", prefix, a->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -359,8 +359,10 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
|
|||
fprintf(self->dumper.out, " iVals = codes_get_array(ibufr, '%s->%s')\n", prefix, a->name);
|
||||
}
|
||||
else {
|
||||
if (!grib_is_missing_long(a, value)) {
|
||||
fprintf(self->dumper.out, " iVal = codes_get(ibufr, '%s->%s')\n", prefix, a->name);
|
||||
if (!codes_bufr_key_exclude_from_dump(prefix)) {
|
||||
if (!grib_is_missing_long(a, value)) {
|
||||
fprintf(self->dumper.out, " iVal = codes_get(ibufr, '%s->%s')\n", prefix, a->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -524,10 +524,12 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
|
|||
fprintf(self->dumper.out, " CODES_CHECK(codes_set_long_array(h, \"%s->%s\", ivalues, size), 0);\n", prefix, a->name);
|
||||
}
|
||||
else {
|
||||
char* sval = lval_to_string(c, value);
|
||||
fprintf(self->dumper.out, " CODES_CHECK(codes_set_long(h, \"%s->%s\", ", prefix, a->name);
|
||||
fprintf(self->dumper.out, "%s), 0);\n", sval);
|
||||
grib_context_free(c, sval);
|
||||
if (!codes_bufr_key_exclude_from_dump(prefix)) {
|
||||
char* sval = lval_to_string(c, value);
|
||||
fprintf(self->dumper.out, " CODES_CHECK(codes_set_long(h, \"%s->%s\", ", prefix, a->name);
|
||||
fprintf(self->dumper.out, "%s), 0);\n", sval);
|
||||
grib_context_free(c, sval);
|
||||
}
|
||||
}
|
||||
|
||||
if (self->isLeaf == 0) {
|
||||
|
|
|
@ -451,9 +451,11 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
|
|||
}
|
||||
else {
|
||||
/* int r=compute_bufr_key_rank(h,self->keys,a->name); */
|
||||
if (!grib_is_missing_long(a, value)) {
|
||||
fprintf(self->dumper.out, "set %s->%s = ", prefix, a->name);
|
||||
fprintf(self->dumper.out, "%ld ;\n", value);
|
||||
if (!codes_bufr_key_exclude_from_dump(prefix)) {
|
||||
if (!grib_is_missing_long(a, value)) {
|
||||
fprintf(self->dumper.out, "set %s->%s = ", prefix, a->name);
|
||||
fprintf(self->dumper.out, "%ld ;\n", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -573,10 +573,12 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
|
|||
fprintf(self->dumper.out, " call codes_set(ibufr,'%s->%s' &\n,ivalues)\n", pref, a->name);
|
||||
}
|
||||
else {
|
||||
char* sval = lval_to_string(c, value);
|
||||
fprintf(self->dumper.out, " call codes_set(ibufr,'%s->%s'&\n,", pref, a->name);
|
||||
fprintf(self->dumper.out, "%s)\n", sval);
|
||||
grib_context_free(c, sval);
|
||||
if (!codes_bufr_key_exclude_from_dump(prefix)) {
|
||||
char* sval = lval_to_string(c, value);
|
||||
fprintf(self->dumper.out, " call codes_set(ibufr,'%s->%s'&\n,", pref, a->name);
|
||||
fprintf(self->dumper.out, "%s)\n", sval);
|
||||
grib_context_free(c, sval);
|
||||
}
|
||||
}
|
||||
|
||||
if (self->isLeaf == 0) {
|
||||
|
|
|
@ -519,10 +519,12 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
|
|||
fprintf(self->dumper.out, " codes_set_array(ibufr, '%s->%s', ivalues)\n", prefix, a->name);
|
||||
}
|
||||
else {
|
||||
char* sval = lval_to_string(c, value);
|
||||
fprintf(self->dumper.out, " codes_set(ibufr, '%s->%s', ", prefix, a->name);
|
||||
fprintf(self->dumper.out, "%s)\n", sval);
|
||||
grib_context_free(c, sval);
|
||||
if (!codes_bufr_key_exclude_from_dump(prefix)) {
|
||||
char* sval = lval_to_string(c, value);
|
||||
fprintf(self->dumper.out, " codes_set(ibufr, '%s->%s', ", prefix, a->name);
|
||||
fprintf(self->dumper.out, "%s)\n", sval);
|
||||
grib_context_free(c, sval);
|
||||
}
|
||||
}
|
||||
|
||||
if (self->isLeaf == 0) {
|
||||
|
|
|
@ -466,19 +466,19 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
|
|||
}
|
||||
else {
|
||||
/* int r=compute_bufr_key_rank(h,self->keys,a->name); */
|
||||
if (!grib_is_missing_long(a, value)) {
|
||||
fprintf(self->dumper.out, "%s->%s = ", prefix, a->name);
|
||||
fprintf(self->dumper.out, "%ld\n", value);
|
||||
}
|
||||
else {
|
||||
fprintf(self->dumper.out, "%s->%s = MISSING\n", prefix, a->name);
|
||||
if (!codes_bufr_key_exclude_from_dump(prefix)) {
|
||||
if (!grib_is_missing_long(a, value)) {
|
||||
fprintf(self->dumper.out, "%s->%s = ", prefix, a->name);
|
||||
fprintf(self->dumper.out, "%ld\n", value);
|
||||
}
|
||||
else {
|
||||
fprintf(self->dumper.out, "%s->%s = MISSING\n", prefix, a->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (self->isLeaf == 0) {
|
||||
char* prefix1;
|
||||
|
||||
prefix1 = (char*)grib_context_malloc_clear(c, sizeof(char) * (strlen(a->name) + strlen(prefix) + 5));
|
||||
char* prefix1 = (char*)grib_context_malloc_clear(c, sizeof(char) * (strlen(a->name) + strlen(prefix) + 5));
|
||||
snprintf(prefix1, 1024, "%s->%s", prefix, a->name);
|
||||
|
||||
dump_attributes(d, a, prefix1);
|
||||
|
|
Loading…
Reference in New Issue