source: BOL/script_install_amaury/check_version.sh

Last change on this file was 4676, checked in by Laurent Fairhead, 9 months ago

Checking for parallel distribution in debug mode now

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 14.9 KB
Line 
1#!/bin/bash
2# $Id: check_version.sh 4676 2023-09-05 16:27:58Z abarral $
3
4#set -vx
5
6# AFAIRE
7# On pourrait gerer le justcheck en creant un repertoire
8# avec
9#  if recheck
10#   resubench=./RESUBENCH$$
11#  else
12#   resubench=$RESU_D/$datelmdz$rel_svn
13#On pourrait ainsi utiliser une fonction independante qui genere les messages
14# comme check_version_message
15
16
17
18#########################################################################
19# Verification de a convergence du modele par rapport aux versions
20# precedentes
21# + 1+1=2
22#########################################################################
23
24version_ref=latest
25resolution=48x36x39
26compilo=gfortran
27parallel=mpi_omp
28# Option pour le debug du script check_version lui meme qui consiste a ne
29# pars reexecuter l'installation et les simulations mais a simplement
30# refaire les diff sur des simulations existantes.
31justcheck=0 # just compare results not writing of results in RESUBENCH
32tmpdir=/tmp/`whoami` ; mkdir -p $tmpdir
33tmpdir=/home/lmdz/tmp
34rel_svn=""
35local_d=`pwd`
36
37install=1
38rad=rrtm
39check_1D=1
40check_SP=1
41check_1p1=1
42check_Debug=1
43check_isotopes=1
44check_parallel=1
45check_compile=1
46check_ini=1
47mail_address=lmdz-commit@listes.lmd.ipsl.fr
48MODEL=""
49branche=trunk
50
51#########################################################################
52# Pour aller chercher des fichiers par wget si pas sur le cpte lmdz
53#########################################################################
54
55if [ `whoami` = lmdz ] ; then
56   get="ln -sf /u/lmdz/WWW"
57else
58   get="wget https://www.lmd.jussieu.fr/~lmdz"
59fi
60
61#########################################################################
62# Options du script
63#########################################################################
64
65while (($# > 0))
66  do
67  case $1 in
68      "-h") cat <<fin
69check_version.sh [-h] version [-latest version_ref]
70version is the name of the version of LMDZ to be checked modipsl.version.tar.gz
71version_ref is the version to be compared with.
72Default "latest".
73options:
74  -c compiler : sets the compiler to use
75  -justcheck  : just check results, do not overwrite anything
76  -r svn : revision
77  -latest latest : latest is the date of the last version tested
78  -model_dir : directory where tun run the bench if LMDZ is already installed
79fin
80          exit;;
81
82      "-c") compilo="$2" ; shift ; shift ;;
83      "-justcheck") justcheck=1 ; shift ;;
84      "-r") rel_svn="$2" ; shift ; shift ;;
85      "-latest") version_ref="$2" ; shift ; shift ;;
86      "-model_dir") MODEL="$2" ; shift ; shift ;;
87      *) version="$1" ; shift ;;
88   esac
89done
90
91################################################################################
92# Definition des noms des repertoires à comparer
93################################################################################
94
95# branche=`echo $version | cut -d. -f2`
96if [ "$MODEL" = "" ] ; then
97   MODEL=$tmpdir/LMDZ$version$rel_svn
98   branche=`echo $version |cut -c 10-`
99   datelmdz=`echo $version | cut -d. -f1`
100else
101   #if [ $install = 1 ] ; then echo Use model_dir only if the model is already installed ; exit ; fi
102   install=0
103   if [ "`echo $MODEL | cut -c1`" != "/" ] ; then MODEL=`pwd`/$MODEL ; fi # MODEL transformed in absolute path if not
104   datelmdz=`date +%Y%m%d`$$
105fi
106
107echo version $version $branche $datelmdz
108RESU_D=~/WWW/RESUBENCH/$branche/$compilo
109if [ $justcheck = 0 ] ; then
110   resubench=$RESU_D/$datelmdz$rel_svn
111   if [ -d $resubench ] ; then mv $resubench $resubench$$ ; fi
112   mkdir -p $resubench
113fi
114latest=$RESU_D/$version_ref
115echo $latest 
116
117# recuperation de la version a laquelle on compare pour le message final :
118comparea=`ls -ld $RESU_D/$version_ref | awk -F/ ' { print $NF } '`
119echo comparea $comparea
120
121################################################################################
122echo 0. Installation du modele
123################################################################################
124
125# Edition de install.sh, install.sh avec bench 48x36x19
126if [ $install = 1 ] ; then
127   cd $tmpdir
128   if [ "$rel_svn" = "" ] ; then opt_svn="" ; else opt_svn="-r $rel_svn" ; fi
129   \rm -f install_lmdz.sh ; $get/pub/install_lmdz.sh ; chmod +x install_lmdz.sh
130   # On install sans les bench pour que les benchs soient faits à la main
131   # ./install_lmdz.sh -v $version $opt_svn -d $resolution -SCM -parallel $parallel -veget CMIP6
132     ./install_lmdz.sh -unstable -v $version $opt_svn -d $resolution      -parallel $parallel -veget CMIP6 -bench 0
133fi
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
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.