mirror of https://github.com/ecmwf/eccodes.git
ECC-992: Implement warning mode (ECCODES_GRIB_DATA_QUALITY_CHECKS=2)
This commit is contained in:
parent
089604ec03
commit
39eda000c8
|
@ -2113,16 +2113,24 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max
|
|||
int err = 0;
|
||||
long min_field_value_allowed=0, max_field_value_allowed=0;
|
||||
double dmin_allowed=0, dmax_allowed=0;
|
||||
grib_context* ctx = h->context;
|
||||
int is_error = 1;
|
||||
/*
|
||||
* If grib_data_quality_checks == 1, limits failure results in an error
|
||||
* If grib_data_quality_checks == 2, limits failure results in a warning
|
||||
*/
|
||||
Assert( ctx->grib_data_quality_checks == 1 || ctx->grib_data_quality_checks == 2 );
|
||||
is_error = (ctx->grib_data_quality_checks == 1);
|
||||
|
||||
/* The limit keys must exist if we are here */
|
||||
err = grib_get_long(h, "param_value_min", &min_field_value_allowed);
|
||||
if (err) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR,"grib_data_quality_check: Could not get param_value_min");
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR,"grib_data_quality_check: Could not get param_value_min");
|
||||
return err;
|
||||
}
|
||||
err = grib_get_long(h, "param_value_max", &max_field_value_allowed);
|
||||
if (err) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR,"grib_data_quality_check: Could not get param_value_max");
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR,"grib_data_quality_check: Could not get param_value_max");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -2132,11 +2140,12 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max
|
|||
if (min_val < dmin_allowed || max_val > dmax_allowed) {
|
||||
long paramId = 0;
|
||||
if (grib_get_long(h, "paramId", ¶mId) == GRIB_SUCCESS) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR,
|
||||
"Parameter %ld: min/max (%g, %g) is outside allowable limits (%g, %g)",
|
||||
paramId, min_val, max_val, dmin_allowed, dmax_allowed);
|
||||
fprintf(stderr, "ECCODES %s : Parameter %ld: min/max (%g, %g) is outside allowable limits (%g, %g)\n",
|
||||
(is_error? "ERROR":"WARNING"), paramId, min_val, max_val, dmin_allowed, dmax_allowed);
|
||||
}
|
||||
if (is_error) {
|
||||
return GRIB_OUT_OF_RANGE; /* Failure */
|
||||
}
|
||||
return GRIB_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
return GRIB_SUCCESS;
|
||||
|
|
|
@ -41,6 +41,13 @@ set -e
|
|||
[ $status -ne 0 ]
|
||||
grep -q 'outside allowable limits' $tempErr
|
||||
|
||||
|
||||
# Data quality checks enabled but only as a warning. Repacking should pass
|
||||
export ECCODES_GRIB_DATA_QUALITY_CHECKS=2
|
||||
${tools_dir}/grib_copy -r $tempOut /dev/null 2>$tempErr
|
||||
grep -q 'outside allowable limits' $tempErr
|
||||
|
||||
|
||||
# Data quality checks enabled. Scaling should fail
|
||||
export ECCODES_GRIB_DATA_QUALITY_CHECKS=1
|
||||
set +e
|
||||
|
@ -59,6 +66,7 @@ set -e
|
|||
grep -q 'GRIB2 simple packing: unable to set values' $tempErr
|
||||
grep -q 'outside allowable limits' $tempErr
|
||||
|
||||
|
||||
# Override the defaults
|
||||
# ----------------------
|
||||
tempDir=tempdir.$label
|
||||
|
|
Loading…
Reference in New Issue