source: BOL/script_install/check_version.sh @ 4108

Last change on this file since 4108 was 4108, checked in by fhourdin, 2 years ago

Correction du controle-qualité pour le 1D
Fredho

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