diff --git a/definitions/grib1/grid_definition_192.78.def b/definitions/grib1/grid_definition_192.78.def index e70f7019a..a7c3e746b 100644 --- a/definitions/grib1/grid_definition_192.78.def +++ b/definitions/grib1/grid_definition_192.78.def @@ -2,6 +2,8 @@ # DWD local grid definition 192 - triangular grid base on icosahedron subdivision +constant isGridded = true; + # n2 - exponent of 2 for the number of intervals on main triangle sides unsigned[2] n2 : dump ; diff --git a/src/bufr_util.cc b/src/bufr_util.cc index 000435488..7691c1fe0 100644 --- a/src/bufr_util.cc +++ b/src/bufr_util.cc @@ -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; +} diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index 6d72509de..32644b1ee 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -1385,6 +1385,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); diff --git a/src/grib_dumper_class_bufr_decode_C.cc b/src/grib_dumper_class_bufr_decode_C.cc index 294f7931e..49805279b 100644 --- a/src/grib_dumper_class_bufr_decode_C.cc +++ b/src/grib_dumper_class_bufr_decode_C.cc @@ -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); + } } } diff --git a/src/grib_dumper_class_bufr_decode_filter.cc b/src/grib_dumper_class_bufr_decode_filter.cc index ca1e7f454..0fff0fc14 100644 --- a/src/grib_dumper_class_bufr_decode_filter.cc +++ b/src/grib_dumper_class_bufr_decode_filter.cc @@ -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); diff --git a/src/grib_dumper_class_bufr_decode_fortran.cc b/src/grib_dumper_class_bufr_decode_fortran.cc index 739ec1362..b07f59b49 100644 --- a/src/grib_dumper_class_bufr_decode_fortran.cc +++ b/src/grib_dumper_class_bufr_decode_fortran.cc @@ -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); + } } } diff --git a/src/grib_dumper_class_bufr_decode_python.cc b/src/grib_dumper_class_bufr_decode_python.cc index 8c77c8325..632cbe98b 100644 --- a/src/grib_dumper_class_bufr_decode_python.cc +++ b/src/grib_dumper_class_bufr_decode_python.cc @@ -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); + } } } diff --git a/src/grib_dumper_class_bufr_encode_C.cc b/src/grib_dumper_class_bufr_encode_C.cc index b69f765c6..de68b423f 100644 --- a/src/grib_dumper_class_bufr_encode_C.cc +++ b/src/grib_dumper_class_bufr_encode_C.cc @@ -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) { diff --git a/src/grib_dumper_class_bufr_encode_filter.cc b/src/grib_dumper_class_bufr_encode_filter.cc index 38a704842..d55eb767a 100644 --- a/src/grib_dumper_class_bufr_encode_filter.cc +++ b/src/grib_dumper_class_bufr_encode_filter.cc @@ -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); + } } } diff --git a/src/grib_dumper_class_bufr_encode_fortran.cc b/src/grib_dumper_class_bufr_encode_fortran.cc index 8ddc771b6..b0f462019 100644 --- a/src/grib_dumper_class_bufr_encode_fortran.cc +++ b/src/grib_dumper_class_bufr_encode_fortran.cc @@ -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) { diff --git a/src/grib_dumper_class_bufr_encode_python.cc b/src/grib_dumper_class_bufr_encode_python.cc index ba2a0998a..f4bcba49b 100644 --- a/src/grib_dumper_class_bufr_encode_python.cc +++ b/src/grib_dumper_class_bufr_encode_python.cc @@ -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) { diff --git a/src/grib_dumper_class_bufr_simple.cc b/src/grib_dumper_class_bufr_simple.cc index 7dc758bc4..ca4701f38 100644 --- a/src/grib_dumper_class_bufr_simple.cc +++ b/src/grib_dumper_class_bufr_simple.cc @@ -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); diff --git a/tests/grib_ls.sh b/tests/grib_ls.sh index f702c0747..2a6f6c5ab 100755 --- a/tests/grib_ls.sh +++ b/tests/grib_ls.sh @@ -40,7 +40,13 @@ ${tools_dir}/grib_ls -l 0,0,1 $infile >> $tempLog ${tools_dir}/grib_get -l 0,0,1 $infile >> $tempLog ${tools_dir}/grib_get -p count,step $infile >> $tempLog ${tools_dir}/grib_get -P count $infile >> $tempLog -${tools_dir}/grib_get -i 0 $infile + +# ECC-786 and ECC-791 +result=$( ${tools_dir}/grib_get -p shortName -i 0 $infile ) +[ "$result" = "t 199.078 " ] +result=$( ${tools_dir}/grib_get -i 8191 $infile ) +[ "$result" = "160.852 " ] + files=" reduced_gaussian_lsm.grib1 reduced_gaussian_model_level.grib1 diff --git a/tools/grib_tools.cc b/tools/grib_tools.cc index b039c8d0d..fef2950e0 100644 --- a/tools/grib_tools.cc +++ b/tools/grib_tools.cc @@ -1285,7 +1285,7 @@ void grib_print_key_values(grib_runtime_options* options, grib_handle* h) snprintf(value, 32, options->format, v); strlenvalue = (int)strlen(value); width = strlenvalue < options->default_print_width ? options->default_print_width + 2 : strlenvalue + 2; - fprintf(dump_file, "%-*s", (int)width, value); + fprintf(dump_file, "%s%-*s", (written_to_dump?" ":""), (int)width, value); written_to_dump = 1; } if (written_to_dump) {