forked from gantech/NaluRtest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pass_fail.sh
executable file
·82 lines (68 loc) · 1.93 KB
/
pass_fail.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
determine_pass_fail() {
diffAnywhere=0
tolerance=$1
logFileName=$2
localNormFileName=$3
goldNormFileName=$4
# check for required files: log file and gold
if [ ! -f "$logFileName" ]; then
diffAnywhere=1
fi
# check for gold norm file
if [ ! -f "$goldNormFileName" ]; then
diffAnywhere=1
fi
grep "Mean System Norm:" "$logFileName" | awk '{print $4 " " $5 " " $6 }' > "$localNormFileName"
# make sure the grep worked
if [ ! -f "$localNormFileName" ]; then
diffAnywhere=1
fi
# read in gold norm values
goldCount=1
goldFileContent=( `cat "$goldNormFileName"`)
for gfc in "${goldFileContent[@]}"
do
goldNorm[goldCount]=$gfc
((goldCount++))
done
# read in local norm values
localCount=1
localFileContent=( `cat "$localNormFileName"`)
for lfc in "${localFileContent[@]}"
do
localNorm[localCount]=$lfc
((localCount++))
done
if [ $(echo " $goldCount - $localCount" | bc) -eq 0 ]; then
# the lengths the same... proceed
for ((i=0;i<$goldCount;++i)); do
modLocalNorm=$(printf "%1.32f" ${localNorm[i]})
modGoldNorm=$(printf "%1.32f" ${goldNorm[i]})
# compute the difference
diff=$(echo $modLocalNorm - $modGoldNorm | bc)
# make sure diff is positive.. abs anyone?
zero=0.0
minusOne=-1.0
if [ $(echo " $diff < $zero" | bc) -eq 1 ]; then
absDiff=$(echo $diff*$minusOne | bc)
else
absDiff=$diff
fi
# test the difference
if [ $(echo " $absDiff > $tolerance" | bc) -eq 1 ]; then
diffAnywhere=1
fi
# find the max
if [ $(echo " $absDiff > $GlobalMaxSolutionDiff " | bc) -eq 1 ]; then
GlobalMaxSolutionDiff=$absDiff
fi
done
else
# length was not the same; fail
diffAnywhere=1
GlobalMaxSolutionDiff=1000000.0
fi
# extract simulation time
return $diffAnywhere
}