From 8a05412b73139d8e6a1929ca07e5de2e9f2f31e2 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 22 Dec 2022 16:46:00 +0000 Subject: [PATCH] Examples: Check results --- examples/F90/bufr_attributes.sh | 20 +++++++------------- examples/F90/bufr_clone.sh | 15 +++++++-------- examples/F90/bufr_expanded.sh | 17 ++++++----------- examples/F90/bufr_get_keys.sh | 2 +- examples/F90/bufr_keys_iterator.sh | 16 ++++++---------- examples/F90/bufr_read_synop.sh | 19 ++++++------------- 6 files changed, 33 insertions(+), 56 deletions(-) diff --git a/examples/F90/bufr_attributes.sh b/examples/F90/bufr_attributes.sh index 12418e86a..c4d0b781b 100755 --- a/examples/F90/bufr_attributes.sh +++ b/examples/F90/bufr_attributes.sh @@ -11,24 +11,18 @@ . ./include.ctest.sh -#Define a common label for all the tmp files +# Define a common label for all the tmp files label="bufr_attributes_test_f" -#Define tmp file +# Define tmp file fTmp=${label}.tmp.txt rm -f ${fTmp} -#We check "syno_multi.bufr". The path is -#hardcoded in the example +# We check "syno_multi.bufr". The path is hard coded in the example +${examples_dir}/eccodes_f_bufr_attributes > $fTmp -REDIRECT=/dev/null +# Check the results +grep -q 'airTemperatureAt2M->percentConfidence->code: *33007' $fTmp +grep -q 'airTemperatureAt2M->percentConfidence->width: *7' $fTmp -#Write the values into a file and compare with reference -${examples_dir}/eccodes_f_bufr_attributes #2> $REDIRECT > $fTmp - -#TODO: check the results - -#cat $fTmp - -#Clean up rm -f ${fTmp} diff --git a/examples/F90/bufr_clone.sh b/examples/F90/bufr_clone.sh index f22cd64d2..ab4902b81 100755 --- a/examples/F90/bufr_clone.sh +++ b/examples/F90/bufr_clone.sh @@ -9,31 +9,30 @@ . ./include.ctest.sh -#Define a common label for all the tmp files +# Define a common label for all the tmp files label="bufr_clone_test_f" -#Prepare tmp file fBufrTmp=${label}.clone.bufr rm -f $fBufrTmp -#We clone a bufr file with multiple messages. +# We clone a bufr file with multiple messages f=${data_dir}/bufr/syno_multi.bufr REDIRECT=/dev/null -#The input ($f) and output ($fBufrTmp) are hardcoded in the f90 example!!! +# The input ($f) and output ($fBufrTmp) are hardcoded in the f90 example ${examples_dir}/eccodes_f_bufr_clone >$REDIRECT 2> $REDIRECT -#Compare clone to the original +# Compare clone to the original. Should be different set +e ${tools_dir}/bufr_compare $f $fBufrTmp >$REDIRECT 2> $REDIRECT -#Check if clone is different +# Check if clone is different if [ $? -eq 0 ]; then - echo "cloning produced identical files " >&2 + echo "Error: cloning produced identical files " >&2 exit 1 fi set -e -#Clean up +# Clean up rm -f ${fBufrTmp} diff --git a/examples/F90/bufr_expanded.sh b/examples/F90/bufr_expanded.sh index 79d1f3018..9c3c37ace 100755 --- a/examples/F90/bufr_expanded.sh +++ b/examples/F90/bufr_expanded.sh @@ -9,33 +9,28 @@ . ./include.ctest.sh -#Define a common label for all the tmp files +# Define a common label for all the tmp files label="bufr_expanded_test_f" -#Prepare tmp file fTmp=${label}.tmp.txt rm -f $fTmp #----------------------------------------------------- # Test reading the expanded values #---------------------------------------------------- - #f=${data_dir}/bufr/syno_1.bufr REDIRECT=/dev/null -#We check "syno_1.bufr". The path is -#hardcoded in the example +# We check "syno_1.bufr". The path is hard coded in the example -#Write the values into a file +# Write the values into a file ${examples_dir}/eccodes_f_bufr_expanded > $fTmp 2> $REDIRECT -#TODO: add a better check. It could be compared against the bufrdc -# references. +#TODO: add a better check. It could be compared against the bufrdc references -#Check if there is any output +# Check if there is any output [ -s ${fTmp} ] -#cat $fTmp +# cat $fTmp -#Clean up rm -f ${fTmp} diff --git a/examples/F90/bufr_get_keys.sh b/examples/F90/bufr_get_keys.sh index 943ae1411..a36d205b3 100755 --- a/examples/F90/bufr_get_keys.sh +++ b/examples/F90/bufr_get_keys.sh @@ -28,7 +28,7 @@ ${examples_dir}/eccodes_f_bufr_get_keys 2> $REDIRECT > $fTmp #TODO: check the results -#cat $fTmp +#cat $fTmp #Clean up rm -f ${fTmp} diff --git a/examples/F90/bufr_keys_iterator.sh b/examples/F90/bufr_keys_iterator.sh index ee9d27ca0..6e3982b88 100755 --- a/examples/F90/bufr_keys_iterator.sh +++ b/examples/F90/bufr_keys_iterator.sh @@ -10,23 +10,19 @@ . ./include.ctest.sh -#Define a common label for all the tmp files +# Define a common label for all the tmp files label="bufr_keys_iterator_test_f" -#Define tmp file fTmp=${label}".tmp.txt" rm -f $fTmp -REDIRECT=/dev/null - f=${data_dir}/bufr/syno_1.bufr -#The input ($f) is hardcoded in the f90 example!!! -${examples_dir}/eccodes_f_bufr_keys_iterator #2> $REDIRECT > $fTmp +# The input ($f) is hard coded in the example +${examples_dir}/eccodes_f_bufr_keys_iterator > $fTmp -#TODO: check the output +# Check the output +grep -q '#49#dataPresentIndicator' $fTmp +grep -q '#1#generatingApplication' $fTmp -#cat $fTmp - -#Clean up rm -f $fTmp diff --git a/examples/F90/bufr_read_synop.sh b/examples/F90/bufr_read_synop.sh index 26028306f..1a634df4f 100755 --- a/examples/F90/bufr_read_synop.sh +++ b/examples/F90/bufr_read_synop.sh @@ -11,24 +11,17 @@ . ./include.ctest.sh -#Define a common label for all the tmp files +# Define a common label for all the tmp files label="bufr_read_synop_test_f" -#Define tmp file fTmp=${label}".tmp.txt" rm -f $fTmp -#We check "syno_multi.bufr". The path is -#hardcoded in the example +# We check "syno_multi.bufr". The path is hard coded in the example +${examples_dir}/eccodes_f_bufr_read_synop > $fTmp -REDIRECT=/dev/null +# Check the output +grep -q 'cloudType .low.:' $fTmp +grep -q 'cloudType .high.:' $fTmp -#Write the values into a file and compare with reference -${examples_dir}/eccodes_f_bufr_read_synop #2> $REDIRECT > $fTmp - -#TODO: check the output - -#cat $fTmp - -#Clean up rm -f $fTmp