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