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