ctest for E0LL2Y with reference energy diff
[unres.git] / ctest / prota_unres_energy_check.sh
diff --git a/ctest/prota_unres_energy_check.sh b/ctest/prota_unres_energy_check.sh
new file mode 100755 (executable)
index 0000000..e8107d7
--- /dev/null
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+# Writen by Dawid JagieÅ‚a and Adam Sieradzan
+#
+#
+#----------------------------------------
+# variables
+
+extremediff="10000.0"                  # extreme energy difference, comething went terribly wrong
+expectenergy="-56066670.000000"                # expected total energy
+cutoffdiff="0.1"                       # energy cutoff variation - more then this rises warning 
+file=$1                                        # Output file to search energy value from
+
+function floating(){
+    echo $1 | sed -e 's/[eE]+/*10^/'
+}
+
+#---------------------------------------------------------------------------
+# MAIN CODE
+#---------------------------------------------------------------------------
+
+# Check if file exist
+if [ ! -f $file ]; then
+    echo "CRITICAL: out file do not exist"
+    exit 2
+fi
+
+# Check if energy value is not a number
+grepene=`grep ETOT $file| awk '{print $2}'`
+if [[ $grepene == "NaN" ]]; then
+    echo "CRITICAL: energy is NaN"
+    exit 2
+fi
+
+# Check if energy value is extremely different from expected
+blaene=`floating $grepene`
+myene=`echo $blaene |bc`
+diff=`echo $myene"+("$expectenergy")"|bc`
+absdiff=`echo $diff| sed 's/-//'`
+
+true1=`echo "$absdiff >= $extremediff"|bc`
+if [ $true1 -eq 1 ]; then
+    echo "CRITICAL: energy is loo large $absdiff, ene= $myene"
+    exit 2
+fi
+
+# Check if Energy value is as expected
+true2=`echo "$absdiff<=$cutoffdiff"|bc`
+if [ $true2 -eq 1 ]; then
+    echo "OK: absdiff= $absdiff, ene= $myene"
+    exit 0
+else
+    echo "WARNING: energy is somewhat different $absdiff, ene= $myene"
+    exit 1
+fi
+