source: BOL/script_install/install.sh @ 1911

Last change on this file since 1911 was 1911, checked in by lguez, 11 years ago

Stop when there is an error.

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