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