1 | #!/bin/bash |
---|
2 | |
---|
3 | #set -vx |
---|
4 | |
---|
5 | ########################################################################### |
---|
6 | # Author : Laurent Fairhead et Frédéric Hourdin |
---|
7 | # Usage : install_lmdz.sh -help |
---|
8 | # |
---|
9 | # bash installation script of the LMDZ model on different computer types : |
---|
10 | # Linux PC, "mesocentre" (IPSL-UPMC, IPSL-X), super-computer (IDRIS) |
---|
11 | # |
---|
12 | # The model is downloaded in the following directory tree |
---|
13 | # $MODEL/modipsl/modeles/... |
---|
14 | # using the "modipsl" infrastructure created by the "IPSL" |
---|
15 | # for coupled (atmosphere/ocean/vegetation/chemistry) climate modeling |
---|
16 | # activities. |
---|
17 | # Here we only download atmospheric (LMDZ) and vegetation (ORCHIDEE) |
---|
18 | # components. |
---|
19 | # |
---|
20 | # The sources of the models can be found in the "modeles" directory. |
---|
21 | # In the present case, LMDZ, ORCHIDEE, and IOIPSL or XIOS (handling of input-outputs |
---|
22 | # using the NetCDF library). |
---|
23 | # |
---|
24 | # The script downloads various source files (including a version of NetCDF) |
---|
25 | # and utilities, compiles the model, and runs a test simulation in a |
---|
26 | # minimal configuration. |
---|
27 | # |
---|
28 | # Prerequisites : pgf90/gfortran, bash or ksh, wget , gunzip, tar, ... |
---|
29 | # |
---|
30 | # Modif 18/11/2011 |
---|
31 | # changes for option real 8. |
---|
32 | # We compile with -r8 (or equivalent) and -DNC_DOUBLE for the GCM |
---|
33 | # but with -r4 for netcdf. Variable real must be set to |
---|
34 | # r4 or r8 at the beginning of the script below. |
---|
35 | # |
---|
36 | ########################################################################### |
---|
37 | |
---|
38 | echo install_lmdz.sh DEBUT `date` |
---|
39 | set -e |
---|
40 | |
---|
41 | ################################################################ |
---|
42 | # Choice of installation options |
---|
43 | ################################################################ |
---|
44 | |
---|
45 | ################################################################ |
---|
46 | # A function to fetch files either locally or on the internet |
---|
47 | ################################################################ |
---|
48 | function myget { #1st and only argument should be file name |
---|
49 | # Path on local computer where to look for the datafile |
---|
50 | if [ -f /u/lmdz/WWW/LMDZ/pub/$1 ] ; then |
---|
51 | \cp -f -p /u/lmdz/WWW/LMDZ/pub/$1 . |
---|
52 | elif [ -f ~/LMDZ/pub/$1 ] ; then |
---|
53 | \cp -f -p ~/LMDZ/pub/$1 . |
---|
54 | else |
---|
55 | wget --no-check-certificate -nv http://lmdz.lmd.jussieu.fr/pub/$1 |
---|
56 | save_pub_locally=0 |
---|
57 | if [ $save_pub_locally = 1 ] ; then # saving wget files on ~/LMDZ/pub |
---|
58 | dir=~/LMDZ/pub/`dirname $1` ; mkdir -p $dir ; cp -r `basename $1` $dir |
---|
59 | fi |
---|
60 | fi |
---|
61 | } |
---|
62 | |
---|
63 | # 04_2021 : tester si r4 marche encore ! |
---|
64 | #real=r4 |
---|
65 | real=r8 |
---|
66 | |
---|
67 | |
---|
68 | ######################################################################### |
---|
69 | # Valeur par défaut des parametres |
---|
70 | ######################################################################### |
---|
71 | svn="" |
---|
72 | #version=trunk |
---|
73 | version=20220131.trunk |
---|
74 | |
---|
75 | getlmdzor=1 |
---|
76 | netcdf=0 # 1: for automatic installation; |
---|
77 | # or 0: do not install NetCDF and look for it in standard locations; |
---|
78 | # or absolute path: look for NetCDF there |
---|
79 | check_linux=1 |
---|
80 | ioipsl=1 |
---|
81 | bench=1 |
---|
82 | pclinux=1 |
---|
83 | pcmac=0 # default: not on a Mac |
---|
84 | compiler=gfortran |
---|
85 | SCM=0 |
---|
86 | # surface/vegetation scheme treatment |
---|
87 | # controlled by the single variable veget which can have the following values |
---|
88 | # - NONE: bucket scheme (default) |
---|
89 | # - CMIP6: orchidee version used in CMIP exercise, rev 5661 |
---|
90 | # - number: orchidee version number |
---|
91 | veget=NONE |
---|
92 | # choose the resolution for the bench runs |
---|
93 | # grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE) |
---|
94 | # 96x71x19 standard configuration |
---|
95 | grid_resolution=144x142x79 |
---|
96 | grid_resolution=96x95x39 |
---|
97 | grid_resolution=48x36x19 |
---|
98 | grid_resolution=32x32x39 |
---|
99 | # choose the physiq version you want to test |
---|
100 | #physiq=NPv6.0.14splith |
---|
101 | physiq= |
---|
102 | |
---|
103 | ## parallel can take the values none/mpi/omp/mpi_omp |
---|
104 | parallel=mpi_omp |
---|
105 | parallel=none |
---|
106 | idris_acct=lmd |
---|
107 | OPT_GPROF="" |
---|
108 | OPT_MAKELMDZ="" |
---|
109 | MODEL="" |
---|
110 | |
---|
111 | ## also compile XIOS? (and more recent NetCDF/HDF5 libraries) Default=no |
---|
112 | with_xios="n" |
---|
113 | opt_makelmdz_xios="" |
---|
114 | |
---|
115 | ## compile with oldrad/rrtm/ecrad radiatif code (Default=rrtm) |
---|
116 | rad=rrtm |
---|
117 | |
---|
118 | ## compile_with_fcm=1 : use makelmdz_fcm (1) or makelmdz (0) |
---|
119 | compile_with_fcm=1 |
---|
120 | |
---|
121 | #Compilation with Cosp (cosp=NONE/v1/v2 ; default=NONE) |
---|
122 | cosp=NONE |
---|
123 | opt_cosp="" |
---|
124 | |
---|
125 | # Check if on a Mac |
---|
126 | if [ `uname` = "Darwin" ] |
---|
127 | then |
---|
128 | pcmac=1 |
---|
129 | export MAKE=make |
---|
130 | fi |
---|
131 | #echo "pcmac="$pcmac |
---|
132 | |
---|
133 | env_file="" |
---|
134 | |
---|
135 | ######################################################################### |
---|
136 | # Options interactives |
---|
137 | ######################################################################### |
---|
138 | while (($# > 0)) |
---|
139 | do |
---|
140 | case $1 in |
---|
141 | "-h") cat <<........fin |
---|
142 | $0 [ -v version ] [ -r svn_release ] |
---|
143 | [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ] |
---|
144 | [-name LOCAL_MODEL_NAME] [-gprof] [-opt_makelmdz] [-rad RADIATIF] |
---|
145 | |
---|
146 | -v "version" like 20150828.trunk |
---|
147 | see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk |
---|
148 | |
---|
149 | -r "svn_release" : either the svn release number or "last" |
---|
150 | |
---|
151 | -compiler gfortran|ifort|pgf90 (default: gfortran) |
---|
152 | |
---|
153 | -parallel PARA : can be mpi_omp (mpi with openMP) or none (for sequential) |
---|
154 | |
---|
155 | -d GRID_RESOLUTION should be among the available benchs if -bench 1 |
---|
156 | among which : 48x36x19, 48x36x39 |
---|
157 | if wanting to run a bench simulation in addition to compilation |
---|
158 | default : 48x36x19 |
---|
159 | |
---|
160 | -bench activating the bench or not (0/1). Default 1 |
---|
161 | |
---|
162 | -name LOCAL_MODEL_NAME : default = LMDZversion.release |
---|
163 | |
---|
164 | -netcdf 0, 1 or PATH |
---|
165 | 0: do not download NetCDF, look for it in standard locations |
---|
166 | 1: download and compile NetCDF |
---|
167 | PATH: full path to an existing installed NetCDF library |
---|
168 | |
---|
169 | -xios also download and compile the XIOS library |
---|
170 | (requires the NetCDF4-HDF5 library, also installed by default) |
---|
171 | (requires to also have -parallel mpi_omp) |
---|
172 | |
---|
173 | -gprof to compile with -pg to enable profiling with gprof |
---|
174 | |
---|
175 | -cosp to run without our with cospv1 or cospv2 [none/v1/v2] |
---|
176 | |
---|
177 | -rad RADIATIF can be oldrad, rrtm or ecrad radiatif code |
---|
178 | |
---|
179 | -nofcm to compile without fcm |
---|
180 | |
---|
181 | -SCM install 1D version automatically |
---|
182 | |
---|
183 | -debug compile everything in debug mode |
---|
184 | |
---|
185 | -opt_makelmdz to call makelmdz or makelmdz_fcm with additional options |
---|
186 | |
---|
187 | -physiq to choose which physics package to use |
---|
188 | |
---|
189 | -env_file specify an arch.env file to overwrite the existing one |
---|
190 | |
---|
191 | -veget surface model to run [NONE/CMIP6/xxxx] |
---|
192 | |
---|
193 | ........fin |
---|
194 | exit ;; |
---|
195 | "-v") version=$2 ; shift ; shift ;; |
---|
196 | "-r") svn=$2 ; shift ; shift ;; |
---|
197 | "-compiler") compiler=$2 |
---|
198 | case $compiler in |
---|
199 | "gfortran"|"ifort"|"pgf90") compiler=$2 ; shift ; shift ;; |
---|
200 | *) echo "Only gfortran , ifort or pgf90 for the compiler option" ; exit |
---|
201 | esac ;; |
---|
202 | "-d") grid_resolution=$2 ; shift ; shift ;; |
---|
203 | "-gprof") OPT_GPROF="-pg" ; shift ;; |
---|
204 | "-cosp") cosp=$2 |
---|
205 | case $cosp in |
---|
206 | "none"|"v1"|"v2") cosp=$2 ; shift ; shift ;; |
---|
207 | *) echo Only none v1 v2 for cosp option ; exit |
---|
208 | esac ;; |
---|
209 | "-nofcm") compile_with_fcm=0 ; shift ;; |
---|
210 | "-SCM") SCM=1 ; shift ;; |
---|
211 | "-opt_makelmdz") OPT_MAKELMDZ="$2" ; shift ; shift ;; |
---|
212 | "-rrtm") rrtm="$2" ; if [ "$2" = "false" ] ; then rad="oldrad" ; else rad="rrtm" ; fi ; shift ; shift ;; |
---|
213 | "-rad") rad=$2 |
---|
214 | case $rad in |
---|
215 | "oldrad"|"rrtm"|"ecrad") rad=$2 ; shift ; shift ;; |
---|
216 | *) echo Only oldrad rrtm ecrad for rad option ; exit |
---|
217 | esac ;; |
---|
218 | "-parallel") parallel=$2 |
---|
219 | case $parallel in |
---|
220 | "none"|"mpi"|"omp"|"mpi_omp") parallel=$2 ; shift ; shift ;; |
---|
221 | *) echo Only none mpi omp mpi_omp for the parallel option ; exit |
---|
222 | esac ;; |
---|
223 | "-bench") bench=$2 ; shift ; shift ;; |
---|
224 | "-debug") optim=-debug ; shift ;; |
---|
225 | "-name") MODEL=$2 ; shift ; shift ;; |
---|
226 | "-netcdf") netcdf=$2 ; shift ; shift ;; |
---|
227 | "-physiq") physiq=$2 ; shift ; shift ;; |
---|
228 | "-xios") with_xios="y" ; shift ;; |
---|
229 | "-env_file") env_file=$2 ; shift ; shift ;; |
---|
230 | "-veget") veget=$2 ; shift ; shift ;; |
---|
231 | *) ./install_lmdz.sh -h ; exit |
---|
232 | esac |
---|
233 | done |
---|
234 | |
---|
235 | # Option de compilation du rayonnement : depend de $mysvn ><= r4185, sera donc definie plus bas |
---|
236 | #opt_rad="" |
---|
237 | #case $rad in |
---|
238 | # rrtm) opt_rad="-rad rrtm" ;; |
---|
239 | # ecrad) opt_rad="-rad ecrad" ;; |
---|
240 | #esac |
---|
241 | |
---|
242 | |
---|
243 | # Option de compilation pour Cosp |
---|
244 | opt_cosp="" |
---|
245 | case cosp in |
---|
246 | v1) opt_cosp="-cosp true" ;; |
---|
247 | v2) opt_cosp="-cospv2 true" ;; |
---|
248 | esac |
---|
249 | |
---|
250 | # Check on veget version |
---|
251 | #if [ "$veget" != 'NONE' -a "$veget" != "CMIP6" -a "$veget" != +([0-9]) ] ; then |
---|
252 | if [ $veget != 'NONE' -a $veget != "CMIP6" ] ; then |
---|
253 | re='^[0-9]+$' |
---|
254 | if ! [[ $veget =~ $re ]] ; then |
---|
255 | echo 'Valeur de l option veget non valable' |
---|
256 | exit |
---|
257 | fi |
---|
258 | fi |
---|
259 | |
---|
260 | #Define veget-related suffix for gcm name |
---|
261 | if [ "$veget" = 'NONE' ] ; then |
---|
262 | suff_orc='' |
---|
263 | #For use with tutorial, orchidee_rev is also defined (will be written in surface_env at the end of the script) |
---|
264 | orchidee_rev='' |
---|
265 | else |
---|
266 | suff_orc='_orch' |
---|
267 | fi |
---|
268 | |
---|
269 | |
---|
270 | if [ $parallel = none ] ; then sequential=1; suff_exe='_seq' ; else sequential=0; suff_exe='_para_mem' ; fi |
---|
271 | |
---|
272 | #Chemin pour placer le modele |
---|
273 | if [ "$MODEL" = "" ] ; then MODEL=./LMDZ$version$svn$optim ; fi |
---|
274 | |
---|
275 | |
---|
276 | arch=local |
---|
277 | |
---|
278 | |
---|
279 | if [ $compiler = g95 ] ; then echo g95 is not supported anymore ; exit ; fi |
---|
280 | |
---|
281 | ################################################################ |
---|
282 | # Specificite des machines |
---|
283 | ################################################################ |
---|
284 | |
---|
285 | hostname=`hostname` |
---|
286 | if [ "$pclinux" = 1 ] ; then o_ins_make="-t g95" ; else o_ins_make="" ; fi |
---|
287 | |
---|
288 | case ${hostname:0:5} in |
---|
289 | |
---|
290 | jean-) compiler="mpiifort" ; |
---|
291 | par_comp="mpiifort" ; |
---|
292 | o_ins_make="-t jeanzay" ; |
---|
293 | make=gmake ; |
---|
294 | module purge |
---|
295 | module load intel-compilers/19.0.4 ; |
---|
296 | #module load intel-mpi/19.0.4 ; |
---|
297 | #module load intel-mkl/19.0.4 ; |
---|
298 | module load hdf5/1.10.5-mpi ; |
---|
299 | module load netcdf/4.7.2-mpi ; |
---|
300 | module load netcdf-fortran/4.5.2-mpi ; |
---|
301 | module load subversion/1.9.7 ; |
---|
302 | export NETCDF_LIBDIR=./ |
---|
303 | export NETCDFFORTRAN_INCDIR=./ |
---|
304 | export NETCDFFORTRAN_LIBDIR=./ |
---|
305 | arch=X64_JEANZAY ;; |
---|
306 | |
---|
307 | cicla|camel) compiler="gfortran" ; |
---|
308 | module load netcdf4/4.3.3.1-gfortran; |
---|
309 | netcdf=/opt/netcdf43/gfortran |
---|
310 | |
---|
311 | if [ $parallel != none ] ; then |
---|
312 | module load openmpi/1.6.5-gfortran ; |
---|
313 | root_mpi=$MPI_HOME ; |
---|
314 | path_mpi=$root_mpi/bin ; |
---|
315 | par_comp=${path_mpi}/mpif90 ; |
---|
316 | mpirun=${path_mpi}/mpirun ; |
---|
317 | fi ; |
---|
318 | arch=local ; |
---|
319 | make=make ; |
---|
320 | o_ins_make="-t g95" ;; |
---|
321 | |
---|
322 | *) if [ $parallel = none -o -f /usr/bin/mpif90 ] ; then |
---|
323 | path_mpi=`which mpif90 | sed -e s:/mpif90::` ; |
---|
324 | if [ -d /usr/lib64/openmpi ] ; then |
---|
325 | root_mpi="/usr/lib64/openmpi" |
---|
326 | else |
---|
327 | root_mpi="/usr" |
---|
328 | fi |
---|
329 | else |
---|
330 | echo "Cannot find mpif90" ; |
---|
331 | if [ $parallel = none ] ; then exit ; fi ; |
---|
332 | fi ; |
---|
333 | if [ $parallel != none ] ; then |
---|
334 | root_mpi=$(which mpif90 | sed -e s:/bin/mpif90::) |
---|
335 | path_mpi=$(which mpif90 | sed -e s:/mpif90::) |
---|
336 | export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH |
---|
337 | fi |
---|
338 | par_comp=${path_mpi}/mpif90 ; |
---|
339 | mpirun=${path_mpi}/mpirun ; |
---|
340 | arch=local ; |
---|
341 | make=make ; |
---|
342 | o_ins_make="-t g95" |
---|
343 | esac |
---|
344 | |
---|
345 | # Flags for parallelism: |
---|
346 | if [ $parallel != none ] ; then |
---|
347 | # MPI_LD are the flags needed for linking with MPI |
---|
348 | MPI_LD="-L${root_mpi}/lib -lmpi" |
---|
349 | if [ "$compiler" = "gfortran" ] ; then |
---|
350 | # MPI_FLAGS are the flags needed for compilation with MPI |
---|
351 | MPI_FLAGS="-fcray-pointer" |
---|
352 | # OMP_FLAGS are the flags needed for compilation with OpenMP |
---|
353 | OMP_FLAGS="-fopenmp -fcray-pointer" |
---|
354 | # OMP_LD are the flags needed for linking with OpenMP |
---|
355 | OMP_LD="-fopenmp" |
---|
356 | elif [ "$compiler" = "ifort" ] ; then |
---|
357 | MPI_FLAGS="" |
---|
358 | OMP_FLAGS="-openmp" |
---|
359 | OMP_LD="-openmp" |
---|
360 | else # pgf90 |
---|
361 | MPI_FLAGS="" |
---|
362 | OMP_FLAGS="-mp" |
---|
363 | OMP_LD="-mp" |
---|
364 | fi |
---|
365 | fi |
---|
366 | |
---|
367 | ##################################################################### |
---|
368 | # Test for old gfortran compilers |
---|
369 | # If the compiler is too old (older than 4.3.x) we test if the |
---|
370 | # temporary gfortran44 patch is available on the computer in which |
---|
371 | # case the compiler is changed from gfortran to gfortran44 |
---|
372 | # Must be aware than parallelism can not be activated in this case |
---|
373 | ##################################################################### |
---|
374 | |
---|
375 | if [ "$compiler" = "gfortran" ] ; then |
---|
376 | gfortran=gfortran |
---|
377 | gfortranv=`gfortran --version | \ |
---|
378 | head -1 | awk ' { print $NF } ' | awk -F. ' { print $1 * 10 + $2 } '` |
---|
379 | if [ $gfortranv -le 43 ] ; then |
---|
380 | echo ERROR : Your gfortran compiler is too old |
---|
381 | echo 'Please choose a new one (ifort) and change the line' |
---|
382 | echo compiler=xxx |
---|
383 | echo in the install_lmdz.sh script and rerun it |
---|
384 | if [ `which gfortran44 | wc -w` -ne 0 ] ; then |
---|
385 | gfortran=gfortran44 |
---|
386 | else |
---|
387 | echo gfotran trop vieux ; exit |
---|
388 | fi |
---|
389 | fi |
---|
390 | compiler=$gfortran |
---|
391 | fi |
---|
392 | ##################################################################### |
---|
393 | |
---|
394 | ## if also compiling XIOS, parallel must be mpi_omp |
---|
395 | if [ "$with_xios" = "y" -a "$parallel" != "mpi_omp" ] ; then |
---|
396 | echo "Error, you must set -parallel mpi_omp if you want XIOS" |
---|
397 | exit |
---|
398 | fi |
---|
399 | |
---|
400 | if [ "$with_xios" = "y" ] ; then |
---|
401 | opt_makelmdz_xios="-io xios" |
---|
402 | fi |
---|
403 | |
---|
404 | if [ "$cosp" = "v2" -a "$with_xios" = "n" ] ; then |
---|
405 | echo "Error, Cospv2 cannot run without Xios" |
---|
406 | exit |
---|
407 | fi |
---|
408 | |
---|
409 | echo '################################################################' |
---|
410 | echo Choix des options de compilation |
---|
411 | echo '################################################################' |
---|
412 | |
---|
413 | export FC=$compiler |
---|
414 | export F90=$compiler |
---|
415 | export F77=$compiler |
---|
416 | export CPPFLAGS= |
---|
417 | OPTIMNC=$OPTIM |
---|
418 | BASE_LD="$OPT_GPROF" |
---|
419 | OPTPREC="$OPT_GPROF" |
---|
420 | ARFLAGS="rs" ; if [ -f /etc/issue ] ; then if [ "`grep -i ubuntu /etc/issue`" != "" ] ; then if [ "`grep -i ubuntu /etc/issue | awk ' { print $2 } ' | cut -d. -f1`" -ge 16 ] ; then ARFLAGS="rU" ; fi ; fi ; fi |
---|
421 | |
---|
422 | |
---|
423 | |
---|
424 | if [ "$compiler" = "$gfortran" ] ; then |
---|
425 | OPTIM='-O3' |
---|
426 | OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=snan" |
---|
427 | OPTDEV="-Wall -fbounds-check" |
---|
428 | fmod='I ' |
---|
429 | OPTPREC="$OPTPREC -cpp -ffree-line-length-0" |
---|
430 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE" ; fi |
---|
431 | export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
432 | export FFLAGS=" $OPTIMNC" |
---|
433 | export CC=gcc |
---|
434 | export CXX=g++ |
---|
435 | export fpp_flags="-P -C -traditional -ffreestanding" |
---|
436 | |
---|
437 | elif [ $compiler = mpif90 ] ; then |
---|
438 | OPTIM='-O3' |
---|
439 | OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all" |
---|
440 | OPTDEV="-Wall -fbounds-check" |
---|
441 | BASE_LD="$BASE_LD -lblas" |
---|
442 | fmod='I ' |
---|
443 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer" ; fi |
---|
444 | export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
445 | export FFLAGS=" $OPTIMNC" |
---|
446 | export CC=gcc |
---|
447 | export CXX=g++ |
---|
448 | |
---|
449 | elif [ $compiler = pgf90 ] ; then |
---|
450 | OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align' |
---|
451 | OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback' |
---|
452 | OPTDEV='-g -Mbounds -Ktrap=fp -traceback' |
---|
453 | fmod='module ' |
---|
454 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE" ; fi |
---|
455 | export CPPFLAGS="-DpgiFortran" |
---|
456 | export CC=pgcc |
---|
457 | export CFLAGS="-O2 -Msignextend" |
---|
458 | export CXX=pgCC |
---|
459 | export CXXFLAGS="-O2 -Msignextend" |
---|
460 | export FFLAGS="-O2 $OPTIMNC" |
---|
461 | export F90FLAGS="-O2 $OPTIMNC" |
---|
462 | compile_with_fcm=1 |
---|
463 | |
---|
464 | elif [ $compiler = ifort ] ; then |
---|
465 | OPTIM="-O2 -fp-model strict -ip -align all " |
---|
466 | OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check" |
---|
467 | OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check" |
---|
468 | fmod='module ' |
---|
469 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi |
---|
470 | export CPP="icc -E" |
---|
471 | export FFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
472 | export FCFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
473 | export CC=icc |
---|
474 | export CFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
475 | export CXX=icpc |
---|
476 | export CXXFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
477 | export fpp_flags="-P -traditional" |
---|
478 | # Pourquoi forcer la compilation fcm. Marche mieux sans |
---|
479 | #compile_with_fcm=1 |
---|
480 | |
---|
481 | elif [ $compiler = mpiifort ] ; then |
---|
482 | echo on ne fait rien la |
---|
483 | # Pourquoi forcer la compilation fcm. Marche mieux sans |
---|
484 | #compile_with_fcm=1 |
---|
485 | |
---|
486 | else |
---|
487 | echo unexpected compiler $compiler ; exit |
---|
488 | fi |
---|
489 | |
---|
490 | OPTIMGCM="$OPTIM $OPTPREC" |
---|
491 | |
---|
492 | hostname=`hostname` |
---|
493 | |
---|
494 | ########################################################################## |
---|
495 | # If installing on known machines such as Jean-Zay at IDRIS, |
---|
496 | # don't check for available software and don't install netcdf |
---|
497 | if [ ${hostname:0:5} = jean- ] ; then |
---|
498 | netcdf=0 # no need to recompile netcdf, alreday available |
---|
499 | check_linux=0 |
---|
500 | pclinux=0 |
---|
501 | ioipsl=0 # no need to recompile ioipsl, already available |
---|
502 | #netcdf="/smplocal/pub/NetCDF/4.1.3" |
---|
503 | compiler="mpiifort" |
---|
504 | fmod='module ' |
---|
505 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -i4 -r8 -DNC_DOUBLE" ; fi |
---|
506 | OPTIM="-auto -align all -O2 -fp-model strict -xHost " |
---|
507 | OPTIMGCM="$OPTIM $OPTPREC" |
---|
508 | fi |
---|
509 | ########################################################################## |
---|
510 | |
---|
511 | |
---|
512 | mkdir -p $MODEL |
---|
513 | echo $MODEL |
---|
514 | MODEL=`( cd $MODEL ; pwd )` # to get absolute path, if necessary |
---|
515 | |
---|
516 | |
---|
517 | echo '################################################################' |
---|
518 | if [ "$check_linux" = 1 ] ; then |
---|
519 | echo Check if required software is available |
---|
520 | echo '################################################################' |
---|
521 | |
---|
522 | #### Ehouarn: test if the required shell is available |
---|
523 | #### Maj FH-LF-AS 2021-04 : default=bash ; if bash missing, use ksh |
---|
524 | use_shell="bash" # default |
---|
525 | if [ "`which bash`" = "" ] ; then |
---|
526 | echo "no bash ; we will use ksh" |
---|
527 | use_shell="ksh" |
---|
528 | if [ "`which ksh`" = "" ] ; then |
---|
529 | echo "bash (or ksh) needed!! Install it!" |
---|
530 | exit |
---|
531 | fi |
---|
532 | fi |
---|
533 | |
---|
534 | for logiciel in wget tar gzip make $compiler gcc cmake ; do |
---|
535 | if [ "`which $logiciel`" = "" ] ; then |
---|
536 | echo You must first install $logiciel on your system |
---|
537 | exit |
---|
538 | fi |
---|
539 | done |
---|
540 | |
---|
541 | if [ $pclinux = 1 ] ; then |
---|
542 | cd $MODEL |
---|
543 | cat <<eod > tt.f90 |
---|
544 | print*,'coucou' |
---|
545 | end |
---|
546 | eod |
---|
547 | $compiler tt.f90 -o a.out |
---|
548 | ./a.out >| tt |
---|
549 | if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then |
---|
550 | echo problem installing with compiler $compiler ; exit ; fi |
---|
551 | \rm tt a.out tt.f90 |
---|
552 | fi |
---|
553 | fi |
---|
554 | |
---|
555 | ########################################################################### |
---|
556 | if [ $getlmdzor = 1 -a ! -d $MODEL/modipsl ] ; then |
---|
557 | ########################################################################### |
---|
558 | echo '##########################################################' |
---|
559 | echo Download a slightly modified version of LMDZ |
---|
560 | echo '##########################################################' |
---|
561 | cd $MODEL |
---|
562 | myget src/modipsl.$version.tar.gz |
---|
563 | echo install_lmdz.sh wget_OK `date` |
---|
564 | gunzip modipsl.$version.tar.gz |
---|
565 | tar xf modipsl.$version.tar |
---|
566 | \rm modipsl.$version.tar |
---|
567 | fi |
---|
568 | |
---|
569 | ########################################################################### |
---|
570 | if [ $netcdf = 1 -a ! -d $MODEL/netcdf ] ; then |
---|
571 | ########################################################################### |
---|
572 | cd $MODEL |
---|
573 | netcdflog=`pwd`/netcdf.log |
---|
574 | echo '##########################################################' |
---|
575 | echo Compiling the Netcdf library |
---|
576 | echo '##########################################################' |
---|
577 | echo log file : $netcdflog |
---|
578 | if [ "$with_xios" = "n" ] ; then |
---|
579 | myget import/install_netcdf4_hdf5_seq.bash |
---|
580 | chmod +x install_netcdf4_hdf5_seq.bash |
---|
581 | |
---|
582 | if [ "$compiler" = "gfortran" ] |
---|
583 | then |
---|
584 | ./install_netcdf4_hdf5_seq.bash -prefix $MODEL/netcdf4_hdf5_seq \ |
---|
585 | -compiler gnu > $netcdflog 2>&1 |
---|
586 | elif [ "$compiler" = "ifort" ] |
---|
587 | then |
---|
588 | ./install_netcdf4_hdf5_seq.bash -prefix $MODEL/netcdf4_hdf5_seq \ |
---|
589 | -compiler intel > $netcdflog 2>&1 |
---|
590 | else |
---|
591 | echo "unexpected compiler $compiler" ; exit |
---|
592 | fi |
---|
593 | |
---|
594 | # LF rajout d'une verrue, pour une raison non encore expliquee, |
---|
595 | # la librairie est parfois rangée dans lib64 et non dans lib |
---|
596 | # par certains compilateurs |
---|
597 | if [ ! -e lib -a -d lib64 ] ; then ln -s lib64 lib; fi |
---|
598 | else |
---|
599 | # download and compile hdf5 and netcdf, etc. using the install_netcdf4_hdf5.bash script |
---|
600 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_netcdf4_hdf5.bash |
---|
601 | myget import/install_netcdf4_hdf5.bash |
---|
602 | chmod u=rwx install_netcdf4_hdf5.bash |
---|
603 | if [ "$compiler" = "gfortran" ] ; then |
---|
604 | ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC gcc -FC gfortran -CXX g++ -MPI $root_mpi > $netcdflog 2>&1 |
---|
605 | elif [ "$compiler" = "ifort" ] ; then |
---|
606 | ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC icc -FC ifort -CXX icpc -MPI $root_mpi > $netcdflog 2>&1 |
---|
607 | elif [ "$compiler" = "pgf90" ] ; then |
---|
608 | ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC pgcc -FC pgf90 -CXX pgCC -MPI $root_mpi > $netcdflog 2>&1 |
---|
609 | else |
---|
610 | echo "unexpected compiler $compiler" ; exit |
---|
611 | fi |
---|
612 | fi # of if [ "$with_xios" = "n" ] |
---|
613 | echo install_lmdz.sh netcdf_OK `date` |
---|
614 | fi # of if [ $netcdf = 1 ] |
---|
615 | |
---|
616 | # ncdfdir contains the directory where netcdf is installed |
---|
617 | if [ $netcdf = 1 ] ; then |
---|
618 | if [ "$with_xios" = "y" ] ; then |
---|
619 | ncdfdir=$MODEL/netcdf4_hdf5 |
---|
620 | else |
---|
621 | ncdfdir=$MODEL/netcdf4_hdf5_seq |
---|
622 | fi |
---|
623 | elif [ $netcdf = 0 ] |
---|
624 | then |
---|
625 | ncdfdir=/usr |
---|
626 | else |
---|
627 | ncdfdir=$netcdf |
---|
628 | fi |
---|
629 | |
---|
630 | #========================================================================= |
---|
631 | if [[ ! -f $MODEL/modipsl/lib/libioipsl.a ]] |
---|
632 | then |
---|
633 | if [ $ioipsl = 1 ] ; then |
---|
634 | #========================================================================= |
---|
635 | echo OK ioipsl=$ioipsl |
---|
636 | echo '##########################################################' |
---|
637 | echo 'Installing MODIPSL, the installation package manager for the ' |
---|
638 | echo 'IPSL models and tools' |
---|
639 | echo '##########################################################' |
---|
640 | echo `date` |
---|
641 | |
---|
642 | cd $MODEL/modipsl |
---|
643 | \rm -rf lib/* |
---|
644 | cd util |
---|
645 | cp AA_make.gdef AA_make.orig |
---|
646 | F_C="$compiler -c " ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then F_C="$compiler -c -cpp " ; fi |
---|
647 | if [ "$compiler" = "pgf90" ] ; then F_C="$compiler -c -Mpreprocess" ; fi |
---|
648 | sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp |
---|
649 | sed -e "s:F_L = g95:F_L = $compiler:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \ |
---|
650 | -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ |
---|
651 | -e 's:g95.*.NCDF_INC.*.$:g95 NCDF_INC= '"$ncdfdir"'/include:' \ |
---|
652 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \ |
---|
653 | -e 's:g95 L_O =:g95 L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \ |
---|
654 | -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \ |
---|
655 | -e 's:#-Q- g95 M_K = gmake:#-Q- g95 M_K = make:' \ |
---|
656 | tmp >| AA_make.gdef |
---|
657 | |
---|
658 | if [ $pcmac == 1 ] |
---|
659 | then |
---|
660 | cp AA_make.gdef tmp |
---|
661 | sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef |
---|
662 | fi |
---|
663 | |
---|
664 | |
---|
665 | # We use lines for g95 even for the other compilers to run ins_make |
---|
666 | if [ "$use_shell" = "ksh" ] ; then |
---|
667 | ./ins_make $o_ins_make |
---|
668 | else # bash |
---|
669 | sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash |
---|
670 | if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar |
---|
671 | echo 'Warning jean-zay not in AA_make.gdef' |
---|
672 | echo 'Think about updating' |
---|
673 | exit 1 |
---|
674 | fi |
---|
675 | |
---|
676 | chmod u=rwx ins_make.bash |
---|
677 | ./ins_make.bash $o_ins_make |
---|
678 | fi # of if [ "$use_shell" = "ksh" ] |
---|
679 | |
---|
680 | echo install_lmdz.sh MODIPSL_OK `date` |
---|
681 | |
---|
682 | cd $MODEL/modipsl/modeles/IOIPSL/src |
---|
683 | ioipsllog=`pwd`/ioipsl.log |
---|
684 | echo '##########################################################' |
---|
685 | echo 'Compiling IOIPSL, the interface library with Netcdf' |
---|
686 | echo '##########################################################' |
---|
687 | echo `date` |
---|
688 | echo log file : $ioipsllog |
---|
689 | |
---|
690 | if [ "$use_shell" = "bash" ] ; then |
---|
691 | cp Makefile Makefile.ksh |
---|
692 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
---|
693 | fi |
---|
694 | # if [ "$pclinux" = 1 ] ; then |
---|
695 | # Build IOIPSL modules and library |
---|
696 | $make clean |
---|
697 | $make > $ioipsllog 2>&1 |
---|
698 | if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then # copy module files to lib |
---|
699 | cp -f *.mod ../../../lib |
---|
700 | fi |
---|
701 | # Build IOIPSL tools (ie: "rebuild", if present) |
---|
702 | if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then |
---|
703 | cd $MODEL/modipsl/modeles/IOIPSL/tools |
---|
704 | # adapt Makefile & rebuild script if in bash |
---|
705 | if [ "$use_shell" = "bash" ] ; then |
---|
706 | cp Makefile Makefile.ksh |
---|
707 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
---|
708 | cp rebuild rebuild.ksh |
---|
709 | sed -e 's:/bin/ksh:/bin/bash:g' \ |
---|
710 | -e 's:print -u2:echo:g' \ |
---|
711 | -e 's:print:echo:g' rebuild.ksh > rebuild |
---|
712 | fi |
---|
713 | $make clean |
---|
714 | $make > $ioipsllog 2>&1 |
---|
715 | fi |
---|
716 | # fi # of if [ "$pclinux" = 1 ] |
---|
717 | |
---|
718 | else # of if [ $ioipsl = 1 ] |
---|
719 | if [ ${hostname:0:5} = jean- ] ; then |
---|
720 | cd $MODEL/modipsl |
---|
721 | cd util |
---|
722 | if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then |
---|
723 | echo 'Warning jean-zay not in AA_make.gdef' |
---|
724 | echo 'Think about updating' |
---|
725 | exit 1 |
---|
726 | fi |
---|
727 | ./ins_make $o_ins_make |
---|
728 | # Compile IOIPSL on jean-zay |
---|
729 | cd $MODEL/modipsl/modeles/IOIPSL/src |
---|
730 | gmake > ioipsl.log |
---|
731 | cd $MODEL/modipsl/modeles/IOIPSL/tools |
---|
732 | gmake > ioipsl.log |
---|
733 | |
---|
734 | fi |
---|
735 | echo install_lmdz.sh ioipsl_OK `date` |
---|
736 | fi # of if [ $ioipsl = 1 ] |
---|
737 | fi |
---|
738 | # Saving ioipsl lib for possible parallel compile |
---|
739 | cd $MODEL/modipsl |
---|
740 | tar cf ioipsl.tar lib/ bin/ |
---|
741 | |
---|
742 | #========================================================================= |
---|
743 | if [ "$with_xios" = "y" ] ; then |
---|
744 | echo '##########################################################' |
---|
745 | echo 'Compiling XIOS' |
---|
746 | echo '##########################################################' |
---|
747 | cd $MODEL/modipsl/modeles |
---|
748 | xioslog=`pwd`/xios.log |
---|
749 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_xios.bash |
---|
750 | myget import/install_xios.bash |
---|
751 | chmod u=rwx install_xios.bash |
---|
752 | if [ ${hostname:0:5} = jean- ] ; then |
---|
753 | svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5 XIOS |
---|
754 | cd XIOS/arch |
---|
755 | svn update |
---|
756 | cd .. |
---|
757 | echo "Compiling XIOS, start" `date` "(it takes about 20 min on Jean-Zay)" |
---|
758 | echo "log file: $xioslog" |
---|
759 | ./make_xios --prod --arch $arch --job 4 > xios.log 2>&1 |
---|
760 | else |
---|
761 | ./install_xios.bash -prefix $MODEL/modipsl/modeles \ |
---|
762 | -netcdf ${ncdfdir} -hdf5 ${ncdfdir} \ |
---|
763 | -MPI $root_mpi -arch $arch > xios.log 2>&1 |
---|
764 | fi # of case Jean-Zay |
---|
765 | if [ -f XIOS/lib/libxios.a ] ; then |
---|
766 | echo "XIOS library successfully generated" |
---|
767 | echo install_lmdz.sh XIOS_OK `date` |
---|
768 | fi |
---|
769 | fi |
---|
770 | |
---|
771 | #============================================================================ |
---|
772 | veget_version=false |
---|
773 | if [ "$veget" != 'NONE' ] ; then |
---|
774 | cd $MODEL/modipsl/modeles/ORCHIDEE |
---|
775 | set +e ; svn upgrade ; set -e |
---|
776 | if [ "$veget" = "CMIP6" ] ; then |
---|
777 | veget_version=orchidee2.0 |
---|
778 | orchidee_rev=6592 |
---|
779 | else # specific orchidee revision newer than CMIP6, on 2_1 or 2_2 branches |
---|
780 | veget_version=orchidee2.1 |
---|
781 | orchidee_rev=$veget |
---|
782 | if [ $veget -lt 4465 ] ; then |
---|
783 | echo 'Stopping, ORCHIDEE version too old, script needs work on the CPP flags to pass to makelmdz' |
---|
784 | exit 1 |
---|
785 | fi |
---|
786 | set +e |
---|
787 | # which branch is my version on? |
---|
788 | orcbranch=`svn log -v -q svn://forge.ipsl.jussieu.fr/orchidee/ -r $veget |grep ORCHIDEE |head -1| sed -e 's:ORCHIDEE/.*$:ORCHIDEE:' | awk '{print $2}'` |
---|
789 | # switch to that branch |
---|
790 | echo IF YOU INSTALL ORCHIDEE THE VERY FIRST TIME, ASK for PASSWORD at orchidee-help@listes.ipsl.fr |
---|
791 | svn switch -r $veget --accept theirs-full svn://forge.ipsl.jussieu.fr/orchidee/$orcbranch |
---|
792 | svn log -r $veget | grep $veget |
---|
793 | if [ $? -gt 0 ] ; then |
---|
794 | echo 'Cannot update ORCHIDEE as not on the right branch for ORCHIDEE' |
---|
795 | exit |
---|
796 | fi |
---|
797 | set -e |
---|
798 | set +e ; svn update -r $veget ; set -e |
---|
799 | fi |
---|
800 | # Correctif suite debug Jean-Zay |
---|
801 | sed -i -e 's/9010 FORMAT(A52,F17.14)/9010 FORMAT(A52,F20.14)/' src_stomate/stomate.f90 |
---|
802 | opt_orc="-prod" ; if [ "$optim" = "-debug" ] ; then opt_orc="-debug" ; fi |
---|
803 | |
---|
804 | orchideelog=`pwd`/orchidee.log |
---|
805 | echo '########################################################' |
---|
806 | echo 'Compiling ORCHIDEE, the continental surface model ' |
---|
807 | echo '########################################################' |
---|
808 | echo Start of the first compilation of orchidee, in sequential mode: `date` |
---|
809 | echo log file : $orchideelog |
---|
810 | |
---|
811 | export ORCHPATH=`pwd` |
---|
812 | xios_orchid="-noxios" |
---|
813 | if [ "$with_xios" = "y" ] ; then |
---|
814 | xios_orchid="-xios" |
---|
815 | fi |
---|
816 | if [ -d tools ] ; then |
---|
817 | ################################################################### |
---|
818 | # Pour les experts qui voudraient changer de version d'orchidee. |
---|
819 | # Attention : necessite d'avoir le password pour orchidee |
---|
820 | |
---|
821 | # Correctif suite debug Jean-Zay |
---|
822 | if [ -f src_global/time.f90 ] ; then sed -i -e 's/CALL tlen2itau/\!CALL tlen2itau/' src_global/time.f90 ; fi |
---|
823 | ################################################################### |
---|
824 | if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi |
---|
825 | cd arch |
---|
826 | sed -e s:"%COMPILER .*.$":"%COMPILER $compiler":1 \ |
---|
827 | -e s:"%LINK .*.$":"%LINK $compiler":1 \ |
---|
828 | -e s:"%FPP_FLAGS .*.$":"%FPP_FLAGS $fpp_flags":1 \ |
---|
829 | -e s:"%PROD_FFLAGS .*.$":"%PROD_FFLAGS $OPTIM":1 \ |
---|
830 | -e s:"%DEV_FFLAGS .*.$":"%DEV_FFLAGS $OPTDEV":1 \ |
---|
831 | -e s:"%DEBUG_FFLAGS .*.$":"%DEBUG_FFLAGS $OPTDEB":1 \ |
---|
832 | -e s:"%BASE_FFLAGS .*.$":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
833 | -e s:"%BASE_LD .*.$":"%BASE_LD $BASE_LD":1 \ |
---|
834 | -e s:"%ARFLAGS .*.$":"%ARFLAGS $ARFLAGS":1 \ |
---|
835 | arch-gfortran.fcm > arch-local.fcm |
---|
836 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path |
---|
837 | echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path |
---|
838 | echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path |
---|
839 | echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path |
---|
840 | echo 'XIOS_INCDIR=${ORCHDIR}/../XIOS/inc' >> arch-local.path |
---|
841 | echo 'XIOS_LIBDIR="${ORCHDIR}/../XIOS/lib -lxios"' >> arch-local.path |
---|
842 | cd ../ |
---|
843 | |
---|
844 | echo ./makeorchidee_fcm -j $xios_orchid $opt_orc -parallel none -arch $arch |
---|
845 | ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel none -arch $arch > $orchideelog 2>&1 |
---|
846 | pwd |
---|
847 | else # of "if [ -d tools ]" |
---|
848 | if [ -d src_parallel ] ; then |
---|
849 | liste_src="parallel parameters global stomate sechiba driver" |
---|
850 | if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi |
---|
851 | fi |
---|
852 | for d in $liste_src ; do src_d=src_$d |
---|
853 | echo src_d $src_d |
---|
854 | echo ls ; ls |
---|
855 | if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi |
---|
856 | cd $src_d ; \rm -f *.mod make ; $make clean |
---|
857 | $make > $orchideelog 2>&1 ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi |
---|
858 | cd .. |
---|
859 | done |
---|
860 | fi # of "if [ -d tools ]" |
---|
861 | echo install_lmdz.sh orchidee_compil_seq_OK `date` |
---|
862 | fi # of if [ "$veget" != 'NONE' ] |
---|
863 | |
---|
864 | |
---|
865 | #============================================================================ |
---|
866 | # Ehouarn: the directory name LMDZ* depends on version/tar file... |
---|
867 | if [ -d $MODEL/modipsl/modeles/LMD* ] ; then |
---|
868 | echo '###############################################################' |
---|
869 | echo 'Preparing LMDZ compilation : arch file, svn switch if needed...' |
---|
870 | echo '###############################################################' |
---|
871 | cd $MODEL/modipsl/modeles/LMD* |
---|
872 | LMDZPATH=`pwd` |
---|
873 | else |
---|
874 | echo "ERROR: No LMD* directory !!!" |
---|
875 | exit |
---|
876 | fi |
---|
877 | |
---|
878 | ########################################################### |
---|
879 | # For those who want to use fcm to compile via : |
---|
880 | # makelmdz_fcm -arch local ..... |
---|
881 | ############################################################ |
---|
882 | |
---|
883 | if [[ "$pclinux" = "1" && ! -f arch/arch-local.path ]] ; then |
---|
884 | |
---|
885 | # create local 'arch' files (if on Linux PC): |
---|
886 | cd arch |
---|
887 | # arch-local.path file |
---|
888 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path |
---|
889 | echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path |
---|
890 | echo 'NETCDF95_INCDIR=$LMDGCM/../../include' >> arch-local.path |
---|
891 | echo 'NETCDF95_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
892 | echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
893 | echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
894 | echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path |
---|
895 | echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path |
---|
896 | echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
897 | echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
898 | |
---|
899 | if [ $pcmac == 1 ] ; then |
---|
900 | BASE_LD="$BASE_LD -Wl,-rpath,${ncdfdir}/lib" |
---|
901 | else |
---|
902 | BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib" |
---|
903 | fi |
---|
904 | # Arch-local.fcm file (adapted from arch-linux-32bit.fcm) |
---|
905 | |
---|
906 | if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi |
---|
907 | sed -e s:"%COMPILER .*.$":"%COMPILER $compiler":1 \ |
---|
908 | -e s:"%LINK .*.$":"%LINK $compiler":1 \ |
---|
909 | -e s:"%PROD_FFLAGS .*.$":"%PROD_FFLAGS $OPTIM":1 \ |
---|
910 | -e s:"%DEV_FFLAGS .*.$":"%DEV_FFLAGS $OPTDEV":1 \ |
---|
911 | -e s:"%DEBUG_FFLAGS .*.$":"%DEBUG_FFLAGS $OPTDEB":1 \ |
---|
912 | -e s:"%BASE_FFLAGS .*.$":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
913 | -e s:"%FPP_DEF .*.$":"%FPP_DEF $FPP_DEF":1 \ |
---|
914 | -e s:"%BASE_LD .*.$":"%BASE_LD $BASE_LD":1 \ |
---|
915 | -e s:"%ARFLAGS .*.$":"%ARFLAGS $ARFLAGS":1 \ |
---|
916 | arch-linux-32bit.fcm > arch-local.fcm |
---|
917 | |
---|
918 | cd .. |
---|
919 | ### Adapt "bld.cfg" (add the shell): |
---|
920 | #whereisthatshell=$(which ${use_shell}) |
---|
921 | #echo "bld::tool::SHELL $whereisthatshell" >> bld.cfg |
---|
922 | |
---|
923 | fi # of if [ "$pclinux" = 1 ] |
---|
924 | |
---|
925 | |
---|
926 | cd $MODEL/modipsl/modeles/LMDZ* |
---|
927 | lmdzlog=`pwd`/lmdz.log |
---|
928 | |
---|
929 | ################################################################## |
---|
930 | # Possibly update LMDZ if a specific svn release is requested |
---|
931 | ################################################################## |
---|
932 | |
---|
933 | set +e ; svn upgrade ; set -e |
---|
934 | |
---|
935 | if [ "$svn" = "last" ] ; then svnopt="" ; else svnopt="-r $svn" ; fi |
---|
936 | if [ "$svn" != "" ] ; then |
---|
937 | set +e ; svn info | grep -q 'http:' |
---|
938 | if [ $? = 0 ] ; then |
---|
939 | svn switch --relocate http://svn.lmd.jussieu.fr/LMDZ https://svn.lmd.jussieu.fr/LMDZ |
---|
940 | fi |
---|
941 | svn update $svnopt |
---|
942 | fi |
---|
943 | set -e |
---|
944 | |
---|
945 | ################################################################## |
---|
946 | # Retrieve the final svn release number, and adjust compilation options accordingly |
---|
947 | mysvn=`svnversion . | egrep -o "[0-9]+"` |
---|
948 | |
---|
949 | # Option de compilation du rayonnement : depend de $mysvn ><= r4185 |
---|
950 | opt_rad="" |
---|
951 | |
---|
952 | case $rad in |
---|
953 | oldrad) iflag_rrtm=0 ; NSW=2 ; opt_rad="" ;; |
---|
954 | rrtm) iflag_rrtm=1 ; NSW=6 ; if [ $mysvn -le 4185 ] ; then opt_rad="-rrtm true" ; else opt_rad="-rad rrtm" ; fi ;; |
---|
955 | ecrad) iflag_rrtm=2 ; NSW=6 ; opt_rad="-rad ecrad" ;; |
---|
956 | *) echo Only oldrad rrtm ecrad for rad option ; exit |
---|
957 | esac |
---|
958 | |
---|
959 | if [ $mysvn -le 4185 -a $rad = "ecrad" ] ; then echo "ecrad only available for LMDZ rev starting with 4186 " ; exit ; fi |
---|
960 | |
---|
961 | ################################################################## |
---|
962 | |
---|
963 | |
---|
964 | if [[ ! -f libf/misc/netcdf95.F90 && ! -d $MODEL/NetCDF95-0.2 ]] |
---|
965 | then |
---|
966 | cd $MODEL |
---|
967 | myget import/NetCDF95-0.2.tar.gz |
---|
968 | tar -xf NetCDF95-0.2.tar.gz |
---|
969 | rm NetCDF95-0.2.tar.gz |
---|
970 | cd NetCDF95-0.2 |
---|
971 | mkdir build |
---|
972 | cd build |
---|
973 | cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$ncdfdir \ |
---|
974 | -DCMAKE_INSTALL_PREFIX=$MODEL/modipsl |
---|
975 | make install |
---|
976 | cd $MODEL/modipsl/modeles/LMDZ* |
---|
977 | fi |
---|
978 | |
---|
979 | echo '##################################################################' |
---|
980 | echo "Preparing script compile.sh for LMDZ compilation" |
---|
981 | echo "It will only be run automatically if bench=1/tuto" |
---|
982 | echo Here bench=$bench |
---|
983 | echo '##################################################################' |
---|
984 | |
---|
985 | if [ "$env_file" != "" ] ; then mv arch/arch-${arch}.env arch/arch-${arch}.orig ; \cp -f $env_file arch/arch-${arch}.env ; fi |
---|
986 | |
---|
987 | if [ $compile_with_fcm = 1 ] ; then makelmdz="makelmdz_fcm $optim -arch $arch -j 8 " ; else makelmdz="makelmdz $optim -arch $arch" ; fi |
---|
988 | |
---|
989 | # sequential compilation |
---|
990 | if [ "$sequential" = 1 ] ; then |
---|
991 | echo Sequential compilation command, saved in compile.sh: |
---|
992 | echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp -d ${grid_resolution} -v $veget_version gcm " |
---|
993 | echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp -d ${grid_resolution} -v $veget_version gcm " > compile.sh |
---|
994 | chmod +x ./compile.sh |
---|
995 | if [ $bench = 1 ] ; then |
---|
996 | echo install_lmdz.sh start_lmdz_seq_compilation `date` |
---|
997 | echo log file: $lmdzlog |
---|
998 | ./compile.sh > $lmdzlog 2>&1 |
---|
999 | echo install_lmdz.sh end_lmdz_seq_compilation `date` |
---|
1000 | fi |
---|
1001 | fi # fin sequential |
---|
1002 | |
---|
1003 | # compiling in parallel mode |
---|
1004 | if [ $parallel != "none" ] ; then |
---|
1005 | echo '##########################################################' |
---|
1006 | echo ' Parallel compile ' |
---|
1007 | echo '##########################################################' |
---|
1008 | echo "(after saving the sequential libs and binaries)" |
---|
1009 | cd $MODEL/modipsl |
---|
1010 | tar cf sequential.tar bin/ lib/ |
---|
1011 | \rm -rf bin/ lib/ |
---|
1012 | tar xf ioipsl.tar |
---|
1013 | # |
---|
1014 | # Orchidee |
---|
1015 | # |
---|
1016 | cd $ORCHPATH |
---|
1017 | if [ -d src_parallel -a $veget != 'NONE' ] ; then |
---|
1018 | cd arch |
---|
1019 | sed \ |
---|
1020 | -e s:"%COMPILER.*.$":"%COMPILER $par_comp":1 \ |
---|
1021 | -e s:"%LINK.*.$":"%LINK $par_comp":1 \ |
---|
1022 | -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS $MPI_FLAGS":1 \ |
---|
1023 | -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS $OMP_FLAGS":1 \ |
---|
1024 | -e s:"%MPI_LD.*.$":"%MPI_LD $MPI_LD":1 \ |
---|
1025 | -e s:"%OMP_LD.*.$":"%OMP_LD $OMP_LD":1 \ |
---|
1026 | arch-local.fcm > tmp.fcm |
---|
1027 | |
---|
1028 | mv tmp.fcm arch-local.fcm |
---|
1029 | cd ../ |
---|
1030 | echo Compiling ORCHIDEE in parallel mode `date` |
---|
1031 | echo logfile $orchideelog |
---|
1032 | echo "NOTE : to recompile it when necessary, use ./compile_orc.sh in modipsl/modeles/ORCHIDEE" |
---|
1033 | echo ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc -parallel $parallel -arch $arch > compile_orc.sh |
---|
1034 | echo ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel $parallel -arch $arch >> compile_orc.sh |
---|
1035 | echo echo Now you must also recompile LMDZ, by running ./compile.sh in modeles/LMDZ >> compile_orc.sh |
---|
1036 | chmod u+x compile_orc.sh |
---|
1037 | ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc -parallel $parallel -arch $arch > $orchideelog 2>&1 |
---|
1038 | ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel $parallel -arch $arch >> $orchideelog 2>&1 |
---|
1039 | echo End of ORCHIDEE compilation in parallel mode `date` |
---|
1040 | elif [ $veget != 'NONE' ] ; then |
---|
1041 | echo '##########################################################' |
---|
1042 | echo ' Orchidee version too old ' |
---|
1043 | echo ' Please update to new version ' |
---|
1044 | echo '##########################################################' |
---|
1045 | exit |
---|
1046 | fi # of [ -d src_parallel -a $veget != 'NONE' ] |
---|
1047 | |
---|
1048 | # LMDZ |
---|
1049 | cd $LMDZPATH |
---|
1050 | if [ $arch = local ] ; then |
---|
1051 | cd arch |
---|
1052 | sed -e s:"%COMPILER.*.$":"%COMPILER $par_comp":1 \ |
---|
1053 | -e s:"%LINK.*.$":"%LINK $par_comp":1 \ |
---|
1054 | -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS $MPI_FLAGS":1 \ |
---|
1055 | -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS $OMP_FLAGS":1 \ |
---|
1056 | -e s:"%ARFLAGS.*.$":"%ARFLAGS $ARFLAGS":1 \ |
---|
1057 | -e s@"%BASE_LD.*.$"@"%BASE_LD -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \ |
---|
1058 | -e s:"%MPI_LD.*.$":"%MPI_LD $MPI_LD":1 \ |
---|
1059 | -e s:"%OMP_LD.*.$":"%OMP_LD $OMP_LD":1 \ |
---|
1060 | arch-local.fcm > tmp.fcm |
---|
1061 | mv tmp.fcm arch-local.fcm |
---|
1062 | cd ../ |
---|
1063 | fi |
---|
1064 | rm -f compile.sh |
---|
1065 | echo resol=${grid_resolution} >> compile.sh |
---|
1066 | if [ ${hostname:0:5} = jean- -a "$cosp" = "v2" ] ; then |
---|
1067 | |
---|
1068 | echo LMDZ compilation command in parallel mode, saved in compile.sh, is : |
---|
1069 | echo "(ATTENTION le probleme de cospv2 sur jean-zay en mode prod n est pas corrige ! )" |
---|
1070 | # ATTENTION le probleme de cospv2 sur jean-zay en mode prod n est pas corrige |
---|
1071 | echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh |
---|
1072 | echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm |
---|
1073 | else |
---|
1074 | echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh |
---|
1075 | echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm |
---|
1076 | fi |
---|
1077 | chmod +x ./compile.sh |
---|
1078 | |
---|
1079 | if [ $bench = 1 ] ; then |
---|
1080 | echo Compiling LMDZ in parallel mode `date`, LMDZ log file: $lmdzlog ; ./compile.sh > $lmdzlog 2>&1 |
---|
1081 | fi |
---|
1082 | |
---|
1083 | fi # of if [ $parallel != "none" ] |
---|
1084 | |
---|
1085 | |
---|
1086 | ################################################################## |
---|
1087 | # Verification du succes de la compilation |
---|
1088 | ################################################################## |
---|
1089 | |
---|
1090 | # Recherche de l'executable dont le nom a change au fil du temps ... |
---|
1091 | # suffix contains radiative option starting with revision 4186 |
---|
1092 | if [ $mysvn -ge 4186 ] ; then suff_exe=_${rad}${suff_exe} ; fi |
---|
1093 | gcm="" |
---|
1094 | #for exe in gcm.e bin/gcm_${grid_resolution}_phylmd_seq_orch.e bin/gcm_${grid_resolution}_phylmd_seq.e bin/gcm_${grid_resolution}_phylmd_para_mem_orch.e bin/gcm_${grid_resolution}_phylmd_para_mem.e ; do |
---|
1095 | for exe in gcm.e bin/gcm_${grid_resolution}_phylmd${suff_exe}${suff_orc}.e ; do if [ -f $exe ] ; then gcm=$exe ; fi |
---|
1096 | done |
---|
1097 | |
---|
1098 | if [ "$gcm" = "" ] ; then |
---|
1099 | if [ $bench = 1 ] ; then |
---|
1100 | echo 'Compilation failed !! Cannot run the benchmark;' |
---|
1101 | exit |
---|
1102 | else |
---|
1103 | echo 'Compilation not done (only done when bench=1)' |
---|
1104 | fi |
---|
1105 | else |
---|
1106 | echo '##########################################################' |
---|
1107 | echo 'Compilation successfull !! ' `date` |
---|
1108 | echo '##########################################################' |
---|
1109 | echo The executable is $gcm |
---|
1110 | fi |
---|
1111 | |
---|
1112 | ################################################################## |
---|
1113 | # Below, we run a benchmark if bench=1 or tuto |
---|
1114 | ################################################################## |
---|
1115 | |
---|
1116 | if [ $bench = tuto ] ; then |
---|
1117 | myget Training/tutorial.tar ; tar xvf tutorial.tar ; cd TUTORIAL ; ./init.sh |
---|
1118 | |
---|
1119 | elif [[ $bench = 1 && ! -d BENCH${grid_resolution} ]] ; then |
---|
1120 | # TOUTE CETTE SECTION DEVRAIT DISPARAITRE POUR UNE COMMANDE |
---|
1121 | # OU DES BENCHS PAR MOTS CLES COMME tuto |
---|
1122 | |
---|
1123 | echo '##########################################################' |
---|
1124 | echo ' Running a test run ' |
---|
1125 | echo '##########################################################' |
---|
1126 | |
---|
1127 | \rm -rf BENCH${grid_resolution} |
---|
1128 | bench=bench_lmdz_${grid_resolution} |
---|
1129 | echo install_lmdz.sh before bench download `date` |
---|
1130 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz |
---|
1131 | myget 3DBenchs/$bench.tar.gz |
---|
1132 | echo install_lmdz.sh after bench download `date` |
---|
1133 | tar xvf $bench.tar.gz |
---|
1134 | |
---|
1135 | if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then |
---|
1136 | cd BENCH${grid_resolution} |
---|
1137 | # copier les fichiers namelist input et output our COSP |
---|
1138 | cp ../DefLists/cosp*_input_nl.txt . |
---|
1139 | cp ../DefLists/cosp*_output_nl.txt . |
---|
1140 | # Activer la cles ok_cosp pour tourner avec COSP |
---|
1141 | sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp |
---|
1142 | \mv -f tmp config.def |
---|
1143 | cd .. |
---|
1144 | fi |
---|
1145 | |
---|
1146 | if [ -n "$physiq" ]; then |
---|
1147 | cd BENCH${grid_resolution} |
---|
1148 | if [ -f physiq.def_${physiq} ]; then |
---|
1149 | cp physiq.def_${physiq} physiq.def |
---|
1150 | echo using physiq.def_${physiq} |
---|
1151 | else |
---|
1152 | echo using standard physiq.def |
---|
1153 | fi |
---|
1154 | cd .. |
---|
1155 | else |
---|
1156 | echo using standard physiq.def |
---|
1157 | fi |
---|
1158 | |
---|
1159 | if [ "$with_xios" = "y" ] ; then |
---|
1160 | cd BENCH${grid_resolution} |
---|
1161 | cp ../DefLists/iodef.xml . |
---|
1162 | cp ../DefLists/context_lmdz.xml . |
---|
1163 | cp ../DefLists/field_def_lmdz.xml . |
---|
1164 | # A raffiner par la suite |
---|
1165 | echo A FAIRE : Copier les *xml en fonction de l option cosp |
---|
1166 | cp ../DefLists/field_def_cosp*.xml . |
---|
1167 | cp ../DefLists/file_def_hist*xml . |
---|
1168 | # adapt iodef.xml to use attached mode |
---|
1169 | sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp |
---|
1170 | \mv -f tmp iodef.xml |
---|
1171 | |
---|
1172 | # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE. |
---|
1173 | # except for histday |
---|
1174 | for histfile in file_def_hist*xml |
---|
1175 | do |
---|
1176 | if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then |
---|
1177 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1178 | sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1179 | sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1180 | else |
---|
1181 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1182 | fi |
---|
1183 | done |
---|
1184 | # and add option "ok_all_xml=y" in config.def |
---|
1185 | echo "### XIOS outputs" >> config.def |
---|
1186 | echo 'ok_all_xml=.true.' >> config.def |
---|
1187 | |
---|
1188 | #activer les sorties pour Cosp |
---|
1189 | if [ "$cosp" = "v1" ] ; then |
---|
1190 | histfile=file_def_histdayCOSP_lmdz.xml |
---|
1191 | sed -e 's@enabled=".FALSE."@enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1192 | sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1193 | sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1194 | fi |
---|
1195 | if [ "$cosp" = "v2" ] ; then |
---|
1196 | histfile=file_def_histdayCOSPv2_lmdz.xml |
---|
1197 | sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1198 | contextfile=context_lmdz.xml |
---|
1199 | sed -e 's@src="./file_def_histdayCOSP_lmdz.xml"@src="./file_def_histdayCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile |
---|
1200 | sed -e 's@src="./file_def_histmthCOSP_lmdz.xml"@src="./file_def_histmthCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile |
---|
1201 | sed -e 's@src="./file_def_histhfCOSP_lmdz.xml"@src="./file_def_histhfCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile |
---|
1202 | fieldfile=field_def_lmdz.xml |
---|
1203 | sed -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' $fieldfile > tmp ; \mv -f tmp $fieldfile |
---|
1204 | fi |
---|
1205 | |
---|
1206 | cd .. |
---|
1207 | fi |
---|
1208 | |
---|
1209 | # Cas Bensh avec ecrad |
---|
1210 | if [ "$rad" = "ecrad" ] ; then |
---|
1211 | cd BENCH${grid_resolution} |
---|
1212 | cp ../DefLists/namelist_ecrad . |
---|
1213 | cp -r ../libf/phylmd/ecrad/data . |
---|
1214 | cd .. |
---|
1215 | fi |
---|
1216 | |
---|
1217 | # Adjusting bench physiq.def to radiative code chosen |
---|
1218 | cd BENCH${grid_resolution} |
---|
1219 | sed -e 's/iflag_rrtm=.*.$/iflag_rrtm='$iflag_rrtm'/' -e 's/NSW=.*.$/NSW='$NSW'/' physiq.def > tmpdef |
---|
1220 | \mv tmpdef physiq.def |
---|
1221 | cd .. |
---|
1222 | |
---|
1223 | cp $gcm BENCH${grid_resolution}/gcm.e |
---|
1224 | |
---|
1225 | cd BENCH${grid_resolution} |
---|
1226 | # On cree le fichier bench.sh au besoin |
---|
1227 | # Dans le cas 48x36x39 le bench.sh existe deja en parallele |
---|
1228 | |
---|
1229 | if [ "$grid_resolution" = "48x36x39" ] ; then |
---|
1230 | echo On ne touche pas au bench.sh |
---|
1231 | # But we have to adapt "run_local.sh" for $mpirun |
---|
1232 | sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp |
---|
1233 | mv -f tmp run_local.sh |
---|
1234 | chmod u=rwx run_local.sh |
---|
1235 | elif [ "${parallel:0:3}" = "mpi" ] ; then |
---|
1236 | # Lancement avec deux procs mpi et 2 openMP |
---|
1237 | echo "export OMP_STACKSIZE=800M" > bench.sh |
---|
1238 | if [ "${parallel:4:3}" = "omp" ] ; then |
---|
1239 | echo "export OMP_NUM_THREADS=2" >> bench.sh |
---|
1240 | fi |
---|
1241 | if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then |
---|
1242 | if [ ${hostname:0:5} = jean- ] ; then |
---|
1243 | chmod +x ../arch.env |
---|
1244 | ../arch.env |
---|
1245 | echo "ulimit -s 2000000" >> bench.sh |
---|
1246 | else |
---|
1247 | echo "ulimit -s 200000" >> bench.sh |
---|
1248 | fi |
---|
1249 | else |
---|
1250 | echo "ulimit -s unlimited" >> bench.sh |
---|
1251 | fi |
---|
1252 | if [ ${hostname:0:5} = jean- ] ; then |
---|
1253 | . ../arch/arch-${arch}.env |
---|
1254 | echo "srun -n 2 -A $idris_acct@cpu gcm.e > listing 2>&1" >> bench.sh |
---|
1255 | else |
---|
1256 | echo "$mpirun -np 2 gcm.e > listing 2>&1" >> bench.sh |
---|
1257 | fi |
---|
1258 | # Add rebuild, using reb.sh if it is there |
---|
1259 | echo 'if [ -f reb.sh ] ; then' >> bench.sh |
---|
1260 | echo ' ./reb.sh histday ; ./reb.sh histmth ; ./reb.sh histhf ; ./reb.sh histins ; ./reb.sh stomate_history ; ./reb.sh sechiba_history ; ./reb.sh sechiba_out_2 ' >> bench.sh |
---|
1261 | echo 'fi' >> bench.sh |
---|
1262 | else |
---|
1263 | echo "./gcm.e > listing 2>&1" > bench.sh |
---|
1264 | fi |
---|
1265 | # Getting orchidee stuff |
---|
1266 | if [ $veget == 'CMIP6' ] ; then |
---|
1267 | #echo 'myget 3DBenchs/BENCHorch11.tar.gz' |
---|
1268 | #myget 3DBenchs/BENCHorch11.tar.gz |
---|
1269 | #tar xvzf BENCHorch11.tar.gz |
---|
1270 | echo 'myget 3DBenchs/BENCHCMIP6.tar.gz' |
---|
1271 | myget 3DBenchs/BENCHCMIP6.tar.gz |
---|
1272 | tar xvzf BENCHCMIP6.tar.gz |
---|
1273 | sed -e "s:VEGET=n:VEGET=y:" config.def > tmp |
---|
1274 | mv -f tmp config.def |
---|
1275 | if [ "$with_xios" = "y" ] ; then |
---|
1276 | cp ../../ORCHIDEE/src_xml/context_orchidee.xml . |
---|
1277 | echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp |
---|
1278 | cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml . |
---|
1279 | cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml . |
---|
1280 | cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml . |
---|
1281 | if [ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ] ; then |
---|
1282 | cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml . |
---|
1283 | echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp |
---|
1284 | fi |
---|
1285 | sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp |
---|
1286 | mv tmp iodef.xml |
---|
1287 | sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml |
---|
1288 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml |
---|
1289 | sed -e 's@output_level="_AUTO_"@output_level="1"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml |
---|
1290 | sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml |
---|
1291 | sed -e 's@compression_level="4"@compression_level="0"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml |
---|
1292 | sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' orchidee.def > tmp ; \mv -f tmp orchidee.def |
---|
1293 | fi |
---|
1294 | fi |
---|
1295 | echo EXECUTION DU BENCH |
---|
1296 | set +e |
---|
1297 | date ; ./bench.sh > out.bench 2>&1 ; date |
---|
1298 | set -e |
---|
1299 | tail listing |
---|
1300 | |
---|
1301 | |
---|
1302 | echo '##########################################################' |
---|
1303 | echo 'Simulation finished in' `pwd` |
---|
1304 | echo 'You have compiled with:' |
---|
1305 | cat ../compile.sh |
---|
1306 | if [ $parallel = "none" ] ; then |
---|
1307 | echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e' |
---|
1308 | echo 'or ./bench.sh' |
---|
1309 | else |
---|
1310 | echo 'You may re-run it with : ' |
---|
1311 | echo 'cd ' `pwd` '; ./bench.sh' |
---|
1312 | # echo 'ulimit -s unlimited' |
---|
1313 | # echo 'export OMP_NUM_THREADS=2' |
---|
1314 | # echo 'export OMP_STACKSIZE=800M' |
---|
1315 | # echo "$mpirun -np 2 gcm.e " |
---|
1316 | fi |
---|
1317 | echo '##########################################################' |
---|
1318 | |
---|
1319 | fi # bench |
---|
1320 | |
---|
1321 | |
---|
1322 | ################################################################# |
---|
1323 | # Installation eventuelle du 1D |
---|
1324 | ################################################################# |
---|
1325 | |
---|
1326 | if [ $SCM = 1 ] ; then |
---|
1327 | cd $MODEL |
---|
1328 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/1D.tar.gz |
---|
1329 | myget 1D/1D.tar.gz |
---|
1330 | tar xvf 1D.tar.gz |
---|
1331 | cd 1D |
---|
1332 | ./run.sh -rad $rad |
---|
1333 | fi |
---|
1334 | #set -vx |
---|
1335 | |
---|
1336 | ################################################################# |
---|
1337 | # sauvegarde des options veget pour utilisation eventuelle tutorial_prod |
---|
1338 | ################################################################# |
---|
1339 | cd $MODEL/modipsl/modeles |
---|
1340 | #echo surface_env file created in $MODEL |
---|
1341 | echo 'veget='$veget > surface_env |
---|
1342 | #opt_veget="-v $veget_version" |
---|
1343 | #echo 'opt_veget="'$opt_veget\" >> surface_env |
---|
1344 | echo 'opt_veget="'-v $veget_version\" >> surface_env |
---|
1345 | echo 'orchidee_rev='$orchidee_rev >> surface_env |
---|
1346 | echo 'suforch='$suff_orc >> surface_env |
---|
1347 | |
---|
1348 | |
---|
1349 | |
---|
1350 | |
---|