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