source: flex_extract.git/Testing/Regression/FortranEtadot/run_regrtest.sh @ 6bc4b42

ctbtodev
Last change on this file since 6bc4b42 was 6bc4b42, checked in by pesei <petra seibert -@…>, 5 years ago

Add script to run regression tests

called run_regrtest.sh + small corr on run_ref.sh

  • Property mode set to 100755
File size: 3.4 KB
Line 
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
10export OMP_NUM_THREADS=4 # you may want to change this
11export OMP_PLACES=sockets
12testhome=`pwd`
13path1=../../../Source/Fortran/
14path=../${path1}
15exedebug=calc_etadot_debug.out
16exefast=calc_etadot_fast.out
17hash=$(git log --abbrev-commit --pretty=oneline -n 1  --pretty=format:'%h')
18exitonfail=true
19numtest=0
20numpassed=0
21
22rm -f log.run_regr failed
23
24# loop over all reference runs
25
26if [ "$1" = omithigh ]; then # for fast testing, not for production
27  inputs=`ls Inputs |  grep -v high`
28else
29  inputs=`ls Inputs |grep etadothigh`
30fi
31for ref in $inputs; do
32
33  echo 'Working on test case =' $ref
34
35  # loop over debug and fast runs
36  for exe in 'debug' 'fast'; do
37 
38    numtest=$((numtest + 1))
39    failed=false
40
41    rm -f Work/* # make shure that Work is empty
42    cd Work
43    echo '  Run code version "'${exe}'"' | tee -a ../log.run_regr
44
45    thisexe=calc_etadot_${exe}.out
46    ln ../Inputs/${ref}/fort.* .
47    ( time ${path}${thisexe} ) >& log
48   
49    # check whether runs completeted properly
50    grep -q CONGRATULATIONS log
51    if [ $? = "0" ]; then
52      echo '    CONGRATULATIONS found' | tee -a ../log.run_regr
53    else
54      echo '    missing CONGRATULATIONS. Test failed.' | tee -a ../log.run_regr
55      echo $ref $exe 'FAILED' >> ${testhome}/failed
56      if [ "${exitonfail}" = true ]; then exit; else failed=true; fi
57    fi
58    for outfile in 'fort.15' 'VERTICAL.EC'; do
59      if [ -e $outfile ]; then
60        # compare reference and current version
61        # omega case also produces fort.25 - need to add this
62        outref='../Outputs/Output_ref_'${ref}'_'${exe}'/'$outfile
63        test=$(cmp  $outfile $outref)
64        if $test; 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
95done # end of ref loop
96
97echo 
98echo ' Regression test: ' $numpassed 'out of' $numtest 'tests passed'. \
99  | tee -a ../log.run_regr
100echo ' More information may be found in log.run_regr' 
101echo ' 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'.
104if [ -e failed ]; then 
105  echo
106  echo Some tests failed, see file "failed":
107  echo
108  cat failed|sort -u
109fi
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG