source: branches/2017/dev_merge_2017/NEMOGCM/SETTE/sette_rpt.sh @ 9221

Last change on this file since 9221 was 9221, checked in by mathiot, 3 years ago

add extra print in sette_rpt to detect missing config validation directory

  • Property svn:executable set to *
File size: 12.4 KB
Line 
1#!/bin/bash -f
2# set -vx
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
7# validation directory needs to be set here (currently assumed to reside in the ../CONFIG directory)
8#
9#########################################################################################
10######################### Start of function definitions #################################
11##
12
13function restfile() {
14# Rebuild ice restart for SAS CONFIG, and restartability checks. Expects LONG and SHORT run directories.
15# For Stand Alone Surface configuration ocean is not running, just run ice model; so no outputs ocean files.
16# Compares LONG rebuild restart ice file with equivalent entry from the SHORT rebuild restart ice file.
17#
18# check nco module loaded, and load it if not
19if [ ! $( echo $LOADEDMODULES | grep cdo ) ]; then module load cdo >& /dev/null ; fi
20#
21  vdir=$1
22  nam=$2
23  pass=$3
24
25#
26  if [ -d $vdir/$nam ]; then
27    dorv=`ls -1rt $vdir/$nam/$mach/ | tail -1l `
28    dorv=`echo $dorv | sed -e 's:.*/::'`
29    rep1=`ls -1rt $vdir/$nam/$mach/$dorv/ | tail -2l | head -1 `
30    rep2=`ls -1rt $vdir/$nam/$mach/$dorv/ | tail -1l`
31    cd ${SAS_RESTART_DIR}/LONG
32    #SF add here compilation of rebuild_tools to rebuild restart files, and add comparison of restart files
33    cd ${TOOLS_DIR}
34    ./maketools -n REBUILD_NEMO -m ${mach} > /dev/null 2>&1
35    cd ${TOOLS_DIR}/REBUILD_NEMO
36    #SF echo "REBUILD LONG restart SAS files, without standard output"
37    ./rebuild_nemo -t 4 ../../CONFIG/SAS_ST/LONG/SAS_00000240_restart_ice  $NPROC > /dev/null 2>&1
38    #SF echo "REBUILD SHORT restart SAS files, without standard output"
39    ./rebuild_nemo -t 4 ../../CONFIG/SAS_ST/SHORT/SAS_00000240_restart_ice $NPROC >&-
40    cd ${SAS_RESTART_DIR}/LONG
41    #SF echo "COPY rebuild restart files"
42    cp SAS_00000240_restart_ice.nc $vdir/$nam/$mach/$dorv/LONG/.
43    cp ../SHORT/SAS_00000240_restart_ice.nc $vdir/$nam/$mach/$dorv/SHORT/.
44
45    f1o=$vdir/$nam/$mach/$dorv/LONG/SAS_00000240_restart_ice.nc
46    f2o=$vdir/$nam/$mach/$dorv/SHORT/SAS_00000240_restart_ice.nc
47    if  [ ! -f $f1o ] &&  [ ! -f $f2o ] ; then
48      printf "%-20s %s\n" $nam " REBUILD SAS restart ice DOES NOT exists; incomplete test";
49      return;
50    fi
51    #
52    done_oce=0
53    #
54  if  [  -f $f1o ] && [  -f $f2o ]; then
55## Compare the two netcdf files
56    cdo diffn $f1o $f2o > cdo_diff.out 2> /dev/null
57## Identical if cdo_diff.out exists but has zero size
58    if [ ! -s cdo_diff.out ]; then
59       difi=0
60    else
61## Identical if first character of $dif ==0
62       dif=$( grep -om1 '[0-9]* of [0-9]* records differ' cdo_diff.out )
63# difi contains the first character of summary of cdo dif. if = 0, then 0 record differ between the 2 files   
64       if [ -n "$dif" ]; then
65           difi=`echo $dif | cut -c -1`
66       fi
67    fi
68    \rm cdo_diff.out
69
70    if [ $difi == 0 ]; then   
71       if [ $pass == 0 ]; then
72         printf "%-20s %s %s\n" $nam  " ice restarts are IDENTICAL  passed : " $dorv
73       fi
74    else
75       printf "%-20s %s %s\n" $nam  " ice restarts are DIFFERENT  FAILED : " $dorv 
76        #
77   # Offer view of differences on the second pass
78   #
79        if [ $pass == 1 ]; then
80          echo "<return> to view restart_ice.nc differences"
81          read y
82          cdo -diffv $f1o $f2o
83          done_oce=1
84          #echo "<return> to continue"
85          #read y
86        fi
87    fi
88  else
89      printf "%-20s %s\n" $nam " incomplete test";
90      return;
91  fi
92#
93fi
94}
95
96function resttest() { 
97#
98# Restartability checks. Expects LONG and SHORT run directories
99# Compares end of LONG stat files with equivalent entries from the SHORT stat files.
100#
101  vdir=$1
102  nam=$2
103  pass=$3
104#
105  if [ -d $vdir/$nam ]; then
106    dorv=`ls -1rt $vdir/$nam/$mach/ | tail -1l `
107    dorv=`echo $dorv | sed -e 's:.*/::'`
108    f1o=$vdir/$nam/$mach/$dorv/LONG/ocean.output
109    f1s=$vdir/$nam/$mach/$dorv/LONG/run.stat
110    f1t=$vdir/$nam/$mach/$dorv/LONG/tracer.stat
111    f2o=$vdir/$nam/$mach/$dorv/SHORT/ocean.output
112    f2s=$vdir/$nam/$mach/$dorv/SHORT/run.stat
113    f2t=$vdir/$nam/$mach/$dorv/SHORT/tracer.stat
114
115    if  [ ! -f $f1s ] &&  [ ! -f $f1t ] ; then
116      printf "%-20s %s\n" $nam " incomplete test";
117      return;
118    fi
119    if  [ ! -f $f2s ] &&  [ ! -f $f2t ] ; then
120      printf "%-20s %s\n" $nam " incomplete test";
121      return;
122    fi
123#
124    done_oce=0
125
126    if  [  -f $f1s ] && [  -f $f2s ]; then
127      nl=(`wc -l $f2s`)
128      tail -${nl[0]} $f1s > f1.tmp$$
129      cmp -s f1.tmp$$ $f2s
130      if [ $? == 0 ]; then
131        if [ $pass == 0 ]; then
132          printf "%-20s %s %s\n" $nam  " run.stat    restartability  passed : " $dorv
133        fi
134      else
135        printf "%-20s %s %s\n" $nam  " run.stat    restartability  FAILED : " $dorv 
136#
137# Offer view of differences on the second pass
138#
139        if [ $pass == 1 ]; then
140          echo "<return> to view run.stat differences"
141          read y
142          sdiff f1.tmp$$ $f2s
143          echo "<return> to view ocean.output differences"
144          read y
145          sdiff $f1o $f2o | grep "|"
146          done_oce=1
147          echo "<return> to continue"
148          read y
149        fi
150      fi
151    fi
152#
153# Check tracer.stat files (if they exist)
154#
155    if  [  -f $f1t ] && [  -f $f2t ]; then
156      nl=(`wc -l $f2t`)
157      tail -${nl[0]} $f1t > f1.tmp$$
158      cmp -s f1.tmp$$ $f2t
159      if [ $? == 0 ]; then
160        if [ $pass == 0 ]; then
161          printf "%-20s %s %s\n" $nam  " tracer.stat restartability  passed : " $dorv
162        fi
163      else
164        printf "%-20s %s %s\n" $nam  " tracer.stat restartability  FAILED : " $dorv 
165#
166# Offer view of differences on the second pass
167#
168        if [ $pass == 1 ]; then
169          echo "<return> to view tracer.stat differences"
170          read y
171          sdiff f1.tmp$$ $f2t
172#
173# Only offer ocean.output view if it has not been viewed previously
174#
175          if [ $done_oce == 0 ]; then
176            echo "<return> to view ocean.output differences"
177            read y
178            sdiff $f1o $f2o | grep "|"
179          fi
180          echo "<return> to continue"
181          read y
182        fi
183      fi
184    fi
185    rm f1.tmp$$
186  else
187    printf "%-20s %s %s\n" $nam  " directory is MISSING : " $dorv
188  fi
189}
190
191function reprotest(){
192#
193# Reproducibility checks. Expects REPRO_N_M and REPRO_I_J run directories
194# Compares end of stat files from each
195#
196  vdir=$1
197  nam=$2
198  pass=$3
199#
200  if [ -d $vdir/$nam ]; then
201    dorv=`ls -1rt $vdir/$nam/$mach/ | tail -1l `
202    dorv=`echo $dorv | sed -e 's:.*/::'`
203    rep1=`ls -1rt $vdir/$nam/$mach/$dorv/ | grep REPRO | tail -2l | head -1 `
204    rep2=`ls -1rt $vdir/$nam/$mach/$dorv/ | grep REPRO | tail -1l`
205    f1o=$vdir/$nam/$mach/$dorv/$rep1/ocean.output
206    f1s=$vdir/$nam/$mach/$dorv/$rep1/run.stat
207    f1t=$vdir/$nam/$mach/$dorv/$rep1/tracer.stat
208    f2o=$vdir/$nam/$mach/$dorv/$rep2/ocean.output
209    f2s=$vdir/$nam/$mach/$dorv/$rep2/run.stat
210    f2t=$vdir/$nam/$mach/$dorv/$rep2/tracer.stat
211
212    if  [ ! -f $f1s ] && [ ! -f $f1t ] ; then
213      printf "%-20s %s\n" $nam " incomplete test";
214      return;
215    fi
216    if  [ ! -f $f2s ] && [ ! -f $f2t ] ; then
217      printf "%-20s %s\n" $nam " incomplete test";
218      return;
219    fi
220#
221    done_oce=0
222
223    if  [ -f $f1s ] && [ -f $f2s ] ; then
224      cmp -s $f1s $f2s
225      if [ $? == 0 ]; then
226        if [ $pass == 0 ]; then
227          printf "%-20s %s %s\n" $nam  " run.stat    reproducibility passed : " $dorv
228        fi
229      else
230        printf "%-20s %s %s\n" $nam  " run.stat    reproducibility FAILED : " $dorv 
231#
232# Offer view of differences on the second pass
233#
234        if [ $pass == 1 ]; then
235          echo "<return> to view run.stat differences"
236          read y
237          sdiff f1.tmp$$ $f2s
238          echo "<return> to view ocean.output differences"
239          read y
240          sdiff $f1o $f2o | grep "|"
241          done_oce=1
242          echo "<return> to continue"
243          read y
244        fi
245      fi
246    fi
247#
248# Check tracer.stat files (if they exist)
249#
250    if  [ -f $f1t ] && [ -f $f2t ] ; then
251      cmp -s $f1t $f2t
252      if [ $? == 0 ]; then
253        if [ $pass == 0 ]; then           printf "%-20s %s %s\n" $nam  " tracer.stat reproducibility passed : " $dorv
254        fi
255      else
256        printf "%-20s %s %s\n" $nam  " tracer.stat reproducibility  FAILED : " $dorv
257#
258# Offer view of differences on the second pass
259#
260        if [ $pass == 1 ]; then
261          echo "<return> to view tracer.stat differences"
262          read y
263          sdiff $f1t $f2t
264#
265# Only offer ocean.output view if it has not been viewed previously
266#
267          if [ $done_oce == 0 ]; then
268            echo "<return> to view ocean.output differences"
269            read y
270            sdiff $f1o $f2o | grep "|"
271          fi
272          echo "<return> to continue"
273          read y
274        fi
275      fi
276    fi
277  else
278    printf "%-20s %s %s\n" $nam  " directory is MISSING : " $dorv
279  fi
280}
281
282function identictest(){
283#
284#  checks AGRIF does not corrupe results with no AGRIF zoom. Expects ORCA2AGUL/AGRIFNOZ and ORCA2AGUL_NAGR/AGRIFNO  run directories
285# Compares solver.stat files for each
286#
287  vdir=$1
288  dir1=$2
289  dir2=$3
290  pass=$4
291#
292  if [ -d $vdir/$dir1 ] && [ -d $vdir/$dir2 ]; then
293    dorv1=`ls -1rt $vdir/$dir1/$mach/ | tail -1l `
294    dorv1=`echo $dorv1 | sed -e 's:.*/::'`
295    dorv2=`ls -1rt $vdir/$dir2/$mach/ | tail -1l `
296    dorv2=`echo $dorv2 | sed -e 's:.*/::'`
297
298    rep1=`ls -1rt $vdir/$dir1/$mach/$dorv1/ |  tail -2l | head -1 `
299    rep2=`ls -1rt $vdir/$dir2/$mach/$dorv2/ |  tail -1l`
300    f1s=$vdir/$dir1/$mach/$dorv1/$rep1/run.stat
301    f2s=$vdir/$dir2/$mach/$dorv2/$rep2/run.stat
302
303    if  [ ! -f $f1s ] && [ ! -f $f2s ] ; then
304      printf "%-20s %s\n" $dir1 $dir2 " incomplete test";
305      return;
306    fi
307#
308    done_oce=0
309
310    if  [ -f $f1s ] && [ -f $f2s ] ; then
311      cmp -s $f1s $f2s
312      if [ $? == 0 ]; then
313        if [ $pass == 0 ]; then
314          printf "%-20s %s %s %s %s\n" $rep1 $rep2  " AGRIF: run.stat unchanged - test  passed : " $dorv1 $dorv2
315        fi
316      else
317        printf "%-20s %s %s %s %s\n" $rep1 $rep2  " for AGRIF, run.stat test FAILED : " $dorv1 $dorv2
318#
319# Offer view of differences on the second pass
320#
321        if [ $pass == 1 ]; then
322          echo "<return> to view run.stat differences"
323          read y
324          sdiff $f1s $f2s
325          done_oce=1
326          echo "<return> to continue"
327          read y
328        fi
329      fi
330    fi
331  else
332    printf "%-20s %s\n" $dir1 $dir2 " incomplete test";
333  fi
334}
335########################### END of function definitions #################################
336##                                                                                     ##
337##    Main script                                                                      ##
338##                                                                                     ##
339#########################################################################################
340#
341  mach=`grep "COMPILER=" ./sette.sh | sed -e 's/COMPILER=//'`
342  NEMO_VALID=`grep "NEMO_VALIDATION_DIR=" ./param.cfg | sed -e 's/NEMO_VALIDATION_DIR=//'`
343  NEMO_VALID=`eval "echo $NEMO_VALID"`
344#
345  if [ ! -d $NEMO_VALID ]; then
346    echo "$NEMO_VALID validation directory not found"
347    exit
348  fi
349#
350# Directory to run the tests
351  SETTE_DIR=$(cd $(dirname "$0"); pwd)
352  MAIN_DIR=$(dirname $SETTE_DIR)
353  CONFIG_DIR0=${MAIN_DIR}/CONFIG
354  TOOLS_DIR=${MAIN_DIR}/TOOLS
355  COMPIL_DIR=${TOOLS_DIR}/COMPILE
356  NPROC=32
357  SAS_RESTART_DIR=${CONFIG_DIR0}/SAS_ST
358#
359# Show current revision tag and branch name
360#
361cmd="svn"
362[ ! -d "$SETTE_DIR/.svn" ] && cmd="git $cmd"
363revision=`$cmd info | grep Revision | cut -d ":" -f 2 | tr -d ' '`
364branchname=`$cmd info | grep URL | rev | cut -d "/" -f 3 | rev`
365echo "SETTE validation report : $branchname @ r$revision"
366#
367# The script also needs the date or revision tag. Currently this is taken from the latest sub-directory found in each directory
368
369for pass in  0 1
370do
371#
372 if [ $pass == 1 ]; then echo "---------------2nd pass------------------";fi
373#
374
375# Rebuild and restartability test for SAS
376#
377 for restart_file in WSAS_ST
378 do
379   restfile $NEMO_VALID $restart_file $pass
380 done
381#
382# Restartability test
383#
384 for restart_test in WGYREPIS_ST WORCA2LIM3PIS_ST WORCA2OFFPIS_ST WAMM12_ST WISOMIP_ST WORCA2AGR_ST
385 do
386   resttest $NEMO_VALID $restart_test $pass
387 done
388#
389# Reproducibility tests
390#
391 for repro_test in WGYREPIS_ST WORCA2LIM3PIS_ST WORCA2OFFPIS_ST WAMM12_ST WISOMIP_ST WORCA2_LIM3_OBS_ST WORCA2AGR_ST
392 do
393   reprotest $NEMO_VALID $repro_test $pass
394 done
395
396
397
398# AGRIF special check
399 dir1=WORCA2AGUL_NOZOOM_ST
400 dir2=WORCA2AGUL_NOAGR_ST
401 identictest $NEMO_VALID $dir1 $dir2 $pass 
402
403
404done
405#
406## Additional checks for ORCA2AGUL/FIRST standalone AGRIF test
407## still to be added
408
409
410
411exit
Note: See TracBrowser for help on using the repository browser.