From bde7c91735a255dd8b24ae15ed11587d2a97bbc0 Mon Sep 17 00:00:00 2001
From: Peter Alexander <p.m.w.alexander@gmail.com>
Date: Tue, 13 Jun 2017 09:10:10 +0100
Subject: [PATCH] More cluster script changes

---
 scripts/runCalibAndPlum.sh       |  9 +++++----
 scripts/scheduleHindScenarios.sh | 34 ++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 4 deletions(-)
 create mode 100755 scripts/scheduleHindScenarios.sh

diff --git a/scripts/runCalibAndPlum.sh b/scripts/runCalibAndPlum.sh
index b157b8db..3c635f57 100755
--- a/scripts/runCalibAndPlum.sh
+++ b/scripts/runCalibAndPlum.sh
@@ -5,10 +5,11 @@ if [ $# -ne 1 ]; then
 	exit 0
 fi
 
-jobName=${1//\//_}c # remove slash from path as qsub doesnt allow it
-jobName=${jobName/hind1970/h_}
-echo $jobName
-calibJob=${jobName}_c
+jobName=${1//\//_} # remove slash from path as qsub doesnt allow it
+jobName=${jobName/hind1970/h}
+calibJob=${jobName}c
+echo ""
+echo $jobName, $calibJob
 
 qsub -N $calibJob /exports/csce/eddie/geos/groups/LURG/models/PLUM/plumv2/scripts/runPlum.sh $1/calib
 qsub -N $jobName -hold_jid $calibJob /exports/csce/eddie/geos/groups/LURG/models/PLUM/plumv2/scripts/runPlum.sh $1
diff --git a/scripts/scheduleHindScenarios.sh b/scripts/scheduleHindScenarios.sh
new file mode 100755
index 00000000..2e3138c5
--- /dev/null
+++ b/scripts/scheduleHindScenarios.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+if [ "$#" -lt 1  ]; then
+   echo "Need to specify scenario table file"
+   exit
+fi
+
+
+filename="$1"
+output_dir=/exports/csce/eddie/geos/groups/LURG/models/PLUM/output/hind1970
+echo "Starting scenarios in $output_dir"
+
+while read -r datarow
+do
+  IFS=',' read -r -a array <<< "$datarow"
+
+  if [ -z "$header" ]; then
+     header=( "${array[@]}" )
+  else
+     ensemble="${array[0]}"
+     scenario="${array[1]}"
+     scenario_dir=$output_dir/$ensemble/$scenario
+     echo $scenario for $ensemble
+
+     if [ ! -d "$scenario_dir" ]; then
+        echo "Scenario $scenario dir is missing, so skipping"
+        continue;
+     fi
+
+     echo "/exports/csce/eddie/geos/groups/LURG/models/PLUM/plumv2/scripts/runCalibAndPlum.sh hind1970/$ensemble/$scenario"
+     /exports/csce/eddie/geos/groups/LURG/models/PLUM/plumv2/scripts/runCalibAndPlum.sh hind1970/$ensemble/$scenario
+  fi
+done < $filename
+
-- 
GitLab