diff --git a/src/accessor/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc index 3a9a5d031..d3e31fc25 100644 --- a/src/accessor/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -340,16 +340,16 @@ static void print_user_friendly_message(grib_handle* h, const char* name, grib_c static int grib_concept_apply(grib_accessor* a, const char* name) { - int err = 0; - int count = 0; + int err = 0; + int count = 0; grib_concept_condition* e = NULL; - grib_values values[1024] = {{0},}; - grib_sarray* sa = NULL; - grib_concept_value* c = NULL; + grib_values values[1024] = {{0},}; // key/value pair array + grib_sarray* sa = NULL; + grib_concept_value* c = NULL; grib_concept_value* concepts = action_concept_get_concept(a); - grib_handle* h = grib_handle_of_accessor(a); - grib_action* act = a->creator_; - int nofail = action_concept_get_nofail(a); + grib_handle* h = grib_handle_of_accessor(a); + grib_action* act = a->creator_; + const int nofail = action_concept_get_nofail(a); DEBUG_ASSERT(concepts); @@ -380,7 +380,7 @@ static int grib_concept_apply(grib_accessor* a, const char* name) bool resubmit = false; for (int i = 0; i < count; i++) { if (values[i].error == GRIB_NOT_FOUND) { - // Repair the most common cause of failure: input GRIB handle + // Repair the most common cause of failure: input GRIB2 handle // is instantaneous but paramId/shortName being set is for accum/avg etc if (STR_EQUAL(values[i].name, "typeOfStatisticalProcessing")) { // Switch from instantaneous to interval-based @@ -402,6 +402,18 @@ static int grib_concept_apply(grib_accessor* a, const char* name) } } } + //grib_print_values("DEBUG grib_concept_apply", values, stdout, count); + if (err) { + for (int i = 0; i < count; i++) { + if (values[i].error != GRIB_SUCCESS) { + grib_context_log(h->context, GRIB_LOG_ERROR, + "grib_set_values[%d] %s (type=%s) failed: %s", + i, values[i].name, grib_get_type_name(values[i].type), + grib_get_error_message(values[i].error)); + } + } + } + return err; } diff --git a/src/grib_value.cc b/src/grib_value.cc index c56d698ba..d323b7533 100644 --- a/src/grib_value.cc +++ b/src/grib_value.cc @@ -1899,8 +1899,9 @@ void grib_print_values(const char* title, const grib_values* values, FILE* out, fprintf(out, "%s", aVal.string_value); break; } - fprintf(out, " (type=%s)\n", grib_get_type_name(aVal.type)); - //fprintf(out, " (type=%s) (%s)\n", grib_get_type_name(aVal.type), grib_get_error_message(aVal.error)); + fprintf(out, " (type=%s)", grib_get_type_name(aVal.type)); + if (aVal.error) fprintf(out, "\t(%s)\n", grib_get_error_message(aVal.error)); + else fprintf(out, "\n"); } } diff --git a/tests/grib2_product_templates.sh b/tests/grib2_product_templates.sh index 5cbcd0797..579592462 100755 --- a/tests/grib2_product_templates.sh +++ b/tests/grib2_product_templates.sh @@ -74,14 +74,14 @@ grib_check_key_equals $tempGribA productDefinitionTemplateNumber 8 grib_check_key_equals $tempGribA typeOfStatisticalProcessing,stepType '2 max' grib_check_key_equals $tempGribA shortName,name 'max_visp Time-maximum visibility through precipitation' -# Test a failure. paramId=140114 contains wave keys +# Test an expected failure. paramId=140114 contains wave keys set +e $tools_dir/grib_set -s paramId=140114 $sample_g2 $tempGribA 2>$tempText status=$? set -e [ $status -ne 0 ] -# cat $tempText -# check for "typeOfWavePeriodInterval (type=long) failed: Key/value not found" in error log +grep -q "typeOfWavePeriodInterval .* failed: Key/value not found" $tempText +grep -q "scaleFactorOfLowerWavePeriodLimit .* failed: Key/value not found" $tempText # Clean up