1 | #!/bin/bash |
---|
2 | |
---|
3 | ########################################################################### |
---|
4 | # Author : Frédéric Hourdin/LMD/hourdin@lmd.jussieu.fr |
---|
5 | # Usage : install.sh |
---|
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 : g95/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 | echo '################################################################' |
---|
39 | echo Choice of installation options |
---|
40 | echo '################################################################' |
---|
41 | |
---|
42 | |
---|
43 | #real=r4 |
---|
44 | real=r8 |
---|
45 | |
---|
46 | # WARNING !!!! For versions before october 2009, use |
---|
47 | # install.v2.sh instead of install.sh |
---|
48 | |
---|
49 | version=trunk |
---|
50 | version=20141127.trunk |
---|
51 | version=testing |
---|
52 | |
---|
53 | compilo=gfortran # compilo=pgf90 or g95 or gfortran or ifort sur PC linux |
---|
54 | |
---|
55 | #Chemin pour placer le modele |
---|
56 | MODEL=./LMDZ$version |
---|
57 | |
---|
58 | |
---|
59 | getlmdzor=1 |
---|
60 | netcdf=1 # 1 for automatic installation |
---|
61 | # 0 for no installation |
---|
62 | # /.../../netcdf-4.0.1 if wanting to link with an already |
---|
63 | # compiled netcdf library (implies to check option compatibility) |
---|
64 | check_linux=1 |
---|
65 | ioipsl=1 |
---|
66 | veget=1 |
---|
67 | bench=1 |
---|
68 | pclinux=1 |
---|
69 | |
---|
70 | # choose the resolution for the bench runs |
---|
71 | # grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE) |
---|
72 | # 96x71x19 standard configuration |
---|
73 | grid_resolution=48x36x19 |
---|
74 | |
---|
75 | ## compile_with_fcm=1 : use makelmdz_fcm, possible a of version 20111103.trunk (LMDZ5/trunk rev 1578) |
---|
76 | ## compile_with_fcm=0 : use makelmdz |
---|
77 | compile_with_fcm=1 |
---|
78 | |
---|
79 | |
---|
80 | ##################################################################### |
---|
81 | # Test for old gfortran compilers |
---|
82 | # If the compiler is too old (older than 4.3.x) we test if the |
---|
83 | # temporary gfortran44 patch is available on the computer in which |
---|
84 | # case the compiler is changed from gfortran to gfortran44 |
---|
85 | # Must be aware than parallelism can not be activated in this case |
---|
86 | ##################################################################### |
---|
87 | |
---|
88 | if [ $compilo = gfortran ] ; then |
---|
89 | gfortran=gfortran |
---|
90 | gfortranv=`gfortran --version | \ |
---|
91 | head -1 | awk ' { print $NF } ' | awk -F. ' { print $1 * 10 + $2 } '` |
---|
92 | if [ $gfortranv -le 43 ] ; then |
---|
93 | echo ERROR : Your gfortran compiler is too old |
---|
94 | echo 'Please choose a new one (g95, ifort) and change the line' |
---|
95 | echo compilo=xxx |
---|
96 | echo in the install.sh script and rerun it |
---|
97 | if [ `which gfortran44 | wc -w` -ne 0 ] ; then |
---|
98 | gfortran=gfortran44 |
---|
99 | else |
---|
100 | echo gfotran trop vieux ; exit |
---|
101 | fi |
---|
102 | fi |
---|
103 | compilo=$gfortran |
---|
104 | fi |
---|
105 | ##################################################################### |
---|
106 | |
---|
107 | |
---|
108 | |
---|
109 | OPTPREC="" |
---|
110 | echo '################################################################' |
---|
111 | echo Choix des options de compilation |
---|
112 | echo '################################################################' |
---|
113 | |
---|
114 | OPTIMNC=$OPTIM |
---|
115 | export FC=$compilo |
---|
116 | export F90=$compilo |
---|
117 | export F77=$compilo |
---|
118 | export CPPFLAGS= |
---|
119 | BASE_LD= |
---|
120 | if [ $compilo = g95 ] ; then |
---|
121 | # Set the appropriate compilation options |
---|
122 | OPTIM='-i4 -O3' |
---|
123 | OPTDEB="-g -O0 -Wall -ftrace=full -fbounds-check -freal=nan" |
---|
124 | OPTDEV="-g -O1 -Wall" |
---|
125 | fmod='fmod=' |
---|
126 | BASE_LD="" |
---|
127 | if [ $real = r8 ] ; then OPTPREC="-r8 -DNC_DOUBLE" ; fi |
---|
128 | export F90FLAGS=" -cpp -ffree-form $OPTIMNC" |
---|
129 | export FFLAGS=" -cpp $OPTIMNC" |
---|
130 | export CPPFLAGS=-Df2cFortran |
---|
131 | export CC=gcc |
---|
132 | export CXX=g++ |
---|
133 | elif [ $compilo = $gfortran ] ; then |
---|
134 | OPTIM='-O3' |
---|
135 | OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all" |
---|
136 | OPTDEV="-Wall -fbounds-check" |
---|
137 | fmod='I ' |
---|
138 | if [ $real = r8 ] ; then OPTPREC="-fdefault-real-8 -DNC_DOUBLE" ; fi |
---|
139 | export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
140 | export FFLAGS=" $OPTIMNC" |
---|
141 | export CC=gcc |
---|
142 | export CXX=g++ |
---|
143 | elif [ $compilo = mpif90 ] ; then |
---|
144 | OPTIM='-O3' |
---|
145 | OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all" |
---|
146 | OPTDEV="-Wall -fbounds-check" |
---|
147 | BASE_LD="-lblas" |
---|
148 | fmod='I ' |
---|
149 | if [ $real = r8 ] ; then OPTPREC="-fdefault-real-8 -DNC_DOUBLE -fcray-pointer" ; fi |
---|
150 | export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
151 | export FFLAGS=" $OPTIMNC" |
---|
152 | export CC=gcc |
---|
153 | export CXX=g++ |
---|
154 | elif [ $compilo = pgf90 ] ; then |
---|
155 | OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align' |
---|
156 | OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback' |
---|
157 | OPTDEV='-g -Mbounds -Ktrap=fp -traceback' |
---|
158 | fmod='module ' |
---|
159 | if [ $real = r8 ] ; then OPTPREC="-r8 -DNC_DOUBLE" ; fi |
---|
160 | export CPPFLAGS="-DpgiFortran" |
---|
161 | export CC=pgcc |
---|
162 | export CFLAGS="-O2 -Msignextend" |
---|
163 | export CXX=pgCC |
---|
164 | export CXXFLAGS="-O2 -Msignextend" |
---|
165 | export FFLAGS="-O2 $OPTIMNC" |
---|
166 | export F90FLAGS="-O2 $OPTIMNC" |
---|
167 | compile_with_fcm=1 |
---|
168 | elif [ $compilo = ifort ] ; then |
---|
169 | OPTIM="-O2 -fp-model strict -ip -align all " |
---|
170 | OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check" |
---|
171 | OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check" |
---|
172 | fmod='module ' |
---|
173 | if [ $real = r8 ] ; then OPTPREC="-real-size 64 -DNC_DOUBLE" ; fi |
---|
174 | export CPP="icc -E" |
---|
175 | export FFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
176 | export FCFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
177 | export CC=icc |
---|
178 | export CFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
179 | export CXX=icpc |
---|
180 | export CXXFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
181 | compile_with_fcm=1 |
---|
182 | else |
---|
183 | echo unexpected compiler $compilo ; exit |
---|
184 | fi |
---|
185 | |
---|
186 | OPTIMGCM="$OPTIM $OPTPREC" |
---|
187 | |
---|
188 | hostname=`hostname` |
---|
189 | |
---|
190 | ########################################################################## |
---|
191 | # If installing on know machines such as IBM x3750 (Ada) |
---|
192 | # at IDRIS, don't check for available software and don"t install netcdf |
---|
193 | if [ ${hostname:0:5} = ada33 ] ; then |
---|
194 | netcdf=0 # no need to recompile netcdf, alreday available |
---|
195 | check_linux=0 |
---|
196 | pclinux=0 |
---|
197 | ioipsl=0 # no need to recompile ioipsl, already available |
---|
198 | #netcdf="/smplocal/pub/NetCDF/4.1.3" |
---|
199 | compilo="ifort" |
---|
200 | fmod='module ' |
---|
201 | if [ $real = r8 ] ; then OPTPREC="-real-size 64 -DNC_DOUBLE" ; fi |
---|
202 | OPTIM="-O2 -fp-model strict -ip -axAVX,SSE4.2 -align all " |
---|
203 | OPTIMGCM="$OPTIM $OPTPREC" |
---|
204 | fi |
---|
205 | ########################################################################## |
---|
206 | |
---|
207 | |
---|
208 | mkdir -p $MODEL |
---|
209 | echo $MODEL |
---|
210 | MODEL=`( cd $MODEL ; pwd )` # to get absolute path, if necessary |
---|
211 | |
---|
212 | |
---|
213 | |
---|
214 | # Option -fendian=big is only to be used with ARPEGE1D. |
---|
215 | # The -r8 should probably be avoided if running on 32 bit machines |
---|
216 | # Option r8 is not mandatory and generates larger executables. |
---|
217 | # It is however mandatory if using ARPEGE1D |
---|
218 | # Better optimization options might be a better choice (e.g. -O3) |
---|
219 | |
---|
220 | |
---|
221 | echo '################################################################' |
---|
222 | if [ "$check_linux" = 1 ] ; then |
---|
223 | echo Check if required software is available |
---|
224 | echo '################################################################' |
---|
225 | |
---|
226 | #### Ehouarn: test if ksh and/or bash are available |
---|
227 | use_shell="ksh" # default: use ksh |
---|
228 | if [ "`which ksh`" = "" ] ; then |
---|
229 | echo "no ksh ... we will use bash" |
---|
230 | use_shell="bash" |
---|
231 | if [ "`which bash`" = "" ] ; then |
---|
232 | echo "ksh (or bash) needed!! Install it!" |
---|
233 | fi |
---|
234 | fi |
---|
235 | |
---|
236 | |
---|
237 | for logiciel in csh wget tar gzip make $compilo gcc ; do |
---|
238 | if [ "`which $logiciel`" = "" ] ; then |
---|
239 | echo You must first install $logiciel on your system |
---|
240 | exit |
---|
241 | fi |
---|
242 | done |
---|
243 | |
---|
244 | if [ $pclinux = 1 ] ; then |
---|
245 | cd $MODEL |
---|
246 | cat <<eod > tt.f90 |
---|
247 | print*,'coucou' |
---|
248 | end |
---|
249 | eod |
---|
250 | $compilo tt.f90 -o a.out |
---|
251 | ./a.out >| tt |
---|
252 | if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then |
---|
253 | echo problem installing with compiler $compilo ; exit ; fi |
---|
254 | \rm tt a.out tt.f90 |
---|
255 | fi |
---|
256 | fi |
---|
257 | |
---|
258 | ########################################################################### |
---|
259 | if [ $getlmdzor = 1 ] ; then |
---|
260 | echo '##########################################################' |
---|
261 | echo Download a slightly modified version of LMDZ |
---|
262 | echo '##########################################################' |
---|
263 | cd $MODEL |
---|
264 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/modipsl.$version.tar.gz |
---|
265 | echo install.sh wget_OK `date` |
---|
266 | gunzip modipsl.$version.tar.gz |
---|
267 | tar xvf modipsl.$version.tar |
---|
268 | \rm modipsl.$version.tar |
---|
269 | |
---|
270 | # We download LMDZ and make some modifications to make it |
---|
271 | #compatible with $compilo |
---|
272 | # and we use an old stable but robust and well tested version of ORCHIDEE |
---|
273 | # That version of ORCHIDEE can be obtained using |
---|
274 | # wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/getlmdzor.x |
---|
275 | fi |
---|
276 | |
---|
277 | echo OK1 |
---|
278 | |
---|
279 | if [ $netcdf = 1 ] ; then |
---|
280 | echo '##########################################################' |
---|
281 | echo Compiling the Netcdf library |
---|
282 | echo '##########################################################' |
---|
283 | cd $MODEL |
---|
284 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/netcdf-4.0.1.tar.gz |
---|
285 | gunzip netcdf-4.0.1.tar.gz |
---|
286 | tar xvf netcdf-4.0.1.tar |
---|
287 | \rm -f netcdf-4.0.1.tar |
---|
288 | |
---|
289 | cd netcdf-4.0.1 |
---|
290 | |
---|
291 | sed -e 's/gfortran/'$gfortran'/g' configure >| tmp ; mv -f tmp configure ; chmod +x configure |
---|
292 | localdir=`pwd -P` |
---|
293 | ./configure --prefix=$localdir --disable-cxx |
---|
294 | sed -e 's/gfortran/'$gfortran'/g' Makefile >| tmp ; mv -f tmp Makefile |
---|
295 | make check |
---|
296 | make install |
---|
297 | echo install.sh netcdf_OK `date` |
---|
298 | fi # of if [ $netcdf = 1 ] |
---|
299 | |
---|
300 | |
---|
301 | #======================================================================================= |
---|
302 | echo OK2 ioipsl=$ioipsl |
---|
303 | echo '##########################################################' |
---|
304 | echo 'Installing MODIPSL, the installation package manager for the ' |
---|
305 | echo 'IPSL models and tools' |
---|
306 | echo '##########################################################' |
---|
307 | |
---|
308 | if [ $netcdf = 0 -o $netcdf = 1 ] ; then |
---|
309 | ncdfdir=$MODEL/netcdf-4.0.1 |
---|
310 | else |
---|
311 | ncdfdir=$netcdf |
---|
312 | fi |
---|
313 | |
---|
314 | if [ $ioipsl = 1 ] ; then |
---|
315 | cd $MODEL/modipsl |
---|
316 | \rm -rf lib/* |
---|
317 | |
---|
318 | cd util |
---|
319 | |
---|
320 | cp AA_make.gdef AA_make.orig |
---|
321 | F_C="$compilo -c " ; if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then F_C="$compilo -c -cpp " ; fi |
---|
322 | if [ "$compilo" = "pgf90" ] ; then F_C="$compilo -c -Mpreprocess" ; fi |
---|
323 | sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp |
---|
324 | sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \ |
---|
325 | -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ |
---|
326 | -e 's:g95.*.NCDF_INC.*.$:g95 NCDF_INC= '"$ncdfdir"'/include:' \ |
---|
327 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdf:' \ |
---|
328 | -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \ |
---|
329 | -e 's:#-Q- g95 M_K = gmake:#-Q- g95 M_K = make:' \ |
---|
330 | tmp >| AA_make.gdef |
---|
331 | |
---|
332 | |
---|
333 | if [ "$use_shell" = "ksh" ] ; then |
---|
334 | if [ "$pclinux" = 1 ] ; then |
---|
335 | ./ins_make -t g95 # We use lines for g95 even for the other compilers |
---|
336 | fi |
---|
337 | else # bash |
---|
338 | sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash |
---|
339 | chmod u=rwx ins_make.bash |
---|
340 | if [ "$pclinux" = 1 ] ; then |
---|
341 | ./ins_make.bash -t g95 # We use lines for g95 even for the other compilers |
---|
342 | else |
---|
343 | ./ins_make.bash |
---|
344 | fi |
---|
345 | fi # of if [ "$use_shell" = "ksh" ] |
---|
346 | |
---|
347 | #======================================================================================= |
---|
348 | echo '##########################################################' |
---|
349 | echo 'Compiling IOIPSL, the interface library with Netcdf' |
---|
350 | echo '##########################################################' |
---|
351 | |
---|
352 | cd $MODEL/modipsl/modeles/IOIPSL/src |
---|
353 | if [ "$use_shell" = "bash" ] ; then |
---|
354 | cp Makefile Makefile.ksh |
---|
355 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
---|
356 | fi |
---|
357 | if [ "$pclinux" = 1 ] ; then |
---|
358 | # Build IOIPSL modules and library |
---|
359 | if [ $compilo = g95 ] ; then |
---|
360 | cp restcom.f90 restcom.f90.orig |
---|
361 | sed -e 's:cmode=or(NF90_NOCLOBBER,NF90_64BIT_OFFSET):cmode=NF90_NOCLOBBER:' restcom.f90.orig > restcom.f90 |
---|
362 | fi |
---|
363 | make clean |
---|
364 | make |
---|
365 | if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then # copy module files to lib |
---|
366 | cp -f *.mod ../../../lib |
---|
367 | fi |
---|
368 | # Build IOIPSL tools (ie: "rebuild", if present) |
---|
369 | if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then |
---|
370 | cd $MODEL/modipsl/modeles/IOIPSL/tools |
---|
371 | # adapt Makefile & rebuild script if in bash |
---|
372 | if [ "$use_shell" = "bash" ] ; then |
---|
373 | cp Makefile Makefile.ksh |
---|
374 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
---|
375 | cp rebuild rebuild.ksh |
---|
376 | sed -e 's:/bin/ksh:/bin/bash:g' \ |
---|
377 | -e 's:print -u2:echo:g' \ |
---|
378 | -e 's:print:echo:g' rebuild.ksh > rebuild |
---|
379 | fi |
---|
380 | make clean |
---|
381 | make |
---|
382 | fi |
---|
383 | fi # of if [ "$pclinux" = 1 ] |
---|
384 | |
---|
385 | else # of if [ $ioipsl = 1 ] |
---|
386 | if [ ${hostname:0:5} = ada33 ] ; then |
---|
387 | cd $MODEL/modipsl |
---|
388 | cd util |
---|
389 | |
---|
390 | cp AA_make.gdef AA_make.orig |
---|
391 | sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp |
---|
392 | sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c:F_C = $compilo -c": \ |
---|
393 | -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ |
---|
394 | -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:' \ |
---|
395 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L/smplocal/pub/NetCDF/4.1.3/lib -lnetcdff -lnetcdf:' \ |
---|
396 | -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \ |
---|
397 | -e 's:#-Q- g95 M_K = gmake:#-Q- g95 M_K = make:' \ |
---|
398 | tmp >| AA_make.gdef |
---|
399 | |
---|
400 | ./ins_make -t g95 # We use lines for g95 even for the other compilers |
---|
401 | |
---|
402 | # on Ada, IOIPSL is already installed in ~rpsl035/IOIPSL_PLUS |
---|
403 | # so link it to current settings |
---|
404 | cd $MODEL/modipsl/modeles/ |
---|
405 | \rm -r -f IOIPSL |
---|
406 | ln -s ~rpsl035/IOIPSL_PLUS IOIPSL |
---|
407 | cd .. |
---|
408 | ln -s ~rpsl035/IOIPSL_PLUS/modipsl/bin/* bin/ |
---|
409 | ln -s ~rpsl035/IOIPSL_PLUS/modipsl/lib/* lib/ |
---|
410 | |
---|
411 | fi # of if [ ${hostname:0:5} = ada33 ] |
---|
412 | echo install.sh ioipsl_OK `date` |
---|
413 | fi # of if [ $ioipsl = 1 ] |
---|
414 | |
---|
415 | |
---|
416 | #============================================================================ |
---|
417 | veget_version=false |
---|
418 | if [ "$veget" = 1 ] ; then |
---|
419 | echo '########################################################' |
---|
420 | echo 'Compiling ORCHIDEE, the continental surfaces model ' |
---|
421 | echo '########################################################' |
---|
422 | cd $MODEL/modipsl/modeles/ORCHIDEE |
---|
423 | echo OKpwd ; pwd |
---|
424 | if [ -d src_parallel ] ; then |
---|
425 | liste_src="parallel parameters global stomate sechiba driver" |
---|
426 | veget_version=orchidee2.0 |
---|
427 | else |
---|
428 | # Obsolete, for ORCHIDEE_beton only |
---|
429 | liste_src="parameters stomate sechiba " |
---|
430 | # A trick to compile ORCHIDEE depending on if we are using real*4 or real*8 |
---|
431 | cd src_parameters ; \cp reqdprec.$real reqdprec.f90 ; cd .. |
---|
432 | veget_version=orchidee1.9 |
---|
433 | fi |
---|
434 | echo liste_strc $liste_src |
---|
435 | |
---|
436 | for d in $liste_src ; do src_d=src_$d |
---|
437 | echo src_d $src_d |
---|
438 | echo ls ; ls |
---|
439 | if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi |
---|
440 | cd $src_d ; \rm -f *.mod make ; make clean |
---|
441 | make ; if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi |
---|
442 | cd .. |
---|
443 | done |
---|
444 | echo install.sh orchidee_OK `date` |
---|
445 | fi # of if [ "$veget" = 1 ] |
---|
446 | |
---|
447 | |
---|
448 | #============================================================================ |
---|
449 | # Ehouarn: it may be directory LMDZ4 or LMDZ5 depending on tar file... |
---|
450 | if [ -d $MODEL/modipsl/modeles/LMDZ[45] ] ; then |
---|
451 | echo '##########################################################' |
---|
452 | echo 'Compiling LMDZ' |
---|
453 | echo '##########################################################' |
---|
454 | cd $MODEL/modipsl/modeles/LMDZ[45] |
---|
455 | else |
---|
456 | echo "ERROR: No LMDZ4 (or LMDZ5) directory !!!" |
---|
457 | exit |
---|
458 | fi |
---|
459 | |
---|
460 | ########################################################### |
---|
461 | # For those who want to use fcm to compile via : |
---|
462 | # makelmdz_fcm -arch local ..... |
---|
463 | ############################################################ |
---|
464 | |
---|
465 | if [ "$pclinux" = "1" ] ; then |
---|
466 | |
---|
467 | # create local 'arch' files (if on Linux PC): |
---|
468 | cd arch |
---|
469 | # arch-local.path file |
---|
470 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdf\"" > arch-local.path |
---|
471 | echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path |
---|
472 | echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
473 | echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
474 | echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
475 | echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
476 | # arch-local.fcm file (adapted from arch-linux-32bit.fcm) |
---|
477 | |
---|
478 | if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi |
---|
479 | sed -e s:"%COMPILER .*.$":"%COMPILER $compilo":1 \ |
---|
480 | -e s:"%LINK .*.$":"%LINK $compilo":1 \ |
---|
481 | -e s:"%PROD_FFLAGS .*.$":"%PROD_FFLAGS $OPTIM":1 \ |
---|
482 | -e s:"%DEV_FFLAGS .*.$":"%DEV_FFLAGS $OPTDEV":1 \ |
---|
483 | -e s:"%DEBUG_FFLAGS .*.$":"%DEBUG_FFLAGS $OPTDEB":1 \ |
---|
484 | -e s:"%BASE_FFLAGS .*.$":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
485 | -e s:"%FPP_DEF .*.$":"%FPP_DEF $FPP_DEF":1 \ |
---|
486 | arch-linux-32bit.fcm > arch-local.fcm |
---|
487 | |
---|
488 | cd .. |
---|
489 | ### Adapt "bld.cfg" (add the shell): |
---|
490 | whereisthatshell=$(which ${use_shell}) |
---|
491 | echo "bld::tool::SHELL $whereisthatshell" >> bld.cfg |
---|
492 | |
---|
493 | fi # of if [ "$pclinux" = 1 ] |
---|
494 | |
---|
495 | |
---|
496 | cd $MODEL/modipsl/modeles/LMDZ? |
---|
497 | |
---|
498 | ################################################################## |
---|
499 | # Compile LMDZ |
---|
500 | ################################################################## |
---|
501 | echo install.sh avant_compilation `date` |
---|
502 | if [ $compile_with_fcm = 1 ] ; then makelmdz="makelmdz_fcm -arch local" ; else makelmdz=makelmdz ; fi |
---|
503 | |
---|
504 | ./$makelmdz -d ${grid_resolution} -v $veget_version gcm |
---|
505 | echo install.sh apres_compilation `date` |
---|
506 | |
---|
507 | |
---|
508 | if [ -f gcm.e ] || [ -f bin/gcm_${grid_resolution}_phylmd_seq_orch.e ] || [ -f bin/gcm_${grid_resolution}_phylmd_seq.e ] ; then |
---|
509 | echo '##########################################################' |
---|
510 | echo 'Compilation successfull !! ' |
---|
511 | echo '##########################################################' |
---|
512 | else |
---|
513 | echo 'Compilation failed !!' |
---|
514 | exit |
---|
515 | fi |
---|
516 | |
---|
517 | ################################################################## |
---|
518 | # Below, we run a benchmark test (if bench=0) |
---|
519 | ################################################################## |
---|
520 | if [ $bench = 0 ] ; then |
---|
521 | exit |
---|
522 | fi |
---|
523 | |
---|
524 | echo '##########################################################' |
---|
525 | echo ' Running a test run ' |
---|
526 | echo '##########################################################' |
---|
527 | |
---|
528 | \rm -rf BENCH${grid_resolution} |
---|
529 | bench=bench_lmdz_${grid_resolution} |
---|
530 | echo install.sh avant_chargement_bench `date` |
---|
531 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/$bench.tar.gz |
---|
532 | echo install.sh apres_chargement_bench `date` |
---|
533 | gunzip $bench.tar.gz |
---|
534 | tar xvf $bench.tar |
---|
535 | |
---|
536 | if [ -f gcm.e ] ; then |
---|
537 | cp gcm.e BENCH${grid_resolution}/ |
---|
538 | elif [ -f bin/gcm_${grid_resolution}_phylmd_seq_orch.e ] ; then |
---|
539 | cp bin/gcm_${grid_resolution}_phylmd_seq_orch.e BENCH${grid_resolution}/gcm.e |
---|
540 | elif [ -f bin/gcm_${grid_resolution}_phylmd_seq.e ] ; then |
---|
541 | cp bin/gcm_${grid_resolution}_phylmd_seq.e BENCH${grid_resolution}/gcm.e |
---|
542 | else |
---|
543 | echo "No gcm.e found" |
---|
544 | exit |
---|
545 | fi |
---|
546 | |
---|
547 | |
---|
548 | cd BENCH${grid_resolution} |
---|
549 | ./bench.sh > bench.out 2>&1 |
---|
550 | |
---|
551 | |
---|
552 | echo '##########################################################' |
---|
553 | echo ' Bench results ' |
---|
554 | echo '##########################################################' |
---|
555 | |
---|
556 | cat ./bench.out |
---|
557 | echo install.sh FIN_du_BENCH `date` |
---|
558 | |
---|
559 | echo '##########################################################' |
---|
560 | echo 'Simulation finished in' `pwd` |
---|
561 | echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e' |
---|
562 | echo 'or ./bench.sh' |
---|
563 | echo '##########################################################' |
---|
564 | |
---|
565 | if [ "$gfortran" = "gfortran44" ] ; then |
---|
566 | echo Your gfortran compiler was too old so that the model was automatically |
---|
567 | echo compiled with gfortran44 instead. It can not be used in parallel mode. |
---|
568 | echo You can change the compiler at the begining of the install.sh |
---|
569 | echo script and reinstall. |
---|
570 | fi |
---|