diff --git a/tests/bufr_compare.sh b/tests/bufr_compare.sh index 2fa007941..53609d7ba 100755 --- a/tests/bufr_compare.sh +++ b/tests/bufr_compare.sh @@ -153,6 +153,14 @@ status=$? set -e [ $status -eq 1 ] +#---------------------------------------------------- +# ECC-656: using relative comparison (-R) with 'all' +#---------------------------------------------------- +f='airc_142.bufr' +echo 'set unpack=1;set airTemperature=228; set height=1.037e+04; set pack=1; write;' |\ + ${tools_dir}/codes_bufr_filter -o $fBufrTmp - $f +${tools_dir}/bufr_compare -R airTemperature=0.004,height=0.001 $f $fBufrTmp +${tools_dir}/bufr_compare -R all=0.004 $f $fBufrTmp # Clean up # ------------- diff --git a/tools/bufr_compare.c b/tools/bufr_compare.c index e465c27ec..d4398a30c 100644 --- a/tools/bufr_compare.c +++ b/tools/bufr_compare.c @@ -893,12 +893,22 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g } 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)==0 ) { + value_tolerance=(options->tolerance[i]).double_value; + break; + } + } + } } if((err1 = grib_get_double_array(handle1,name,dval1,&len1)) != GRIB_SUCCESS) diff --git a/tools/grib_options.c b/tools/grib_options.c index 4d2283a87..bcf6f2338 100644 --- a/tools/grib_options.c +++ b/tools/grib_options.c @@ -93,9 +93,9 @@ grib_options_help grib_options_help_list[] ={ {"P:","key[:{s|d|i}],key[:{s|d|i}],...", "\n\t\tAs -p adding the declared keys to the default list.\n"}, {"R:","key1=relative_error1,key2=relative_error2,...\n", - "\tCompare floating point values using the relative error as tolerance." -"\n\t\tkey1=relative_error will compare key1 using relative_error1." -"\n\t\tall=relative_error will compare all the floating point keys using relative_error. Default all=0.\n"}, + "\tCompare floating point values using the relative error as tolerance." + "\n\t\tkey1=relative_error1 will compare key1 using relative_error1." + "\n\t\tall=relative_error will compare all the floating point keys using relative_error. Default all=0.\n"}, {"S",0,"Strict. Only messages matching all the constraints are copied to" "\n\t\tthe output file\n"}, {"T:","T | B | M | A","Message type. T->GTS, B->BUFR, M->METAR (Experimental),A->Any (Experimental).\n\t\t\tThe input file is interpreted according to the message type.\n"},