From 8f8365f0bab10d9a081a7bdad8bb2be013446b19 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Wed, 24 Nov 2021 13:27:45 +0000
Subject: [PATCH] BF: Fix var naming bugs by unifying cpu/gpu submit code

---
 eddy/runEddy | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/eddy/runEddy b/eddy/runEddy
index 4254d03..17d7888 100755
--- a/eddy/runEddy
+++ b/eddy/runEddy
@@ -52,30 +52,32 @@ if [ "${cuda_exes}" == "" ] && [ "${cpu_exes}" == "" ]; then
 fi
 
 # Launch both GPU and CPU versions
+# Store job IDs separately so we
+# can qalter the openmp jobs below
 cuda_jids=""
-for cuda_exe in ${cuda_exes};
+cpu_jids=""
+for exe in ${cuda_exes} ${cpu_exes};
 do
-  tmp=`basename ${cuda_exe}`
-  variant=`echo ${tmp} | sed 's/eddy_//'`
-  jid=`fsl_sub -l ${outdir} -q cuda.q ${cuda_exe} --out=${outdir}/eddyOutput_${variant} ${eddy_args}`
-  if [ $? -ne 0 ]; then
-    echo "Error submitting ${cuda_exe} ${cuda_args}"
-    exit 1
+  variant=`basename ${exe}`
+  variant=`echo ${variante | sed 's/eddy_//'`
+  
+  if [[ "${exe}" == *"cuda"* ]]; then
+    fsl_sub="fsl_sub -l ${outdir} -q cuda.q"
+  else
+    fsl_sub="fsl_sub -l ${outdir} -q long.q -s openmp,6"
   fi
-  cuda_jids="${cuda_jids} ${jid}"
-done
 
-cpu_jids=""
-for cpu_exe in ${cpu_exes};
-do
-  tmp=`basename ${cuda_exe}`
-  variant=`echo ${tmp} | sed 's/eddy_//'`
-  jid=`fsl_sub -l ${outdir} -q long.q -s openmp,6 ${cpu_exe} --out=${outdir}/eddyOutput_${variant} ${eddy_args}`
+  jid=`${fsl_sub} ${exe} --out=${outdir}/eddyOutput_${variant} ${eddy_args}`
   if [ $? -ne 0 ]; then
-    echo "Error submitting ${cuda_exe} ${cuda_args}"
+    echo "Error submitting ${exe} ${eddy_args}"
     exit 1
-  fi    
-  cpu_jids="${cpu_jids} ${jid}"
+  fi
+  
+  if [[ "${exe}" == *"cuda"* ]]; then
+    cuda_jids="${cuda_jids} ${jid}"
+  else
+    cpu_jids="${cpu_jids} ${jid}"
+  fi  
 done
 
 # If running on a cluster, wait
-- 
GitLab