New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
sette_rpt.sh in utils/CI/sette – NEMO

source: utils/CI/sette/sette_rpt.sh @ 13900

Last change on this file since 13900 was 13795, checked in by smueller, 4 years ago

Adjustment of a subdirectory name in the tests used by SETTE to detect modified working copies (ticket #2571)

  • Property svn:executable set to *
File size: 16.2 KB
RevLine 
[6124]1#!/bin/bash -f
[9019]2# set -vx
[6124]3# simple SETTE report generator.
4#
5# This version should be run in the SETTE directory.
6# The machine name will be picked up from the sette.sh script but the location of the
[9602]7# validation directory needs to be set here (currently assumed to reside in the ../cfgs directory)
[6124]8#
9#########################################################################################
10######################### Start of function definitions #################################
11##
[8468]12
[11161]13function get_dorv() {
14  if [ $lastchange == 'old' ] ; then
[8468]15    dorv=`ls -1rt $vdir/$nam/$mach/ | tail -1l `
16    dorv=`echo $dorv | sed -e 's:.*/::'`
[12569]17    dorv2=`ls -1rt $vdir/$nam2/$mach/ 2>/dev/null | tail -1l `
[11497]18    dorv2=`echo $dorv2 | sed -e 's:.*/::'`
[9019]19  else
[11161]20    dorv=$lastchange
[11497]21    dorv2=$lastchange
[9019]22  fi
[8468]23}
24
[11161]25function get_ktdiff() {
26  ktdiff=`diff ${1} ${2} | head -2 | grep it | awk '{ print $4 }'`
27}
28
[6124]29function resttest() { 
30#
31# Restartability checks. Expects LONG and SHORT run directories
32# Compares end of LONG stat files with equivalent entries from the SHORT stat files.
33#
34  vdir=$1
35  nam=$2
36  pass=$3
37#
[11161]38# get $dorv
39  get_dorv
40#
41# check if directory is here
42  if [ ! -d $vdir/$nam/$mach/$dorv ]; then
43    printf "%-27s %s %s\n" $nam  " directory                  MISSING : " $dorv
44    return
45  fi
46
47  if [ -d $vdir/$nam/$mach/$dorv ]; then
48    # check ocean output
49    runtest $vdir $nam $pass RST
50    #
51    # run restartibility test
[6124]52    f1o=$vdir/$nam/$mach/$dorv/LONG/ocean.output
[9019]53    f1s=$vdir/$nam/$mach/$dorv/LONG/run.stat
[6124]54    f1t=$vdir/$nam/$mach/$dorv/LONG/tracer.stat
55    f2o=$vdir/$nam/$mach/$dorv/SHORT/ocean.output
[9019]56    f2s=$vdir/$nam/$mach/$dorv/SHORT/run.stat
[6124]57    f2t=$vdir/$nam/$mach/$dorv/SHORT/tracer.stat
58
[6152]59    if  [ ! -f $f1s ] &&  [ ! -f $f1t ] ; then
[9525]60      printf "%-27s %s\n" $nam " incomplete test";
[6124]61      return;
62    fi
[6152]63    if  [ ! -f $f2s ] &&  [ ! -f $f2t ] ; then
[9525]64      printf "%-27s %s\n" $nam " incomplete test";
[6124]65      return;
66    fi
67#
68    done_oce=0
69
[6152]70    if  [  -f $f1s ] && [  -f $f2s ]; then
71      nl=(`wc -l $f2s`)
72      tail -${nl[0]} $f1s > f1.tmp$$
73      cmp -s f1.tmp$$ $f2s
74      if [ $? == 0 ]; then
75        if [ $pass == 0 ]; then
[9525]76          printf "%-27s %s %s\n" $nam  " run.stat    restartability  passed : " $dorv
[6152]77        fi
78      else
[11161]79        get_ktdiff f1.tmp$$ $f2s
80        printf "\e[38;5;196m%-27s %s %s %s %-5s %s\e[0m\n" $nam  " run.stat    restartability  FAILED : " $dorv " (results are different after " $ktdiff " time steps)"
[6124]81#
82# Offer view of differences on the second pass
83#
[6152]84        if [ $pass == 1 ]; then
[9019]85          echo "<return> to view run.stat differences"
[6152]86          read y
87          sdiff f1.tmp$$ $f2s
88          echo "<return> to view ocean.output differences"
89          read y
90          sdiff $f1o $f2o | grep "|"
91          done_oce=1
92          echo "<return> to continue"
93          read y
94        fi
[6124]95      fi
96    fi
97#
98# Check tracer.stat files (if they exist)
99#
[6152]100    if  [  -f $f1t ] && [  -f $f2t ]; then
[6124]101      nl=(`wc -l $f2t`)
102      tail -${nl[0]} $f1t > f1.tmp$$
103      cmp -s f1.tmp$$ $f2t
104      if [ $? == 0 ]; then
[6152]105        if [ $pass == 0 ]; then
[9525]106          printf "%-27s %s %s\n" $nam  " tracer.stat restartability  passed : " $dorv
[6152]107        fi
[6124]108      else
[11161]109        get_ktdiff f1.tmp$$ $f2t
110        printf "\e[38;5;196m%-27s %s %s %s %-5s %s\e[0m\n" $nam  " tracer.stat    restartability  FAILED : " $dorv " (results are different after " $ktdiff " time steps)"
[6124]111#
112# Offer view of differences on the second pass
113#
114        if [ $pass == 1 ]; then
115          echo "<return> to view tracer.stat differences"
116          read y
117          sdiff f1.tmp$$ $f2t
118#
119# Only offer ocean.output view if it has not been viewed previously
120#
121          if [ $done_oce == 0 ]; then
122            echo "<return> to view ocean.output differences"
123            read y
124            sdiff $f1o $f2o | grep "|"
125          fi
126          echo "<return> to continue"
127          read y
128        fi
129      fi
130    fi
131    rm f1.tmp$$
132  fi
133}
134
135function reprotest(){
136#
137# Reproducibility checks. Expects REPRO_N_M and REPRO_I_J run directories
138# Compares end of stat files from each
139#
140  vdir=$1
141  nam=$2
142  pass=$3
143#
[11161]144# get $dorv
145  get_dorv
146#
147# check if directory is here
148  if [ ! -d $vdir/$nam/$mach/$dorv ]; then
149    printf "%-27s %s %s\n" $nam  " directory                  MISSING : " $dorv
150    return
151  fi
152#
153  if [ -d $vdir/$nam/$mach/$dorv ]; then
154    # check ocean output
155    runtest $vdir $nam $pass REPRO
156    #
157    # check reproducibility
[9019]158    rep1=`ls -1rt $vdir/$nam/$mach/$dorv/ | grep REPRO | tail -2l | head -1 `
159    rep2=`ls -1rt $vdir/$nam/$mach/$dorv/ | grep REPRO | tail -1l`
[13785]160    if [ $rep1 == $rep2 ]; then
161       rep2=''
162    fi
[6124]163    f1o=$vdir/$nam/$mach/$dorv/$rep1/ocean.output
[9019]164    f1s=$vdir/$nam/$mach/$dorv/$rep1/run.stat
[6124]165    f1t=$vdir/$nam/$mach/$dorv/$rep1/tracer.stat
166    f2o=$vdir/$nam/$mach/$dorv/$rep2/ocean.output
[9019]167    f2s=$vdir/$nam/$mach/$dorv/$rep2/run.stat
[6124]168    f2t=$vdir/$nam/$mach/$dorv/$rep2/tracer.stat
169
[6152]170    if  [ ! -f $f1s ] && [ ! -f $f1t ] ; then
[9525]171      printf "%-27s %s\n" $nam " incomplete test";
[6124]172      return;
173    fi
[6152]174    if  [ ! -f $f2s ] && [ ! -f $f2t ] ; then
[9525]175      printf "%-27s %s\n" $nam " incomplete test";
[6124]176      return;
177    fi
178#
179    done_oce=0
180
[6152]181    if  [ -f $f1s ] && [ -f $f2s ] ; then
182      cmp -s $f1s $f2s
183      if [ $? == 0 ]; then
184        if [ $pass == 0 ]; then
[9525]185          printf "%-27s %s %s\n" $nam  " run.stat    reproducibility passed : " $dorv
[6152]186        fi
187      else
[11161]188        get_ktdiff $f1s $f2s
189        printf "\e[38;5;196m%-27s %s %s %s %-5s %s\e[0m\n" $nam  " run.stat    reproducibility FAILED : " $dorv " (results are different after " $ktdiff " time steps)"
[6124]190#
191# Offer view of differences on the second pass
192#
[6152]193        if [ $pass == 1 ]; then
[9019]194          echo "<return> to view run.stat differences"
[6152]195          read y
[9911]196          sdiff $f1s $f2s
[6152]197          echo "<return> to view ocean.output differences"
198          read y
199          sdiff $f1o $f2o | grep "|"
200          done_oce=1
201          echo "<return> to continue"
202          read y
203        fi
[6124]204      fi
205    fi
206#
207# Check tracer.stat files (if they exist)
208#
[6152]209    if  [ -f $f1t ] && [ -f $f2t ] ; then
[6124]210      cmp -s $f1t $f2t
211      if [ $? == 0 ]; then
[9525]212        if [ $pass == 0 ]; then           printf "%-27s %s %s\n" $nam  " tracer.stat reproducibility passed : " $dorv
[6152]213        fi
[6124]214      else
[11161]215        get_ktdiff $f1t $f2t
[12569]216        printf "\e[38;5;196m%-27s %s %s %s %-5s %s\e[0m\n" $nam  " tracer.stat reproducibility FAILED : " $dorv " (results are different after " $ktdiff " time steps)"
[6124]217#
218# Offer view of differences on the second pass
219#
220        if [ $pass == 1 ]; then
221          echo "<return> to view tracer.stat differences"
222          read y
223          sdiff $f1t $f2t
224#
225# Only offer ocean.output view if it has not been viewed previously
226#
227          if [ $done_oce == 0 ]; then
228            echo "<return> to view ocean.output differences"
229            read y
230            sdiff $f1o $f2o | grep "|"
231          fi
232          echo "<return> to continue"
233          read y
234        fi
235      fi
236    fi
[9223]237  fi
238}
[11161]239function runcmpres(){
[9223]240#
[11161]241# compare *.stat file with reference file from a previous sette test or previous version
242# store in NEMO_VALID_REF at revision NEMO_REV_REF
243# Compares end of stat files from each
[9223]244#
245  vdir=$1
246  nam=$2
[11161]247  vdirref=$3
248  dorvref=$4
249  pass=$5
[9223]250#
[11161]251# get $dorv
252  get_dorv
253#
254# check if reference directory is present
255  if [ ! -d $vdirref/$nam/$mach/$dorvref ]; then
256    printf "%-27s %s\n" $nam " REFERENCE directory at $dorvref is MISSING"
257    return
258  fi
259  if [ ! -d $vdir/$nam/$mach/$dorv ]; then
260    printf "%-27s %s\n" $nam " VALID     directory at $dorv is MISSING"
261    return
262  fi
263
264#
265  if [ -d $vdir/$nam/$mach/$dorv ]; then
266    f1s=$vdir/$nam/$mach/$dorv/LONG/run.stat
267    f1t=$vdir/$nam/$mach/$dorv/LONG/tracer.stat
268    f2s=$vdirref/$nam/$mach/$dorvref/LONG/run.stat
269    f2t=$vdirref/$nam/$mach/$dorvref/LONG/tracer.stat
270    if  [ ! -f $f1s ] && [ ! -f $f1t ] ; then
271      printf "%-20s %s\n" $nam " incomplete test";
272      return;
[9911]273    fi
[11161]274    if  [ ! -f $f2s ] && [ ! -f $f2t ] ; then
275      printf "%-20s %s\n" $nam " incomplete test";
[9223]276      return;
[11161]277    fi
278#
279    done_oce=0
280
281    if  [ -f $f1s ] && [ -f $f2s ] ; then
282      cmp -s $f1s $f2s
283      if [ $? == 0 ]; then
284        if [ $pass == 0 ]; then
285          printf "%-20s %s %s\n" $nam  " run.stat    files are identical "
286        fi
287      else
[12569]288        get_ktdiff $f1s $f2s
289        printf "%-20s %s %s %-5s %s\n" $nam  " run.stat    files are DIFFERENT (results are different after " $ktdiff " time steps)"
[11161]290#
291# Offer view of differences on the second pass
292#
[9223]293        if [ $pass == 1 ]; then
[11161]294          echo "<return> to view run.stat differences"
[9223]295          read y
[11161]296          sdiff $f1s $f2s
297          done_oce=1
298          echo "<return> to continue"
299          read y
[9223]300        fi
301      fi
302    fi
[11161]303    # Check tracer.stat files (if they exist)
304#
305    if  [ -f $f1t ] && [ -f $f2t ] ; then
306      cmp -s $f1t $f2t
307      if [ $? == 0 ]; then
308        if [ $pass == 0 ]; then         
309          printf "%-20s %s %s\n" $nam  " tracer.stat files are identical "
310        fi
311      else
[12569]312        get_ktdiff $f1t $f2t
313        printf "%-20s %s %s %-5s %s\n" $nam  " tracer.stat files are DIFFERENT (results are different after " $ktdiff " time steps) "
[11161]314#
315# Offer view of differences on the second pass
316#
317        if [ $pass == 1 ]; then
318          echo "<return> to view tracer.stat differences"
319          read y
320          sdiff $f1t $f2t
321        fi
322      fi
323    fi
324  fi
325}
326
327function runtest(){
328#
329# Run checks.
330# Check presence of E R R O R in ocean.output from each
331#
332  vdir=$1
333  nam=$2
334  pass=$3
335  ttype=$4
336  [[ $ttype == 'RST' ]] && ttype="LONG|SHORT"
337#
338# get $dorv
339  get_dorv
340#
341# no print needed if the repository is not here (already catch before)
342#
343  if [ -d $vdir/$nam/$mach/$dorv/ ]; then
344    #
345    # apply check for all ttype directory
346    rep1=$(ls -rt $vdir/$nam/$mach/$dorv/ | grep -E $ttype)
347    for tdir in $rep1 ; do
348       f1o=$vdir/$nam/$mach/$dorv/$tdir/ocean.output
349       if  [ ! -f $f1o ] ; then
350          if [ $pass == 0 ]; then printf "%-27s %s %s\n" $nam " ocean.output               MISSING : " $dorv ; fi
351          return;
352       else
353          nerr=`grep 'E R R O R' $f1o | wc -l`
354          if [[ $nerr > 0 ]]; then
355             printf "\e[38;5;196m%-27s %s %s %s\e[0m\n" $nam " run                         FAILED : " $dorv " ( E R R O R in ocean.output) " 
356             if [ $pass == 1 ]; then
357                echo "<return> to view end of ocean.output"
358                read y
359                tail -100 $f1o
360                echo ''
361                echo "full ocean.output available here: $f1o"
362             fi
363             return;
364          fi
365       fi
366    done
[9221]367  else
[11161]368    if [ $pass == 0 ]; then printf "%-27s %s %s\n" $nam  " directory                  MISSING : " $dorv ; fi
[6124]369  fi
370}
[9019]371
372function identictest(){
373#
[11497]374# Checks AGRIF does not corrupt results with no AGRIF zoom by comparing run.stat files
[9019]375#
376  vdir=$1
[11497]377  nam=$2
378  nam2=$3
[9019]379  pass=$4
380#
[11497]381  get_dorv
[9019]382#
[11497]383  rep=`ls -1rt $vdir/$nam/$mach/$dorv/ |  tail -1l`
384  f1s=${vdir}/${nam}/${mach}/${dorv}/${rep}/run.stat
385  f2s=${vdir}/${nam2}/${mach}/${dorv2}/${rep}/run.stat
386#
387  if  [ -f $f1s ] && [ -f $f2s ] ; then
[9019]388      cmp -s $f1s $f2s
389      if [ $? == 0 ]; then
[11497]390          if [ $pass == 0 ]; then
391         printf "%-5s %s %-5s %s %s %s\n" $rep "AGRIF vs" $rep "NOAGRIF run.stat    unchanged  -    passed : " $dorv $dorv2
392          fi
[9019]393      else
[11497]394          get_ktdiff $f1s $f2s
395          printf "\e[38;5;196m%-5s %s %-5s %s %s %s %s %-5s %s\e[0m\n" $rep "AGRIF vs" $rep "NOAGRIF run.stat    changed  -     FAILED : " $dorv $dorv2 " (results are different after " $ktdiff " time steps)"
[9019]396#
397# Offer view of differences on the second pass
398#
[11497]399          if [ $pass == 1 ]; then
400         echo "<return> to view run.stat differences"
401         read y
402         sdiff $f1s $f2s
403         echo "<return> to continue"
404         read y
405          fi
[9019]406      fi
407  else
[11497]408      printf "%-27s %-27s %s\n" $nam $nam2 " incomplete test"
[9019]409  fi
410}
[6124]411########################### END of function definitions #################################
412##                                                                                     ##
413##    Main script                                                                      ##
414##                                                                                     ##
415#########################################################################################
416#
[11161]417# LOAD param variable (COMPILER, NEMO_VALIDATION_DIR, SVN_CMD)
418  SETTE_DIR=$(cd $(dirname "$0"); pwd)
419  MAIN_DIR=$(dirname $SETTE_DIR)
420  . ./param.cfg
421
422  mach=${COMPILER}
423  NEMO_VALID=${NEMO_VALIDATION_DIR}
424  NEMO_VALID_REF=${NEMO_VALIDATION_REF}
[6124]425#
426  if [ ! -d $NEMO_VALID ]; then
427    echo "$NEMO_VALID validation directory not found"
428    exit
429  fi
430#
[9019]431#
432# Show current revision tag and branch name
433#
[11161]434echo ""
[12569]435lastchange=`${SVN_CMD} info ${MAIN_DIR} | grep 'Last Changed Rev' | awk '{print $NF}'`
436revision=`${SVN_CMD} info ${MAIN_DIR} | grep 'Revision' | awk '{print $NF}'`
437branchname=`${SVN_CMD} info ${MAIN_DIR} | grep ^URL | awk -F ipsl/forge/projets/nemo/svn/ '{print $NF}'`
[11161]438echo "Current code is : $branchname @ r$revision  ( last change @ r$lastchange )"
[13795]439[ `${SVN_CMD} status -q ${MAIN_DIR}/{cfgs,tests,src} | wc -l` -ge 1 ] && lastchange=${lastchange}+
[11161]440
[12569]441# overwrite revision or compiler
442  if [ $# -gt 0 ]; then
443    while getopts r:c:h option; do
444       case $option in
445          c) mach=$OPTARG;;
446          r) rev=$OPTARG;;
447          h | *) echo ''
448                 echo 'sette_rpt.sh : ' 
449                 echo '     display result for the latest change'
450                 echo ' -c COMPILER_name :'
451                 echo '     display result for the specified compiler'
452                 echo ' -r REVISION_number :'
453                 echo '     display sette results for the specified revision (set old for the latest revision available for each config)'
454                 echo ''
455                 exit 42;;
456       esac
457    done
458    shift $((OPTIND - 1))
459fi
[11161]460
[12569]461# if $1 (remaining arguments)
462if [[ ! -z $1 ]] ; then rev=$1 ; fi
463
464# by default use the current lastchanged revision
465lastchange=${rev:-$lastchange}
466
[11161]467echo ""
468echo "SETTE validation report generated for : "
469echo ""
470echo "       $branchname @ r$lastchange (last changed revision)"
471echo ""
472echo "       on $COMPILER arch file"
473echo ""
474
[9019]475#
[6124]476# The script also needs the date or revision tag. Currently this is taken from the latest sub-directory found in each directory
477
[12569]478for pass in  $RPT_PASSES 
[6124]479do
480#
[9525]481 if [ $pass == 0 ]; then
482   echo "" 
483   echo "!!---------------1st pass------------------!!"
484 fi
485 if [ $pass == 1 ]; then
486    echo ""
487    echo "!!---------------2nd pass------------------!!"
488 fi
[6124]489#
[8468]490
[6124]491# Restartability test
[9525]492 echo ""
[9518]493 echo "   !----restart----!   "
[13382]494 for restart_test in WGYRE_PISCES_ST WORCA2_ICE_PISCES_ST WORCA2_OFF_PISCES_ST WAMM12_ST WORCA2_SAS_ICE_ST WAGRIF_DEMO_ST WWED025_ST WISOMIP+_ST WOVERFLOW_ST WLOCK_EXCHANGE_ST WVORTEX_ST WICE_AGRIF_ST
[6124]495 do
496   resttest $NEMO_VALID $restart_test $pass
497 done
498#
499# Reproducibility tests
[9525]500 echo ""
[9518]501 echo "   !----repro----!   "
[13382]502 for repro_test in WGYRE_PISCES_ST WORCA2_ICE_PISCES_ST WORCA2_OFF_PISCES_ST WAMM12_ST WORCA2_SAS_ICE_ST WORCA2_ICE_OBS_ST WAGRIF_DEMO_ST WWED025_ST WISOMIP+_ST WVORTEX_ST WICE_AGRIF_ST
[6124]503 do
504   reprotest $NEMO_VALID $repro_test $pass
505 done
[9019]506
[9518]507# AGRIF special check to ensure results are unchanged with and without key_agrif
[9525]508 echo ""
[9518]509 echo "   !----agrif check----!   "
[9776]510 dir1=WAGRIF_DEMO_NOAGRIF_ST
511 dir2=WAGRIF_DEMO_ST
[9019]512 identictest $NEMO_VALID $dir1 $dir2 $pass 
[11161]513#
514# before/after tests
515 if [ $lastchange == 'old' ] ; then
516    echo ""
517    echo "   !---- 'old' specified as revision => no comparison with reference results ----!   "
518    echo ""
519 else
520   echo ""
521   echo "   !----result comparison check----!   "
522   if [ $NEMO_VALID_REF != "/path/to/reference/sette/results" ]; then
523     echo ''
524     echo 'check result differences between :'
525     echo "VALID directory : $NEMO_VALID at rev $lastchange"
526     echo 'and'
527     echo "REFERENCE directory : $NEMO_VALID_REF at rev $NEMO_REV_REF"
528     echo ''
[13382]529     for repro_test in WGYRE_PISCES_ST WORCA2_ICE_PISCES_ST WORCA2_OFF_PISCES_ST WAMM12_ST WORCA2_SAS_ICE_ST WAGRIF_DEMO_ST WWED025_ST WISOMIP+_ST WVORTEX_ST WICE_AGRIF_ST WOVERFLOW_ST WLOCK_EXCHANGE_ST
[11161]530     do
531       runcmpres $NEMO_VALID $repro_test $NEMO_VALID_REF $NEMO_REV_REF $pass
532     done
533   else
534     echo ''
535     echo ' No path for comparison specified. Result are not compare with any other revision. '
536     echo ' To do it please fill NEMO_VALID_REF and NEMO_REV_REF in param.cfg. '
537     echo ''
538   fi
539 fi
[9019]540done
[6124]541#
542exit
Note: See TracBrowser for help on using the repository browser.