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