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