[12663] | 1 | #!/bin/bash |
---|
| 2 | #set -vx |
---|
| 3 | # ncmax $var_nm $fl_nm : What is maximum of variable? |
---|
| 4 | function ncmax { ncap2 -O -C -v -s "foo=${1}.max();print(foo)" ${2} ~/foo.nc | cut -f 3- -d ' ' ; } |
---|
| 5 | # ncmin $var_nm $fl_nm : What is minimum of variable? |
---|
| 6 | function ncmin { ncap2 -O -C -v -s "foo=${1}.min();print(foo)" ${2} ~/foo.nc | cut -f 3- -d ' ' ; } |
---|
| 7 | # ncmdn $var_nm $fl_nm : What is median of variable? |
---|
| 8 | function ncmdn { ncap2 -O -C -v -s "foo=gsl_stats_median_from_sorted_data(${1}.sort());print(foo)" ${2} ~/foo.nc | cut -f 3- -d ' ' ; } |
---|
| 9 | |
---|
| 10 | ## |
---|
| 11 | ## simple report generator for the test case |
---|
| 12 | ## |
---|
| 13 | |
---|
| 14 | ## |
---|
| 15 | ## Variables which may need to be adapted to your experiment: |
---|
| 16 | ## |
---|
| 17 | # RUNDIR = directory where the test case is executed: contains all outputs |
---|
[13242] | 18 | RUNDIR=`pwd` |
---|
[12663] | 19 | # NB_NEMO_IT = expected total number of NEMO iterations |
---|
| 20 | NB_NEMO_IT=160 |
---|
| 21 | # NB_OASIS_OUTFILES = number of debug.root.0* OASIS output files |
---|
| 22 | NB_OASIS_OUTFILES=2 |
---|
| 23 | ## |
---|
| 24 | ## END of variables to be checked - Nothing need to be changed below |
---|
| 25 | ## |
---|
| 26 | # check if directory is here |
---|
| 27 | if [ ! -d $RUNDIR ]; then |
---|
| 28 | printf "%-27s %s %s\n" $RUNDIR "directory does not exist. Check RUNDIR variable in script. Stop" |
---|
| 29 | return |
---|
| 30 | fi |
---|
| 31 | |
---|
| 32 | cd $RUNDIR |
---|
| 33 | |
---|
| 34 | echo " " |
---|
| 35 | echo "Check results of test case in directory: " `pwd` |
---|
| 36 | echo " " |
---|
| 37 | ## |
---|
| 38 | ## Check if OASIS execution has been successful |
---|
| 39 | ## |
---|
| 40 | echo " OASIS successful (true if OASIS outputs in debug.root.0? includes SUCCESSFUL RUN) : " |
---|
| 41 | count=0 |
---|
| 42 | for file in debug.root.0* |
---|
| 43 | do |
---|
| 44 | echo $file ; grep "SUCCESSFUL RUN" $file |
---|
| 45 | count=`expr $count + 1` |
---|
| 46 | done |
---|
| 47 | echo "OASIS success checked on $count files" |
---|
| 48 | [ $count = $NB_OASIS_OUTFILES ] && echo true || echo false |
---|
| 49 | ## |
---|
| 50 | ## Check if NEMO execution has been sucessful |
---|
| 51 | ## |
---|
| 52 | echo " " |
---|
| 53 | echo " NEMO execution is successful if the run.stat file contains one line for each of NB_NEMO_IT iterations, indicating they have indeed been computed" |
---|
| 54 | if [ ! -f ./run.stat ]; then |
---|
| 55 | echo " the run.stat file does not exist: NEMO did not end its first time step" |
---|
| 56 | echo " NEMO UNSUCESSFUL. Stop" |
---|
| 57 | return |
---|
| 58 | fi |
---|
| 59 | echo "From run.stat NEMO output file, NEMO has executed the 160 time steps:" |
---|
| 60 | nemo_iterations=`wc -l ./run.stat | awk {'print $1'} `; [ $nemo_iterations = $NB_NEMO_IT ] && echo true || echo false |
---|
| 61 | |
---|
| 62 | ## |
---|
| 63 | ## Check mean value of sst field seen by toyatm |
---|
| 64 | ## |
---|
| 65 | if [ ! -f ./ATSSTSST_toyatm_01.nc ]; then |
---|
| 66 | echo " the ATSSTSST_toyatm_01.nc file does not exist: the test is not successful" |
---|
| 67 | echo " Test case UNSUCESSFUL. Stop" |
---|
| 68 | return |
---|
| 69 | fi |
---|
| 70 | echo " " |
---|
| 71 | echo "Examining ATSSTSST variable sea surface temperature as seen by toyatm, unit is degree Kelvin (min. should be around 271., max. around 302., median around 280.)" |
---|
| 72 | ASSTmin=`ncmin ATSSTSST ATSSTSST_toyatm_01.nc` |
---|
| 73 | ASSTmax=`ncmax ATSSTSST ATSSTSST_toyatm_01.nc` |
---|
| 74 | ASSTmed=`ncmdn ATSSTSST ATSSTSST_toyatm_01.nc` |
---|
| 75 | echo "Minimum value of ATSSTSST variable in ATSSTSST_toyatm_01.nc file = " $ASSTmin |
---|
| 76 | echo "Maximum value of ATSSTSST variable in ATSSTSST_toyatm_01.nc file = " $ASSTmax |
---|
| 77 | echo "Median value of ATSSTSST variable in ATSSTSST_toyatm_01.nc file = " $ASSTmed |
---|
| 78 | MINMAX=0 |
---|
| 79 | if [ ${ASSTmin%%.*} -lt 270 -o ${ASSTmax%%.*} -gt 310 ]; then |
---|
| 80 | echo " Min. or max. values of ATSSTSST do not look reasonable. Check the test again " |
---|
| 81 | MINMAX=1 |
---|
| 82 | fi |
---|
| 83 | ## |
---|
| 84 | ## Summary |
---|
| 85 | ## |
---|
| 86 | echo " " |
---|
| 87 | if [ $count = $NB_OASIS_OUTFILES ] && [ $nemo_iterations = $NB_NEMO_IT ] && [ $MINMAX = 0 ] |
---|
| 88 | then |
---|
| 89 | echo " The run looks very succesful!" |
---|
| 90 | echo " Have a look to the ASTSSTSST.nc file (using ncview for example): sea surface temperatures as seen by the toyatm and compare it to the reference file (CPL/ref_ATSSTSST_last_time_step.jpg) " |
---|
| 91 | echo " Units are in degrees Kelvin and it will confirm the test is successful" |
---|
| 92 | echo " " |
---|
| 93 | else |
---|
| 94 | echo "The test case is unsuccessful. Check all inputs and outputs" |
---|
| 95 | fi |
---|