[8747] | 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 |
---|
[9602] | 8 | # validation directory needs to be set here (currently assumed to reside in the ../cfgs directory) |
---|
[8747] | 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 | # |
---|
| 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" |
---|
[9602] | 34 | ./rebuild_nemo -t 4 ../../cfgs/SAS_LONG/LONG/SAS_00000100_restart_ice $NPROC > /dev/null 2>&1 |
---|
[8747] | 35 | #SF echo "REBUILD SHORT restart SAS files, without standard output" |
---|
[9602] | 36 | ./rebuild_nemo -t 4 ../../cfgs/SAS_LONG/SHORT/SAS_00000100_restart_ice $NPROC >&- |
---|
[8747] | 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 | #SF cdo -diffv $f1o $f2o |
---|
| 70 | /smplocal/pub/cdo/1.5.9/bin/cdo -diffv $f1o $f2o |
---|
| 71 | done_oce=1 |
---|
| 72 | #echo "<return> to continue" |
---|
| 73 | #read y |
---|
| 74 | fi |
---|
| 75 | fi |
---|
| 76 | fi |
---|
| 77 | # |
---|
| 78 | fi |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | function resttest() { |
---|
| 82 | # |
---|
| 83 | # Restartability checks. Expects LONG and SHORT run directories |
---|
| 84 | # Compares end of LONG stat files with equivalent entries from the SHORT stat files. |
---|
| 85 | # |
---|
| 86 | vdir=$1 |
---|
| 87 | nam=$2 |
---|
| 88 | pass=$3 |
---|
| 89 | # |
---|
| 90 | if [ -d $vdir/$nam ]; then |
---|
| 91 | dorv=`ls -1rt $vdir/$nam/$mach/ | tail -1l ` |
---|
| 92 | dorv=`echo $dorv | sed -e 's:.*/::'` |
---|
| 93 | f1o=$vdir/$nam/$mach/$dorv/LONG/ocean.output |
---|
| 94 | f1s=$vdir/$nam/$mach/$dorv/LONG/run.stat |
---|
| 95 | f1t=$vdir/$nam/$mach/$dorv/LONG/tracer.stat |
---|
| 96 | f2o=$vdir/$nam/$mach/$dorv/SHORT/ocean.output |
---|
| 97 | f2s=$vdir/$nam/$mach/$dorv/SHORT/run.stat |
---|
| 98 | f2t=$vdir/$nam/$mach/$dorv/SHORT/tracer.stat |
---|
| 99 | |
---|
| 100 | if [ ! -f $f1s ] && [ ! -f $f1t ] ; then |
---|
| 101 | printf "%-20s %s\n" $nam " incomplete test"; |
---|
| 102 | return; |
---|
| 103 | fi |
---|
| 104 | if [ ! -f $f2s ] && [ ! -f $f2t ] ; then |
---|
| 105 | printf "%-20s %s\n" $nam " incomplete test"; |
---|
| 106 | return; |
---|
| 107 | fi |
---|
| 108 | # |
---|
| 109 | done_oce=0 |
---|
| 110 | |
---|
| 111 | if [ -f $f1s ] && [ -f $f2s ]; then |
---|
| 112 | nl=(`wc -l $f2s`) |
---|
| 113 | tail -${nl[0]} $f1s > f1.tmp$$ |
---|
| 114 | cmp -s f1.tmp$$ $f2s |
---|
| 115 | if [ $? == 0 ]; then |
---|
| 116 | if [ $pass == 0 ]; then |
---|
| 117 | printf "%-20s %s %s\n" $nam " run.stat restartability passed : " $dorv |
---|
| 118 | fi |
---|
| 119 | else |
---|
| 120 | printf "%-20s %s %s\n" $nam " run.stat restartability FAILED : " $dorv |
---|
| 121 | # |
---|
| 122 | # Offer view of differences on the second pass |
---|
| 123 | # |
---|
| 124 | if [ $pass == 1 ]; then |
---|
| 125 | echo "<return> to view run.stat differences" |
---|
| 126 | read y |
---|
| 127 | sdiff f1.tmp$$ $f2s |
---|
| 128 | echo "<return> to view ocean.output differences" |
---|
| 129 | read y |
---|
| 130 | sdiff $f1o $f2o | grep "|" |
---|
| 131 | done_oce=1 |
---|
| 132 | echo "<return> to continue" |
---|
| 133 | read y |
---|
| 134 | fi |
---|
| 135 | fi |
---|
| 136 | fi |
---|
| 137 | # |
---|
| 138 | # Check tracer.stat files (if they exist) |
---|
| 139 | # |
---|
| 140 | if [ -f $f1t ] && [ -f $f2t ]; then |
---|
| 141 | nl=(`wc -l $f2t`) |
---|
| 142 | tail -${nl[0]} $f1t > f1.tmp$$ |
---|
| 143 | cmp -s f1.tmp$$ $f2t |
---|
| 144 | if [ $? == 0 ]; then |
---|
| 145 | if [ $pass == 0 ]; then |
---|
| 146 | printf "%-20s %s %s\n" $nam " tracer.stat restartability passed : " $dorv |
---|
| 147 | fi |
---|
| 148 | else |
---|
| 149 | printf "%-20s %s %s\n" $nam " tracer.stat restartability FAILED : " $dorv |
---|
| 150 | # |
---|
| 151 | # Offer view of differences on the second pass |
---|
| 152 | # |
---|
| 153 | if [ $pass == 1 ]; then |
---|
| 154 | echo "<return> to view tracer.stat differences" |
---|
| 155 | read y |
---|
| 156 | sdiff f1.tmp$$ $f2t |
---|
| 157 | # |
---|
| 158 | # Only offer ocean.output view if it has not been viewed previously |
---|
| 159 | # |
---|
| 160 | if [ $done_oce == 0 ]; then |
---|
| 161 | echo "<return> to view ocean.output differences" |
---|
| 162 | read y |
---|
| 163 | sdiff $f1o $f2o | grep "|" |
---|
| 164 | fi |
---|
| 165 | echo "<return> to continue" |
---|
| 166 | read y |
---|
| 167 | fi |
---|
| 168 | fi |
---|
| 169 | fi |
---|
| 170 | rm f1.tmp$$ |
---|
| 171 | fi |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | function reprotest(){ |
---|
| 175 | # |
---|
| 176 | # Reproducibility checks. Expects REPRO_N_M and REPRO_I_J run directories |
---|
| 177 | # Compares end of stat files from each |
---|
| 178 | # |
---|
| 179 | vdir=$1 |
---|
| 180 | nam=$2 |
---|
| 181 | pass=$3 |
---|
| 182 | # |
---|
| 183 | if [ -d $vdir/$nam ]; then |
---|
| 184 | dorv=`ls -1rt $vdir/$nam/$mach/ | tail -1l ` |
---|
| 185 | dorv=`echo $dorv | sed -e 's:.*/::'` |
---|
| 186 | rep1=`ls -1rt $vdir/$nam/$mach/$dorv/ | tail -2l | head -1 ` |
---|
| 187 | rep2=`ls -1rt $vdir/$nam/$mach/$dorv/ | tail -1l` |
---|
| 188 | f1o=$vdir/$nam/$mach/$dorv/$rep1/ocean.output |
---|
| 189 | f1s=$vdir/$nam/$mach/$dorv/$rep1/run.stat |
---|
| 190 | f1t=$vdir/$nam/$mach/$dorv/$rep1/tracer.stat |
---|
| 191 | f2o=$vdir/$nam/$mach/$dorv/$rep2/ocean.output |
---|
| 192 | f2s=$vdir/$nam/$mach/$dorv/$rep2/run.stat |
---|
| 193 | f2t=$vdir/$nam/$mach/$dorv/$rep2/tracer.stat |
---|
| 194 | |
---|
| 195 | if [ ! -f $f1s ] && [ ! -f $f1t ] ; then |
---|
| 196 | printf "%-20s %s\n" $nam " incomplete test"; |
---|
| 197 | return; |
---|
| 198 | fi |
---|
| 199 | if [ ! -f $f2s ] && [ ! -f $f2t ] ; then |
---|
| 200 | printf "%-20s %s\n" $nam " incomplete test"; |
---|
| 201 | return; |
---|
| 202 | fi |
---|
| 203 | # |
---|
| 204 | done_oce=0 |
---|
| 205 | |
---|
| 206 | if [ -f $f1s ] && [ -f $f2s ] ; then |
---|
| 207 | cmp -s $f1s $f2s |
---|
| 208 | if [ $? == 0 ]; then |
---|
| 209 | if [ $pass == 0 ]; then |
---|
| 210 | printf "%-20s %s %s\n" $nam " run.stat reproducibility passed : " $dorv |
---|
| 211 | fi |
---|
| 212 | else |
---|
| 213 | printf "%-20s %s %s\n" $nam " run.stat reproducibility FAILED : " $dorv |
---|
| 214 | # |
---|
| 215 | # Offer view of differences on the second pass |
---|
| 216 | # |
---|
| 217 | if [ $pass == 1 ]; then |
---|
| 218 | echo "<return> to view run.stat differences" |
---|
| 219 | read y |
---|
| 220 | sdiff f1.tmp$$ $f2s |
---|
| 221 | echo "<return> to view ocean.output differences" |
---|
| 222 | read y |
---|
| 223 | sdiff $f1o $f2o | grep "|" |
---|
| 224 | done_oce=1 |
---|
| 225 | echo "<return> to continue" |
---|
| 226 | read y |
---|
| 227 | fi |
---|
| 228 | fi |
---|
| 229 | fi |
---|
| 230 | # |
---|
| 231 | # Check tracer.stat files (if they exist) |
---|
| 232 | # |
---|
| 233 | if [ -f $f1t ] && [ -f $f2t ] ; then |
---|
| 234 | cmp -s $f1t $f2t |
---|
| 235 | if [ $? == 0 ]; then |
---|
| 236 | if [ $pass == 0 ]; then printf "%-20s %s %s\n" $nam " tracer.stat reproducibility passed : " $dorv |
---|
| 237 | fi |
---|
| 238 | else |
---|
| 239 | printf "%-20s %s %s\n" $nam " tracer.stat reproducibility FAILED : " $dorv |
---|
| 240 | # |
---|
| 241 | # Offer view of differences on the second pass |
---|
| 242 | # |
---|
| 243 | if [ $pass == 1 ]; then |
---|
| 244 | echo "<return> to view tracer.stat differences" |
---|
| 245 | read y |
---|
| 246 | sdiff $f1t $f2t |
---|
| 247 | # |
---|
| 248 | # Only offer ocean.output view if it has not been viewed previously |
---|
| 249 | # |
---|
| 250 | if [ $done_oce == 0 ]; then |
---|
| 251 | echo "<return> to view ocean.output differences" |
---|
| 252 | read y |
---|
| 253 | sdiff $f1o $f2o | grep "|" |
---|
| 254 | fi |
---|
| 255 | echo "<return> to continue" |
---|
| 256 | read y |
---|
| 257 | fi |
---|
| 258 | fi |
---|
| 259 | fi |
---|
| 260 | fi |
---|
| 261 | } |
---|
| 262 | ########################### END of function definitions ################################# |
---|
| 263 | ## ## |
---|
| 264 | ## Main script ## |
---|
| 265 | ## ## |
---|
| 266 | ######################################################################################### |
---|
| 267 | # |
---|
| 268 | mach=`grep "COMPILER=" ./sette.sh | sed -e 's/COMPILER=//'` |
---|
| 269 | NEMO_VALID=`grep "NEMO_VALIDATION_DIR=" ./param.cfg | sed -e 's/NEMO_VALIDATION_DIR=//'` |
---|
| 270 | # Directory to run the tests |
---|
| 271 | SETTE_DIR=$(cd $(dirname "$0"); pwd) |
---|
| 272 | MAIN_DIR=$(dirname $SETTE_DIR) |
---|
[9602] | 273 | CONFIG_DIR0=${MAIN_DIR}/cfgs |
---|
[9605] | 274 | TOOLS_DIR=${MAIN_DIR}/tools |
---|
[8747] | 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 | # |
---|
| 287 | for pass in 0 1 |
---|
| 288 | do |
---|
| 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 | # |
---|
[9663] | 303 | for restart_test in WGYREPIS_LONG WORCA2ICEPIS_LONG WORCA2OFFPIS_LONG WAMM12_LONG WISOMIP_LONG WORCA2AGUL_LONG |
---|
[8747] | 304 | do |
---|
| 305 | resttest $NEMO_VALID $restart_test $pass |
---|
| 306 | done |
---|
| 307 | # |
---|
| 308 | # Reproducibility tests |
---|
| 309 | # |
---|
[9663] | 310 | for repro_test in WGYREPIS_32 WORCA2ICEPIS_32 WORCA2OFFPIS_32 WAMM12_32 WISOMIP_32 WORCA2_ICE_OBS WORCA2AGUL_1_2 WORCA2AGUL_16 WORCA2AGUL_2_2_NAG |
---|
[8747] | 311 | do |
---|
| 312 | reprotest $NEMO_VALID $repro_test $pass |
---|
| 313 | done |
---|
| 314 | # |
---|
| 315 | done |
---|
| 316 | exit |
---|