[2d1c338] | 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 | |
---|
[6bc4b42] | 8 | export OMP_NUM_THREADS=4 # you may want to change this |
---|
[2d1c338] | 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 |
---|
[6bc4b42] | 23 | # requires > 16 GB |
---|
[2d1c338] | 24 | inputs=`ls Inputs | grep -v high` |
---|
| 25 | else |
---|
| 26 | inputs=`ls Inputs` |
---|
| 27 | fi |
---|
| 28 | for ref in $inputs; do |
---|
| 29 | |
---|
| 30 | echo 'Working on test case =' $ref |
---|
| 31 | |
---|
| 32 | # loop over debug and fast runs |
---|
| 33 | for exe in 'debug' 'fast'; do |
---|
| 34 | |
---|
| 35 | cd Work |
---|
| 36 | echo ' Run code version "'${exe}'"' |
---|
| 37 | |
---|
| 38 | thisexe=calc_etadot_${exe}.out |
---|
| 39 | ln ../Inputs/${ref}/fort.* . |
---|
| 40 | ( time ${path}${thisexe} ) >& log |
---|
| 41 | |
---|
| 42 | # check whether runs completeted properly |
---|
| 43 | outdir='Outputs/Output_ref_'${ref}'_'${exe} |
---|
| 44 | grep -q CONGRATULATIONS log |
---|
| 45 | if [ $? = "0" ]; then |
---|
| 46 | echo ' CONGRATULATIONS found' >> ../log.run_ref |
---|
| 47 | mv log ../${outdir} |
---|
| 48 | else |
---|
| 49 | echo ' missing CONGRATULATIONS. Test failed.' |
---|
| 50 | echo $ref $exe 'FAILED' >> ${testhome}/failed |
---|
| 51 | if [ "${exitonfail}" = true ]; then exit; fi |
---|
| 52 | fi |
---|
| 53 | for outfile in 'fort.15' 'VERTICAL.EC'; do |
---|
| 54 | if [ -e $outfile ]; then |
---|
| 55 | mv ${outfile} ../${outdir} |
---|
| 56 | else |
---|
| 57 | echo ' missing '${outfile}' Test failed.' |
---|
| 58 | echo $ref $exe 'FAILED' >> ${testhome}/failed |
---|
| 59 | if [ "${exitonfail}" = true ]; then exit; fi |
---|
| 60 | fi |
---|
| 61 | done |
---|
| 62 | |
---|
| 63 | cd .. |
---|
| 64 | rm Work/* # this is for being more safe |
---|
| 65 | |
---|
| 66 | done # end of exe loop |
---|
| 67 | |
---|
| 68 | # compare debug and fast |
---|
| 69 | # omega case also produces fort.25 - need to add this |
---|
| 70 | for outfile in 'fort.15' 'VERTICAL.EC'; do |
---|
| 71 | outdebug='Outputs/Output_ref_'${ref}'_debug/'$outfile |
---|
| 72 | outfast='Outputs/Output_ref_'${ref}'_fast/'$outfile |
---|
| 73 | test=$(cmp $outdebug $outfast) |
---|
| 74 | if $test; then |
---|
| 75 | echo $outfile ' equal for debug and fast' >> log.run_ref |
---|
| 76 | else |
---|
| 77 | echo 'WARNING:' $outfile ' not equal for debug and fast, test failed' |
---|
| 78 | echo $ref $exe 'FAILED' >> ${testhome}/failed |
---|
| 79 | if [ "${exitonfail}" = true ]; then exit; fi |
---|
| 80 | fi |
---|
| 81 | done |
---|
| 82 | |
---|
| 83 | # save and show runtimes |
---|
| 84 | for exe in 'debug' 'fast'; do |
---|
| 85 | log='Outputs/Output_ref_'${ref}'_'${exe}'/log' |
---|
| 86 | times=$(tail -3 ${log}) |
---|
| 87 | real=$(echo $times | grep real | awk '{print $2}') |
---|
| 88 | user=$(echo $times | grep user | awk '{print $4}') |
---|
| 89 | sys=$( echo $times | grep sys | awk '{print $6}') |
---|
| 90 | echo $hash, "'"reference"'", "'"${ref}'_'${exe}"'", ${real}, ${user}, ${sys} >> runtimes.csv |
---|
| 91 | tail -1 runtimes.csv >> log.run_ref |
---|
| 92 | done |
---|
| 93 | |
---|
| 94 | echo # go to next reference run |
---|
| 95 | |
---|
| 96 | done |
---|
| 97 | echo |
---|
| 98 | echo More information in log.run_ref |
---|
| 99 | |
---|
| 100 | # the following code is executed only if exitonfail is not set to 'true'. |
---|
| 101 | if [ -e failed ]; then |
---|
| 102 | echo |
---|
| 103 | echo Some tests failed, see file "failed": |
---|
| 104 | echo |
---|
| 105 | cat failed|sort -u |
---|
| 106 | fi |
---|