source: BOL/script_install/instal1d.sh @ 1693

Last change on this file since 1693 was 1693, checked in by Laurent Fairhead, 12 years ago

Mise à jour de la procédure d'installation par install.sh
En particulier, bascule sur la testing par défaut


Updates to the isntall.sh procedure
In particular, switch to the testing branch by default

  • Property svn:executable set to *
File size: 12.3 KB
Line 
1#!/bin/ksh
2#
3#   Script d'installation de LMDZ_1D, pour la version trunk
4# du 07 Octobre 2011 (=1575) et au-dela.
5#   ATTENTION : la prise en compte de l'heure de démarrage n'existe que dans les versions
6# postérieures au 3 Novembre 2011 (=1577).
7#   Le script est conçu pour fonctionner aussi avec des versions antérieures mais ce n'est
8# pas testé : Use at your own risk!
9#
10#Directory où est place le modele installé par install.sh
11
12
13version=`sed -n "s/version *=//p" install.sh`
14echo $version
15modele=`pwd`/LMDZ${version}
16#Les directories de simulation seront placés sous $modele/1dcases .
17#Le code physique sera place sous $modele/modipsl/modeles/LMDZ5/libf/.
18#
19cd $modele
20#
21LMDGCM=`pwd`
22
23
24
25##########################################################################################
26# Recuperation des sources du modele 1D et des cas.
27
28cd $LMDGCM/modipsl/modeles/LMDZ5/libf/
29LMDlibf=`pwd`
30cd $LMDGCM
31# On va chercher les fichiers
32interne=no
33###interne=yes
34if [ $interne = no ]
35then
36 wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/lmdz1d_source_20121016.tar.gz
37 tar xvfz lmdz1d_source_20121016.tar.gz
38 rm -f lmdz1d_source_20121016.tar.gz
39 source=${LMDGCM}/lmdz1d_source_20121016
40else
41 cp -a /home/jygz/LMDZ/SLMDZ/LMDZ5_source_20120112/lmdz1d_source_20120112 .
42 source=${LMDGCM}/lmdz1d_source_20120112
43fi
44#
45
46##########################################################################################
47# Creation des repertoires des cas.
48##########################################################################################
49
50if [ -f 1dcases ]
51then
52  echo '1dcases existe deja'
53  echo 'on continue'
54else
55  echo 'creation du directory 1dcases'
56  mkdir 1dcases
57fi
58cd 1dcases
59
60
61for cas in ayotte eq_rd_cv case_e hapex92_init twpice toga rico arm_cu ; do
62   if [ -f $cas ]
63   then
64      echo $cas existe deja
65      echo 'on continue, mais il  faudra verifier qu il ne manque rien dans '$cas
66   else
67      echo 'creation du directory de simulation '$cas
68      cp -a ${source}/$cas .
69   fi
70   dir $cas
71done
72
73
74##########################################################################################
75# On teste si la version svn est plus recentes que la 1640 pour la gestion du 1D
76cd $LMDGCM/modipsl/modeles
77new1d=`svn info LMDZ5 | grep Revision | awk ' { fl = 0 ; if ( $2 > 1640 )  fl=1 ; print fl } '`
78
79
80if [ $new1d = 1 ] ; then
81
82cd $LMDlibf
83wget http://lmdz.lmd.jussieu.fr/utilisateurs/outils/utilisation-de-lmdz/install_1d_src-sh
84chmod +x install_1d_src-sh
85./install_1d_src-sh
86
87
88else
89##########################################################################################
90# Ancienne gestion des sources 1D avec corrections.
91# Voir commemnt faire cohabiter une partie de cette facon de faire avec la nouvelle
92
93cd ${LMDlibf}
94if [ -d phy1d ]
95then
96 echo 'phy1d existe deja'
97 echo 'on continue'
98 cd phy1d
99 echo 'on cree le lien vers ../dyn3d/mod_const_para.F90 si necessaire'
100 if [ ! -f mod_const_para.F90 ]
101 then
102  ln -s ../dyn3d/mod_const_para.F90  mod_const_para.F90
103  ln -s ../dyn3d/infotrac.F90        infotrac.F90
104  ln -s ../dyn3d/conf_gcm.F          conf_gcm.F
105  ln -s ../dyn3d/pres2lev.F90        pres2lev.F90
106  ln -s ../dyn3d/control_mod.F90     control_mod.F90
107  ln -s ../dyn3d/q_sat.F             q_sat.F
108 fi
109else
110 \rm -rf phy1d
111 echo 'creation du directory phy1d'
112 mkdir phy1d
113 echo copie de phylmd dans phy1d
114 cp -a phylmd/* phy1d
115 cp -a ${source}/phy1d_source/* phy1d
116 cp -af ${source}/phy1d_source_upd/* phy1d
117 cd phy1d
118 ln -s ../dyn3d/mod_const_para.F90  mod_const_para.F90
119 ln -s ../dyn3d/infotrac.F90        infotrac.F90
120 ln -s ../dyn3d/conf_gcm.F          conf_gcm.F
121 ln -s ../dyn3d/pres2lev.F90        pres2lev.F90
122 ln -s ../dyn3d/control_mod.F90     control_mod.F90
123 ln -s ../dyn3d/q_sat.F             q_sat.F
124#
125 grep -i "subroutine *writelim" *.F *.F90 >/dev/null
126 if [ "$?" = "0" ]
127 then
128  echo Use writelim free version of 1DUTILS.h
129  mv 1DUTILS.h_no_writelim 1DUTILS.h
130 else
131  echo Use 1DUTILS.h version including subroutine writelim
132  mv 1DUTILS.h_with_writelim 1DUTILS.h
133  rm -f ttt
134  sed -e "s/^ *call *writelim *( *1 *,/      call writelim (/" lmdz1d.F >ttt
135  rm -f lmdz1d.F
136  mv ttt lmdz1d.F
137 fi
138 rm -f 1DUTILS.h*writelim
139#
140############################################################################
141#                                                                          #
142#               CORRECTIONS spécifiques au 1D                              #
143#                                                                          #
144############################################################################
145#
146 echo Update physiq.F and suppress lambda_th
147 rm -f physiq.F
148 sed -e "/add_phys_tend.*_vdf/s/add_phys_tend/add_pbl_tend/;" ../phylmd/physiq.F >physiq.F.ori
149#
150 echo Update phys_output_mod.F90 and suppress lambda_th
151 rm -f phys_output_mod.F90
152sed -e "/SUBROUTINE *convers_timesteps/,/END SUBROUTINE convers_timesteps/{
153 /USE *phys_cal_mod/d
154 /use *ioipsl/a\\
155    USE phys_cal_mod
156 s/ioget_mon_len(annee_ref,day_ref)/mth_len/
157};/SUBROUTINE *phys_output_open/,/end *subroutine *phys_output_open/{
158 /USE *ioipsl/a\\
159  USE phys_cal_mod, only : hour
160 /ymds2ju.*annee_ref.*zjulian/c\\
161!!!      CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)       !jyg \\
162! correction pour l heure initiale                               !jyg \\
163!                                                                !jyg \\
164      CALL ymds2ju(annee_ref, 1, idayref, hour, zjulian)         !jyg
165}" ../phylmd/phys_output_mod.F90 >phys_output_mod.F90.ori
166#
167 echo Update pbl_surface_mod.F90
168 rm -f pbl_surface_mod.F90
169 sed -e "/^ *INCLUDE *\"temps.h\"/{
170 a\\
171!****************************************************************************************\\
172! Declarations specifiques pour le 1D. A reprendre \\
173    INCLUDE \"flux_arp.h\"
174 }; /^.*REAL *::.*fsens *, *flat/d; /^.*LOGICAL *::.*ok_flux_surf/d; /^.*COMMON.*flux_arp.*/d " ../phylmd/pbl_surface_mod.F90 >pbl_surface_mod.F90.ori
175fi
176#
177############################################################################
178#                                                                          #
179#               CORRECTIONS DE BUGS (corrections necessaires au            #
180#                                    fonctionnement du 1D pour le cas      #
181#                                    où une version trop vieille de LMDZ   #
182#                                    est utilisée)                         #
183#                                                                          #
184############################################################################
185#
186 echo Update coef_diff_turb_mod.F90
187 rm -f coef_diff_turb_mod.F90
188sed -e "/zfr *= *(zq+ratqs\*zq-zqs) *\/ *(2.0\*ratqs\*zq)/{
189c\\
190!!jyg : pour eviter une division par 0                                   \\
191!!!!          zfr = (zq+ratqs*zq-zqs) / (2.0*ratqs*zq)                   \\
192          zfr = (zq+ratqs*zq-zqs) / (2.0*ratqs*MAX(zq,zqs/(1.+ratqs)))
193}" ../phylmd/coef_diff_turb_mod.F90 >coef_diff_turb_mod.F90
194#
195 echo Update physiq.F and suppress lambda_th
196 rm -f physiq.F
197 sed -e "/REAL/s/lambda_th(klon,klev),//;/lambda_th.*=/d" physiq.F.ori >physiq.F
198#
199 echo Update phys_output_mod.F90 and suppress lambda_th
200 rm -f phys_output_mod.F90
201sed -e "/save.*o_lambda_th/d;/CALL histdef3d(iff,clef_stations(iff),/{
202N;/o_lambda_th/d
203}" phys_output_mod.F90.ori >phys_output_mod.F90
204#
205 echo Update phys_output_write.h and suppress lambda_th
206 rm -f phys_output_write.h
207sed -e "/IF *( *o_lambda_th/,/ENDIF/d" ../phylmd/phys_output_write.h >phys_output_write.h
208#
209 mv pbl_surface_mod.F90.ori pbl_surface_mod.F90
210#
211############################################################################
212#                                                                          #
213#               CORRECTIONS pour version en developpement :                #
214#                  fabrication éventuelle de phy1dref et phy1d            #
215#                                                                          #
216#        Partie à effacer si on ne veut pas de ces corrections             #
217#        (par ex. si le 3D les contients dejà, ou s'il est trop ancien)    #
218#                                                                          #
219############################################################################
220#
221 
222#
223if [ -d ${source}/phy1d_source_new ]
224then
225#  D'abord on recopie la physique que l'on vient de construire dans phy1dref
226#
227  echo Creation de phy1dref
228  cd ..
229  cp -a phy1d phy1dref
230  echo Ajout des nouveaux codes-source
231  cp -af ${source}/phy1d_source_new/* phy1d
232  cd phy1d
233#
234  echo Update physiq.F dans phy1d
235  rm -f physiq.F
236  sed -e "/if *(iflag_thermals\.gt\.1) *then/{
237N;/call *calltherm/s/(iflag_thermals\.gt\.1)/(iflag_thermals>=1)/
238};/if *(iflag_thermals>1) *then/{
239N;N;/d_t_lscth.*d_t_lscst/s/(iflag_thermals>1)/(iflag_thermals>=1)/
240}" ../phy1dref/physiq.F >physiq.F
241#
242  echo Update phys_output_mod.F90 dans phy1d
243  rm -f phys_output_mod.F90
244  sed -e "/type(ctrl_out).*o_ovapinit/{
245a\\
246  type(ctrl_out),save :: o_oliq         = ctrl_out((/ 2, 3, 4, 10, 10, 10 /),'oliq')
247};/CALL *histdef3d.*o_ovap%flag/{
248a\\
249          CALL histdef3d(iff,clef_stations(iff),o_oliq%flag,o_oliq%name, \"Condensed water\", \"kg/kg\" )
250};/if *(iflag_thermals\.gt\.1) *THEN/,/endif *!iflag_thermals\.gt\.1/{
251/if *(iflag_thermals\.gt\.1)/{
252N;N;h;/dqlscth.*dqlscst/{
253s/(iflag_thermals\.gt\.1)/(iflag_thermals>=1)/
254}
255};/endif *!iflag_thermals\.gt\.1/{
256x;/dqlscth.*dqlscst/{
257x;s/iflag_thermals\.gt\.1/iflag_thermals>=1/
258}
259}
260}" ../phy1dref/phys_output_mod.F90 >phys_output_mod.F90
261#
262  echo Update phys_output_write.h dans phy1d
263  rm -f phys_output_write.h
264  sed -e "/IF.*o_ovap%flag/,/ENDIF/{
265/ENDIF/{
266a\\
267                                                               \\
268       IF (o_oliq%flag(iff)<=lev_files(iff)) THEN              \\
269      CALL histwrite_phy(nid_files(iff),clef_stations(iff),    \\
270     $                   o_oliq%name,itau_w,ql_seri)            \\
271       ENDIF
272}
273};/IF *(o_mc\%flag(iff)/,/ENDIF/s/(iflag_thermals\.gt\.1)/(iflag_thermals>=1)/;/if *(iflag_thermals>1) *then/,/endif *! *iflag_thermals>1/{
274/if *(iflag_thermals>1)/{
275N;N;N;h;/o_dtlscth\%flag(iff)/s/(iflag_thermals>1)/(iflag_thermals>=1)/
276};/endif *! *iflag_thermals>1/{
277x;/o_dtlscth\%flag(iff)/{
278x;s/iflag_thermals>1/iflag_thermals>=1/
279}
280}
281};/IF *(iflag_thermals\.gt\.1) *THEN/{
282N;N;/o_ftime_th%flag(iff)/s/(iflag_thermals\.gt\.1)/(iflag_thermals>=1)/
283}" ../phy1dref/phys_output_write.h >phys_output_write.h
284#
285fi
286#
287fi
288############################################################################
289#                                                                          #
290#              FIN DES CORRECTIONS                                         #
291#                                                                          #
292############################################################################
293#
294##   Nettoyage
295\rm -r ${source}
296#
297cd ${LMDlibf}/..
298\rm -f makefile
299for i in 1ere 2eme 3eme ; do
300   echo 1ere compilation : makegcm -d 39 -p 1d lmdz1d
301   ./makegcm -d 39 -p 1d lmdz1d
302done
303if [ -f lmdz1d.e ]
304then
305 echo Compilation réussie
306 ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/ayotte
307 ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/case_e
308 ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/eq_rd_cv
309 ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/hapex92_init
310 ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/rico
311 ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/toga
312 ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/twpice
313else
314 echo La compilation a échoué
315 stop
316fi
317#
318echo ========================
319echo '   Simulation test 1D'
320echo ========================
321##echo Execution d un cas d equilibre radiatif-convectif
322##cd ${LMDGCM}/1dcases/eq_rd_cv
323##./xqt.x NPv3.1
324##echo Si la derniere ligne avant \"SIMULATION FINISHED\" est \"Everything is cool!\", alors la simulation a reussi.
325echo Execution de case_e
326cd ${LMDGCM}/1dcases/case_e
327./xqt.x NPv3.1
328echo Si la derniere ligne avant \"SIMULATION FINISHED\" est \"Everything is cool!\", alors la simulation a reussi.
329##echo Execution du cas Hapex92_init
330##cd ${LMDGCM}/1dcases/hapex92_init
331##./xqt.x NPv3.1
332##echo Si la derniere ligne avant \"SIMULATION FINISHED\" est \"Everything is cool!\", alors la simulation a reussi.
333echo 'Execution d une partie de Toga (1mois)'
334cd ${LMDGCM}/1dcases/toga
335./xqt.x NPv3.1
336echo Si la derniere ligne avant \"SIMULATION FINISHED\" est \"Everything is cool!\", alors la simulation a reussi.
337echo Execution de arm_cu
338
339
340armcu=0
341if [ $armcu=1 ] ; then
342cd ${LMDGCM}/1dcases/arm_cu
343./compile.x ; ./compile.x ; ./compile.x
344ln -s lmdz1d_L40.e lmdz1d.e
345./xqt.x NPv3.1
346echo Si la derniere ligne avant \"SIMULATION FINISHED\" est \"Everything is cool!\", alors la simulation a reussi.
347fi
348
349
350
Note: See TracBrowser for help on using the repository browser.