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 | LMDZ_HOME="/u/lmdz/WWW/Distrib" |
---|
46 | if [ -f $LMDZ_HOME/$1 ] ; then |
---|
47 | \cp -f -p $LMDZ_HOME/$1 . |
---|
48 | else |
---|
49 | wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$1 |
---|
50 | fi |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | #real=r4 |
---|
55 | real=r8 |
---|
56 | |
---|
57 | # WARNING !!!! For versions before october 2009, use |
---|
58 | # install.v2.sh instead of install.sh |
---|
59 | |
---|
60 | ######################################################################### |
---|
61 | # Valeur par défaut des parametres |
---|
62 | ######################################################################### |
---|
63 | svn="" |
---|
64 | version=testing |
---|
65 | getlmdzor=1 |
---|
66 | netcdf=1 # 1 for automatic installation |
---|
67 | # 0 for no installation |
---|
68 | # /.../../netcdf-4.0.1 if wanting to link with an already |
---|
69 | # compiled netcdf library (implies to check option compatibility) |
---|
70 | check_linux=1 |
---|
71 | ioipsl=1 |
---|
72 | veget=1 |
---|
73 | bench=1 |
---|
74 | pclinux=1 |
---|
75 | SCM=0 |
---|
76 | # use the old orchidee interface without the calculation of z0h |
---|
77 | no_z0h_orc=1 |
---|
78 | # choose the resolution for the bench runs |
---|
79 | # grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE) |
---|
80 | # 96x71x19 standard configuration |
---|
81 | grid_resolution=144x142x79 |
---|
82 | grid_resolution=48x36x19 |
---|
83 | |
---|
84 | ## parallel can take the values none/mpi/omp/mpi_omp |
---|
85 | parallel=mpi_omp |
---|
86 | parallel=none |
---|
87 | OPT_GPROF="" |
---|
88 | OPT_MAKELMDZ="" |
---|
89 | MODEL="" |
---|
90 | |
---|
91 | ######################################################################### |
---|
92 | # Options interactives |
---|
93 | ######################################################################### |
---|
94 | while (($# > 0)) |
---|
95 | do |
---|
96 | case $1 in |
---|
97 | "-h") cat <<........fin |
---|
98 | $0 [ -v version ] [ -r svn_release ] |
---|
99 | [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ] |
---|
100 | [-name LOCAL_MODEL_NAME] [-gprof] [-opt_makelmdz] |
---|
101 | |
---|
102 | -v "version" like 20150828.trunk |
---|
103 | see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk |
---|
104 | |
---|
105 | -r "svn_release" : either the svn release number or "last" |
---|
106 | |
---|
107 | -parallel PARA : can be mpi_omp (mpi with openMP) or none (for sequential) |
---|
108 | |
---|
109 | -d GRID_RESOLUTION should be among the available benchs if -bench 1 |
---|
110 | among which : 48x36x19, 48x36x39 |
---|
111 | if wanting to run a bench simulation in addition to compilation |
---|
112 | default : 48x36x19 |
---|
113 | |
---|
114 | -bench activating the bench or not (0/1). Default 1 |
---|
115 | |
---|
116 | -name LOCAL_MODEL_NAME : default = LMDZversion.release |
---|
117 | |
---|
118 | -gprof to compile with -pg to enable profiling with gprof |
---|
119 | -SCM install 1D version automatically |
---|
120 | -opt_makelmdz to call makelmdz or makelmdz_fcm with additional options |
---|
121 | ........fin |
---|
122 | exit ;; |
---|
123 | "-v") version=$2 ; shift ; shift ;; |
---|
124 | "-r") svn=$2 ; shift ; shift ;; |
---|
125 | "-d") grid_resolution=$2 ; shift ; shift ;; |
---|
126 | "-gprof") OPT_GPROF="-pg" ; shift ;; |
---|
127 | "-SCM") SCM=1 ; shift ;; |
---|
128 | "-opt_makelmdz") OPT_MAKELMDZ="$2" ; shift ; shift ;; |
---|
129 | "-parallel") parallel=$2 |
---|
130 | case $parallel in |
---|
131 | "mpi"|"omp"|"mpi_omp") parallel=$2 ; shift ; shift ;; |
---|
132 | *) echo Only mpi omp mpi_omp for the parallel option ; exit |
---|
133 | esac ;; |
---|
134 | "-bench") bench=$2 ; shift ; shift ;; |
---|
135 | "-name") MODEL=$2 ; shift ; shift ;; |
---|
136 | *) ./install_lmdz.sh -h ; exit |
---|
137 | esac |
---|
138 | done |
---|
139 | |
---|
140 | if [ $parallel = none ] ; then sequential=1 ; else sequential=0 ; fi |
---|
141 | |
---|
142 | |
---|
143 | compilo=gfortran # compilo=pgf90 or gfortran or ifort sur PC linux |
---|
144 | #Chemin pour placer le modele |
---|
145 | if [ "$MODEL" = "" ] ; then MODEL=./LMDZ$version$svn ; fi |
---|
146 | |
---|
147 | |
---|
148 | ## compile_with_fcm=1 : use makelmdz_fcm (1) or makelmdz (0) |
---|
149 | compile_with_fcm=1 |
---|
150 | arch=local |
---|
151 | |
---|
152 | |
---|
153 | if [ $compilo = g95 ] ; then echo g95 is not supported anymore ; exit ; fi |
---|
154 | |
---|
155 | ################################################################ |
---|
156 | # Specificite des machines |
---|
157 | ################################################################ |
---|
158 | |
---|
159 | hostname=`hostname` |
---|
160 | if [ "$pclinux" = 1 ] ; then o_ins_make="-t g95" ; else o_ins_make="" ; fi |
---|
161 | |
---|
162 | case ${hostname:0:5} in |
---|
163 | |
---|
164 | ada33) compilo="ifort" ; |
---|
165 | par_comp="ifort" ; |
---|
166 | o_ins_make="-t ada" ; |
---|
167 | make=gmake ; |
---|
168 | # module load intel/2013.0 ; |
---|
169 | arch=X64_ADA ;; |
---|
170 | |
---|
171 | *) compilo="gfortran" ; |
---|
172 | if [ $parallel = none -o -f /usr/bin/mpif90 ] ; then |
---|
173 | path_mpi="" ; |
---|
174 | # Pour les installations Scientifique Linux LMD ou ciclad : |
---|
175 | elif [ -f /usr/lib64/openmpi/1.4.5-gfortran/bin/mpif90 ] ; then |
---|
176 | path_mpi=/usr/lib64/openmpi/1.4.5-gfortran/bin/ ; |
---|
177 | else |
---|
178 | echo Je ne trouve pas mpif90 ; |
---|
179 | exit ; |
---|
180 | fi ; |
---|
181 | par_comp=${path_mpi}mpif90 ; |
---|
182 | mpirun=${path_mpi}mpirun ; |
---|
183 | arch=local ; |
---|
184 | make=make ; |
---|
185 | o_ins_make="-t g95" |
---|
186 | esac |
---|
187 | |
---|
188 | |
---|
189 | # MPI_FLAGS are the flags needed for compilation with MPI |
---|
190 | MPI_FLAGS="-I/usr/include/openmpi-x86_64 -fcray-pointer" |
---|
191 | MPI_FLAGS="-fcray-pointer" |
---|
192 | # MPI_LD are the flags needed for linking with MPI |
---|
193 | MPI_LD="-L/usr/lib64/openmpi/lib -lmpi" |
---|
194 | # OMP_FLAGS are the flags needed for compilation with OpenMP |
---|
195 | OMP_FLAGS="-fopenmp -fcray-pointer" |
---|
196 | # OMP_LD are the flags needed for linking with OpenMP |
---|
197 | OMP_LD="-fopenmp -L/usr/lib64 -lnuma" |
---|
198 | OMP_LD="-fopenmp" |
---|
199 | |
---|
200 | |
---|
201 | ##################################################################### |
---|
202 | # Test for old gfortran compilers |
---|
203 | # If the compiler is too old (older than 4.3.x) we test if the |
---|
204 | # temporary gfortran44 patch is available on the computer in which |
---|
205 | # case the compiler is changed from gfortran to gfortran44 |
---|
206 | # Must be aware than parallelism can not be activated in this case |
---|
207 | ##################################################################### |
---|
208 | |
---|
209 | if [ "$compilo" = "gfortran" ] ; then |
---|
210 | gfortran=gfortran |
---|
211 | gfortranv=`gfortran --version | \ |
---|
212 | head -1 | awk ' { print $NF } ' | awk -F. ' { print $1 * 10 + $2 } '` |
---|
213 | if [ $gfortranv -le 43 ] ; then |
---|
214 | echo ERROR : Your gfortran compiler is too old |
---|
215 | echo 'Please choose a new one (ifort) and change the line' |
---|
216 | echo compilo=xxx |
---|
217 | echo in the install.sh script and rerun it |
---|
218 | if [ `which gfortran44 | wc -w` -ne 0 ] ; then |
---|
219 | gfortran=gfortran44 |
---|
220 | else |
---|
221 | echo gfotran trop vieux ; exit |
---|
222 | fi |
---|
223 | fi |
---|
224 | compilo=$gfortran |
---|
225 | fi |
---|
226 | ##################################################################### |
---|
227 | |
---|
228 | |
---|
229 | |
---|
230 | echo '################################################################' |
---|
231 | echo Choix des options de compilation |
---|
232 | echo '################################################################' |
---|
233 | |
---|
234 | export FC=$compilo |
---|
235 | export F90=$compilo |
---|
236 | export F77=$compilo |
---|
237 | export CPPFLAGS= |
---|
238 | OPTIMNC=$OPTIM |
---|
239 | BASE_LD="$OPT_GPROF" |
---|
240 | OPTPREC="$OPT_GPROF" |
---|
241 | |
---|
242 | if [ "$compilo" = "$gfortran" ] ; then |
---|
243 | OPTIM='-O3' |
---|
244 | OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=nan" |
---|
245 | OPTDEV="-Wall -fbounds-check" |
---|
246 | fmod='I ' |
---|
247 | OPTPREC="$OPTPREC -cpp -ffree-line-length-0" |
---|
248 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE" ; fi |
---|
249 | export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
250 | export FFLAGS=" $OPTIMNC" |
---|
251 | export CC=gcc |
---|
252 | export CXX=g++ |
---|
253 | export fpp_flags="-P -C -traditional -ffreestanding" |
---|
254 | |
---|
255 | elif [ $compilo = mpif90 ] ; then |
---|
256 | OPTIM='-O3' |
---|
257 | OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all" |
---|
258 | OPTDEV="-Wall -fbounds-check" |
---|
259 | BASE_LD="$BASE_LD -lblas" |
---|
260 | fmod='I ' |
---|
261 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer" ; fi |
---|
262 | export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
263 | export FFLAGS=" $OPTIMNC" |
---|
264 | export CC=gcc |
---|
265 | export CXX=g++ |
---|
266 | |
---|
267 | elif [ $compilo = pgf90 ] ; then |
---|
268 | OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align' |
---|
269 | OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback' |
---|
270 | OPTDEV='-g -Mbounds -Ktrap=fp -traceback' |
---|
271 | fmod='module ' |
---|
272 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE" ; fi |
---|
273 | export CPPFLAGS="-DpgiFortran" |
---|
274 | export CC=pgcc |
---|
275 | export CFLAGS="-O2 -Msignextend" |
---|
276 | export CXX=pgCC |
---|
277 | export CXXFLAGS="-O2 -Msignextend" |
---|
278 | export FFLAGS="-O2 $OPTIMNC" |
---|
279 | export F90FLAGS="-O2 $OPTIMNC" |
---|
280 | compile_with_fcm=1 |
---|
281 | |
---|
282 | elif [ $compilo = ifort ] ; then |
---|
283 | OPTIM="-O2 -fp-model strict -ip -align all " |
---|
284 | OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check" |
---|
285 | OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check" |
---|
286 | fmod='module ' |
---|
287 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi |
---|
288 | export CPP="icc -E" |
---|
289 | export FFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
290 | export FCFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
291 | export CC=icc |
---|
292 | export CFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
293 | export CXX=icpc |
---|
294 | export CXXFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
295 | compile_with_fcm=1 |
---|
296 | |
---|
297 | else |
---|
298 | echo unexpected compiler $compilo ; exit |
---|
299 | fi |
---|
300 | |
---|
301 | OPTIMGCM="$OPTIM $OPTPREC" |
---|
302 | |
---|
303 | hostname=`hostname` |
---|
304 | |
---|
305 | ########################################################################## |
---|
306 | # If installing on know machines such as IBM x3750 (Ada) |
---|
307 | # at IDRIS, don't check for available software and don"t install netcdf |
---|
308 | if [ ${hostname:0:5} = ada33 ] ; then |
---|
309 | netcdf=0 # no need to recompile netcdf, alreday available |
---|
310 | check_linux=0 |
---|
311 | pclinux=0 |
---|
312 | ioipsl=1 # no need to recompile ioipsl, already available |
---|
313 | #netcdf="/smplocal/pub/NetCDF/4.1.3" |
---|
314 | compilo="ifort" |
---|
315 | fmod='module ' |
---|
316 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi |
---|
317 | OPTIM="-O2 -fp-model strict -ip -axAVX,SSE4.2 -align all " |
---|
318 | OPTIMGCM="$OPTIM $OPTPREC" |
---|
319 | fi |
---|
320 | ########################################################################## |
---|
321 | |
---|
322 | |
---|
323 | |
---|
324 | mkdir -p $MODEL |
---|
325 | echo $MODEL |
---|
326 | MODEL=`( cd $MODEL ; pwd )` # to get absolute path, if necessary |
---|
327 | |
---|
328 | |
---|
329 | |
---|
330 | # Option -fendian=big is only to be used with ARPEGE1D. |
---|
331 | # The -r8 should probably be avoided if running on 32 bit machines |
---|
332 | # Option r8 is not mandatory and generates larger executables. |
---|
333 | # It is however mandatory if using ARPEGE1D |
---|
334 | # Better optimization options might be a better choice (e.g. -O3) |
---|
335 | |
---|
336 | |
---|
337 | echo '################################################################' |
---|
338 | if [ "$check_linux" = 1 ] ; then |
---|
339 | echo Check if required software is available |
---|
340 | echo '################################################################' |
---|
341 | |
---|
342 | #### Ehouarn: test if ksh and/or bash are available |
---|
343 | use_shell="ksh" # default: use ksh |
---|
344 | if [ "`which ksh`" = "" ] ; then |
---|
345 | echo "no ksh ... we will use bash" |
---|
346 | use_shell="bash" |
---|
347 | if [ "`which bash`" = "" ] ; then |
---|
348 | echo "ksh (or bash) needed!! Install it!" |
---|
349 | fi |
---|
350 | fi |
---|
351 | |
---|
352 | |
---|
353 | for logiciel in csh wget tar gzip make $compilo gcc ; do |
---|
354 | if [ "`which $logiciel`" = "" ] ; then |
---|
355 | echo You must first install $logiciel on your system |
---|
356 | exit |
---|
357 | fi |
---|
358 | done |
---|
359 | |
---|
360 | if [ $pclinux = 1 ] ; then |
---|
361 | cd $MODEL |
---|
362 | cat <<eod > tt.f90 |
---|
363 | print*,'coucou' |
---|
364 | end |
---|
365 | eod |
---|
366 | $compilo tt.f90 -o a.out |
---|
367 | ./a.out >| tt |
---|
368 | if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then |
---|
369 | echo problem installing with compiler $compilo ; exit ; fi |
---|
370 | \rm tt a.out tt.f90 |
---|
371 | fi |
---|
372 | fi |
---|
373 | |
---|
374 | ########################################################################### |
---|
375 | if [ $getlmdzor = 1 ] ; then |
---|
376 | echo '##########################################################' |
---|
377 | echo Download a slightly modified version of LMDZ |
---|
378 | echo '##########################################################' |
---|
379 | cd $MODEL |
---|
380 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/modipsl.$version.tar.gz |
---|
381 | myget modipsl.$version.tar.gz |
---|
382 | echo install.sh wget_OK `date` |
---|
383 | gunzip modipsl.$version.tar.gz |
---|
384 | tar xvf modipsl.$version.tar |
---|
385 | \rm modipsl.$version.tar |
---|
386 | |
---|
387 | fi |
---|
388 | |
---|
389 | echo OK1 |
---|
390 | |
---|
391 | if [ $netcdf = 1 ] ; then |
---|
392 | echo '##########################################################' |
---|
393 | echo Compiling the Netcdf library |
---|
394 | echo '##########################################################' |
---|
395 | cd $MODEL |
---|
396 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/netcdf-4.0.1.tar.gz |
---|
397 | myget netcdf-4.0.1.tar.gz |
---|
398 | gunzip netcdf-4.0.1.tar.gz |
---|
399 | tar xvf netcdf-4.0.1.tar |
---|
400 | \rm -f netcdf-4.0.1.tar |
---|
401 | |
---|
402 | cd netcdf-4.0.1 |
---|
403 | |
---|
404 | sed -e 's/gfortran/'$gfortran'/g' configure >| tmp ; mv -f tmp configure ; chmod +x configure |
---|
405 | localdir=`pwd -P` |
---|
406 | ./configure --prefix=$localdir --enable-shared --disable-cxx |
---|
407 | sed -e 's/gfortran/'$gfortran'/g' Makefile >| tmp ; mv -f tmp Makefile |
---|
408 | $make check |
---|
409 | $make install |
---|
410 | echo install.sh netcdf_OK `date` |
---|
411 | fi # of if [ $netcdf = 1 ] |
---|
412 | |
---|
413 | |
---|
414 | #======================================================================================= |
---|
415 | echo OK2 ioipsl=$ioipsl |
---|
416 | echo '##########################################################' |
---|
417 | echo 'Installing MODIPSL, the installation package manager for the ' |
---|
418 | echo 'IPSL models and tools' |
---|
419 | echo '##########################################################' |
---|
420 | |
---|
421 | if [ $netcdf = 0 -o $netcdf = 1 ] ; then |
---|
422 | ncdfdir=$MODEL/netcdf-4.0.1 |
---|
423 | else |
---|
424 | ncdfdir=$netcdf |
---|
425 | fi |
---|
426 | |
---|
427 | if [ $ioipsl = 1 ] ; then |
---|
428 | cd $MODEL/modipsl |
---|
429 | \rm -rf lib/* |
---|
430 | |
---|
431 | cd util |
---|
432 | |
---|
433 | cp AA_make.gdef AA_make.orig |
---|
434 | F_C="$compilo -c " ; if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then F_C="$compilo -c -cpp " ; fi |
---|
435 | if [ "$compilo" = "pgf90" ] ; then F_C="$compilo -c -Mpreprocess" ; fi |
---|
436 | sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp |
---|
437 | sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \ |
---|
438 | -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ |
---|
439 | -e 's:g95.*.NCDF_INC.*.$:g95 NCDF_INC= '"$ncdfdir"'/include:' \ |
---|
440 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \ |
---|
441 | -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \ |
---|
442 | -e 's:#-Q- g95 M_K = gmake:#-Q- g95 M_K = make:' \ |
---|
443 | tmp >| AA_make.gdef |
---|
444 | |
---|
445 | |
---|
446 | # We use lines for g95 even for the other compilers to run ins_make |
---|
447 | if [ "$use_shell" = "ksh" ] ; then |
---|
448 | ./ins_make $o_ins_make |
---|
449 | else # bash |
---|
450 | sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash |
---|
451 | if [ "`grep ada AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar |
---|
452 | \cp -f ~rdzt401/bin/AA_make.gdef . |
---|
453 | fi |
---|
454 | chmod u=rwx ins_make.bash |
---|
455 | ./ins_make.bash $o_ins_make |
---|
456 | fi # of if [ "$use_shell" = "ksh" ] |
---|
457 | |
---|
458 | #======================================================================================= |
---|
459 | echo '##########################################################' |
---|
460 | echo 'Compiling IOIPSL, the interface library with Netcdf' |
---|
461 | echo '##########################################################' |
---|
462 | |
---|
463 | cd $MODEL/modipsl/modeles/IOIPSL/src |
---|
464 | if [ "$use_shell" = "bash" ] ; then |
---|
465 | cp Makefile Makefile.ksh |
---|
466 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
---|
467 | fi |
---|
468 | # if [ "$pclinux" = 1 ] ; then |
---|
469 | # Build IOIPSL modules and library |
---|
470 | echo EOEOFOOEOOOOOOOOOOOOOOOOOOOOOOOOOOOO |
---|
471 | $make clean |
---|
472 | $make |
---|
473 | if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then # copy module files to lib |
---|
474 | cp -f *.mod ../../../lib |
---|
475 | fi |
---|
476 | # Build IOIPSL tools (ie: "rebuild", if present) |
---|
477 | if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then |
---|
478 | cd $MODEL/modipsl/modeles/IOIPSL/tools |
---|
479 | # adapt Makefile & rebuild script if in bash |
---|
480 | if [ "$use_shell" = "bash" ] ; then |
---|
481 | cp Makefile Makefile.ksh |
---|
482 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
---|
483 | cp rebuild rebuild.ksh |
---|
484 | sed -e 's:/bin/ksh:/bin/bash:g' \ |
---|
485 | -e 's:print -u2:echo:g' \ |
---|
486 | -e 's:print:echo:g' rebuild.ksh > rebuild |
---|
487 | fi |
---|
488 | $make clean |
---|
489 | $make |
---|
490 | fi |
---|
491 | # fi # of if [ "$pclinux" = 1 ] |
---|
492 | |
---|
493 | else # of if [ $ioipsl = 1 ] |
---|
494 | if [ ${hostname:0:5} = ada33 ] ; then |
---|
495 | cd $MODEL/modipsl |
---|
496 | cd util |
---|
497 | |
---|
498 | cp AA_make.gdef AA_make.orig |
---|
499 | sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp |
---|
500 | sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c:F_C = $compilo -c": \ |
---|
501 | -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ |
---|
502 | -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:' \ |
---|
503 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L/smplocal/pub/NetCDF/4.1.3/lib -lnetcdff -lnetcdf:' \ |
---|
504 | -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \ |
---|
505 | -e 's:#-Q- g95 M_K = gmake:#-Q- g95 M_K = make:' \ |
---|
506 | tmp >| AA_make.gdef |
---|
507 | |
---|
508 | ./ins_make $o_ins_make # We use lines for g95 even for the other compilers |
---|
509 | |
---|
510 | # on Ada, IOIPSL is already installed in ~rpsl035/IOIPSL_PLUS |
---|
511 | # so link it to current settings |
---|
512 | cd $MODEL/modipsl/modeles/ |
---|
513 | \rm -r -f IOIPSL |
---|
514 | ln -s ~rpsl035/IOIPSL_PLUS IOIPSL |
---|
515 | cd .. |
---|
516 | ln -s ~rpsl035/IOIPSL_PLUS/modipsl_Tagv2_2_3/bin/* bin/ |
---|
517 | ln -s ~rpsl035/IOIPSL_PLUS/modipsl_Tagv2_2_3/lib/* lib/ |
---|
518 | |
---|
519 | fi # of if [ ${hostname:0:5} = ada33 ] |
---|
520 | echo install.sh ioipsl_OK `date` |
---|
521 | fi # of if [ $ioipsl = 1 ] |
---|
522 | # Saving ioipsl lib for possible parallel compile |
---|
523 | cd $MODEL/modipsl |
---|
524 | tar cf ioipsl.tar lib/ bin/ |
---|
525 | |
---|
526 | #============================================================================ |
---|
527 | veget_version=false |
---|
528 | if [ "$veget" = 1 ] ; then |
---|
529 | echo '########################################################' |
---|
530 | echo 'Compiling ORCHIDEE, the continental surfaces model ' |
---|
531 | echo '########################################################' |
---|
532 | cd $MODEL/modipsl/modeles/ORCHIDEE |
---|
533 | export ORCHPATH=`pwd` |
---|
534 | if [ -d tools ] ; then |
---|
535 | orchidee_rev=2247 |
---|
536 | veget_version=orchidee2.0 |
---|
537 | cd arch |
---|
538 | sed -e s:"%COMPILER .*.$":"%COMPILER $compilo":1 \ |
---|
539 | -e s:"%LINK .*.$":"%LINK $compilo":1 \ |
---|
540 | -e s:"%FPP_FLAGS .*.$":"%FPP_FLAGS $fpp_flags":1 \ |
---|
541 | -e s:"%PROD_FFLAGS .*.$":"%PROD_FFLAGS $OPTIM":1 \ |
---|
542 | -e s:"%DEV_FFLAGS .*.$":"%DEV_FFLAGS $OPTDEV":1 \ |
---|
543 | -e s:"%DEBUG_FFLAGS .*.$":"%DEBUG_FFLAGS $OPTDEB":1 \ |
---|
544 | -e s:"%BASE_FFLAGS .*.$":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
545 | -e s:"%BASE_LD .*.$":"%BASE_LD $BASE_LD":1 \ |
---|
546 | arch-gfortran.fcm > arch-local.fcm |
---|
547 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path |
---|
548 | echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path |
---|
549 | echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path |
---|
550 | echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path |
---|
551 | cd ../ |
---|
552 | # compiling ORCHIDEE sequential mode |
---|
553 | ./makeorchidee_fcm -j 8 -noxios -prod -parallel none -arch $arch |
---|
554 | echo ./makeorchidee_fcm -j 8 -noxios -prod -parallel none -arch $arch |
---|
555 | echo Fin de la premiere compilation orchidee ; pwd |
---|
556 | else |
---|
557 | if [ -d src_parallel ] ; then |
---|
558 | liste_src="parallel parameters global stomate sechiba driver" |
---|
559 | veget_version=orchidee2.0 |
---|
560 | else |
---|
561 | # Obsolete, for ORCHIDEE_beton only |
---|
562 | liste_src="parameters stomate sechiba " |
---|
563 | # A trick to compile ORCHIDEE depending on if we are using real*4 or real*8 |
---|
564 | cd src_parameters ; \cp reqdprec.$real reqdprec.f90 ; cd .. |
---|
565 | veget_version=orchidee1.9 |
---|
566 | fi |
---|
567 | for d in $liste_src ; do src_d=src_$d |
---|
568 | echo src_d $src_d |
---|
569 | echo ls ; ls |
---|
570 | if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi |
---|
571 | cd $src_d ; \rm -f *.mod make ; $make clean |
---|
572 | $make ; if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi |
---|
573 | cd .. |
---|
574 | done |
---|
575 | fi |
---|
576 | echo install.sh orchidee_OK `date` |
---|
577 | fi # of if [ "$veget" = 1 ] |
---|
578 | |
---|
579 | |
---|
580 | #============================================================================ |
---|
581 | # Ehouarn: it may be directory LMDZ4 or LMDZ5 depending on tar file... |
---|
582 | if [ -d $MODEL/modipsl/modeles/LMD* ] ; then |
---|
583 | echo '##########################################################' |
---|
584 | echo 'Compiling LMDZ' |
---|
585 | echo '##########################################################' |
---|
586 | cd $MODEL/modipsl/modeles/LMD* |
---|
587 | LMDZPATH=`pwd` |
---|
588 | else |
---|
589 | echo "ERROR: No LMD* directory !!!" |
---|
590 | exit |
---|
591 | fi |
---|
592 | |
---|
593 | ########################################################### |
---|
594 | # For those who want to use fcm to compile via : |
---|
595 | # makelmdz_fcm -arch local ..... |
---|
596 | ############################################################ |
---|
597 | |
---|
598 | if [ "$pclinux" = "1" ] ; then |
---|
599 | |
---|
600 | # create local 'arch' files (if on Linux PC): |
---|
601 | cd arch |
---|
602 | # arch-local.path file |
---|
603 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path |
---|
604 | echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path |
---|
605 | echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
606 | echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
607 | echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path |
---|
608 | echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path |
---|
609 | echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
610 | echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
611 | |
---|
612 | BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib" |
---|
613 | # arch-local.fcm file (adapted from arch-linux-32bit.fcm) |
---|
614 | |
---|
615 | if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi |
---|
616 | sed -e s:"%COMPILER .*.$":"%COMPILER $compilo":1 \ |
---|
617 | -e s:"%LINK .*.$":"%LINK $compilo":1 \ |
---|
618 | -e s:"%PROD_FFLAGS .*.$":"%PROD_FFLAGS $OPTIM":1 \ |
---|
619 | -e s:"%DEV_FFLAGS .*.$":"%DEV_FFLAGS $OPTDEV":1 \ |
---|
620 | -e s:"%DEBUG_FFLAGS .*.$":"%DEBUG_FFLAGS $OPTDEB":1 \ |
---|
621 | -e s:"%BASE_FFLAGS .*.$":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
622 | -e s:"%FPP_DEF .*.$":"%FPP_DEF $FPP_DEF":1 \ |
---|
623 | -e s:"%BASE_LD .*.$":"%BASE_LD $BASE_LD":1 \ |
---|
624 | arch-linux-32bit.fcm > arch-local.fcm |
---|
625 | |
---|
626 | cd .. |
---|
627 | ### Adapt "bld.cfg" (add the shell): |
---|
628 | whereisthatshell=$(which ${use_shell}) |
---|
629 | echo "bld::tool::SHELL $whereisthatshell" >> bld.cfg |
---|
630 | |
---|
631 | fi # of if [ "$pclinux" = 1 ] |
---|
632 | |
---|
633 | |
---|
634 | cd $MODEL/modipsl/modeles/LMD* |
---|
635 | |
---|
636 | ################################################################## |
---|
637 | # Mise a jour eventuelle de LMDZ en cas de specification de la release svn |
---|
638 | ################################################################## |
---|
639 | |
---|
640 | if [ "$svn" = "last" ] ; then svnopt="" ; else svnopt="-r $svn" ; fi |
---|
641 | if [ "$svn" != "" ] ; then set +e ; svn upgrade ; set -e ; svn update $svnopt ; fi |
---|
642 | |
---|
643 | ################################################################## |
---|
644 | # Compile LMDZ |
---|
645 | ################################################################## |
---|
646 | |
---|
647 | echo install.sh avant_compilation `date` |
---|
648 | if [ $compile_with_fcm = 1 ] ; then makelmdz="makelmdz_fcm -arch $arch -j 8" ; else makelmdz="makelmdz -arch $arch" ; fi |
---|
649 | |
---|
650 | # use the orchidee interface that has no z0h |
---|
651 | if [ "$no_z0h_orc" = 1 ] ; then |
---|
652 | veget_version="$veget_version -cpp ORCHIDEE_NOZ0H" |
---|
653 | fi |
---|
654 | |
---|
655 | # sequential compilation and bench |
---|
656 | if [ "$sequential" = 1 ] ; then |
---|
657 | echo "./$makelmdz $OPT_MAKELMDZ -rrtm true -d ${grid_resolution} -v $veget_version gcm" >> compile.sh |
---|
658 | chmod +x ./compile.sh ; ./compile.sh |
---|
659 | echo install.sh apres_compilation `date` |
---|
660 | |
---|
661 | |
---|
662 | fi # fin sequential |
---|
663 | |
---|
664 | |
---|
665 | |
---|
666 | # compiling in parallel mode |
---|
667 | if [ $parallel != "none" ] ; then |
---|
668 | echo '##########################################################' |
---|
669 | echo ' Parallel compile ' |
---|
670 | echo '##########################################################' |
---|
671 | # saving the sequential libs and binaries |
---|
672 | cd $MODEL/modipsl |
---|
673 | tar cf sequential.tar bin/ lib/ |
---|
674 | \rm -rf bin/ lib/ |
---|
675 | tar xf ioipsl.tar |
---|
676 | # |
---|
677 | # Orchidee |
---|
678 | # |
---|
679 | cd $ORCHPATH |
---|
680 | if [ -d src_parallel ] ; then |
---|
681 | cd arch |
---|
682 | sed \ |
---|
683 | -e s:"%COMPILER.*.$":"%COMPILER $par_comp":1 \ |
---|
684 | -e s:"%LINK.*.$":"%LINK $par_comp":1 \ |
---|
685 | -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS $MPI_FLAGS":1 \ |
---|
686 | -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS $OMP_FLAGS":1 \ |
---|
687 | -e s:"%MPI_LD.*.$":"%MPI_LD $MPI_LD":1 \ |
---|
688 | -e s:"%OMP_LD.*.$":"%OMP_LD $OMP_LD":1 \ |
---|
689 | arch-local.fcm > tmp.fcm |
---|
690 | |
---|
691 | mv tmp.fcm arch-local.fcm |
---|
692 | cd ../ |
---|
693 | # compiling ORCHIDEE parallel mode |
---|
694 | ./makeorchidee_fcm -j 8 -clean -noxios -prod -parallel $parallel -arch $arch |
---|
695 | ./makeorchidee_fcm -j 8 -noxios -prod -parallel $parallel -arch $arch |
---|
696 | echo ./makeorchidee_fcm -j 8 -clean -noxios -prod -parallel $parallel -arch $arch |
---|
697 | echo ./makeorchidee_fcm -j 8 -noxios -prod -parallel $parallel -arch $arch |
---|
698 | echo deuxieme compilation orchidee ; pwd |
---|
699 | else |
---|
700 | echo '##########################################################' |
---|
701 | echo ' Orchidee version too old ' |
---|
702 | echo ' Please update to new version ' |
---|
703 | echo '##########################################################' |
---|
704 | exit |
---|
705 | fi |
---|
706 | # LMDZ |
---|
707 | cd $LMDZPATH |
---|
708 | if [ $arch = local ] ; then |
---|
709 | cd arch |
---|
710 | sed -e s:"%COMPILER.*.$":"%COMPILER $par_comp":1 \ |
---|
711 | -e s:"%LINK.*.$":"%LINK $par_comp":1 \ |
---|
712 | -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS $MPI_FLAGS":1 \ |
---|
713 | -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS $OMP_FLAGS":1 \ |
---|
714 | -e s:"%MPI_LD.*.$":"%MPI_LD $MPI_LD":1 \ |
---|
715 | -e s:"%OMP_LD.*.$":"%OMP_LD $OMP_LD":1 \ |
---|
716 | arch-local.fcm > tmp.fcm |
---|
717 | mv tmp.fcm arch-local.fcm |
---|
718 | cd ../ |
---|
719 | fi |
---|
720 | rm -f compile.sh |
---|
721 | if [ ${hostname:0:5} = ada33 ] ; then echo "module load intel/2013.0" > compile.sh ; fi |
---|
722 | echo resol=${grid_resolution} >> compile.sh |
---|
723 | echo ./$makelmdz $OPT_MAKELMDZ -rrtm true -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh |
---|
724 | chmod +x ./compile.sh ; ./compile.sh |
---|
725 | |
---|
726 | echo Compilation finished |
---|
727 | |
---|
728 | fi |
---|
729 | |
---|
730 | echo LLLLLLLLLLLLLLLLLLLLLLLLLLL |
---|
731 | if [ "$gfortran" = "gfortran44" ] ; then |
---|
732 | echo Your gfortran compiler was too old so that the model was automatically |
---|
733 | echo compiled with gfortran44 instead. It can not be used in parallel mode. |
---|
734 | echo You can change the compiler at the begining of the install.sh |
---|
735 | echo script and reinstall. |
---|
736 | fi |
---|
737 | |
---|
738 | ################################################################## |
---|
739 | # Verification du succes de la compilation |
---|
740 | ################################################################## |
---|
741 | |
---|
742 | # Recherche de l'executable dont le nom a change au fil du temps ... |
---|
743 | gcm="" |
---|
744 | 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 |
---|
745 | if [ -f $exe ] ; then gcm=$exe ; fi |
---|
746 | done |
---|
747 | |
---|
748 | if [ "$gcm" = "" ] ; then |
---|
749 | echo 'Compilation failed !!' |
---|
750 | exit |
---|
751 | else |
---|
752 | echo '##########################################################' |
---|
753 | echo 'Compilation successfull !! ' |
---|
754 | echo '##########################################################' |
---|
755 | echo The executable is $gcm |
---|
756 | fi |
---|
757 | |
---|
758 | ################################################################## |
---|
759 | # Below, we run a benchmark test (if bench=0) |
---|
760 | ################################################################## |
---|
761 | |
---|
762 | if [ $bench != 0 ] ; then |
---|
763 | |
---|
764 | echo '##########################################################' |
---|
765 | echo ' Running a test run ' |
---|
766 | echo '##########################################################' |
---|
767 | |
---|
768 | \rm -rf BENCH${grid_resolution} |
---|
769 | bench=bench_lmdz_${grid_resolution} |
---|
770 | echo install.sh avant_chargement_bench `date` |
---|
771 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz |
---|
772 | myget $bench.tar.gz |
---|
773 | echo install.sh after bench download `date` |
---|
774 | tar xvf $bench.tar.gz |
---|
775 | |
---|
776 | cp $gcm BENCH${grid_resolution}/gcm.e |
---|
777 | |
---|
778 | |
---|
779 | cd BENCH${grid_resolution} |
---|
780 | # On cree le fichier bench.sh au besoin |
---|
781 | # Dans le cas 48x36x39 le bench.sh existe deja en parallele |
---|
782 | |
---|
783 | if [ "$grid_resolution" = "48x36x39" ] ; then |
---|
784 | echo On ne touche pas au bench.sh |
---|
785 | # But we have to adapt "run_local.sh" for $mpirun |
---|
786 | sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp |
---|
787 | mv -f tmp run_local.sh |
---|
788 | chmod u=rwx run_local.sh |
---|
789 | elif [ "${parallel:0:3}" = "mpi" ] ; then |
---|
790 | # Lancement avec deux procs mpi et 2 openMP |
---|
791 | echo "export OMP_STACKSIZE=800M" > bench.sh |
---|
792 | if [ "${parallel:4:3}" = "omp" ] ; then |
---|
793 | echo "export OMP_NUM_THREADS=2" >> bench.sh |
---|
794 | fi |
---|
795 | echo "ulimit -s unlimited" >> bench.sh |
---|
796 | echo "$mpirun -np 2 gcm.e > listing 2>&1" >> bench.sh |
---|
797 | else |
---|
798 | echo "./gcm.e > listing 2>&1" > bench.sh |
---|
799 | fi |
---|
800 | echo EXECUTION DU BENCH |
---|
801 | date ; ./bench.sh > out.bench 2>&1 ; date |
---|
802 | tail listing |
---|
803 | |
---|
804 | |
---|
805 | echo '##########################################################' |
---|
806 | echo 'Simulation finished in' `pwd` |
---|
807 | echo 'You have compiled with:' |
---|
808 | cat ../compile.sh |
---|
809 | if [ $parallel = "none" ] ; then |
---|
810 | echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e' |
---|
811 | echo 'or ./bench.sh' |
---|
812 | else |
---|
813 | echo 'You may re-run it with : ' |
---|
814 | echo 'cd ' `pwd` '; ./bench.sh' |
---|
815 | echo 'ulimit -s unlimited' |
---|
816 | echo 'export OMP_NUM_THREADS=2' |
---|
817 | echo 'export OMP_STACKSIZE=800M' |
---|
818 | echo "$mpirun -np 2 gcm.e " |
---|
819 | fi |
---|
820 | echo '##########################################################' |
---|
821 | |
---|
822 | fi |
---|
823 | |
---|
824 | |
---|
825 | ################################################################# |
---|
826 | # Installation eventuelle du 1D |
---|
827 | ################################################################# |
---|
828 | |
---|
829 | if [ $SCM = 1 ] ; then |
---|
830 | cd $MODEL |
---|
831 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/1D.tar.gz |
---|
832 | myget 1D.tar.gz |
---|
833 | tar xvf 1D.tar.gz |
---|
834 | cd 1D |
---|
835 | ./run.sh |
---|
836 | fi |
---|