1 | #!/bin/bash |
---|
2 | |
---|
3 | # Do the reference runs and compare output of fast and debug |
---|
4 | |
---|
5 | # Copyright Petra Seibert, 2019 |
---|
6 | # SPDX-License-Identifier: MIT-0 |
---|
7 | |
---|
8 | export OMP_NUM_THREADS=4 |
---|
9 | export OMP_PLACES=sockets |
---|
10 | testhome=`pwd` |
---|
11 | path1=../../../Source/Fortran/ |
---|
12 | path=../${path1} |
---|
13 | exedebug=calc_etadot_debug.out |
---|
14 | exefast=calc_etadot_fast.out |
---|
15 | hash=$(git log --abbrev-commit --pretty=oneline -n 1 --pretty=format:'%h') |
---|
16 | exitonfail=true |
---|
17 | rm -f log.run_ref failed |
---|
18 | |
---|
19 | # loop over all reference runs |
---|
20 | rm -f log.run_ref |
---|
21 | |
---|
22 | if [ "$1" = omithigh ]; then # for fast testing, not for production |
---|
23 | inputs=`ls Inputs | grep -v high` |
---|
24 | else |
---|
25 | inputs=`ls Inputs` |
---|
26 | fi |
---|
27 | for ref in $inputs; do |
---|
28 | |
---|
29 | echo 'Working on test case =' $ref |
---|
30 | |
---|
31 | # loop over debug and fast runs |
---|
32 | for exe in 'debug' 'fast'; do |
---|
33 | |
---|
34 | cd Work |
---|
35 | echo ' Run code version "'${exe}'"' |
---|
36 | |
---|
37 | thisexe=calc_etadot_${exe}.out |
---|
38 | ln ../Inputs/${ref}/fort.* . |
---|
39 | ( time ${path}${thisexe} ) >& log |
---|
40 | |
---|
41 | # check whether runs completeted properly |
---|
42 | outdir='Outputs/Output_ref_'${ref}'_'${exe} |
---|
43 | grep -q CONGRATULATIONS log |
---|
44 | if [ $? = "0" ]; then |
---|
45 | echo ' CONGRATULATIONS found' >> ../log.run_ref |
---|
46 | mv log ../${outdir} |
---|
47 | else |
---|
48 | echo ' missing CONGRATULATIONS. Test failed.' |
---|
49 | echo $ref $exe 'FAILED' >> ${testhome}/failed |
---|
50 | if [ "${exitonfail}" = true ]; then exit; fi |
---|
51 | fi |
---|
52 | for outfile in 'fort.15' 'VERTICAL.EC'; do |
---|
53 | if [ -e $outfile ]; then |
---|
54 | mv ${outfile} ../${outdir} |
---|
55 | else |
---|
56 | echo ' missing '${outfile}' Test failed.' |
---|
57 | echo $ref $exe 'FAILED' >> ${testhome}/failed |
---|
58 | if [ "${exitonfail}" = true ]; then exit; fi |
---|
59 | fi |
---|
60 | done |
---|
61 | |
---|
62 | cd .. |
---|
63 | rm Work/* # this is for being more safe |
---|
64 | |
---|
65 | done # end of exe loop |
---|
66 | |
---|
67 | # compare debug and fast |
---|
68 | # omega case also produces fort.25 - need to add this |
---|
69 | for outfile in 'fort.15' 'VERTICAL.EC'; do |
---|
70 | outdebug='Outputs/Output_ref_'${ref}'_debug/'$outfile |
---|
71 | outfast='Outputs/Output_ref_'${ref}'_fast/'$outfile |
---|
72 | test=$(cmp $outdebug $outfast) |
---|
73 | if $test; then |
---|
74 | echo $outfile ' equal for debug and fast' >> log.run_ref |
---|
75 | else |
---|
76 | echo 'WARNING:' $outfile ' not equal for debug and fast, test failed' |
---|
77 | echo $ref $exe 'FAILED' >> ${testhome}/failed |
---|
78 | if [ "${exitonfail}" = true ]; then exit; fi |
---|
79 | fi |
---|
80 | done |
---|
81 | |
---|
82 | # save and show runtimes |
---|
83 | for exe in 'debug' 'fast'; do |
---|
84 | log='Outputs/Output_ref_'${ref}'_'${exe}'/log' |
---|
85 | times=$(tail -3 ${log}) |
---|
86 | real=$(echo $times | grep real | awk '{print $2}') |
---|
87 | user=$(echo $times | grep user | awk '{print $4}') |
---|
88 | sys=$( echo $times | grep sys | awk '{print $6}') |
---|
89 | echo $hash, "'"reference"'", "'"${ref}'_'${exe}"'", ${real}, ${user}, ${sys} >> runtimes.csv |
---|
90 | tail -1 runtimes.csv >> log.run_ref |
---|
91 | done |
---|
92 | |
---|
93 | echo # go to next reference run |
---|
94 | |
---|
95 | done |
---|
96 | echo |
---|
97 | echo More information in log.run_ref |
---|
98 | |
---|
99 | # the following code is executed only if exitonfail is not set to 'true'. |
---|
100 | if [ -e failed ]; then |
---|
101 | echo |
---|
102 | echo Some tests failed, see file "failed": |
---|
103 | echo |
---|
104 | cat failed|sort -u |
---|
105 | fi |
---|