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