diff --git a/tests/grib_compare.sh b/tests/grib_compare.sh index 7524569f7..415e600cf 100755 --- a/tests/grib_compare.sh +++ b/tests/grib_compare.sh @@ -67,5 +67,16 @@ set -e [ $status -eq 1 ] +# ECC-355: -R with "all" option +# ---------------------------------------- +${tools_dir}grib_copy -w count=1 ${data_dir}/tigge_cf_ecmwf.grib2 $temp1 +${tools_dir}grib_copy -w count=1 ${data_dir}/tigge_pf_ecmwf.grib2 $temp2 +BLACKLIST="typeOfProcessedData,typeOfEnsembleForecast,perturbationNumber" +# Specify relative tolerances for each floating point key +${tools_dir}grib_compare -b $BLACKLIST -R referenceValue=0.03,codedValues=2 $temp1 $temp2 +# Now try the "all" option with the highest relative diff value +${tools_dir}grib_compare -b $BLACKLIST -R all=2 $temp1 $temp2 + + rm -f $temp1 $temp2 rm -f $outfile diff --git a/tools/grib_compare.c b/tools/grib_compare.c index 5cc4b40d1..a6c800d75 100644 --- a/tools/grib_compare.c +++ b/tools/grib_compare.c @@ -818,12 +818,22 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han } if (!compareAbsolute) { + int all_specified = 0; /* =1 if relative comparison with "all" specified */ for (i=0;itolerance_count;i++) { - if (!strcmp((options->tolerance[i]).name,name)) { + if (!strcmp((options->tolerance[i]).name, "all")) { + all_specified = 1; value_tolerance=(options->tolerance[i]).double_value; break; } } + if (!all_specified) { + for (i=0;itolerance_count;i++) { + if (!strcmp((options->tolerance[i]).name,name)) { + value_tolerance=(options->tolerance[i]).double_value; + break; + } + } + } } if((err1 = grib_get_double_array(h1,name,dval1,&len1)) != GRIB_SUCCESS)