mirror of https://github.com/ecmwf/eccodes.git
ECC-1559: GRIB encoding: data quality checks should test if shortName=unknown
This commit is contained in:
parent
a9fae8c2b5
commit
ee3f3500f7
|
@ -2142,6 +2142,7 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max
|
|||
bool is_error = true;
|
||||
char description[1024] = {0,};
|
||||
char step[32] = "unknown";
|
||||
char shortName[32] = {0,};
|
||||
size_t len = 32;
|
||||
|
||||
// If grib_data_quality_checks == 1, limits failure results in an error
|
||||
|
@ -2150,6 +2151,13 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max
|
|||
Assert(ctx->grib_data_quality_checks == 1 || ctx->grib_data_quality_checks == 2);
|
||||
is_error = (ctx->grib_data_quality_checks == 1);
|
||||
|
||||
err = grib_get_string(h, "shortName", shortName, &len);
|
||||
if (err || STR_EQUAL(shortName, "unknown")) {
|
||||
fprintf(stderr, "ECCODES %s : Invalid metadata: shortName=unknown\n",
|
||||
(is_error ? "ERROR" : "WARNING"));
|
||||
if (is_error) return GRIB_INVALID_MESSAGE;
|
||||
}
|
||||
|
||||
// The limit keys must exist if we are here
|
||||
err = grib_get_double(h, "param_value_min", &min_field_value_allowed);
|
||||
if (err) {
|
||||
|
|
|
@ -200,13 +200,26 @@ unset ECCODES_EXTRA_DEFINITION_PATH
|
|||
|
||||
# Check CCSDS encoding too
|
||||
# -------------------------
|
||||
if [ $HAVE_AEC -eq 1 ]; then
|
||||
export ECCODES_GRIB_DATA_QUALITY_CHECKS=1
|
||||
set +e
|
||||
${tools_dir}/grib_set -s scaleValuesBy=1000 $sample_ccsds $tempGrib2 2>$tempErr
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
fi
|
||||
|
||||
# Invalid shortName
|
||||
export ECCODES_GRIB_DATA_QUALITY_CHECKS=1
|
||||
input2=${data_dir}/reduced_gaussian_surface.grib2
|
||||
${tools_dir}/grib_set -s discipline=254 $input2 $tempOut
|
||||
grib_check_key_equals $tempOut 'shortName' 'unknown'
|
||||
set +e
|
||||
${tools_dir}/grib_set -s scaleValuesBy=1000 $sample_ccsds $tempGrib2 2>$tempErr
|
||||
${tools_dir}/grib_set -s scaleValuesBy=2 $tempOut $tempGrib2 2>$tempErr
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
|
||||
grep -q "Invalid metadata: shortName=unknown" $tempErr
|
||||
|
||||
# Clean up
|
||||
rm -rf $tempDir
|
||||
|
|
Loading…
Reference in New Issue