source: branches/2017/dev_CNRS_2017/NEMOGCM/SETTE/sette_rpt.sh @ 8896

Last change on this file since 8896 was 8896, checked in by flavoni, 3 years ago

merge of sette tests and report with the new ones of the trunk

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