source: BOL/script_install/check_version.sh @ 4097

Last change on this file since 4097 was 4097, checked in by Laurent Fairhead, 2 years ago

Work by Frederic to make the quality control script more modular

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