-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_output.sh
More file actions
executable file
·51 lines (37 loc) · 1.33 KB
/
check_output.sh
File metadata and controls
executable file
·51 lines (37 loc) · 1.33 KB
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
#!/bin/bash
# simply script to check the output from slurm
# border values should be 1 and the array should be symmetrical
directory=$1
rows=$2
for filename in $directory/*.txt; do
# array starts from row 5
startrow=5;
endrow=$(($startrow + $rows - 1))
midrow=$(($startrow + $rows / 2))
## Check all 1 in first row and first column
# symmetry check will ensure last row and last column is also 1
ok1=`awk -v start=$startrow 'NR == startrow { for (i=1; i<=NF; i++) if ($i != 1) print "NO"}' $filename`
ok2=`awk -v start=$startrow -v end=$endrow 'NR>=start && NR<=end && $1 != 1 {print "NO"}' $filename`
## Check symmetry
# splits the 1000 dimension array into two sections,
# one with first 500 lines using sed
# second with last 500 lines using sed
# second section rows are reversed using tac
# second sections columns are reversed using awk
# check symmetry using diff
ok3=`diff --ignore-space-change <(sed -n "$startrow,$(($midrow - 1)) p" $filename) \
<(sed -n "$midrow,$endrow p" $filename | tac \
| awk '{ for (i=NF; i>1; i--) printf("%s ", $i); print $1; }')`
if [[ $ok1 ]]; then
echo $filename "FAILED: first row check"
fi
if [[ $ok2 ]]; then
echo $filename "FAILED: first column check"
fi
if [[ $ok3 ]]; then
echo $filename "FAILED: symmetry check"
fi
if [[ -z "${ok1}${ok2}${ok3}" ]]; then
echo $filename "OK"
fi
done