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