[8827] | 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 | |
---|
| 14 | function 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 | # |
---|
[8849] | 19 | # check nco module loaded, and load it if not |
---|
| 20 | if [ ! $( echo $LOADEDMODULES | grep cdo ) ]; then module load cdo >& /dev/null ; fi |
---|
| 21 | # |
---|
[8827] | 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 |
---|
[8849] | 32 | #SF add here compilation of rebuild_tools to rebuild restart files, and add comparison of restart files |
---|
[8827] | 33 | cd ${TOOLS_DIR} |
---|
| 34 | ./maketools -n REBUILD_NEMO -m ${mach} > /dev/null 2>&1 |
---|
| 35 | cd ${TOOLS_DIR}/REBUILD_NEMO |
---|
[8849] | 36 | #SF echo "REBUILD LONG restart SAS files, without standard output" |
---|
[8839] | 37 | ./rebuild_nemo -t 4 ../../CONFIG/SAS_ST/LONG/SAS_00000240_restart_ice $NPROC > /dev/null 2>&1 |
---|
[8849] | 38 | #SF echo "REBUILD SHORT restart SAS files, without standard output" |
---|
[8839] | 39 | ./rebuild_nemo -t 4 ../../CONFIG/SAS_ST/SHORT/SAS_00000240_restart_ice $NPROC >&- |
---|
[8827] | 40 | cd ${SAS_RESTART_DIR}/LONG |
---|
[8849] | 41 | #SF echo "COPY rebuild restart files" |
---|
[8827] | 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 | 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; |
---|
[8849] | 49 | fi |
---|
[8827] | 50 | # |
---|
[8849] | 51 | done_oce=0 |
---|
[8827] | 52 | # |
---|
[8849] | 53 | if [ -f $f1o ] && [ -f $f2o ]; then |
---|
| 54 | ## Compare the two netcdf files |
---|
[8852] | 55 | cdo diffn $f1o $f2o > cdo_diff.out 2> /dev/null |
---|
[8864] | 56 | ## Identical if cdo_diff.out exists but has zero size |
---|
| 57 | if [ ! -s cdo_diff.out ]; then |
---|
| 58 | difi=0 |
---|
| 59 | else |
---|
[8849] | 60 | ## Identical if first character of $dif ==0 |
---|
[8864] | 61 | dif=$( grep -om1 '[0-9]* of [0-9]* records differ' cdo_diff.out ) |
---|
[8852] | 62 | # difi contains the first character of summary of cdo dif. if = 0, then 0 record differ between the 2 files |
---|
[8864] | 63 | if [ -n "$dif" ]; then |
---|
| 64 | difi=`echo $dif | cut -c -1` |
---|
| 65 | fi |
---|
[8852] | 66 | fi |
---|
| 67 | \rm cdo_diff.out |
---|
[8849] | 68 | |
---|
[8852] | 69 | if [ $difi == 0 ]; then |
---|
| 70 | if [ $pass == 0 ]; then |
---|
[8864] | 71 | printf "%-20s %s %s\n" $nam " ice restarts are IDENTICAL passed : " $dorv |
---|
[8852] | 72 | fi |
---|
| 73 | else |
---|
[8864] | 74 | printf "%-20s %s %s\n" $nam " ice restarts are DIFFERENT FAILED : " $dorv |
---|
[8827] | 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 |
---|
[8852] | 87 | else |
---|
| 88 | printf "%-20s %s\n" $nam " incomplete test"; |
---|
| 89 | return; |
---|
| 90 | fi |
---|
[8827] | 91 | # |
---|
| 92 | fi |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | function 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/solver.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/solver.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 " solver.stat restartability passed : " $dorv |
---|
| 132 | fi |
---|
| 133 | else |
---|
| 134 | printf "%-20s %s %s\n" $nam " solver.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 solver.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 | function reprotest(){ |
---|
| 188 | # |
---|
| 189 | # Reproducibility checks. Expects REPRO_N_M and REPRO_I_J run directories |
---|
| 190 | # Compares end of stat files from each |
---|
| 191 | # |
---|
| 192 | vdir=$1 |
---|
| 193 | nam=$2 |
---|
| 194 | pass=$3 |
---|
| 195 | # |
---|
| 196 | if [ -d $vdir/$nam ]; then |
---|
| 197 | dorv=`ls -1rt $vdir/$nam/$mach/ | tail -1l ` |
---|
| 198 | dorv=`echo $dorv | sed -e 's:.*/::'` |
---|
| 199 | rep1=`ls -1rt $vdir/$nam/$mach/$dorv/ | grep REPRO | tail -2l | head -1 ` |
---|
| 200 | rep2=`ls -1rt $vdir/$nam/$mach/$dorv/ | grep REPRO | tail -1l` |
---|
| 201 | f1o=$vdir/$nam/$mach/$dorv/$rep1/ocean.output |
---|
| 202 | f1s=$vdir/$nam/$mach/$dorv/$rep1/solver.stat |
---|
| 203 | f1t=$vdir/$nam/$mach/$dorv/$rep1/tracer.stat |
---|
| 204 | f2o=$vdir/$nam/$mach/$dorv/$rep2/ocean.output |
---|
| 205 | f2s=$vdir/$nam/$mach/$dorv/$rep2/solver.stat |
---|
| 206 | f2t=$vdir/$nam/$mach/$dorv/$rep2/tracer.stat |
---|
| 207 | |
---|
| 208 | if [ ! -f $f1s ] && [ ! -f $f1t ] ; then |
---|
| 209 | printf "%-20s %s\n" $nam " incomplete test"; |
---|
[8839] | 210 | return; |
---|
[8827] | 211 | fi |
---|
| 212 | if [ ! -f $f2s ] && [ ! -f $f2t ] ; then |
---|
| 213 | printf "%-20s %s\n" $nam " incomplete test"; |
---|
[8839] | 214 | return; |
---|
[8827] | 215 | fi |
---|
| 216 | # |
---|
| 217 | done_oce=0 |
---|
| 218 | |
---|
| 219 | if [ -f $f1s ] && [ -f $f2s ] ; then |
---|
| 220 | cmp -s $f1s $f2s |
---|
[8839] | 221 | if [ $? == 0 ]; then |
---|
| 222 | if [ $pass == 0 ]; then |
---|
[8827] | 223 | printf "%-20s %s %s\n" $nam " solver.stat reproducibility passed : " $dorv |
---|
| 224 | fi |
---|
| 225 | else |
---|
[8839] | 226 | printf "%-20s %s %s\n" $nam " solver.stat reproducibility FAILED : " $dorv |
---|
[8827] | 227 | # |
---|
| 228 | # Offer view of differences on the second pass |
---|
| 229 | # |
---|
| 230 | if [ $pass == 1 ]; then |
---|
| 231 | echo "<return> to view solver.stat differences" |
---|
| 232 | read y |
---|
| 233 | sdiff f1.tmp$$ $f2s |
---|
| 234 | echo "<return> to view ocean.output differences" |
---|
| 235 | read y |
---|
| 236 | sdiff $f1o $f2o | grep "|" |
---|
| 237 | done_oce=1 |
---|
| 238 | echo "<return> to continue" |
---|
| 239 | read y |
---|
| 240 | fi |
---|
| 241 | fi |
---|
| 242 | fi |
---|
| 243 | # |
---|
| 244 | # Check tracer.stat files (if they exist) |
---|
| 245 | # |
---|
| 246 | if [ -f $f1t ] && [ -f $f2t ] ; then |
---|
| 247 | cmp -s $f1t $f2t |
---|
[8839] | 248 | if [ $? == 0 ]; then |
---|
[8827] | 249 | if [ $pass == 0 ]; then printf "%-20s %s %s\n" $nam " tracer.stat reproducibility passed : " $dorv |
---|
| 250 | fi |
---|
| 251 | else |
---|
| 252 | printf "%-20s %s %s\n" $nam " tracer.stat reproducibility FAILED : " $dorv |
---|
| 253 | # |
---|
| 254 | # Offer view of differences on the second pass |
---|
| 255 | # |
---|
| 256 | if [ $pass == 1 ]; then |
---|
| 257 | echo "<return> to view tracer.stat differences" |
---|
| 258 | read y |
---|
| 259 | sdiff $f1t $f2t |
---|
| 260 | # |
---|
| 261 | # Only offer ocean.output view if it has not been viewed previously |
---|
| 262 | # |
---|
| 263 | if [ $done_oce == 0 ]; then |
---|
| 264 | echo "<return> to view ocean.output differences" |
---|
| 265 | read y |
---|
| 266 | sdiff $f1o $f2o | grep "|" |
---|
| 267 | fi |
---|
| 268 | echo "<return> to continue" |
---|
| 269 | read y |
---|
| 270 | fi |
---|
| 271 | fi |
---|
| 272 | fi |
---|
| 273 | fi |
---|
| 274 | } |
---|
[8839] | 275 | |
---|
| 276 | function identictest(){ |
---|
| 277 | # |
---|
| 278 | # checks AGRIF does not corrupe results with no AGRIF zoom. Expects ORCA2AGUL/AGRIFNOZ and ORCA2AGUL_NAGR/AGRIFNO run directories |
---|
| 279 | # Compares solver.stat files for each |
---|
| 280 | # |
---|
| 281 | vdir=$1 |
---|
| 282 | dir1=$2 |
---|
| 283 | dir2=$3 |
---|
| 284 | pass=$4 |
---|
| 285 | # |
---|
| 286 | if [ -d $vdir/$dir1 ] && [ -d $vdir/$dir2 ]; then |
---|
| 287 | dorv1=`ls -1rt $vdir/$dir1/$mach/ | tail -1l ` |
---|
| 288 | dorv1=`echo $dorv1 | sed -e 's:.*/::'` |
---|
| 289 | dorv2=`ls -1rt $vdir/$dir2/$mach/ | tail -1l ` |
---|
| 290 | dorv2=`echo $dorv2 | sed -e 's:.*/::'` |
---|
| 291 | |
---|
| 292 | rep1=`ls -1rt $vdir/$dir1/$mach/$dorv1/ | tail -2l | head -1 ` |
---|
| 293 | rep2=`ls -1rt $vdir/$dir2/$mach/$dorv2/ | tail -1l` |
---|
| 294 | f1s=$vdir/$dir1/$mach/$dorv1/$rep1/solver.stat |
---|
| 295 | f2s=$vdir/$dir2/$mach/$dorv2/$rep2/solver.stat |
---|
| 296 | |
---|
| 297 | if [ ! -f $f1s ] && [ ! -f $f2s ] ; then |
---|
| 298 | printf "%-20s %s\n" $dir1 $dir2 " incomplete test"; |
---|
| 299 | return; |
---|
| 300 | fi |
---|
| 301 | # |
---|
| 302 | done_oce=0 |
---|
| 303 | |
---|
| 304 | if [ -f $f1s ] && [ -f $f2s ] ; then |
---|
| 305 | cmp -s $f1s $f2s |
---|
| 306 | if [ $? == 0 ]; then |
---|
| 307 | if [ $pass == 0 ]; then |
---|
| 308 | printf "%-20s %s %s %s %s\n" $rep1 $rep2 " AGRIF: solver.stat unchanged - test passed : " $dorv1 $dorv2 |
---|
| 309 | fi |
---|
| 310 | else |
---|
| 311 | printf "%-20s %s %s %s %s\n" $rep1 $rep2 " for AGRIF, solver.stat test FAILED : " $dorv1 $dorv2 |
---|
| 312 | # |
---|
| 313 | # Offer view of differences on the second pass |
---|
| 314 | # |
---|
| 315 | if [ $pass == 1 ]; then |
---|
| 316 | echo "<return> to view solver.stat differences" |
---|
| 317 | read y |
---|
| 318 | sdiff $f1s $f2s |
---|
| 319 | done_oce=1 |
---|
| 320 | echo "<return> to continue" |
---|
| 321 | read y |
---|
| 322 | fi |
---|
| 323 | fi |
---|
| 324 | fi |
---|
| 325 | else |
---|
| 326 | printf "%-20s %s\n" $dir1 $dir2 " incomplete test"; |
---|
| 327 | fi |
---|
| 328 | } |
---|
[8827] | 329 | ########################### END of function definitions ################################# |
---|
| 330 | ## ## |
---|
| 331 | ## Main script ## |
---|
| 332 | ## ## |
---|
| 333 | ######################################################################################### |
---|
| 334 | # |
---|
[8864] | 335 | mach=`grep "COMPILER=" ./new_sette.sh | sed -e 's/COMPILER=//'` |
---|
[8827] | 336 | NEMO_VALID=`grep "NEMO_VALIDATION_DIR=" ./param.cfg | sed -e 's/NEMO_VALIDATION_DIR=//'` |
---|
| 337 | # Directory to run the tests |
---|
| 338 | SETTE_DIR=$(cd $(dirname "$0"); pwd) |
---|
| 339 | MAIN_DIR=$(dirname $SETTE_DIR) |
---|
| 340 | CONFIG_DIR0=${MAIN_DIR}/CONFIG |
---|
| 341 | TOOLS_DIR=${MAIN_DIR}/TOOLS |
---|
| 342 | COMPIL_DIR=${TOOLS_DIR}/COMPILE |
---|
| 343 | NPROC=32 |
---|
| 344 | |
---|
[8839] | 345 | SAS_RESTART_DIR=${CONFIG_DIR0}/SAS_ST |
---|
[8827] | 346 | # |
---|
| 347 | if [ ! -d $NEMO_VALID ]; then |
---|
| 348 | echo "$NEMO_VALID validation directory not found" |
---|
| 349 | exit |
---|
| 350 | fi |
---|
| 351 | # |
---|
[8864] | 352 | # Show current revision tag and branch name |
---|
| 353 | # |
---|
| 354 | cmd="svn" |
---|
| 355 | [ ! -d "$SETTE_DIR/.svn" ] && cmd="git $cmd" |
---|
| 356 | revision=`$cmd info | grep Revision | cut -d ":" -f 2 | tr -d ' '` |
---|
| 357 | branchname=`$cmd info | grep URL | rev | cut -d "/" -f 3 | rev` |
---|
| 358 | echo "SETTE validation report : $branchname @ r$revision" |
---|
| 359 | # |
---|
[8827] | 360 | # The script also needs the date or revision tag. Currently this is taken from the latest sub-directory found in each directory |
---|
| 361 | # |
---|
| 362 | for pass in 0 1 |
---|
| 363 | do |
---|
| 364 | # |
---|
| 365 | if [ $pass == 1 ]; then echo "---------------2nd pass------------------";fi |
---|
| 366 | # |
---|
| 367 | |
---|
| 368 | # Rebuild and restartability test for SAS |
---|
| 369 | # |
---|
[8839] | 370 | for restart_file in WSAS_ST |
---|
[8827] | 371 | do |
---|
| 372 | restfile $NEMO_VALID $restart_file $pass |
---|
| 373 | done |
---|
| 374 | # |
---|
| 375 | # Restartability test |
---|
| 376 | # |
---|
[8839] | 377 | for restart_test in WGYREPIS_ST WORCA2LIM3PIS_ST WORCA2OFFPIS_ST WAMM12_ST WISOMIP_ST WORCA2AGR_ST |
---|
[8827] | 378 | do |
---|
| 379 | resttest $NEMO_VALID $restart_test $pass |
---|
| 380 | done |
---|
| 381 | # |
---|
| 382 | # Reproducibility tests |
---|
| 383 | # |
---|
[8839] | 384 | for repro_test in WGYREPIS_ST WORCA2LIM3PIS_ST WORCA2OFFPIS_ST WAMM12_ST WISOMIP_ST WORCA2_LIM3_OBS_ST WORCA2AGR_ST |
---|
[8827] | 385 | do |
---|
| 386 | reprotest $NEMO_VALID $repro_test $pass |
---|
| 387 | done |
---|
[8839] | 388 | |
---|
| 389 | |
---|
| 390 | |
---|
| 391 | # AGRIF special check |
---|
| 392 | dir1=WORCA2AGUL_NOZOOM_ST |
---|
| 393 | dir2=WORCA2AGUL_NOAGR_ST |
---|
| 394 | identictest $NEMO_VALID $dir1 $dir2 $pass |
---|
| 395 | |
---|
| 396 | |
---|
| 397 | done |
---|
[8827] | 398 | # |
---|
[8839] | 399 | ## Additional checks for ORCA2AGUL/FIRST standalone AGRIF test |
---|
| 400 | ## still to be added |
---|
| 401 | |
---|
| 402 | |
---|
| 403 | |
---|
[8827] | 404 | exit |
---|