source: BOL/script_install/install.sh @ 2601

Last change on this file since 2601 was 2430, checked in by fhourdin, 9 years ago

Modifications to compile ORCHIDEE r3013

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