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