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