From 57d2ecddf67af8a74c918bfe868f9bc029a4cf7c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Riette?= <sebastien.riette@meteo.fr>
Date: Mon, 2 Oct 2023 17:41:26 +0200
Subject: [PATCH] S. Riette Oct 23: small testprogs dataset hosted on github

---
 tools/INSTALL.sh           | 35 +++++++++++++++++++++++++++++++++++
 tools/INSTALL_testprogs.md |  9 ++++-----
 2 files changed, 39 insertions(+), 5 deletions(-)
 create mode 100755 tools/INSTALL.sh

diff --git a/tools/INSTALL.sh b/tools/INSTALL.sh
new file mode 100755
index 000000000..862b33b4e
--- /dev/null
+++ b/tools/INSTALL.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+#set -x
+set -e
+set -o pipefail #abort if left command on a pipe fails
+
+PHYEXTOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+function usage {
+  echo "Usage: $0 [-h] [--install-dataset]"
+  echo "--install-dataset          Install a reduced dataset for the test programs"
+}
+
+install_dataset=0
+
+while [ -n "$1" ]; do
+  case "$1" in
+    '--install-dataset') install_dataset=1;;
+  esac
+  shift
+done
+
+if [ $install_dataset -eq 1 ]; then
+  cd $PHYEXTOOLSDIR/testprogs_data/
+  for file in https://github.com/UMR-CNRM/PHYEX/files/12783926/ice_adjust.tar.gz \
+              https://github.com/UMR-CNRM/PHYEX/files/12783935/rain_ice.tar.gz \
+              https://github.com/UMR-CNRM/PHYEX/files/12783942/rain_ice_old.tar.gz \
+              https://github.com/UMR-CNRM/PHYEX/files/12783945/shallow.tar.gz \
+              https://github.com/UMR-CNRM/PHYEX/files/12783952/turb.tar.gz; do
+    basefile=$(basename $file)
+    wget --no-check-certificate $file -O $basefile
+    tar xf $basefile
+    rm -f $basefile
+  done
+fi
diff --git a/tools/INSTALL_testprogs.md b/tools/INSTALL_testprogs.md
index 6429882e2..8a3e92417 100644
--- a/tools/INSTALL_testprogs.md
+++ b/tools/INSTALL_testprogs.md
@@ -7,11 +7,10 @@ These programs need data. This document describes how to generate the data, the
 
 This document is written using the markdown language. With pandoc, it can be converted to HTML (pandoc -s \<filename\>.md -o \<filename\>.html) or PDF (pandoc -s \<filename\>.md -o \<filename\>.pdf). 
 
+## DATA
 
-## DATA GENERATION
+There are two options.
 
-Please, refer to the [Offline](../docs/Offline.md) documentation.
+On one hand, the data can be generated (please, refer to the [Offline](../docs/Offline.md) documentation) and, once produced, be put in the corresponding directories under tools/testprogs\_data.
 
-## DATA INSTALLATION
-
-Once produced, the data must be put in the corresponding directories under tools/testprogs\_data.
+On the other hand, a reduced dataset can be automatically dowloaded and installed using the INSTALL.sh script.
-- 
GitLab