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 branches/2017/dev_CNRS_2017/NEMOGCM/SETTE – NEMO

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

Last change on this file since 8882 was 8882, checked in by flavoni, 6 years ago

dev_CNRS_2017 branch: merged dev_r7881_ENHANCE09_RK3 with trunk r8864

  • Property svn:executable set to *
File size: 9.9 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  vdir=$1
19  nam=$2
20  pass=$3
21#
22  if [ -d $vdir/$nam ]; then
23    dorv=`ls -1rt $vdir/$nam/$mach/ | tail -1l `
24    dorv=`echo $dorv | sed -e 's:.*/::'`
25    rep1=`ls -1rt $vdir/$nam/$mach/$dorv/ | tail -2l | head -1 `
26    rep2=`ls -1rt $vdir/$nam/$mach/$dorv/ | tail -1l`
27    cd ${SAS_RESTART_DIR}/LONG
28    #SF add here compilation of rebuild_tools to rebuild restart files, and add comparison of restart files
29    cd ${TOOLS_DIR}
30    ./maketools -n REBUILD_NEMO -m ${mach} > /dev/null 2>&1
31    cd ${TOOLS_DIR}/REBUILD_NEMO
32    #SF echo "REBUILD LONG restart SAS files, without standard output"
33    ./rebuild_nemo -t 4 ../../CONFIG/SAS_LONG/LONG/SAS_00000240_restart_ice  $NPROC > /dev/null 2>&1
34    #SF echo "REBUILD SHORT restart SAS files, without standard output"
35    ./rebuild_nemo -t 4 ../../CONFIG/SAS_LONG/SHORT/SAS_00000240_restart_ice $NPROC >&-
36    cd ${SAS_RESTART_DIR}/LONG
37    #SF echo "COPY rebuild restart files"
38    cp SAS_00000240_restart_ice.nc $vdir/$nam/$mach/$dorv/LONG/.
39    cp ../SHORT/SAS_00000240_restart_ice.nc $vdir/$nam/$mach/$dorv/SHORT/.
40
41    f1o=$vdir/$nam/$mach/$dorv/LONG/SAS_00000240_restart_ice.nc
42    f2o=$vdir/$nam/$mach/$dorv/SHORT/SAS_00000240_restart_ice.nc
43    if  [ ! -f $f1o ] &&  [ ! -f $f2o ] ; then
44      printf "%-20s %s\n" $nam " REBUILD SAS restart ice DOES NOT exists; incomplete test";
45      return;
46    fi
47    #
48    done_oce=0
49    #
50    if  [  -f $f1o ] && [  -f $f2o ]; then
51      cmp -s $f1o $f2o 
52      #SF  cmp SAS_00000240_restart_ice.nc  ../SHORT/SAS_00000240_restart_ice.nc  > diff_restart.txt
53      if [ $? == 0 ]; then
54        if [ $pass == 0 ]; then
55          printf "%-20s %s %s\n" $nam  " SAS restart files are IDENTICAL :  passed : " $dorv
56        fi
57      else
58        printf "%-20s %s %s\n" $nam  " SAS restart files are DIFFERENT : FAILED : " $dorv 
59        #
60   # Offer view of differences on the second pass
61   #
62        if [ $pass == 1 ]; then
63          echo "BE CAREFUL:  NEED cdo to see differences!!!!! "
64          echo "DO which cdo and replace cdo PATH to the cdo command in SETTE_rpt.sh "
65          echo "IF cdo is not available you need to do difference of netcdf file by hand"
66          echo "<return> to view restart_ice.nc differences"
67          read y
68          cdo -diffv $f1o $f2o
69          done_oce=1
70          #echo "<return> to continue"
71          #read y
72        fi
73      fi
74    fi
75#
76fi
77}
78
79function resttest() { 
80#
81# Restartability checks. Expects LONG and SHORT run directories
82# Compares end of LONG stat files with equivalent entries from the SHORT stat files.
83#
84  vdir=$1
85  nam=$2
86  pass=$3
87#
88  if [ -d $vdir/$nam ]; then
89    dorv=`ls -1rt $vdir/$nam/$mach/ | tail -1l `
90    dorv=`echo $dorv | sed -e 's:.*/::'`
91    f1o=$vdir/$nam/$mach/$dorv/LONG/ocean.output
92    f1s=$vdir/$nam/$mach/$dorv/LONG/run.stat
93    f1t=$vdir/$nam/$mach/$dorv/LONG/tracer.stat
94    f2o=$vdir/$nam/$mach/$dorv/SHORT/ocean.output
95    f2s=$vdir/$nam/$mach/$dorv/SHORT/run.stat
96    f2t=$vdir/$nam/$mach/$dorv/SHORT/tracer.stat
97
98    if  [ ! -f $f1s ] &&  [ ! -f $f1t ] ; then
99      printf "%-20s %s\n" $nam " incomplete test";
100      return;
101    fi
102    if  [ ! -f $f2s ] &&  [ ! -f $f2t ] ; then
103      printf "%-20s %s\n" $nam " incomplete test";
104      return;
105    fi
106#
107    done_oce=0
108
109    if  [  -f $f1s ] && [  -f $f2s ]; then
110      nl=(`wc -l $f2s`)
111      tail -${nl[0]} $f1s > f1.tmp$$
112      cmp -s f1.tmp$$ $f2s
113      if [ $? == 0 ]; then
114        if [ $pass == 0 ]; then
115          printf "%-20s %s %s\n" $nam  " run.stat    restartability  passed : " $dorv
116        fi
117      else
118        printf "%-20s %s %s\n" $nam  " run.stat    restartability  FAILED : " $dorv 
119#
120# Offer view of differences on the second pass
121#
122        if [ $pass == 1 ]; then
123          echo "<return> to view run.stat differences"
124          read y
125          sdiff f1.tmp$$ $f2s
126          echo "<return> to view ocean.output differences"
127          read y
128          sdiff $f1o $f2o | grep "|"
129          done_oce=1
130          echo "<return> to continue"
131          read y
132        fi
133      fi
134    fi
135#
136# Check tracer.stat files (if they exist)
137#
138    if  [  -f $f1t ] && [  -f $f2t ]; then
139      nl=(`wc -l $f2t`)
140      tail -${nl[0]} $f1t > f1.tmp$$
141      cmp -s f1.tmp$$ $f2t
142      if [ $? == 0 ]; then
143        if [ $pass == 0 ]; then
144          printf "%-20s %s %s\n" $nam  " tracer.stat restartability  passed : " $dorv
145        fi
146      else
147        printf "%-20s %s %s\n" $nam  " tracer.stat restartability  FAILED : " $dorv 
148#
149# Offer view of differences on the second pass
150#
151        if [ $pass == 1 ]; then
152          echo "<return> to view tracer.stat differences"
153          read y
154          sdiff f1.tmp$$ $f2t
155#
156# Only offer ocean.output view if it has not been viewed previously
157#
158          if [ $done_oce == 0 ]; then
159            echo "<return> to view ocean.output differences"
160            read y
161            sdiff $f1o $f2o | grep "|"
162          fi
163          echo "<return> to continue"
164          read y
165        fi
166      fi
167    fi
168    rm f1.tmp$$
169  fi
170}
171
172function reprotest(){
173#
174# Reproducibility checks. Expects REPRO_N_M and REPRO_I_J run directories
175# Compares end of stat files from each
176#
177  vdir=$1
178  nam=$2
179  pass=$3
180#
181  if [ -d $vdir/$nam ]; then
182    dorv=`ls -1rt $vdir/$nam/$mach/ | tail -1l `
183    dorv=`echo $dorv | sed -e 's:.*/::'`
184    rep1=`ls -1rt $vdir/$nam/$mach/$dorv/ | tail -2l | head -1 `
185    rep2=`ls -1rt $vdir/$nam/$mach/$dorv/ | tail -1l`
186    f1o=$vdir/$nam/$mach/$dorv/$rep1/ocean.output
187    f1s=$vdir/$nam/$mach/$dorv/$rep1/run.stat
188    f1t=$vdir/$nam/$mach/$dorv/$rep1/tracer.stat
189    f2o=$vdir/$nam/$mach/$dorv/$rep2/ocean.output
190    f2s=$vdir/$nam/$mach/$dorv/$rep2/run.stat
191    f2t=$vdir/$nam/$mach/$dorv/$rep2/tracer.stat
192
193    if  [ ! -f $f1s ] && [ ! -f $f1t ] ; then
194      printf "%-20s %s\n" $nam " incomplete test";
195      return;
196    fi
197    if  [ ! -f $f2s ] && [ ! -f $f2t ] ; then
198      printf "%-20s %s\n" $nam " incomplete test";
199      return;
200    fi
201#
202    done_oce=0
203
204    if  [ -f $f1s ] && [ -f $f2s ] ; then
205      cmp -s $f1s $f2s
206      if [ $? == 0 ]; then
207        if [ $pass == 0 ]; then
208          printf "%-20s %s %s\n" $nam  " run.stat    reproducibility passed : " $dorv
209        fi
210      else
211        printf "%-20s %s %s\n" $nam  " run.stat    reproducibility FAILED : " $dorv 
212#
213# Offer view of differences on the second pass
214#
215        if [ $pass == 1 ]; then
216          echo "<return> to view run.stat differences"
217          read y
218          sdiff f1.tmp$$ $f2s
219          echo "<return> to view ocean.output differences"
220          read y
221          sdiff $f1o $f2o | grep "|"
222          done_oce=1
223          echo "<return> to continue"
224          read y
225        fi
226      fi
227    fi
228#
229# Check tracer.stat files (if they exist)
230#
231    if  [ -f $f1t ] && [ -f $f2t ] ; then
232      cmp -s $f1t $f2t
233      if [ $? == 0 ]; then
234        if [ $pass == 0 ]; then           printf "%-20s %s %s\n" $nam  " tracer.stat reproducibility passed : " $dorv
235        fi
236      else
237        printf "%-20s %s %s\n" $nam  " tracer.stat reproducibility  FAILED : " $dorv
238#
239# Offer view of differences on the second pass
240#
241        if [ $pass == 1 ]; then
242          echo "<return> to view tracer.stat differences"
243          read y
244          sdiff $f1t $f2t
245#
246# Only offer ocean.output view if it has not been viewed previously
247#
248          if [ $done_oce == 0 ]; then
249            echo "<return> to view ocean.output differences"
250            read y
251            sdiff $f1o $f2o | grep "|"
252          fi
253          echo "<return> to continue"
254          read y
255        fi
256      fi
257    fi
258  fi
259}
260########################### END of function definitions #################################
261##                                                                                     ##
262##    Main script                                                                      ##
263##                                                                                     ##
264#########################################################################################
265#
266  mach=`grep "COMPILER=" ./sette.sh | sed -e 's/COMPILER=//'`
267  NEMO_VALID=`grep "NEMO_VALIDATION_DIR=" ./param.cfg | sed -e 's/NEMO_VALIDATION_DIR=//'`
268# Directory to run the tests
269 SETTE_DIR=$(cd $(dirname "$0"); pwd)
270 MAIN_DIR=$(dirname $SETTE_DIR)
271 CONFIG_DIR0=${MAIN_DIR}/CONFIG
272 TOOLS_DIR=${MAIN_DIR}/TOOLS
273 COMPIL_DIR=${TOOLS_DIR}/COMPILE
274 NPROC=32
275
276  SAS_RESTART_DIR=${CONFIG_DIR0}/SAS_LONG
277#
278  if [ ! -d $NEMO_VALID ]; then
279    echo "$NEMO_VALID validation directory not found"
280    exit
281  fi
282#
283
284# The script also needs the date or revision tag. Currently this is taken from the latest sub-directory found in each directory
285
286for pass in  0 1
287do
288#
289 if [ $pass == 1 ]; then echo "---------------2nd pass------------------";fi
290#
291
292# Rebuild and restartability test for SAS
293#
294 for restart_file in WSAS_LONG
295 do
296 #  restfile $SAS_RESTART_DIR LONG $pass
297   restfile $NEMO_VALID $restart_file $pass
298 done
299#
300# Restartability test
301#
302 for restart_test in WGYREPIS_LONG WORCA2LIM3PIS_LONG WORCA2OFFPIS_LONG WAMM12_LONG WISOMIP_LONG WORCA2AGUL_LONG
303 do
304   resttest $NEMO_VALID $restart_test $pass
305 done
306#
307# Reproducibility tests
308#
309 for repro_test in WGYREPIS_32 WORCA2LIM3PIS_32 WORCA2OFFPIS_32 WAMM12_32 WISOMIP_32 WORCA2_LIM3_OBS WORCA2AGUL_1_2 WORCA2AGUL_16 WORCA2AGUL_2_2_NAG
310 do
311   reprotest $NEMO_VALID $repro_test $pass
312 done
313#
314done
315exit
Note: See TracBrowser for help on using the repository browser.