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.
new_sette_rpt.sh in trunk/NEMOGCM/SETTE – NEMO

source: trunk/NEMOGCM/SETTE/new_sette_rpt.sh @ 8849

Last change on this file since 8849 was 8849, checked in by clevy, 6 years ago

correct SAS check and AGRIF test, ticket #1983

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