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