--- /dev/null
+#!/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
+