From d6ee840490945ec496e91cecb6db54b8a14b009c Mon Sep 17 00:00:00 2001
From: Soren Rasmussen <s.c.rasmussen@gmail.com>
Date: Thu, 10 Oct 2024 14:33:02 -0600
Subject: [PATCH] Add help message and ability to turn on verbose wget output.
 Wget output devaults to -nv so that the Github Actions output won't be filled
 with the wget download status. This will make debugging failed testcases
 easier

---
 contrib/get_aerosol_climo.sh   | 33 +++++++++++++++++++++++++++++++--
 contrib/get_all_static_data.sh | 33 +++++++++++++++++++++++++++++++--
 contrib/get_mg_inccn_data.sh   | 33 +++++++++++++++++++++++++++++++--
 contrib/get_thompson_tables.sh | 33 +++++++++++++++++++++++++++++++--
 4 files changed, 124 insertions(+), 8 deletions(-)

diff --git a/contrib/get_aerosol_climo.sh b/contrib/get_aerosol_climo.sh
index 37f0a8cf2..bdb7feabe 100755
--- a/contrib/get_aerosol_climo.sh
+++ b/contrib/get_aerosol_climo.sh
@@ -1,5 +1,35 @@
 #!/bin/bash
 
+# Function to display help message
+print_help() {
+    echo "get_aerosol_climo.sh: contrib/get_aerosol_climo.sh [-v,--verbose]"
+    echo "    Script for downloading/extracting the GOCART climatological aerosol data."
+    echo ""
+    echo "Options:"
+    echo "    -v, --verbose    Turn on wget verbose output."
+    echo "    --help           Show this help message and exit."
+}
+
+verbose="-nv"
+# Parse command-line arguments
+while [[ "$#" -gt 0 ]]; do
+    case $1 in
+        --help)
+            print_help
+            exit 0
+            ;;
+        -v|--verbose)
+            verbose="-v"
+            ;;
+        *)
+            echo "Unknown option: $1"
+            print_help
+            exit 1
+            ;;
+    esac
+    shift
+done
+
 #set -ex
 
 # Directory where this script is located
@@ -20,10 +50,9 @@ data_files=("FV3_aeroclim1" "FV3_aeroclim2" "FV3_aeroclim3" "FV3_aeroclim_optics
 cd $BASEDIR/scm/data/physics_input_data/
 for file in "${data_files[@]}"; do
     echo "Retrieving $file.tar.gz"
-    wget https://github.com/NCAR/ccpp-scm/releases/download/v7.0.0/${file}.tar.gz
+    wget ${verbose} https://github.com/NCAR/ccpp-scm/releases/download/v7.0.0/${file}.tar.gz
     tar -xvf ${file}.tar.gz
     rm -f ${file}.tar.gz
 done
 
 cd $BASEDIR/
-
diff --git a/contrib/get_all_static_data.sh b/contrib/get_all_static_data.sh
index b4b85e9f0..ee039a0c8 100755
--- a/contrib/get_all_static_data.sh
+++ b/contrib/get_all_static_data.sh
@@ -1,5 +1,35 @@
 #!/bin/bash
 
+# Function to display help message
+print_help() {
+    echo "get_all_static_data.sh: contrib/get_all_static_data.sh [-v,--verbose]"
+    echo "    Script for downloading/extracting the processed SCM case data."
+    echo ""
+    echo "Options:"
+    echo "    -v, --verbose    Turn on wget verbose output."
+    echo "    --help           Show this help message and exit."
+}
+
+verbose="-nv"
+# Parse command-line arguments
+while [[ "$#" -gt 0 ]]; do
+    case $1 in
+        --help)
+            print_help
+            exit 0
+            ;;
+        -v|--verbose)
+            verbose="-v"
+            ;;
+        *)
+            echo "Unknown option: $1"
+            print_help
+            exit 1
+            ;;
+    esac
+    shift
+done
+
 #set -ex
 
 # Directory where this script is located
@@ -21,10 +51,9 @@ for file in "${data_files[@]}"; do
     mkdir -p $BASEDIR/scm/data/$file
     cd $BASEDIR/scm/data/$file
     echo "Retrieving $file"
-    wget https://github.com/NCAR/ccpp-scm/releases/download/v7.0.0/${file}.tar.gz
+    wget ${verbose} https://github.com/NCAR/ccpp-scm/releases/download/v7.0.0/${file}.tar.gz
     tar -xf ${file}.tar.gz
     rm -f ${file}.tar.gz
 done
 
 cd $BASEDIR/
-
diff --git a/contrib/get_mg_inccn_data.sh b/contrib/get_mg_inccn_data.sh
index b650ce338..c70045c1f 100755
--- a/contrib/get_mg_inccn_data.sh
+++ b/contrib/get_mg_inccn_data.sh
@@ -1,5 +1,35 @@
 #!/bin/bash
 
+# Function to display help message
+print_help() {
+    echo "get_mg_inccn_data.sh: contrib/get_mg_inccn_data.sh [-v,--verbose]"
+    echo "    Script for downloading/extracting the Morrison-Gettelman data."
+    echo ""
+    echo "Options:"
+    echo "    -v, --verbose    Turn on wget verbose output."
+    echo "    --help           Show this help message and exit."
+}
+
+verbose="-nv"
+# Parse command-line arguments
+while [[ "$#" -gt 0 ]]; do
+    case $1 in
+        --help)
+            print_help
+            exit 0
+            ;;
+        -v|--verbose)
+            verbose="-v"
+            ;;
+        *)
+            echo "Unknown option: $1"
+            print_help
+            exit 1
+            ;;
+    esac
+    shift
+done
+
 set -ex
 
 # Directory where this script is located
@@ -16,8 +46,7 @@ BASEDIR=$MYDIR/..
 
 # Change to directory containing the physics input data, download and extract archive
 cd $BASEDIR/scm/data/physics_input_data/
-wget https://github.com/NCAR/ccpp-scm/releases/download/v7.0.0/MG_INCCN_data.tar.gz
+wget ${verbose} https://github.com/NCAR/ccpp-scm/releases/download/v7.0.0/MG_INCCN_data.tar.gz
 tar -xvf MG_INCCN_data.tar.gz
 rm -f MG_INCCN_data.tar.gz
 cd $BASEDIR/
-
diff --git a/contrib/get_thompson_tables.sh b/contrib/get_thompson_tables.sh
index 6a192c4d0..b1f632326 100755
--- a/contrib/get_thompson_tables.sh
+++ b/contrib/get_thompson_tables.sh
@@ -1,5 +1,35 @@
 #!/bin/bash
 
+# Function to display help message
+print_help() {
+    echo "get_thompson_tables.sh: contrib/get_thompson_tables.sh [-v,--verbose]"
+    echo "    Script for downloading/extracting the Thompson lookup tables."
+    echo ""
+    echo "Options:"
+    echo "    -v, --verbose    Turn on wget verbose output."
+    echo "    --help           Show this help message and exit."
+}
+
+verbose="-nv"
+# Parse command-line arguments
+while [[ "$#" -gt 0 ]]; do
+    case $1 in
+        --help)
+            print_help
+            exit 0
+            ;;
+        -v|--verbose)
+            verbose="-v"
+            ;;
+        *)
+            echo "Unknown option: $1"
+            print_help
+            exit 1
+            ;;
+    esac
+    shift
+done
+
 set -ex
 
 if [[ $(uname -s) == Darwin ]]; then
@@ -15,8 +45,7 @@ BASEDIR=$MYDIR/..
 
 # Change to directory containing the physics input data, download and extract archive
 cd $BASEDIR/scm/data/physics_input_data/
-wget https://github.com/NCAR/ccpp-scm/releases/download/v7.0.0/thompson_tables.tar.gz
+wget ${verbose} https://github.com/NCAR/ccpp-scm/releases/download/v7.0.0/thompson_tables.tar.gz
 tar -xvf thompson_tables.tar.gz
 rm -f thompson_tables.tar.gz
 cd $BASEDIR/
-