From 749034dc78bb97b845eeea10ba52574b1ba4b292 Mon Sep 17 00:00:00 2001
From: Jourdain <jourdain@cines.fr>
Date: Mon, 10 Feb 2020 15:41:40 +0100
Subject: [PATCH] Finalize small test case (implement run and validate)

---
 RAMSES/compile.sh                             |  8 ++++++-
 RAMSES/machines/occigen-bdw/batch_small.slurm |  2 +-
 RAMSES/testcase_small/prepare.sh              | 23 ++++++++++++++-----
 RAMSES/testcase_small/run.sh                  |  9 ++++++++
 RAMSES/testcase_small/validate.sh             | 18 +++++++++++++++
 5 files changed, 52 insertions(+), 8 deletions(-)
 mode change 100644 => 100755 RAMSES/testcase_small/run.sh
 mode change 100644 => 100755 RAMSES/testcase_small/validate.sh

diff --git a/RAMSES/compile.sh b/RAMSES/compile.sh
index 86ac237..ff8fc75 100755
--- a/RAMSES/compile.sh
+++ b/RAMSES/compile.sh
@@ -1,7 +1,9 @@
 #!/bin/bash
 
 source machines/occigen-bdw/env
-
+echo "************************************************************"
+echo "* Compile "
+echo "************************************************************"
 compile(){
     cd $ramses_dir/ramses/bin
     make clean
@@ -12,3 +14,7 @@ compile(){
 }
 
 compile
+echo "************************************************************"
+echo "* End Compile "
+echo "************************************************************"
+
diff --git a/RAMSES/machines/occigen-bdw/batch_small.slurm b/RAMSES/machines/occigen-bdw/batch_small.slurm
index a50839e..7d68c0d 100644
--- a/RAMSES/machines/occigen-bdw/batch_small.slurm
+++ b/RAMSES/machines/occigen-bdw/batch_small.slurm
@@ -16,6 +16,6 @@ SIMU=$bench_dir/DEBUG/
 NML="cosmo.nml"
 #locate the executable file here
 RAMSES=$ramses_dir/ramses/bin/ramses3d
-DATE=$( date +%Y-%m-%d_%Hh%M )
+DATE=`date +"%m-%d-%y-%H-%M-%S"`
 cd $SIMU
 srun --mpi=pmi2 -K1 --resv-ports -n $SLURM_NTASKS  $RAMSES $NML > $SIMU'/run_'$DATE.log
diff --git a/RAMSES/testcase_small/prepare.sh b/RAMSES/testcase_small/prepare.sh
index 060e4b9..46a6853 100755
--- a/RAMSES/testcase_small/prepare.sh
+++ b/RAMSES/testcase_small/prepare.sh
@@ -1,8 +1,19 @@
 #!/bin/bash
-
 source ../machines/occigen-bdw/env
-
-# Copy input for small case
-cp $STOREDIR/testcase_small.tar.gz $bench_dir/.
-cd $bench_dir/
-tar zxvf testcase_small.tar.gz
+echo "************************************************************"
+echo "* Prepare small case in $bench_dir"
+echo "************************************************************"
+if [[ $HOSTNAME = *"occigen"* ]]; then
+	#cp /store/CINES/dci/SHARED/abs/ramses/testcase_small.tar.gz $bench_dir/.
+	tar zxvf /store/CINES/dci/SHARED/abs/ramses/testcase_small.tar.gz -C $bench_dir/.
+elif [[ $HOSTNAME = *"jean-zay"* ]]; then
+	tar zxvf $SCRATCH/abs/ramses/testcase_small.tar.gz -C $bench_dir/.
+elif [[ $HOSTNAME = *"irene"* ]]; then
+	 tar zxvf  $CCCSCRATCHDIR/abs/ramses/testcase_small.tar.gz -C $bench_dir/.
+else
+	echo "Hostname not recognized: abort"
+	exit 1
+fi
+echo "************************************************************"
+echo "* End Prepare small case "
+echo "************************************************************"
diff --git a/RAMSES/testcase_small/run.sh b/RAMSES/testcase_small/run.sh
old mode 100644
new mode 100755
index e69de29..d230188
--- a/RAMSES/testcase_small/run.sh
+++ b/RAMSES/testcase_small/run.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+cd ../machines/occigen-bdw
+source ./env
+if [ -z "$bench_dir" ]; then
+echo "bench_dir missing"
+exit 1
+fi
+
+sbatch batch_small.slurm 
diff --git a/RAMSES/testcase_small/validate.sh b/RAMSES/testcase_small/validate.sh
old mode 100644
new mode 100755
index e69de29..43f22f4
--- a/RAMSES/testcase_small/validate.sh
+++ b/RAMSES/testcase_small/validate.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+source ../machines/occigen-bdw/env 
+cd $bench_dir/DEBUG
+
+log_file=`ls -thlx run_* | awk -F " " '{ print $1 }'`
+start_t=`grep startup $log_file | awk '{ print $5 }'`
+end_t=`grep "Total elapsed time:"  $log_file | awk '{ print $4 }'`
+perf=`bc -l <<< $end_t-$start_t`
+
+if [ -z "$perf" ] || [ -z "$end_t" ]
+then
+    echo "bench is not validated"
+else
+    echo "bench is validated"
+    echo "end = $end_t s"
+    echo "perf = $perf s (total simulation time excluding initialization and i/o)"
+fi
+
-- 
GitLab