commit 20f337f25c078741bd881ef1b1d72652d72e53e8
parent 43fdf3986ea9f6d43d510f2de766f140ad5fe768
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 4 Sep 2023 13:16:46 +0200
Add a shell script to automate the load_from_file test
This script checks that the htcp data loaded is identical to that
extracted from the netcdf file by the ncdump tool. Note that the script
assumes that the paths of the dump_netcdf_<data|desc>.sh scripts and the
test_htcp_load_from_file program are stored in the PATH variable.
Diffstat:
2 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@@ -133,6 +133,7 @@ lint:
shellcheck -o all make.sh
shellcheck -o all src/dump_netcdf_data.sh
shellcheck -o all src/dump_netcdf_desc.sh
+ shellcheck -o all src/test_htcp_load_from_file.sh
################################################################################
# Tests
diff --git a/src/test_htcp_load_from_file.sh b/src/test_htcp_load_from_file.sh
@@ -0,0 +1,55 @@
+#!/bin/sh -e
+
+# Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com)
+# Copyright (C) 2018 Centre National de la Recherche Scientifique
+# Copyright (C) 2018 Université Paul Sabatier
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+dump_data() {
+ variable="$1"
+ netcdf="$2"
+ printf "Dump the variable \"%s\" from \"%s\"\n" "${variable}" "${netcdf}"
+ dump_netcdf_data.sh "${variable}" "${netcdf}"
+}
+
+if [ $# -ne 1 ]; then
+ printf "usage: %s netcdf\n" "${0##*/}" >&2
+ exit 1
+fi
+
+nc="$1"
+
+if [ ! -f "${nc}" ]; then
+ printf "Invalid netcdf: %s\n" "${nc}" >&2
+ exit 1
+fi
+
+prefix=$(basename "${nc}")
+prefix=${prefix%.*}
+htcp="${prefix}.htcp"
+path=$(pwd)
+
+printf "Convert \"%s\" to \"%s\"\n" "${nc}" "${htcp}"
+les2htcp -m 1000 -i "${nc}" -fo "${htcp}"
+
+printf "Dump the descriptor of \"%s\"\n" "${nc}"
+dump_netcdf_desc.sh "${nc}"
+
+dump_data "PABST" "${nc}"
+dump_data "RCT" "${nc}"
+dump_data "RVT" "${nc}"
+dump_data "THT" "${nc}"
+
+test_htcp_load_from_file "${prefix}.htcp" "${path}"