#!/bin/csh -f # Run this script from the verification directory # It will automatically configure, compile, run and verify all experiments # in the verification directory for whcih there is an results/output.txt # file. # This is the number of least-significant digits allows to be # in error before the test is classified as a "fail". set on_error_die set digitsOfAccuracy=8 set SKIP=( ) printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' " " Make " " " " Exact "# of" " " " " > summary.txt printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' Config Depend Compile Execute Match Digits Status Experiment >> summary.txt # Pass any arguments foreach arg ($argv) switch ($arg) case -clean: echo Cleaning ... foreach dr ([a-zA-Z01-9]*) if (-d $dr/input) then echo Entering $dr cd $dr/input echo "" make CLEAN \rm -f {*output,*high,*low}.txt *.log \rm -f ?ake* cd ../.. endif end rm -f summary.txt exit 0 breaksw case -nodie: unset on_error_die breaksw case -skip=*: set SKIP = ( $SKIP `echo $arg | sed 's/-skip=//' | sed 's/,/ /g' `) breaksw default: echo Unknown argument given to $0 exit 1 endsw end # Need to make sure we don't meet non-model problems ... unlimit foreach dr ([a-zA-Z01-9]*) if (! -d $dr/input ) continue foreach skip ($SKIP) if ( `echo $dr | sed s/$skip.'*'//` == '' ) continue;continue end set config=- set makedepend=- set compile=- set execute=- set exactmatch=- set accuracy=- set pass=FAIL echo ============================================================================== echo Entering $dr cd $dr echo "" if (! -r results/output.txt) then echo " ***** No results to compare with *****" if (! $?untested) set untested set untested=($untested $dr) else set config=NO cd input echo -n " generating Makefile ..." ../../../tools/genmake -mods=../code >&! make.log if ($status == 0) set config=Yes set makedepend=NO echo " done." echo -n " make depend ..." make cleanlinks depend >>& make.log if ($status == 0) set makedepend=Yes echo " done." echo -n " make ..." make >>& make.log if ($status) then echo " ***** An error occurred during make *****" cat make.log echo The error during compilation occured in \"$dr\" set compile=NO if ($?on_error_die) exit 1 else set compile=Yes set execute=NO endif echo " done." echo -n " running model ..." if ($compile == 'Yes') then ./mitgcmuv > & output.txt if ($status == 0) then set execute=Yes set exactmatch=NO set accuracy=- echo " done." # Compare output based on cg2d residual grep "cg2d_init_res" output.txt | sed 's/.*=//' | nl > high.txt grep "cg2d_init_res" ../results/output.txt | sed 's/.*=//' | nl > oldhigh.txt join high.txt oldhigh.txt > low.txt set nlines=`wc -l low.txt | awk '{print $1}'` echo " comparing $nlines lines of output" @ line = 1 set bestacc=99; set worstline='Exact match' while ($line <= $nlines) set vals=(`grep "^$line" low.txt | awk '{print $2,$3}'`) @ line += 1 unset acc foreach dp (14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) set cmp=(`printf '%23.'$dp'e %23.'$dp'e\n' $vals[1] $vals[2]`) if ($cmp[1] =~ $cmp[2]) then if (! $?acc) then set acc=$dp break endif endif end if (! $?acc) set acc=0 if ($acc < $bestacc) then set worstline=($line $vals[1] $vals[2] `printf '%23.'$acc'e' $vals[1]` $acc) set bestacc=$acc endif # echo $line $vals[1] $vals[2] `printf '%23.'$acc'e' $vals[1]` $acc end if ($nlines == 0) then set bestacc=0 set worstline="Could find no lines in output.txt to compare" endif if ($bestacc == 14 & $?exactmatch) then set exactmatch=Yes echo " " echo " ***** EXACT MATCH *****" endif if ($bestacc > $digitsOfAccuracy) then set pass=Pass echo " " echo " ***** PASS (digits=$bestacc) *****" echo " " echo " worstline: " $worstline else echo " " echo " ***** FAIL (digits=$bestacc) *****" echo " " echo " worstline: " $worstline endif set accuracy=$bestacc else echo " error" echo " ***** An error occured running the model *****" tail output.txt echo The runtime error occured in \"$dr\" if ($?on_error_die) exit 1 set pass=- endif rm -f high.txt oldhigh.txt low.txt oldlow.txt output.txt make.log endif cd .. endif echo "" cd .. # Pretty summary printresults: printf ' %s\t %s\t %s\t %s\t %s\t %s\t %s\t%s\n' $config $makedepend $compile $execute $exactmatch $accuracy $pass $dr >> summary.txt end echo ============================================================================== echo "" echo "Summary:" echo "" cat summary.txt