-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathcheck_output.sh
executable file
·67 lines (62 loc) · 1.69 KB
/
check_output.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
showusage() {
printf "Usage:\n"
printf "./check_output.sh executable mass_relative_tolerance energy_relative_tolerance [n_tasks]\n\n"
}
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
showusage
exit 0
fi
if [[ "$1" == "" ]]; then
printf "ERROR: Did not specify an executable\n\n"
showusage
exit -1
fi
if [[ "$2" == "" ]]; then
printf "ERROR: Did not specify a mass tolerance\n\n"
showusage
exit -1
fi
if [[ "$3" == "" ]]; then
printf "ERROR: Did not specify a total energy tolerance\n\n"
showusage
exit -1
fi
if [[ "$4" == "" ]]; then
n_tasks=1
else
n_tasks=$4
fi
if [[ ! -f $1 ]]; then
exit -1
fi
mpiexec -n $n_tasks $1 > ${1}.output || exit -1
cat ${1}.output
dmass=`grep d_mass ${1}.output | awk '{print $2}'`
if [[ "$dmass" == "NaN" ]]; then
printf "Mass change is NaN\n\n"
exit -1
fi
if (( `awk "BEGIN {val=$dmass; abs=val>0?val:-val; ret=abs<$2?0:-1; print ret}"` )); then
printf "ERROR: Mass change magnitude is too large\n\n"
printf "Change in mass: $dmass"
printf "Mass tolerance: $2"
exit -1
fi
dte=`grep d_te ${1}.output | awk '{print $2}'`
if [[ "$dte" == "NaN" ]]; then
printf "Total energy change is NaN\n\n"
exit -1
fi
if (( `awk "BEGIN {val=$dte; ret=val<0?0:-1; print ret}"` )); then
printf "ERROR: Total energy change must be negative\n\n"
exit -1
fi
if (( `awk "BEGIN {val=$dte; abs=val>0?val:-val; ret=abs<$3?0:-1; print ret}"` )); then
printf "ERROR: Total energy change magnitude is too large\n\n"
printf "Change in total energy: $dte"
printf "Total energy tolerance: $3"
exit -1
fi
printf "Test executable produced correct results within error bounds of expected mass change and total energy change.\n\n"
rm -f ${1}.output