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