From 82f695986a2a0714e7a37a84b8eb7f4df85b1743 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sat, 13 Jan 2024 18:21:13 +0000 Subject: [PATCH] Testing: METAR compare doubles --- tests/metar_compare.sh | 22 +++++++++++++++++++++- tools/metar_compare.cc | 4 ---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/metar_compare.sh b/tests/metar_compare.sh index 2d43f289c..e6e656c4a 100755 --- a/tests/metar_compare.sh +++ b/tests/metar_compare.sh @@ -78,7 +78,7 @@ ${tools_dir}/metar_compare -c latitude -A 17 $temp1 $temp2 rm -f $temp1 $temp2 #---------------------------------------------------- -# Test: comparing with and without the -b switch +# Comparing with and without the -b switch #---------------------------------------------------- if [ $ECCODES_ON_WINDOWS -eq 0 ]; then # Add wrong blocklist. Should still fail @@ -91,5 +91,25 @@ if [ $ECCODES_ON_WINDOWS -eq 0 ]; then ${tools_dir}/metar_compare -b minute,theMessage $metar_file $fMetarTmp fi +#---------------------------------------------------- +# Compare doubles +#---------------------------------------------------- +temp1=temp.$label.1.metar +temp2=temp.$label.2.metar +echo 'METAR LQMO 022350Z 09003KT 6000 FEW010 SCT035 BKN060 09/09 Q1003=' > $temp1 +${tools_dir}/metar_copy -w count=1 $metar_file $temp2 +set +e +${tools_dir}/metar_compare -b theMessage -f -v $temp1 $temp2 > $fLog +status=$? +set -e +[ $status -ne 0 ] +grep -q "temperature .*1 different" $fLog +grep -q "dewPointTemperature .*1 different" $fLog + +# dewPointTemperature diffs: absolute diff. = 1, relative diff. = 0.111111 +${tools_dir}/metar_compare -b temperature,theMessage -R dewPointTemperature=0.12 $temp1 $temp2 + +rm -f $temp1 $temp2 + # Clean up rm -f $fLog $fMetarTmp diff --git a/tools/metar_compare.cc b/tools/metar_compare.cc index 48db23534..7b67c7004 100644 --- a/tools/metar_compare.cc +++ b/tools/metar_compare.cc @@ -755,15 +755,11 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, break; case GRIB_TYPE_BYTES: - if (verbose) - printf(" as bytes\n"); if (options->mode == MODE_METAR) return 0; break; case GRIB_TYPE_LABEL: - if (verbose) - printf(" as label\n"); break; default: