ECC-355: grib_compare: using relative comparison (-R) with 'all' does not work

This commit is contained in:
Shahram Najm 2016-10-12 14:39:58 +01:00
parent 5fb1a2a344
commit d82ffbb9e0
2 changed files with 22 additions and 1 deletions

View File

@ -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

View File

@ -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;i<options->tolerance_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;i<options->tolerance_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)