source: BOL/script_install_amaury/check_version.sh @ 5245

Last change on this file since 5245 was 5156, checked in by abarral, 3 months ago

Add 1D and iso bench
Better svn branch detection for lmdz
Add script to test convergence locally
Lint check_version.sh

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 14.3 KB
RevLine 
[3926]1#!/bin/bash
2
[5156]3set -eu
[4097]4
[4406]5# AFAIRE
6# On pourrait gerer le justcheck en creant un repertoire
7# avec
8#  if recheck
9#   resubench=./RESUBENCH$$
10#  else
11#   resubench=$RESU_D/$datelmdz$rel_svn
12#On pourrait ainsi utiliser une fonction independante qui genere les messages
13# comme check_version_message
14
15
16
[3926]17#########################################################################
18# Verification de a convergence du modele par rapport aux versions
19# precedentes
20# + 1+1=2
21#########################################################################
22
[5156]23function get() {  # fetch lmdz files
24  local file=$1
[3926]25
[5156]26  if [[ -f $file ]]; then return; fi
27  # TODO  in the final version:    \rm -f if exists
[4097]28
[5156]29  if [[ $(whoami) = "lmdz" ]]; then
30     ln -sf "/u/lmdz/WWW/$file" .
31  else
32     wget "https://www.lmd.jussieu.fr/~lmdz/$file"
33  fi
34}
[4097]35
[5156]36function set_default_args_val() {
37  version_ref="latest"
38  resolution="48x36x39"
39  parallel="mpi_omp"
40  # Option pour le debug du script check_version lui meme qui consiste a ne
41  # pars reexecuter l'installation et les simulations mais a simplement
42  # refaire les diff sur des simulations existantes.
43  justcheck=0 # just compare results not writing of results in RESUBENCH
44  tmpdir="/tmp/$(whoami)"; mkdir -p "$tmpdir"
45  tmpdir="/home/lmdz/tmp"
46  rel_svn=""
47  local_d=$(pwd)
[3926]48
[5156]49  install=1
50  rad=rrtm
51  check_1D=1
52  check_1p1=1
53  check_isotopes=1
54  check_parallel=1
55  check_compile=1
56  check_ini=1
57  mail_address=lmdz-commit@listes.lmd.ipsl.fr
58  MODEL=""
59  branche=trunk
60}
[3926]61
[5156]62function read_user_options() {
63  while (($# > 0)); do
64      case $1 in
65          "-h") cat <<fin
66    check_version.sh [-h] version [-latest version_ref]
67    version is the name of the version of LMDZ to be checked modipsl.version.tar.gz
68    version_ref is the version to be compared with.
69    Default "latest".
70    options:
71      -justcheck  : just check results, do not overwrite anything
72      -r svn : revision
73      -latest latest : latest is the date of the last version tested
74      -model_dir : directory where tun run the bench if LMDZ is already installed
[3926]75fin
[5156]76            exit 2;;
[3926]77
[5156]78        "-justcheck") justcheck=1; shift;;
79        "-r") rel_svn="$2"; shift; shift;;
80        "-latest") version_ref="$2"; shift; shift;;
81        "-model_dir") MODEL="$2"; shift; shift;;
82        *) version="$1"; shift;;
83     esac
84  done
85}
[3926]86
[5156]87set_default_args_val
88read_user_options "$@"
89
[4097]90################################################################################
91# Definition des noms des repertoires à comparer
92################################################################################
[3926]93
[5156]94if [[ $MODEL = "" ]]; then
[4097]95   MODEL=$tmpdir/LMDZ$version$rel_svn
[5156]96   branche=$(echo "$version" |cut -c 10-)
97   datelmdz=$(echo "$version" | cut -d. -f1)
[4097]98else
[4107]99   install=0
[5156]100   if [[ "$(echo "$MODEL" | cut -c1)" != "/" ]]; then MODEL=$(pwd)/$MODEL; fi # MODEL transformed in absolute path if not
101   datelmdz=$(date +%Y%m%d)$$
[4097]102fi
103
[5156]104echo "version $version $branche $datelmdz"
105RESU_D=~/WWW/RESUBENCH/$branche/defaul
106if [[ $justcheck = 0 ]]; then
107   resubench="$RESU_D/$datelmdz$rel_svn"
108   if [[ -d $resubench ]]; then mv "$resubench" "$resubench$$"; fi
109   mkdir -p "$resubench"
[4097]110fi
[5156]111latest="$RESU_D/$version_ref"
112echo "$latest"
[3926]113
114# recuperation de la version a laquelle on compare pour le message final :
[5156]115comparea=$(ls -ld "$RESU_D/$version_ref" | awk -F/ ' { print $NF } ')
116echo "comparea $comparea"
[3926]117
[5156]118function install_model() {
119  local opt_svn
[3926]120
[5156]121  echo "0. Installation du modele"
[3926]122
[5156]123  # Edition de install.sh, install.sh avec bench 48x36x19
124  if [[ $install = 1 ]]; then
125     cd $tmpdir
126     if [[ $rel_svn = "" ]]; then opt_svn=""; else opt_svn="-r $rel_svn"; fi
127     get "pub/install_lmdz.sh"; chmod +x install_lmdz.sh
128     # On install sans les bench pour que les benchs soient faits à la main
129     ./install_lmdz.sh -unstable -v "$version" "$opt_svn" -d $resolution -parallel $parallel -veget CMIP6 -bench 0
130  fi
131}
132
133install_model
134
[4097]135################################################################################
136echo 1. Sauvegarde du 1D execute automatiquement a l installation
137################################################################################
138
[5156]139if [ $check_1D = 1 ]; then
[4097]140   cd $MODEL
[5156]141   if [ ! -d 1D ]; then $get/pub/1D/1D.tar.gz; tar xvf 1D.tar.gz; fi     # get 1D model
142   if [ ! -d 1D/EXEC ]; then mv 1D/EXEC 1D/SAVE_EXEC$$; fi
143   cd 1D; sed -e "s:^listecas=.*$:listecas=ARMCU/REF:" run.sh; ./run.sh   # run 1D model
144   # Controling outputs for the ARMCU/REF test case -d $dim"
[4107]145   outf=$MODEL/1D/EXEC/6AL79/ARMCU/REF/restartphy.nc
[5156]146   if [ -f $outf ]; then
147       if [ $justcheck = 0 ]; then
[4097]148          mkdir -p $resubench/ARMCU/REF
[4108]149          cp $outf $resubench/ARMCU/REF/
[4097]150       fi
[4108]151       cmp -s $outf $latest/ARMCU/REF/restartphy.nc
[5156]152       if [ $? = 0 ]; then converge1D=U; else converge1D=u; fi
[4097]153   else
154      converge1D=-
155   fi
[3926]156fi
157
158
[4097]159################################################################################
160echo DEBUT DES TESTS 3D
161################################################################################
[3926]162BENCH=BENCH$resolution
[4097]163cd $MODEL/modipsl/mod*/LMD*
164LMDZdir=`pwd`
[4107]165echo LMDZdir $LMDZdir
[5156]166if [ -d $BENCH ]; then mkdir -p SAVE$$; mv BENCH$resolution SAVE$$; fi
167$get/pub/3DBenchs/bench_lmdz_$resolution.tar.gz; tar xvf bench_lmdz_$resolution.tar.gz
168cd $BENCH; $get/pub/3DBenchs/BENCHCMIP6.tar.gz .;  tar xvf BENCHCMIP6.tar.gz
[4097]169sed -i'' -e "s:VEGET=n:VEGET=y:" config.def
[5156]170./compilegcm_fcm.sh; ./bench.sh > out.bench 2>&1
[3926]171
172
[5156]173if [ -f restartphy.nc ]; then
174   if [ ! -f gcm.install ]; then \cp -f gcm.e gcm.install; fi
[3926]175
176#########################################################################
[4097]177echo 3. Verification de la convergence avec la version precedente
178echo Physique Standard
[3926]179#########################################################################
180
[4097]181   # Faite soit sur les restart.nc soit sur une exctraction de ps.nc
182   # Il est arrive qu'on ait convergence meteo sans identite des restart
183   #  (pb d'entete, de traceurs ...)
184   # Aide a l'interpretation de resultats problematiques
185   #    Les resultats de la simu ancienne physique sont directement
186   #      dans BENC*
187   #    Les resultats de la nouvelle physique sont dans SIM1 utilise
188   #      pour 1+1=2
189   #    Les resultats de la simulation debug sont dans SIMD
[3926]190
[4097]191   # Ici on se contente d'analyser le bench automatique qui vient de tourner
[5156]192   if [ $justcheck = 0 ]; then mkdir -p $resubench/$BENCH; fi
193   if [ -f restartphy.nc ]; then
194       if [ $justcheck = 0 ]; then
[4097]195           ncks -M -m -h -v ps -O restart.nc $resubench/$BENCH/ps.nc
196           cp restart.nc $resubench/$BENCH/restart.nc
[3935]197       fi
198       cmp -s ./restart.nc $latest/$BENCH/restart.nc
[5156]199      if [ $? = 0 ]; then converge=S; else converge=s; fi
[3926]200   else
201      converge=-
202   fi
203
[4097]204   #########################################################################
205   echo 4. Verification de 1+1=2
206   echo Avec la nouvelle physique
207   #########################################################################
208   # On utilse l'executable du bench de base
[3926]209
[5156]210   if [ $check_1p1 = 1 ]; then
[4097]211      \cp -f gcm.install gcm.e
212      suf=NPv6.0.14splith
213      sed -e 's/VEGET=y/VEGET=n/' config.def_oraer > config.def
[5156]214      if [ -f physiq.def_$suf ]; then \cp -f physiq.def_$suf physiq.def; fi
[4097]215      $get/Distrib/unpun.sh
[5156]216      chmod +x unpun.sh; ./unpun.sh -parallel $parallel
[4097]217      cmp -s SIM2/ps_end.nc SIM1+1/ps_end.nc
[5156]218      if [ $? = 0 ]; then
[4097]219          unpun=OK
220      else
221          unpun=-
222      fi
[3926]223   fi
224
[4097]225
[3926]226# 2016/06/21 : comparaison des versions nouvelles physique (dans SIM1)
[4097]227   cd $LMDZdir/$BENCH
[5156]228   if [ -f SIM1/restartphy.nc ]; then
229       if [ $justcheck = 0 ]; then
[4097]230           ncks -M -m -h -v ps -O SIM1/restart.nc $resubench/$BENCH/ps$suf.nc
231           cp SIM1/restart.nc $resubench/$BENCH/restart$suf.nc
[3935]232       fi
233       \rm sechiba_out_2.nc sechiba_history.nc sechiba_rest_out.nc
234       cmp -s SIM1/restart.nc $latest/$BENCH/restart$suf.nc
[5156]235      if [ $? = 0 ]; then convergeNP=N; else convergeNP=n; fi
[3926]236   else
237      convergeNP=-
238   fi
239
[4097]240   #########################################################################
241      echo Verification en mode debug + parallele, compile avec makelmdz
242   #########################################################################
243
244   cd $LMDZdir/$BENCH
[5156]245   if [ -f compilegcm.sh -a $check_compile = 1 ]; then
[4097]246      \rm -f gcm.e
[3926]247      ./compilegcm.sh -debug
248      mkdir SIMD
249      cd SIMD
250      ln -s ../SIM1/start* ../SIM1/limit* ../SIM1/sechiba_rest_in.nc ../SIM1/aer*nc ../SIM1/*def .
251      ../run_local.sh 2 2 ../gcm.e > listing 2>&1
252      cd ../
253      suf=D
[5156]254      if [ -f SIMD/restartphy.nc ]; then
255          if [ $justcheck = 0 ]; then
[3935]256              ncks -M -m -h -v ps -O SIMD/restart.nc $resubench/$BENCH/ps$suf.nc
257              cp SIMD/restart.nc $resubench/$BENCH/restart$suf.nc
[4097]258          fi
[3935]259          cmp -s SIMD/restart.nc $latest/$BENCH/restart$suf.nc
[5156]260          if [ $? = 0 ]; then convergeD=D; else convergeD=d; fi
[3926]261      else
262         convergeD=-
263      fi
264   fi
[4097]265
266   #########################################################################
[4676]267      echo Test en fonction du nombre de processeurs
268   #########################################################################
269
270echo CHECK $parallel $check_parallel
[5156]271   if [ "$parallel" = "mpi_omp" -a $check_parallel = 1 ]; then
[4676]272      mkdir -p $LMDZdir/$BENCH/SIM1_41
273      cd $LMDZdir/$BENCH/SIM1_41
274      ln -s ../SIM1/start* ../SIM1/limit* ../SIM1/sechiba_rest_in.nc ../SIM1/aer*nc ../SIM1/*def .
275      ../run_local.sh 4 1 ../gcm.e > listing
276      cd ..
277      echo ON EST AVANT LE CMP
278      cmp -s SIMD/restart.nc SIM1_41/restart.nc
[5156]279      if [ $? = 0 ]; then
280          if [ "$unpun" = "OK" ]; then
[4676]281             unpun=OK2
282          else
283             unpun=-OK
284          fi
285      else
286          unpun=${unpun}-
287      fi
288   fi
289
290   #########################################################################
[4097]291      echo Verification des isotopes
292   #########################################################################
293
[5156]294   if [ $check_isotopes = 1 ]; then
[4097]295      cd $LMDZdir
296      pwd
297      $get/pub/3DBenchs/bench_lmdz_iso_48x36x39.tar.gz
298      tar xvf bench_lmdz_iso_48x36x39.tar.gz
299      cd BENCHiso48x36x39
300      ./compile.sh
[4197]301      exec=../bin/gcm_48x36x39_phylmdiso_${rad}_seq_iso_isoverif.e
[5156]302      if [ -f $exec ]; then
[4097]303             $exec > listing 2>&1
304             suf=I
[5156]305             if [ -f restartphy.nc ]; then
306                 if [ $justcheck = 0 ]; then
[4097]307                     cp restart.nc $resubench/$BENCH/restart$suf.nc
308                 fi
309                 cmp -s restart.nc $latest/$BENCH/restart$suf.nc
[5156]310                 if [ $? = 0 ]; then convergeI=I; else convergeI=i; fi
[4097]311             else
312                 # compiled but failed the isoverif test
313                 convergeI=x
314             fi
315      else
316          # compilation failed; cleaning up for next compilation
317          convergeI=-
318          \rm -f libf/grid/dimensions.h
319          \rm -f .lock
320      fi
[3955]321   fi
[3926]322
[4097]323   #########################################################################
324      echo Verification de initialisation
325   #########################################################################
326
[5156]327   if [ $check_ini = 1 ]; then
[4097]328      cd $LMDZdir
329      rm -rf INIT
330      mkdir INIT
331      cp $BENCH/*def INIT
332      cd INIT
333      pwd
334      $get/Distrib/initialisation.sh
335      sed -e 's/grid_resolution=48x36x39/grid_resolution='$resolution'/' initialisation.sh > ini.sh
[5156]336      chmod +x ini.sh; ./ini.sh
337      if [ -f limit.nc ]; then
[4097]338         var=Tsoil01srf01
[5156]339         if [ $justcheck = 0 ]; then
[4097]340             mkdir -p $resubench/START$resolution
341             ncks -M -m -h -v $var startphy.nc -O  $resubench/START$resolution/$var.nc
342             cp startphy.nc $resubench/START$resolution/
343         fi
344          cmp -s  startphy.nc  $latest/START$resolution/startphy.nc
[5156]345         if [ $? = 0 ]; then
[4097]346             init=OK
347         else
348             init=noc
349         fi
[3926]350      else
[4097]351         init=-
[3926]352      fi
353   fi
[3955]354
[4097]355   ########################################################################
356      echo end of test cases
357   ########################################################################   
[3926]358   bench=OK
359else
360   echo PROBLEME : LE BENCH N EST PAS ALLE AU BOUT
361   bench=-
362fi
363
[5156]364if [ $justcheck = 0 ]; then
[3935]365    latest=$RESU_D/latest
366    \rm -f $latest
367    ln -sf  $resubench $latest
368fi
[3926]369
[3935]370
[4097]371cd $LMDZdir/..
[3926]372LMDZ=`\ls -d LMD*` #Nom du modele LMDZ sur modeles/ : LMDZ4, LMDZ5, LMDZ
373
374svn upgrade # Il faut mettre à jour le svn si la version sur
375            # laquelle le checkout a ete fait est plus ancienne
376            # ce qu'on souhaite par ailleurs pour pouvoir ensuite
377            # commettre depuis une version ancienne de svn (comme celles
378            # des SL du réseau local
379svnrel=`svn info $LMDZ | grep 'Changed Rev' | head -1 | awk ' { print $4 } '`
380#FH 20160822
[5156]381if [ "$svnrel" = "" ]; then
[3926]382  svnrel=`svn info $LMDZ | grep vision | head -1 | awk ' { print $2 } '`
383fi
384
[3955]385ccc=$converge$convergeNP$convergeD$converge1D$convergeI
[5156]386if [ "$ccc" = "SNDUI" ]; then ccc="OK ";  fi
[3926]387
388
389
[4097]390########################################################################
391# Ectiture du message de bilan
392########################################################################
393
394cd $local_d
395
396echo $version'          '$svnrel'       '$bench'        '$ccc ' '$unpun'        '$init'   (ref:' $comparea ')' > tmp.resu
397cat > tmp.message <<eod
398disponible sur
399https://www.lmd.jussieu.fr/~lmdz/Distrib/modipsl.$version.tar.gz
400
401      Test local LMD network, gfortran, 48x36x19
402      ==========================================
403
404install version         SVN     Bench   Conv.   1+1=2   Init
405                                run     Nnum.      &
406                                        /prev.  mpiXomp
407
408eod
409cat tmp.resu >> tmp.message
410cat >> tmp.message <<eod
411
412
413                                        ||
414                                        \/
415
416S/s/-: 3D standard physics  Converging/runing/not runing
417N/n/-: -  new        -                  -
418D/d/-: new with debug                   -
419U/u/-: unicolonne                       -
420I/i/x/-: isotope            Converging/runing/run failed /compiled failed
421noc: runs but no convergence
422OK <=> SNDUI
423eod
424
425cat tmp.message
426
[5156]427if [ $mail_address != "" ] &&  [ $justcheck = 0 ]; then
[4107]428   ssh lmdz@django "mail -s 'Nouvelle version pour install_lmdz.sh' $mail_address < "$local_d"/tmp.message"
[4406]429#   ssh lmdz@lmdz-forge "mail -s 'Nouvelle version pour install_lmdz.sh' $mail_address < "$local_d"/tmp.message"
[4097]430fi
[4197]431
432#
433# clean up of /tmp/lmdz if everything went smoothly
434#
435grep -q 'OK     OK      OK2     OK' tmp.resu
436RET=$?
[5156]437if [ ${RET} -eq 0 ]; then
[4197]438  echo "Quality control checks out for version $version"
[4580]439  echo "We cleanup $tmpdir/LMDZ$version"
440  echo "\rm -rf $tmpdir/LMDZ$version"
441  \rm -rf $tmpdir/LMDZ$version
[4197]442fi
443
Note: See TracBrowser for help on using the repository browser.