source: BOL/script_install/check_version.sh @ 4197

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

Resolving issue when using oldrad with the default bench suite

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