source: BOL/script_install_amaury/check_version.sh @ 5166

Last change on this file since 5166 was 5156, checked in by abarral, 7 weeks 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
Line 
1#!/bin/bash
2
3set -eu
4
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
17#########################################################################
18# Verification de a convergence du modele par rapport aux versions
19# precedentes
20# + 1+1=2
21#########################################################################
22
23function get() {  # fetch lmdz files
24  local file=$1
25
26  if [[ -f $file ]]; then return; fi
27  # TODO  in the final version:    \rm -f if exists
28
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}
35
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)
48
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}
61
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
75fin
76            exit 2;;
77
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}
86
87set_default_args_val
88read_user_options "$@"
89
90################################################################################
91# Definition des noms des repertoires à comparer
92################################################################################
93
94if [[ $MODEL = "" ]]; then
95   MODEL=$tmpdir/LMDZ$version$rel_svn
96   branche=$(echo "$version" |cut -c 10-)
97   datelmdz=$(echo "$version" | cut -d. -f1)
98else
99   install=0
100   if [[ "$(echo "$MODEL" | cut -c1)" != "/" ]]; then MODEL=$(pwd)/$MODEL; fi # MODEL transformed in absolute path if not
101   datelmdz=$(date +%Y%m%d)$$
102fi
103
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"
110fi
111latest="$RESU_D/$version_ref"
112echo "$latest"
113
114# recuperation de la version a laquelle on compare pour le message final :
115comparea=$(ls -ld "$RESU_D/$version_ref" | awk -F/ ' { print $NF } ')
116echo "comparea $comparea"
117
118function install_model() {
119  local opt_svn
120
121  echo "0. Installation du modele"
122
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
135################################################################################
136echo 1. Sauvegarde du 1D execute automatiquement a l installation
137################################################################################
138
139if [ $check_1D = 1 ]; then
140   cd $MODEL
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"
145   outf=$MODEL/1D/EXEC/6AL79/ARMCU/REF/restartphy.nc
146   if [ -f $outf ]; then
147       if [ $justcheck = 0 ]; then
148          mkdir -p $resubench/ARMCU/REF
149          cp $outf $resubench/ARMCU/REF/
150       fi
151       cmp -s $outf $latest/ARMCU/REF/restartphy.nc
152       if [ $? = 0 ]; then converge1D=U; else converge1D=u; fi
153   else
154      converge1D=-
155   fi
156fi
157
158
159################################################################################
160echo DEBUT DES TESTS 3D
161################################################################################
162BENCH=BENCH$resolution
163cd $MODEL/modipsl/mod*/LMD*
164LMDZdir=`pwd`
165echo LMDZdir $LMDZdir
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
169sed -i'' -e "s:VEGET=n:VEGET=y:" config.def
170./compilegcm_fcm.sh; ./bench.sh > out.bench 2>&1
171
172
173if [ -f restartphy.nc ]; then
174   if [ ! -f gcm.install ]; then \cp -f gcm.e gcm.install; fi
175
176#########################################################################
177echo 3. Verification de la convergence avec la version precedente
178echo Physique Standard
179#########################################################################
180
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
190
191   # Ici on se contente d'analyser le bench automatique qui vient de tourner
192   if [ $justcheck = 0 ]; then mkdir -p $resubench/$BENCH; fi
193   if [ -f restartphy.nc ]; then
194       if [ $justcheck = 0 ]; then
195           ncks -M -m -h -v ps -O restart.nc $resubench/$BENCH/ps.nc
196           cp restart.nc $resubench/$BENCH/restart.nc
197       fi
198       cmp -s ./restart.nc $latest/$BENCH/restart.nc
199      if [ $? = 0 ]; then converge=S; else converge=s; fi
200   else
201      converge=-
202   fi
203
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
209
210   if [ $check_1p1 = 1 ]; then
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
214      if [ -f physiq.def_$suf ]; then \cp -f physiq.def_$suf physiq.def; fi
215      $get/Distrib/unpun.sh
216      chmod +x unpun.sh; ./unpun.sh -parallel $parallel
217      cmp -s SIM2/ps_end.nc SIM1+1/ps_end.nc
218      if [ $? = 0 ]; then
219          unpun=OK
220      else
221          unpun=-
222      fi
223   fi
224
225
226# 2016/06/21 : comparaison des versions nouvelles physique (dans SIM1)
227   cd $LMDZdir/$BENCH
228   if [ -f SIM1/restartphy.nc ]; then
229       if [ $justcheck = 0 ]; then
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
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
235      if [ $? = 0 ]; then convergeNP=N; else convergeNP=n; fi
236   else
237      convergeNP=-
238   fi
239
240   #########################################################################
241      echo Verification en mode debug + parallele, compile avec makelmdz
242   #########################################################################
243
244   cd $LMDZdir/$BENCH
245   if [ -f compilegcm.sh -a $check_compile = 1 ]; then
246      \rm -f gcm.e
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
254      if [ -f SIMD/restartphy.nc ]; then
255          if [ $justcheck = 0 ]; then
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
258          fi
259          cmp -s SIMD/restart.nc $latest/$BENCH/restart$suf.nc
260          if [ $? = 0 ]; then convergeD=D; else convergeD=d; fi
261      else
262         convergeD=-
263      fi
264   fi
265
266   #########################################################################
267      echo Test en fonction du nombre de processeurs
268   #########################################################################
269
270echo CHECK $parallel $check_parallel
271   if [ "$parallel" = "mpi_omp" -a $check_parallel = 1 ]; then
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
279      if [ $? = 0 ]; then
280          if [ "$unpun" = "OK" ]; then
281             unpun=OK2
282          else
283             unpun=-OK
284          fi
285      else
286          unpun=${unpun}-
287      fi
288   fi
289
290   #########################################################################
291      echo Verification des isotopes
292   #########################################################################
293
294   if [ $check_isotopes = 1 ]; then
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
301      exec=../bin/gcm_48x36x39_phylmdiso_${rad}_seq_iso_isoverif.e
302      if [ -f $exec ]; then
303             $exec > listing 2>&1
304             suf=I
305             if [ -f restartphy.nc ]; then
306                 if [ $justcheck = 0 ]; then
307                     cp restart.nc $resubench/$BENCH/restart$suf.nc
308                 fi
309                 cmp -s restart.nc $latest/$BENCH/restart$suf.nc
310                 if [ $? = 0 ]; then convergeI=I; else convergeI=i; fi
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
321   fi
322
323   #########################################################################
324      echo Verification de initialisation
325   #########################################################################
326
327   if [ $check_ini = 1 ]; then
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
336      chmod +x ini.sh; ./ini.sh
337      if [ -f limit.nc ]; then
338         var=Tsoil01srf01
339         if [ $justcheck = 0 ]; then
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
345         if [ $? = 0 ]; then
346             init=OK
347         else
348             init=noc
349         fi
350      else
351         init=-
352      fi
353   fi
354
355   ########################################################################
356      echo end of test cases
357   ########################################################################   
358   bench=OK
359else
360   echo PROBLEME : LE BENCH N EST PAS ALLE AU BOUT
361   bench=-
362fi
363
364if [ $justcheck = 0 ]; then
365    latest=$RESU_D/latest
366    \rm -f $latest
367    ln -sf  $resubench $latest
368fi
369
370
371cd $LMDZdir/..
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
381if [ "$svnrel" = "" ]; then
382  svnrel=`svn info $LMDZ | grep vision | head -1 | awk ' { print $2 } '`
383fi
384
385ccc=$converge$convergeNP$convergeD$converge1D$convergeI
386if [ "$ccc" = "SNDUI" ]; then ccc="OK ";  fi
387
388
389
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
427if [ $mail_address != "" ] &&  [ $justcheck = 0 ]; then
428   ssh lmdz@django "mail -s 'Nouvelle version pour install_lmdz.sh' $mail_address < "$local_d"/tmp.message"
429#   ssh lmdz@lmdz-forge "mail -s 'Nouvelle version pour install_lmdz.sh' $mail_address < "$local_d"/tmp.message"
430fi
431
432#
433# clean up of /tmp/lmdz if everything went smoothly
434#
435grep -q 'OK     OK      OK2     OK' tmp.resu
436RET=$?
437if [ ${RET} -eq 0 ]; then
438  echo "Quality control checks out for version $version"
439  echo "We cleanup $tmpdir/LMDZ$version"
440  echo "\rm -rf $tmpdir/LMDZ$version"
441  \rm -rf $tmpdir/LMDZ$version
442fi
443
Note: See TracBrowser for help on using the repository browser.