source: BOL/script_install/install.sh @ 1837

Last change on this file since 1837 was 1837, checked in by Laurent Fairhead, 11 years ago

Modifications pour pouvoir compiler avec les différentes versions de ORCHIDEE


Modifications needed for compilation with the different versions of ORCHIDEE

LF

File size: 22.2 KB
Line 
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
34echo '################################################################'
35echo  Choice of installation options
36echo '################################################################'
37
38
39#real=r4
40real=r8
41
42# WARNING !!!! For versions before october 2009, use
43# install.v2.sh instead of install.sh
44
45version=20130716.trunk
46version=testing
47
48#Chemin pour placer le modele
49MODEL=./LMDZ$version
50
51getlmdzor=1
52netcdf=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)
56check_linux=1
57ioipsl=1
58veget=1
59bench=1
60pclinux=1
61compilo=gfortran # compilo=pgf90 or g95 or gfortran or ifort sur PC linux
62
63
64#####################################################################
65# Test for old gfortran compilers
66if [ $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
76fi
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 makelmdz
83compile_with_fcm=0
84
85OPTPREC=""
86echo '################################################################'
87echo  Choix des options de compilation
88echo '################################################################'
89
90if [ $compilo = g95 ] ; then
91   if [ $real = r8 ] ; then OPTPREC="-r8 -DNC_DOUBLE" ; fi
92   OPTIM='-i4 -O3'
93elif [ $compilo = gfortran ] ; then
94   if [ $real = r8 ] ; then OPTPREC="-fdefault-real-8 -DNC_DOUBLE" ; fi
95   OPTIM='-O3'
96elif [ $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
101else 
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
107fi
108OPTIMGCM="$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
113grid_resolution=48x36x19
114
115hostname=`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
120if [ ${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"
131fi
132##########################################################################
133
134
135mkdir -p $MODEL
136echo $MODEL
137MODEL=`( 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
148echo '################################################################'
149if [ "$check_linux" = 1 ] ; then
150echo   Check if required software is available
151echo '################################################################'
152
153#### Ehouarn: test if ksh and/or bash are available
154use_shell="ksh" # default: use ksh
155if [ "`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
161fi
162
163
164for logiciel in csh wget tar gzip make $compilo gcc ; do
165if [ "`which $logiciel`" = "" ] ; then
166echo You must first install $logiciel on your system
167exit
168fi
169done
170
171if [ $pclinux = 1 ] ; then
172cd $MODEL
173cat <<eod> tt.f90
174print*,'coucou'
175end
176eod
177$compilo tt.f90 -o a.out
178./a.out >| tt
179if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then
180echo problem installing with compiler $compilo ; exit ; fi
181\rm tt a.out tt.f90
182fi
183fi
184
185###########################################################################
186
187
188
189if [ $getlmdzor = 1 ] ; then
190echo '##########################################################'
191echo  Download a slightly modified version of  LMDZ
192echo '##########################################################'
193cd $MODEL
194wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/modipsl.$version.tar.gz
195gunzip modipsl.$version.tar.gz
196tar 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
204fi
205
206echo OK1
207
208if [ $netcdf = 1 ] ; then
209echo '##########################################################'
210echo Compiling the Netcdf library
211echo '##########################################################'
212cd $MODEL
213wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/netcdf-4.0.1.tar.gz
214gunzip netcdf-4.0.1.tar.gz
215tar xvf netcdf-4.0.1.tar
216\rm -f netcdf-4.0.1.tar
217
218cd netcdf-4.0.1
219
220OPTIMNC=$OPTIM
221if [ $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++
230elif [ $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++
238elif [ $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"
248elif [ $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"
258else
259   echo unexpected compiler $compilo ; exit
260fi
261
262localdir=`pwd -P`
263./configure --prefix=$localdir
264make check
265make install
266fi # of if [ $netcdf = 1 ]
267
268#=======================================================================================
269echo OK2 ioipsl=$ioipsl
270echo '##########################################################'
271echo 'Installing MODIPSL, the installation package manager for the '
272echo 'IPSL models and tools'
273echo '##########################################################'
274
275if [ $netcdf = 0 -o $netcdf = 1 ] ; then
276ncdfdir=$MODEL/netcdf-4.0.1
277else
278ncdfdir=$netcdf
279fi
280
281if [ $ioipsl = 1 ] ; then
282  cd $MODEL/modipsl
283  \rm -r lib/*
284
285  cd util
286
287  if [ $compilo = pgf90 ] ; then 
288    fmod='module '
289  elif [ $compilo = g95 ] ; then
290    fmod='fmod='
291  elif [ $compilo = ifort ] ; then
292    fmod='module '
293  else # gfortran
294    fmod='I '
295  fi
296  cp AA_make.gdef AA_make.orig
297  F_C="$compilo -c " ; if [ $compilo = gfortran ] ; then F_C="$compilo -c -cpp " ; fi
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 = $F_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 # of if [ "$use_shell" = "ksh" ]
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    if [ $compilo = g95 ] ; then
334       cp restcom.f90 restcom.f90.orig
335       sed -e 's:cmode=or(NF90_NOCLOBBER,NF90_64BIT_OFFSET):cmode=NF90_NOCLOBBER:' restcom.f90.orig > restcom.f90 
336    fi
337    make clean
338    make
339    if [ $compilo = gfortran ] ; then # copy module files to lib
340      cp -f *.mod ../../../lib
341    fi
342    # Build IOIPSL tools (ie: "rebuild", if present)
343    if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then
344      cd $MODEL/modipsl/modeles/IOIPSL/tools
345      # adapt Makefile & rebuild script if in bash
346      if [ "$use_shell" = "bash" ] ; then
347        cp Makefile Makefile.ksh
348        sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
349        cp rebuild rebuild.ksh
350        sed -e 's:/bin/ksh:/bin/bash:g' \
351            -e 's:print -u2:echo:g' \
352            -e 's:print:echo:g' rebuild.ksh > rebuild
353      fi
354      make clean
355      make
356    fi
357  fi # of if [ "$pclinux" = 1 ]
358
359else # of if [ $ioipsl = 1 ]
360  if [ ${hostname:0:5} = ada33 ] ; then
361    cd $MODEL/modipsl
362    cd util
363
364    cp AA_make.gdef AA_make.orig
365    sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
366    sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c:F_C = $compilo -c": \
367    -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
368    -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:' \
369    -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L/smplocal/pub/NetCDF/4.1.3/lib -lnetcdff -lnetcdf:' \
370    -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
371    -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
372    tmp >| AA_make.gdef
373
374    ./ins_make -t g95 # We use lines for g95 even for the other compilers
375
376    # on Ada, IOIPSL is already installed in ~rpsl035/IOIPSL_PLUS
377    # so link it to current settings
378    cd $MODEL/modipsl/modeles/
379    \rm -r -f IOIPSL
380    ln -s ~rpsl035/IOIPSL_PLUS IOIPSL
381    cd ..
382    ln -s ~rpsl035/IOIPSL_PLUS/modipsl/bin/* bin/
383    ln -s ~rpsl035/IOIPSL_PLUS/modipsl/lib/* lib/
384
385  fi # of if [ ${hostname:0:5} = ada33 ]
386fi # of if [ $ioipsl = 1 ]
387
388#============================================================================
389veget_version=false
390if [ "$veget" = 1 ] ; then
391  echo '########################################################'
392  echo 'Compiling ORCHIDEE, the continental surfaces model '
393  echo '########################################################'
394  cd $MODEL/modipsl/modeles/ORCHIDEE
395  echo OKpwd ; pwd
396  if [ -d src_parallel ] ; then
397     liste_src="parallel parameters global stomate sechiba driver"
398     veget_version=orchidee2.0
399  else
400     # Obsolete, for ORCHIDEE_beton only
401     liste_src="parameters stomate sechiba "
402     # A trick to compile ORCHIDEE depending on if we are using real*4 or real*8
403     cd src_parameters ; \cp reqdprec.$real reqdprec.f90 ; cd ..
404     veget_version=orchidee1.9
405  fi
406  echo liste_strc $liste_src
407
408  for d in $liste_src ; do src_d=src_$d
409      echo src_d $src_d
410      echo ls ; ls
411      if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi
412      cd $src_d ; \rm -f *.mod make ; make clean
413      make ; if [ $compilo = gfortran ] ; then cp -f *.mod ../../../lib ; fi
414      cd ..
415  done
416fi # of if [ "$veget" = 1 ]
417
418#============================================================================
419# Ehouarn: it may be directory LMDZ4 or LMDZ5 depending on tar file...
420if [ -d $MODEL/modipsl/modeles/LMDZ[45] ] ; then
421  echo '##########################################################'
422  echo 'Compiling LMDZ'
423  echo '##########################################################'
424  cd $MODEL/modipsl/modeles/LMDZ[45]
425else
426  echo "ERROR: No LMDZ4 (or LMDZ5) directory !!!"
427  exit
428fi
429
430#============================================================================
431# Traitement momentanne a cause d'un bug dans makegcm
432cp create_make_gcm create_make_gcm.orig
433nl=`sed -n -e /PROGRAM/= create_make_gcm.orig | tail -1`
434sed -e "$nl s/      PROGRA/PROGRA/" create_make_gcm.orig >| create_make_gcm
435
436#mv -f tmp crea
437if [ "$pclinux" = 1 ] ; then
438  if [ $compilo = gfortran ] ; then
439sed \
440-e 's:\#setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \
441-e 's:\#setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \
442-e 's:setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \
443-e 's:setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \
444-e 's/set FC_LINUX.*.$/set FC_LINUX='$compilo'/' \
445-e 's/g95/gfortran/g' \
446-e 's/-fmod=/-I/g' \
447-e 's/-fno-second-underscore//' -e 's/-fstatic//' \
448-e 's/-lparallel//' \
449-e 's/-lnetcdff//g' \
450-e 's/-lorglob//' \
451-e 's/-ffixed-form//' -e 's/-ffree-form//' \
452-e 's/set OPT_LINUX.*.$/set OPT_LINUX=\"'"$OPTIMGCM"\"'/' makegcm.orig >| makegcm
453  elif [ $compilo = ifort ] ; then
454sed \
455-e 's:\#setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \
456-e 's:\#setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \
457-e 's:setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \
458-e 's:setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \
459-e 's/set FC_LINUX.*.$/set FC_LINUX='$compilo'/' \
460-e 's/g95/ifort/g' \
461-e 's/-fmod=/-module /g' \
462-e 's/-fno-second-underscore//' -e 's/-fstatic//' \
463-e 's/-lparallel//' \
464-e 's/-lnetcdff//g' \
465-e 's/-lorglob//' \
466-e 's/-ffixed-form//' -e 's/-ffree-form//' \
467-e 's/set OPT_LINUX.*.$/set OPT_LINUX=\"'"$OPTIMGCM"\"'/' makegcm.orig >| makegcm
468  else # g95 or pgf90
469sed \
470-e 's:\#setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \
471-e 's:\#setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \
472-e 's:setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \
473-e 's:setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \
474-e 's/set FC_LINUX.*.$/set FC_LINUX='$compilo'/' \
475-e 's/-fno-second-underscore//' -e 's/-fstatic//' \
476-e 's/-lparallel//' \
477-e 's/-lnetcdff//g' \
478-e 's/-lorglob//' \
479-e 's/-ffixed-form//' -e 's/-ffree-form//' \
480-e 's/set OPT_LINUX.*.$/set OPT_LINUX=\"'"$OPTIMGCM"\"'/' makegcm.orig >| makegcm
481  fi
482else
483sed \
484-e 's/-lparallel//' \
485-e 's/-lorglob//' \
486-e 's/-lsxorglob//' \
487-e 's/-lsxparallel//' \
488-e 's/-lsxioipsl/-lioipsl/g' \
489makegcm.orig >| makegcm
490fi
491
492chmod +x makegcm
493
494###########################################################
495# For those who want to use fcm to compile via :
496#  makelmdz_fcm -arch local .....
497############################################################
498
499if [ "$pclinux" = 1 ] ; then
500# create local 'arch' files (if on Linux PC):
501cd arch
502# arch-local.path file
503echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdf\"" > arch-local.path
504echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path
505echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path
506echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
507echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path
508echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
509# arch-local.fcm file (adapted from arch-linux-32bit.fcm)
510if [ $compilo = g95 ] ; then
511sed -e s:"%COMPILER            pgf95":"%COMPILER            g95":1 \
512    -e s:"%LINK                pgf95":"%LINK                g95":1 \
513    -e s:"%PROD_FFLAGS         -fast":"%PROD_FFLAGS         $OPTIM":1 \
514    -e s:"%DEV_FFLAGS          -g -O1":"%DEV_FFLAGS          -g -O1 -Wall":1 \
515    -e s:"%DEBUG_FFLAGS        -g -O0 -Kieee -Ktrap=fp -Mbounds":"%DEBUG_FFLAGS        -g -O0 -Wall -ftrace=full -fbounds-check -freal=nan":1 \
516    -e s:"%BASE_FFLAGS         ":"%BASE_FFLAGS         $OPTPREC":1 \
517   arch-linux-32bit.fcm > arch-local.fcm
518   if [ $real = r8 ] ; then
519     sed -e s:"%FPP_DEF             ":"%FPP_DEF             NC_DOUBLE":1 \
520     arch-local.fcm > arch-local.fcm.new
521     mv -f arch-local.fcm.new arch-local.fcm
522   fi
523elif [ $compilo = gfortran ] ; then
524sed -e s:"%COMPILER            pgf95":"%COMPILER            gfortran":1 \
525    -e s:"%LINK                pgf95":"%LINK                gfortran":1 \
526    -e s:"%PROD_FFLAGS         -fast":"%PROD_FFLAGS         $OPTIM":1 \
527    -e s:"%DEV_FFLAGS          -g -O1":"%DEV_FFLAGS          -Wall -fbounds-check":1 \
528    -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 \
529    -e s:"%BASE_FFLAGS         ":"%BASE_FFLAGS         $OPTPREC":1 \
530   arch-linux-32bit.fcm > arch-local.fcm
531   if [ $real = r8 ] ; then
532     sed -e s:"%FPP_DEF             ":"%FPP_DEF             NC_DOUBLE":1 \
533     arch-local.fcm > arch-local.fcm.new
534     mv -f arch-local.fcm.new arch-local.fcm
535   fi
536elif [ $compilo = pgf90 ] ; then
537sed -e s:"-Wl,-Bstatic -L/usr/lib/gcc-lib/i386-linux/2.95.2":" ":1 \
538    -e s:"%PROD_FFLAGS         -fast":"%PROD_FFLAGS         $OPTIM":1 \
539    -e s:"%BASE_FFLAGS         ":"%BASE_FFLAGS         $OPTPREC":1 \
540   arch-linux-32bit.fcm > arch-local.fcm
541   if [ $real = r8 ] ; then
542     sed -e s:"%FPP_DEF             ":"%FPP_DEF             NC_DOUBLE":1 \
543     arch-local.fcm > arch-local.fcm.new
544     mv -f arch-local.fcm.new arch-local.fcm
545   fi
546elif [ $compilo = ifort ] ; then
547sed -e s:"%COMPILER            pgf95":"%COMPILER            ifort":1 \
548    -e s:"%LINK                pgf95":"%LINK                ifort":1 \
549    -e s:"-Wl,-Bstatic -L/usr/lib/gcc-lib/i386-linux/2.95.2":" ":1 \
550    -e s:"%PROD_FFLAGS         -fast":"%PROD_FFLAGS         $OPTIM":1 \
551    -e s:"%BASE_FFLAGS         ":"%BASE_FFLAGS         $OPTPREC":1 \
552    -e s:"%DEV_FFLAGS          -g -O1":"%DEV_FFLAGS          -p -g -O2 -traceback -fp-stack-check -ftrapuv -check":1 \
553    -e s:"%DEBUG_FFLAGS        -g -O0 -Kieee -Ktrap=fp -Mbounds":"%DEBUG_FFLAGS        -g -no-ftz -traceback -ftrapuv -fp-stack-check -check":1 \
554   arch-linux-32bit.fcm > arch-local.fcm
555   if [ $real = r8 ] ; then
556     sed -e s:"%FPP_DEF             ":"%FPP_DEF             NC_DOUBLE":1 \
557     arch-local.fcm > arch-local.fcm.new
558     mv -f arch-local.fcm.new arch-local.fcm
559   fi
560else
561   echo Unexpected compiler $compilo ; exit
562fi # of if [ $compilo = g95 ] elif [ $compilo = pgf90 ]
563cd ..
564### Adapt "bld.cfg" (add the shell):
565whereisthatshell=$(which ${use_shell})
566echo "bld::tool::SHELL   $whereisthatshell" >> bld.cfg
567
568fi # of if [ "$pclinux" = 1 ]
569
570
571cd $MODEL/modipsl/modeles/LMDZ?
572
573##################################################################
574# Compile LMDZ
575##################################################################
576#ok_veget=false
577#if [ "$veget" = 1 ] ; then ok_veget=true ; fi
578if [ $compile_with_fcm = 1 ] ; then makelmdz=makelmdz_fcm ; else makelmdz=makelmdz ; fi
579if [ "$pclinux" = 1 ] ; then
580        ./$makelmdz -d ${grid_resolution} -arch local -v $veget_version gcm
581else
582   # we are on Ada
583    ./$makelmdz -d ${grid_resolution} -arch X64_ADA -v $veget_version gcm
584fi
585
586if [ -f gcm.e ] || [ -f bin/gcm_${grid_resolution}_phylmd_seq_orch.e ] || [ -f bin/gcm_${grid_resolution}_phylmd_seq.e ] ; then
587echo '##########################################################'
588echo 'Compilation successfull !! '
589echo '##########################################################'
590else
591echo 'Compilation failed !!'
592exit
593fi
594
595##################################################################
596# Below, we run a benchmark test (if bench=0)
597##################################################################
598if [ $bench = 0 ] ; then
599                exit
600fi
601
602echo '##########################################################'
603echo ' Running a test run '
604echo '##########################################################'
605
606\rm -r BENCH${grid_resolution}
607bench=bench_lmdz_${grid_resolution}
608wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/$bench.tar.gz
609gunzip $bench.tar.gz
610tar xvf $bench.tar
611
612if [ -f gcm.e ] ; then 
613    cp gcm.e BENCH${grid_resolution}/
614elif [ -f bin/gcm_${grid_resolution}_phylmd_seq_orch.e ] ; then
615    cp bin/gcm_${grid_resolution}_phylmd_seq_orch.e  BENCH${grid_resolution}/gcm.e
616elif [ -f bin/gcm_${grid_resolution}_phylmd_seq.e ] ; then
617    cp bin/gcm_${grid_resolution}_phylmd_seq.e  BENCH${grid_resolution}/gcm.e
618else
619    echo "No gcm.e found"
620    exit
621fi
622
623cd BENCH${grid_resolution}
624./bench.sh > bench.out  2>&1
625
626echo '##########################################################'
627echo ' Bench results '
628echo '##########################################################'
629
630cat ./bench.out
631
632echo '##########################################################'
633echo 'Simulation finished in' `pwd`
634echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e'
635echo 'or ./bench.sh'
636echo '##########################################################'
Note: See TracBrowser for help on using the repository browser.