From 12c078566f335a997ee118a3fa324ce5b9e4cf3b Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 25 Jun 2024 12:28:40 +0100 Subject: [PATCH] Testing: Function to check GRIB key is scalar --- tests/utils.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/utils.sh b/tests/utils.sh index d51373a3d..a1de94279 100644 --- a/tests/utils.sh +++ b/tests/utils.sh @@ -38,3 +38,14 @@ grib_check_key_exists() # grib_get will fail if the key is not found $tools_dir/grib_get -p $a_key $a_file >/dev/null } + +# This is useful in situations where we intend a key to have +# a single value (size=1). For example when we redefine a transient +grib_check_key_is_scalar() +{ + a_file=$1 + a_key=$2 + a_val=$3 + result=$(echo "print '|[$a_key]|';" | ${tools_dir}/grib_filter - $a_file) + [ "$result" = "|$a_val|" ] +}