| 1 | #!/bin/bash |
|---|
| 2 | # $Id: check_version.sh 4079 2022-02-17 11:53:59Z fhourdin $ |
|---|
| 3 | |
|---|
| 4 | ######################################################################### |
|---|
| 5 | # Verification de a convergence du modele par rapport aux versions |
|---|
| 6 | # precedentes |
|---|
| 7 | # + 1+1=2 |
|---|
| 8 | ######################################################################### |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | version_ref=latest |
|---|
| 12 | resolution=48x36x19 |
|---|
| 13 | resolution=48x36x39 #20160622 : nouveau bench avec deux versions de la physique |
|---|
| 14 | compilo=gfortran |
|---|
| 15 | parallel=none |
|---|
| 16 | parallel=mpi_omp |
|---|
| 17 | justcheck=0 # just compare results not writing of results in RESUBENCH |
|---|
| 18 | tmpdir=/tmp/`whoami` ; mkdir -p $tmpdir |
|---|
| 19 | |
|---|
| 20 | if [ `whoami` = lmdz ] ; then |
|---|
| 21 | get="ln -sf /u/lmdz/WWW/pub" |
|---|
| 22 | getold="ln -sf /u/lmdz/WWW/Distrib" |
|---|
| 23 | else |
|---|
| 24 | get="wget https://www.lmd.jussieu.fr/~lmdz/pub" |
|---|
| 25 | getold="wget https://www.lmd.jussieu.fr/~lmdz/Distrib" |
|---|
| 26 | fi |
|---|
| 27 | |
|---|
| 28 | if [ `hostname` != cameron.lmd.jussieu.fr ] ; then |
|---|
| 29 | echo Machine non prevu |
|---|
| 30 | fi |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | # Option pour le debug du script check_version lui meme qui consiste a ne |
|---|
| 34 | # pars reexecuter l'installation et les simulations mais a simplement |
|---|
| 35 | # refaire les diff sur des simulations existantes. |
|---|
| 36 | diagonly=0 |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | while (($# > 0)) |
|---|
| 41 | do |
|---|
| 42 | case $1 in |
|---|
| 43 | "-h") cat <<fin |
|---|
| 44 | check_version.sh [-h] version [version_ref] |
|---|
| 45 | version is the name of the version of LMDZ to be checked modipsl.version.tar.gz |
|---|
| 46 | version_ref is the version to be compared with. |
|---|
| 47 | Default "latest". |
|---|
| 48 | options: |
|---|
| 49 | -c sets the compiler to use |
|---|
| 50 | -j just check results, do not overwrite anything 0/1 |
|---|
| 51 | fin |
|---|
| 52 | exit;; |
|---|
| 53 | |
|---|
| 54 | "-c") |
|---|
| 55 | compilo="$2" ; shift ; shift ;; |
|---|
| 56 | "-j") |
|---|
| 57 | justcheck="$2" ; shift ; shift ;; |
|---|
| 58 | *) |
|---|
| 59 | version="$1" ; shift ; if [ "$#" = 1 ] ; then version_ref=$1 ; shift ; fi ;; |
|---|
| 60 | esac |
|---|
| 61 | done |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | # branche=`echo $version | cut -d. -f2` |
|---|
| 65 | branche=`echo $version |cut -c 10-` |
|---|
| 66 | datelmdz=`echo $version | cut -d. -f1` |
|---|
| 67 | echo version $version $branche $datelmdz |
|---|
| 68 | |
|---|
| 69 | RESU_D=~/WWW/RESUBENCH/$branche/$compilo |
|---|
| 70 | mkdir -p $RESU_D |
|---|
| 71 | resubench=$RESU_D/$datelmdz |
|---|
| 72 | latest=$RESU_D/$version_ref |
|---|
| 73 | echo version_ref $version_ref $latest |
|---|
| 74 | ls -l $latest |
|---|
| 75 | |
|---|
| 76 | # recuperation de la version a laquelle on compare pour le message final : |
|---|
| 77 | comparea=`ls -ld $RESU_D/$version_ref | awk -F/ ' { print $NF } '` |
|---|
| 78 | |
|---|
| 79 | # LANCEMENT D UN CERTAIN NOMBRE DE TESTS |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | # Edition de install.sh, install.sh avec bench 48x36x19 |
|---|
| 83 | cd $tmpdir |
|---|
| 84 | MODEL=$tmpdir/LMDZ$version |
|---|
| 85 | if [ $diagonly = 0 ] ; then |
|---|
| 86 | \rm -f install_lmdz.sh ; $get/install_lmdz.sh ; chmod +x install_lmdz.sh |
|---|
| 87 | ./install_lmdz.sh -v $version -d $resolution -SCM -parallel $parallel -veget CMIP6 |
|---|
| 88 | fi |
|---|
| 89 | |
|---|
| 90 | ###################################################### |
|---|
| 91 | # Sauvegarde du 1D |
|---|
| 92 | ###################################################### |
|---|
| 93 | outf=$MODEL/1D/EXEC/NPv6.1L79/ARMCU/REF/restartphy.nc |
|---|
| 94 | if [ -f $outf ] ; then |
|---|
| 95 | if [ $justcheck = 0 ] ; then |
|---|
| 96 | mkdir -p $resubench/ARMCU/REF |
|---|
| 97 | cp $MODEL/1D/EXEC/NPv6.1L79/ARMCU/REF/restartphy.nc $resubench/ARMCU/REF/ |
|---|
| 98 | fi |
|---|
| 99 | # cmp -s $resubench/ARMCU/REF/restartphy.nc $latest/ARMCU/REF/restartphy.nc |
|---|
| 100 | cmp -s $MODEL/1D/EXEC/NPv6.1L79/ARMCU/REF/restartphy.nc $latest/ARMCU/REF/restartphy.nc |
|---|
| 101 | if [ $? = 0 ] ; then converge1D=U ; else converge1D=u ; fi |
|---|
| 102 | else |
|---|
| 103 | converge1D=- |
|---|
| 104 | fi |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | ###################################################### |
|---|
| 108 | BENCH=BENCH$resolution |
|---|
| 109 | cd $MODEL/modipsl/mod*/LMD*/$BENCH |
|---|
| 110 | echo BENCH FINI |
|---|
| 111 | ls -lrt |
|---|
| 112 | pwd |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | if [ -f restartphy.nc ] ; then |
|---|
| 119 | ######################################################################### |
|---|
| 120 | echo Verification de la convergence avec la version precedente |
|---|
| 121 | ######################################################################### |
|---|
| 122 | # Faite soit sur les restart.nc soit sur une exctraction de ps.nc |
|---|
| 123 | # A une epoque, ne marchait paps avec les restart a cause des traceurs. |
|---|
| 124 | # Le 2014/01/30, ne marchait plus avec ps.nc car les axes de lattiudes |
|---|
| 125 | # s'étaient inversés pour une raison inconnue. |
|---|
| 126 | # 2016/06/21 : on utilise deux versions de la physique pour le test. |
|---|
| 127 | |
|---|
| 128 | # Aide a l'interpretation de resultats problematiques |
|---|
| 129 | # Les resultats de la simu ancienne physique sont directement |
|---|
| 130 | # dans BENC* |
|---|
| 131 | # Les resultats de la nouvelle physique sont dans SIM1 utilise |
|---|
| 132 | # pour 1+1=2 |
|---|
| 133 | # Les resultats de la simulation debug sont dans SIMD |
|---|
| 134 | |
|---|
| 135 | if [ $justcheck = 0 ] ; then mkdir -p $resubench/$BENCH; fi |
|---|
| 136 | if [ -f restartphy.nc ] ; then |
|---|
| 137 | if [ $justcheck = 0 ] ; then |
|---|
| 138 | ncks -M -m -h -v ps -O restart.nc $resubench/$BENCH/ps.nc |
|---|
| 139 | cp restart.nc $resubench/$BENCH/restart.nc |
|---|
| 140 | fi |
|---|
| 141 | # cmp -s $resubench/$BENCH/restart.nc $latest/$BENCH/restart.nc |
|---|
| 142 | cmp -s ./restart.nc $latest/$BENCH/restart.nc |
|---|
| 143 | if [ $? = 0 ] ; then converge=S ; else converge=s ; fi |
|---|
| 144 | else |
|---|
| 145 | converge=- |
|---|
| 146 | fi |
|---|
| 147 | |
|---|
| 148 | ######################################################################### |
|---|
| 149 | echo Verification de 1+1=2 |
|---|
| 150 | ######################################################################### |
|---|
| 151 | # 2016/06/21 : 1+1=2 est fait sur la nouvelle physique |
|---|
| 152 | # Permet de tester aussi la convergence numérique |
|---|
| 153 | |
|---|
| 154 | suf=NPv5.5 |
|---|
| 155 | suf=NPv6.0.14splith |
|---|
| 156 | # cp -f config.def_oraer config.def |
|---|
| 157 | sed -e 's/VEGET=y/VEGET=n/' config.def_oraer > config.def |
|---|
| 158 | if [ -f physiq.def_$suf ] ; then \cp -f physiq.def_$suf physiq.def ; fi |
|---|
| 159 | if [ $diagonly = 0 ] ; then |
|---|
| 160 | $getold/unpun.sh |
|---|
| 161 | chmod +x unpun.sh ; ./unpun.sh -parallel $parallel |
|---|
| 162 | fi |
|---|
| 163 | cmp -s SIM2/ps_end.nc SIM1+1/ps_end.nc |
|---|
| 164 | if [ $? = 0 ] ; then |
|---|
| 165 | unpun=OK |
|---|
| 166 | else |
|---|
| 167 | unpun=- |
|---|
| 168 | fi |
|---|
| 169 | |
|---|
| 170 | ######################################################################### |
|---|
| 171 | echo Test en fonction du nombre de processeurs |
|---|
| 172 | ######################################################################### |
|---|
| 173 | if [ "$parallel" == "mpi_omp" ] ; then |
|---|
| 174 | mkdir SIM1_41 |
|---|
| 175 | cd SIM1_41 |
|---|
| 176 | ln -s ../SIM1/start* ../SIM1/limit* ../SIM1/sechiba_rest_in.nc ../SIM1/aer*nc ../SIM1/*def . |
|---|
| 177 | ../run_local.sh 4 1 ../gcm.e > listing |
|---|
| 178 | cd .. |
|---|
| 179 | cmp -s SIM1/restart.nc SIM1_41/restart.nc |
|---|
| 180 | if [ $? = 0 ] ; then |
|---|
| 181 | if [ "$unpun" = "OK" ] ; then |
|---|
| 182 | unpun=OK2 |
|---|
| 183 | else |
|---|
| 184 | unpun=-OK |
|---|
| 185 | fi |
|---|
| 186 | else |
|---|
| 187 | unpun=${unpun}- |
|---|
| 188 | fi |
|---|
| 189 | fi |
|---|
| 190 | |
|---|
| 191 | # 2016/06/21 : comparaison des versions nouvelles physique (dans SIM1) |
|---|
| 192 | # if [ -f restartphy.nc ] ; then Correction 2017/04/26 |
|---|
| 193 | if [ -f SIM1/restartphy.nc ] ; then |
|---|
| 194 | if [ $justcheck = 0 ] ; then |
|---|
| 195 | ncks -M -m -h -v ps -O SIM1/restart.nc $resubench/$BENCH/ps$suf.nc |
|---|
| 196 | cp SIM1/restart.nc $resubench/$BENCH/restart$suf.nc |
|---|
| 197 | fi |
|---|
| 198 | \rm sechiba_out_2.nc sechiba_history.nc sechiba_rest_out.nc |
|---|
| 199 | # cmp -s $resubench/$BENCH/restart$suf.nc $latest/$BENCH/restart$suf.nc |
|---|
| 200 | cmp -s SIM1/restart.nc $latest/$BENCH/restart$suf.nc |
|---|
| 201 | if [ $? = 0 ] ; then convergeNP=N ; else convergeNP=n ; fi |
|---|
| 202 | else |
|---|
| 203 | convergeNP=- |
|---|
| 204 | fi |
|---|
| 205 | |
|---|
| 206 | ######################################################################### |
|---|
| 207 | echo Verification en mode debug + parallele |
|---|
| 208 | ######################################################################### |
|---|
| 209 | if [ -f compilegcm.sh ] ; then |
|---|
| 210 | mv gcm.e gcm.install |
|---|
| 211 | ./compilegcm.sh -debug |
|---|
| 212 | mkdir SIMD |
|---|
| 213 | cd SIMD |
|---|
| 214 | ln -s ../SIM1/start* ../SIM1/limit* ../SIM1/sechiba_rest_in.nc ../SIM1/aer*nc ../SIM1/*def . |
|---|
| 215 | ../run_local.sh 2 2 ../gcm.e > listing 2>&1 |
|---|
| 216 | cd ../ |
|---|
| 217 | suf=D |
|---|
| 218 | if [ -f SIMD/restartphy.nc ] ; then |
|---|
| 219 | if [ $justcheck = 0 ] ; then |
|---|
| 220 | ncks -M -m -h -v ps -O SIMD/restart.nc $resubench/$BENCH/ps$suf.nc |
|---|
| 221 | cp SIMD/restart.nc $resubench/$BENCH/restart$suf.nc |
|---|
| 222 | fi |
|---|
| 223 | cmp -s SIMD/restart.nc $latest/$BENCH/restart$suf.nc |
|---|
| 224 | if [ $? = 0 ] ; then convergeD=D ; else convergeD=d ; fi |
|---|
| 225 | else |
|---|
| 226 | convergeD=- |
|---|
| 227 | fi |
|---|
| 228 | fi |
|---|
| 229 | ######################################################################### |
|---|
| 230 | echo Verification des isotopes |
|---|
| 231 | ######################################################################### |
|---|
| 232 | cd .. |
|---|
| 233 | ./makelmdz_fcm -arch local -j 8 -rrtm true -d 48x36x39 -v false -p lmdiso -isotopes true -isoverif true -debug gcm |
|---|
| 234 | if [ -f ./bin/gcm_48x36x39_phylmdiso_seq_iso_isoverif.e ] ; then |
|---|
| 235 | cd $BENCH |
|---|
| 236 | mkdir ISO |
|---|
| 237 | cp ../bin/gcm_48x36x39_phylmdiso_seq_iso_isoverif.e ISO/gcm_iso.e |
|---|
| 238 | cd ISO |
|---|
| 239 | ln -s ../SIM1/start* ../SIM1/limit* ../SIM1/aer*nc . |
|---|
| 240 | cp ../SIM1/physiq.def ../SIM1/gcm.def ../SIM1/vert.def . |
|---|
| 241 | for def in gcm run config traceur physiq |
|---|
| 242 | do |
|---|
| 243 | cp ../${def}_iso.def ${def}.def |
|---|
| 244 | done |
|---|
| 245 | cp ../iso.def . |
|---|
| 246 | ./gcm_iso.e > listing 2>&1 |
|---|
| 247 | cd .. |
|---|
| 248 | suf=I |
|---|
| 249 | if [ -f ISO/restartphy.nc ] ; then |
|---|
| 250 | if [ $justcheck = 0 ] ; then |
|---|
| 251 | cp ISO/restart.nc $resubench/$BENCH/restart$suf.nc |
|---|
| 252 | fi |
|---|
| 253 | cmp -s ISO/restart.nc $latest/$BENCH/restart$suf.nc |
|---|
| 254 | if [ $? = 0 ] ; then convergeI=I ; else convergeI=i ; fi |
|---|
| 255 | else |
|---|
| 256 | # compiled but failed the isoverif test |
|---|
| 257 | convergeI=x |
|---|
| 258 | fi |
|---|
| 259 | else |
|---|
| 260 | # compilation failed; cleaning up for next compilation |
|---|
| 261 | convergeI=- |
|---|
| 262 | \rm -f libf/grid/dimensions.h |
|---|
| 263 | \rm -f .lock |
|---|
| 264 | fi |
|---|
| 265 | |
|---|
| 266 | ######################################################################### |
|---|
| 267 | echo Verification de initialisation |
|---|
| 268 | ###############################################################y########## |
|---|
| 269 | cd $BENCH |
|---|
| 270 | rm -rf ../INIT |
|---|
| 271 | mkdir ../INIT |
|---|
| 272 | cp *def ../INIT |
|---|
| 273 | cd ../INIT |
|---|
| 274 | pwd |
|---|
| 275 | $getold/initialisation.sh |
|---|
| 276 | sed -e 's/grid_resolution=48x36x39/grid_resolution='$resolution'/' initialisation.sh > ini.sh |
|---|
| 277 | chmod +x ini.sh ; ./ini.sh |
|---|
| 278 | if [ -f limit.nc ] ; then |
|---|
| 279 | var=Tsoil01srf01 |
|---|
| 280 | if [ $justcheck = 0 ] ; then |
|---|
| 281 | mkdir -p $resubench/START$resolution |
|---|
| 282 | ncks -M -m -h -v $var startphy.nc -O $resubench/START$resolution/$var.nc |
|---|
| 283 | cp startphy.nc $resubench/START$resolution/ |
|---|
| 284 | fi |
|---|
| 285 | #! cmp -s $resubench/START$resolution/$var.nc $latest/START$resolution/$var.nc |
|---|
| 286 | cmp -s startphy.nc $latest/START$resolution/startphy.nc |
|---|
| 287 | if [ $? = 0 ] ; then |
|---|
| 288 | init=OK |
|---|
| 289 | else |
|---|
| 290 | init=noc |
|---|
| 291 | fi |
|---|
| 292 | else |
|---|
| 293 | init=- |
|---|
| 294 | fi |
|---|
| 295 | |
|---|
| 296 | ######################################################################## |
|---|
| 297 | echo end of test cases |
|---|
| 298 | ######################################################################## |
|---|
| 299 | bench=OK |
|---|
| 300 | else |
|---|
| 301 | echo PROBLEME : LE BENCH N EST PAS ALLE AU BOUT |
|---|
| 302 | bench=- |
|---|
| 303 | fi |
|---|
| 304 | |
|---|
| 305 | if [ $justcheck = 0 ] ; then |
|---|
| 306 | latest=$RESU_D/latest |
|---|
| 307 | \rm -f $latest |
|---|
| 308 | ln -sf $resubench $latest |
|---|
| 309 | fi |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | cd $MODEL/m*/m*/ |
|---|
| 313 | LMDZ=`\ls -d LMD*` #Nom du modele LMDZ sur modeles/ : LMDZ4, LMDZ5, LMDZ |
|---|
| 314 | |
|---|
| 315 | svn upgrade # Il faut mettre à jour le svn si la version sur |
|---|
| 316 | # laquelle le checkout a ete fait est plus ancienne |
|---|
| 317 | # ce qu'on souhaite par ailleurs pour pouvoir ensuite |
|---|
| 318 | # commettre depuis une version ancienne de svn (comme celles |
|---|
| 319 | # des SL du réseau local |
|---|
| 320 | svnrel=`svn info $LMDZ | grep 'Changed Rev' | head -1 | awk ' { print $4 } '` |
|---|
| 321 | #FH 20160822 |
|---|
| 322 | if [ "$svnrel" = "" ] ; then |
|---|
| 323 | svnrel=`svn info $LMDZ | grep vision | head -1 | awk ' { print $2 } '` |
|---|
| 324 | fi |
|---|
| 325 | |
|---|
| 326 | ccc=$converge$convergeNP$convergeD$converge1D$convergeI |
|---|
| 327 | if [ "$ccc" = "SNDUI" ] ; then ccc="OK " ; fi |
|---|
| 328 | |
|---|
| 329 | |
|---|
| 330 | echo $version' '$svnrel' '$bench' '$ccc ' '$unpun' '$init' (ref:' $comparea ')' |
|---|
| 331 | |
|---|
| 332 | exit |
|---|
| 333 | rm -fr $MODEL |
|---|