diff --git a/src/grib_util.c b/src/grib_util.c index 9ca7bf58c..548392650 100644 --- a/src/grib_util.c +++ b/src/grib_util.c @@ -2049,12 +2049,12 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max /* 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_util_grib_data_quality_check: Could not get param_value_min"); + grib_context_log(h->context, 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_util_grib_data_quality_check: Could not get param_value_max"); + grib_context_log(h->context, GRIB_LOG_ERROR,"grib_data_quality_check: Could not get param_value_max"); return err; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f62ad4a13..cb05e72ef 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -68,6 +68,7 @@ list( APPEND tests_no_data_reqd ) # These tests do require data downloads list( APPEND tests_data_reqd + grib_data_quality_checks bpv_limit grib_double_cmp grib_change_packing diff --git a/tests/grib_data_quality_checks.sh b/tests/grib_data_quality_checks.sh new file mode 100755 index 000000000..5e7c9e2d1 --- /dev/null +++ b/tests/grib_data_quality_checks.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Copyright 2005-2019 ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.sh +set -u +# --------------------------------------------------------- +# This is the test for data quality checks +# --------------------------------------------------------- +label="grib_data_quality" +tempOut=temp.${label}.out +tempErr=temp.${label}.err + +input1=${data_dir}/reduced_gaussian_surface.grib1 +input2=${data_dir}/reduced_gaussian_surface.grib2 + +# Data quality checks disabled. Create cause huge values for temperature +unset ECCODES_GRIB_DATA_QUALITY_CHECKS +${tools_dir}/grib_set -s scaleValuesBy=100 $input1 $tempOut +${tools_dir}/grib_set -s scaleValuesBy=100 $input2 $tempOut + +# Data quality checks enabled. Commands should fail +export ECCODES_GRIB_DATA_QUALITY_CHECKS=1 +set +e +${tools_dir}/grib_set -s scaleValuesBy=100 $input1 $tempOut 2>$tempErr +status=$? +set -e +[ $status -ne 0 ] +grep -q 'GRIB1 simple packing: unable to set values' $tempErr +grep -q 'outside allowable limits' $tempErr + +set +e +${tools_dir}/grib_set -s scaleValuesBy=100 $input2 $tempOut 2>$tempErr +status=$? +set -e +[ $status -ne 0 ] +grep -q 'GRIB2 simple packing: unable to set values' $tempErr +grep -q 'outside allowable limits' $tempErr + + +# Clean up +rm -f $tempOut $tempErr