1#!/bin/bash
2log=$1
3
4if [ `uname` = Linux ]; then
5   GREP="egrep -a"
6else
7   GREP="egrep"
8fi
9
10if $GREP -q "not implemented for parallel calculations" $log; then
11   echo "TEST ENDED AS EXPECTED"
12   exit 0
13fi
14
15# QM/MM interaction energy compared:
16CRIT1=`$GREP "\| * (\-|\-0)\.010342041. \| * ( |0)\.0000000000 \| * ( |0)\.005110972. \| * (\-|\-0)\.00523106[89]. \|" $log | wc -l`
17CRIT2=`$GREP "\| * \-76\.230966653. \| * \-76\.236197722. \| * ( |0)\.0000000000 \|" $log | wc -l`
18TEST[1]=`expr $CRIT1 \+ $CRIT2`
19CTRL[1]=2
20ERROR[1]="QM/MM ENERGY NOT CORRECT"
21
22# Dipole moment components compared:
23CRIT1=`$GREP "x * ( |0)\.0770601. * ( |0)\.1958672" $log | wc -l`
24CRIT2=`$GREP "y * ( |0)\.0115747. * ( |0)\.0294200" $log | wc -l`
25CRIT3=`$GREP "z * ( |0)\.8008827. *     2\.0356406" $log | wc -l`
26TEST[2]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3`
27CTRL[2]=12
28ERROR[2]="DIPOLE MOMENT NOT CORRECT"
29
30# Quadrupole moment components compared:
31CRIT1=`$GREP "1 * 1\.5509380. * ( |0)\.0024452. * ( |0)\.1201701." $log | wc -l`
32CRIT2=`$GREP "2 * ( |0)\.0024452. * -1\.670209(5|6). * ( |0)\.0067644." $log | wc -l`
33CRIT3=`$GREP "3 * ( |0)\.1201701. * ( |0)\.0067644. * ( |0)\.1192715." $log | wc -l`
34TEST[3]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3`
35CTRL[3]=12
36ERROR[3]="QUADRUPOLE MOMENT NOT CORRECT"
37
38# Second order electric moment components compared:
39CRIT1=`$GREP "1 * 7\.2124209. * (\-|\-0)\.0016301. * (\-|\-0)\.0801134" $log | wc -l`
40CRIT2=`$GREP "2 * (\-|\-0)\.0016301. * 5\.2692356. * (\-|\-0)\.0045096" $log | wc -l`
41CRIT3=`$GREP "3 * (\-|\-0)\.0801134. * (\-|\-0)\.0045096. * 6\.5288855" $log | wc -l`
42TEST[4]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3`
43CTRL[4]=12
44ERROR[4]="SECOND ORDER MOMENT NOT CORRECT"
45
46PASSED=1
47for i in 1 2 3 4
48do
49   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
50     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
51     PASSED=0
52   fi
53done
54
55if [ $PASSED -eq 1 ]; then
56  echo TEST ENDED PROPERLY
57  exit 0
58else
59  echo THERE IS A PROBLEM
60  exit 1
61fi
62
63