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 trunk/NEMOGCM/SETTE – NEMO

source: trunk/NEMOGCM/SETTE/sette_rpt.sh @ 8727

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

update report

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