source: BOL/script_install/install_lmdz.sh @ 3402

Last change on this file since 3402 was 3386, checked in by fhourdin, 7 years ago

Add possibility to install with cosp(v2) and some "svn upgrade" commands to enforce being up-to-date with local svn version.
EM

File size: 38.4 KB
RevLine 
[1588]1#!/bin/bash
2
3###########################################################################
[3044]4# Author : Laurent Fairhead et Frédéric Hourdin
5# Usage  : install_lmdz.sh -help
[1588]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#
[3044]24# Prerequisites : 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
[3044]38################################################################
39# Choice of installation options
40################################################################
[1588]41
[3044]42# A function to fetch files either locally or on the internet
43function myget { #1st and only argument should be file name
44  # Path on local computer where to look for the datafile
[3076]45  if [ -f /u/lmdz/WWW/LMDZ/pub/$1 ] ; then
46    \cp -f -p /u/lmdz/WWW/LMDZ/pub/$1 .
47  elif [ -f ~/LMDZ/pub/$1 ] ; then
48    \cp -f -p ~/LMDZ/pub/$1 .
[3044]49  else
[3375]50    wget -nv http://www.lmd.jussieu.fr/~lmdz/pub/$1
[3076]51    #dir=~/LMDZ/pub/`dirname $1` ; mkdir -p $dir ; cp -r `basename $1` $dir
[3044]52  fi
53}
[1588]54
[3044]55
[1590]56#real=r4
[1589]57real=r8
58
[1708]59# WARNING !!!! For versions before october 2009, use
60# install.v2.sh instead of install.sh
[1588]61
[3044]62#########################################################################
63# Valeur par défaut des parametres
64#########################################################################
65svn=""
[3076]66version=trunk
[1588]67getlmdzor=1
68netcdf=1   #  1 for automatic installation
69           #  0 for no installation
70           #  /.../../netcdf-4.0.1 if wanting to link with an already
71           #  compiled netcdf library (implies to check option compatibility)
72check_linux=1
73ioipsl=1
[1693]74veget=1
[3386]75orchidee_rev=""  # default revision of ORCHIDEE
[1588]76bench=1
77pclinux=1
[3375]78pcmac=0 # default: not on a Mac
[3088]79compiler=gfortran
[3044]80SCM=0
81# use the old orchidee interface without the calculation of z0h
82no_z0h_orc=1
[2031]83# choose the resolution for the bench runs
[3044]84# grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE)
85#                  96x71x19  standard configuration
86grid_resolution=144x142x79
[2409]87grid_resolution=48x36x19
[1693]88
[3044]89## parallel can take the values none/mpi/omp/mpi_omp
90parallel=mpi_omp
91parallel=none
92OPT_GPROF=""
93OPT_MAKELMDZ=""
94MODEL=""
[2031]95
[3056]96## also compile XIOS? (and more recent NetCDF/HDF5 libraries) Default=no
97with_xios="n"
98opt_makelmdz_xios=""
[3375]99## compile_with_fcm=1 : use makelmdz_fcm (1) or makelmdz (0)
100compile_with_fcm=1
[3386]101cosp=0 ; opt_cosp1=""
102cosp=0 ; opt_cosp2=""
103opt_cosp=""
[3056]104
[3375]105# Check if on a Mac
106if [ `uname` = "Darwin" ]
107then
108    pcmac=1
109    export MAKE=make
110fi
111#echo "pcmac="$pcmac
112
[3044]113#########################################################################
114#  Options interactives
115#########################################################################
116while (($# > 0))
117   do
118   case $1 in
119     "-h") cat <<........fin
120    $0 [ -v version ] [ -r svn_release ]
121           [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ]
122           [-name LOCAL_MODEL_NAME] [-gprof] [-opt_makelmdz]
[2031]123
[3044]124    -v       "version" like 20150828.trunk
125             see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk
[2404]126
[3044]127    -r       "svn_release" : either the svn release number or "last"
[3088]128   
129    -compiler gfortran|ifort|pgf90 (default: gfortran)
[2404]130
[3044]131    -parallel PARA : can be mpi_omp (mpi with openMP) or none (for sequential)
[2404]132
[3044]133    -d        GRID_RESOLUTION should be among the available benchs if -bench 1
134              among which : 48x36x19, 48x36x39
135              if wanting to run a bench simulation in addition to compilation
136              default : 48x36x19
137
138    -bench     activating the bench or not (0/1). Default 1
139
140    -name      LOCAL_MODEL_NAME : default = LMDZversion.release
141
[3056]142    -netcdf    PATH : full path to an existing installed NetCDF library
143               (without -netcdf: also download and install the NetCDF library) 
144   
145    -xios      also download and compile the XIOS library
146               (requires the NetCDF4-HDF5 library, also installed by default)
147               (requires to also have -parallel mpi_omp)
148
[3044]149    -gprof     to compile with -pg to enable profiling with gprof
[3056]150
[3375]151    -orchidee_rev "svn_release" : upgrade included ORCHIDEE model to
[3386]152               given svn release number (default: $orchidee_rev)
[3375]153               (only valid for orchidee2.0 and later)
154
[3386]155    -cosp      to compile with cosp(v1)
156 
157    -cosp2      to compile with cosp(v2)
[3375]158
159    -nofcm     to compile without fcm
160
[3044]161    -SCM        install 1D version automatically
[3056]162
[3044]163    -opt_makelmdz     to call makelmdz or makelmdz_fcm with additional options
164........fin
165     exit ;;
166     "-v") version=$2 ; shift ; shift ;;
167     "-r") svn=$2 ; shift ; shift ;;
[3088]168     "-compiler") compiler=$2
169                  case $compiler in
170                    "gfortran"|"ifort"|"pgf90") compiler=$2 ; shift ; shift ;;
171                    *) echo "Only gfortran , ifort or pgf90 for the compiler option" ; exit
172                  esac ;;
[3044]173     "-d") grid_resolution=$2 ; shift ; shift ;;
174     "-gprof") OPT_GPROF="-pg" ; shift ;;
[3386]175     "-cosp") cosp=1 ; opt_cosp1="-cosp true" ; shift ;;
176     "-cosp2") cosp2=1 ; opt_cosp2="-cosp2 true" ; shift ;;
[3375]177     "-orchidee_rev") orchidee_rev=$2 ; shift ; shift ;;
178     "-nofcm") compile_with_fcm=0 ; shift ;;
[3044]179     "-SCM") SCM=1 ; shift ;;
180     "-opt_makelmdz") OPT_MAKELMDZ="$2" ; shift ; shift ;;
181     "-parallel") parallel=$2
182                  case $parallel in
[3064]183                    "none"|"mpi"|"omp"|"mpi_omp") parallel=$2 ; shift ; shift ;;
184                    *) echo Only none mpi omp mpi_omp for the parallel option ; exit
[3044]185                  esac ;;
186     "-bench") bench=$2 ; shift ; shift ;;
187     "-name") MODEL=$2 ; shift ; shift ;;
[3056]188     "-netcdf") netcdf=$2 ; shift ; shift ;;
189     "-xios") with_xios="y" ; shift ;;
[3044]190     *) ./install_lmdz.sh -h ; exit
191   esac
192done
193
194if [ $parallel = none ] ; then sequential=1 ; else sequential=0 ; fi 
195
196#Chemin pour placer le modele
197if [ "$MODEL" = "" ] ; then MODEL=./LMDZ$version$svn ; fi
198
199
200arch=local
201
202
[3088]203if [ $compiler = g95 ] ; then echo g95 is not supported anymore ; exit ; fi
[3044]204
205################################################################
206# Specificite des machines
207################################################################
208
209hostname=`hostname`
210if [ "$pclinux" = 1 ] ; then o_ins_make="-t g95" ; else o_ins_make="" ; fi
211
212case ${hostname:0:5} in
213
[3088]214   ada33)   compiler="ifort" ;
[3044]215            par_comp="ifort" ;
216            o_ins_make="-t ada" ;
217            make=gmake ;
[3375]218            module load intel/2013.0 ;
[3044]219            arch=X64_ADA ;;
220
[3375]221   cicla|camel)   compiler="gfortran" ;
[3056]222            if [ $parallel != none ] ; then
[3375]223              module load openmpi/1.6.5-gfortran ;
[3056]224              root_mpi=$MPI_HOME ;
225              path_mpi=$root_mpi/bin ;
226              par_comp=${path_mpi}/mpif90 ;
227              mpirun=${path_mpi}/mpirun ;
228            fi ;
229            arch=local  ;
230            make=make ;
231            o_ins_make="-t g95" ;;
232           
[3088]233   *)       if [ $parallel = none -o -f /usr/bin/mpif90 ] ; then
[3076]234                path_mpi=`which mpif90 | sed -e s:/mpif90::` ;
[3056]235                if [ -d /usr/lib64/openmpi ] ; then
236                  root_mpi="/usr/lib64/openmpi"
237                else
238                  root_mpi="/usr"
239                fi
[3088]240            # For Scientifique Linux with gfortran at LMD :
[3375]241            elif [ -f /usr/lib64/openmpi/1.4.5-gfortran/bin/mpif90 -a $compiler = "gfortran" ] ; then
[3056]242                path_mpi=/usr/lib64/openmpi/1.4.5-gfortran/bin ;
243                root_mpi=/usr/lib64/openmpi/1.4.5-gfortran ;
244                export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
[3088]245            # For Scientifique Linux with ifort at LMD :
[3375]246            elif [ -f /usr/lib64/openmpi/1.4.5-ifort/bin/mpif90 -a $compiler = "ifort" ] ; then
[3088]247                path_mpi=/usr/lib64/openmpi/1.4.5-ifort/bin ;
248                root_mpi=/usr/lib64/openmpi/1.4.5-ifort ;
249                export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
250            # For Scientifique Linux with pgf90 at LMD :
[3375]251            elif [ -f /usr/lib64/openmpi/1.4.5-ifort/bin/mpif90 -a $compiler = "pgf90" ] ; then
[3088]252                path_mpi=/usr/lib64/openmpi/1.4.5-pgf/bin ;
253                root_mpi=/usr/lib64/openmpi/1.4.5-pgf ;
254                export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
[3044]255            else
[3056]256               echo "Cannot find mpif90" ;
[3044]257               exit ;
258            fi ;
[3056]259            par_comp=${path_mpi}/mpif90 ;
260            mpirun=${path_mpi}/mpirun ;
[3044]261            arch=local  ;
262            make=make ;
263            o_ins_make="-t g95"
264esac
265
[3088]266# Flags for parallelism:
267if [ $parallel != none ] ; then
268  # MPI_LD are the flags needed for linking with MPI
269  MPI_LD="-L${root_mpi}/lib -lmpi"
270  if [ "$compiler" = "gfortran" ] ; then
271    # MPI_FLAGS are the flags needed for compilation with MPI
272    MPI_FLAGS="-fcray-pointer"
273    # OMP_FLAGS are the flags needed for compilation with OpenMP
274    OMP_FLAGS="-fopenmp -fcray-pointer"
275    # OMP_LD are the flags needed for linking with OpenMP
276    OMP_LD="-fopenmp"
277  elif [ "$compiler" = "ifort" ] ; then
278    MPI_FLAGS=""
279    OMP_FLAGS="-openmp"
280    OMP_LD="-openmp"
281  else # pgf90
282    MPI_FLAGS=""
283    OMP_FLAGS="-mp"
284    OMP_LD="-mp"
285  fi
286fi
[3044]287
[1693]288#####################################################################
289# Test for old gfortran compilers
[2030]290# If the compiler is too old (older than 4.3.x) we test if the
291# temporary gfortran44 patch is available on the computer in which
292# case the compiler is changed from gfortran to gfortran44
293# Must be aware than parallelism can not be activated in this case
294#####################################################################
295
[3088]296if [ "$compiler" = "gfortran" ] ; then
[2030]297   gfortran=gfortran
[1693]298   gfortranv=`gfortran --version | \
299   head -1 | awk ' { print $NF } ' | awk -F. ' { print $1 * 10 + $2 } '`
300   if [ $gfortranv -le 43 ] ; then
[1708]301       echo ERROR : Your gfortran compiler is too old
[3044]302       echo 'Please choose a new one (ifort) and change the line'
[3088]303       echo compiler=xxx
[1693]304       echo in the install.sh script and rerun it
[2030]305       if [ `which gfortran44 | wc -w` -ne 0 ] ; then
306          gfortran=gfortran44
307       else
308          echo gfotran trop vieux ; exit
309       fi
[1693]310   fi
[3088]311   compiler=$gfortran
[1693]312fi
313#####################################################################
314
[3056]315## if also compiling XIOS, parallel must be mpi_omp
316if [ "$with_xios" = "y" -a "$parallel" != "mpi_omp" ] ; then 
317  echo "Error, you must set -parallel mpi_omp if you want XIOS"
318  exit
319fi
[3386]320
321## We can't compile with -cosp and -cosp2
322if [ "$cosp" = 1 -a "$cosp2" = 1 ] ; then
323   echo "Error, you can't run with cosp1 and cosp2"
324   exit
325fi
326if [ "$cosp" = 1 ] ; then
327   opt_cosp="$opt_cosp1"
328fi
329if [ "$cosp2" = 1 ] ; then
330   opt_cosp="$opt_cosp2"
331fi
332
333## if also compiling XIOS, cosp must be activate to define axis in *.xml
334if [ "$with_xios" = "y" -a "$cosp" != "1" ] ; then
335   echo "Error, you must use -cosp option when compiling with -xios"
336   echo "You need to call Cosp in physical first step to define axis variables"
337   exit
338fi
339if [ "$with_xios" = "y" -a "$cosp2" != "1" ] ; then
340   echo "Error, you must use -cosp2 option when compiling with -xios"
341   echo "You need to call Cosp in physical first step to define axis variables"
342   exit
343fi
344
[3056]345if [ "$with_xios" = "y" ] ; then
346  opt_makelmdz_xios="-io xios"
347fi
[1693]348
[1588]349echo '################################################################'
350echo  Choix des options de compilation
351echo '################################################################'
[1589]352
[3088]353export FC=$compiler
354export F90=$compiler
355export F77=$compiler
[2031]356export CPPFLAGS=
[3044]357OPTIMNC=$OPTIM
358BASE_LD="$OPT_GPROF"
359OPTPREC="$OPT_GPROF"
[3076]360ARFLAGS="rs" ; if [ -f /etc/issue ] ; then if [ "`grep -i ubuntu /etc/issue`" != "" ] ; then if [ "`grep -i ubuntu /etc/issue | awk ' { print $2 } ' | cut -d. -f1`" -ge 16 ] ; then ARFLAGS="rU" ; fi ; fi ; fi
[3044]361
[3076]362
363
[3088]364if [ "$compiler" = "$gfortran" ] ; then
[2031]365   OPTIM='-O3'
[3044]366   OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=nan"
[2031]367   OPTDEV="-Wall -fbounds-check"
368   fmod='I '
[3044]369   OPTPREC="$OPTPREC -cpp -ffree-line-length-0"
[2409]370   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE" ; fi
[2031]371   export F90FLAGS=" -ffree-form $OPTIMNC"
372   export FFLAGS=" $OPTIMNC"
373   export CC=gcc
374   export CXX=g++
[3044]375   export fpp_flags="-P -C -traditional -ffreestanding"
376
[3088]377elif [ $compiler = mpif90 ] ; then
[1589]378   OPTIM='-O3'
[3044]379   OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all"
[2031]380   OPTDEV="-Wall -fbounds-check"
[3044]381   BASE_LD="$BASE_LD -lblas"
[2031]382   fmod='I '
[3044]383   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer" ; fi
[2031]384   export F90FLAGS=" -ffree-form $OPTIMNC"
385   export FFLAGS=" $OPTIMNC"
386   export CC=gcc
387   export CXX=g++
[3044]388
[3088]389elif [ $compiler = pgf90 ] ; then
[2203]390   OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align'
391   OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback'
392   OPTDEV='-g -Mbounds -Ktrap=fp -traceback'
[2031]393   fmod='module '
[3044]394   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE" ; fi
[2203]395   export CPPFLAGS="-DpgiFortran"
[2031]396   export CC=pgcc
[2203]397   export CFLAGS="-O2 -Msignextend"
[2031]398   export CXX=pgCC
[2203]399   export CXXFLAGS="-O2 -Msignextend"
400   export FFLAGS="-O2 $OPTIMNC"
401   export F90FLAGS="-O2 $OPTIMNC"
[1590]402   compile_with_fcm=1
[3044]403
[3088]404elif [ $compiler = ifort ] ; then
[2031]405   OPTIM="-O2 -fp-model strict -ip -align all "
406   OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check"
407   OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check"
408   fmod='module '
[3044]409   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi
[2031]410   export CPP="icc -E"
411   export FFLAGS="-O2 -ip -fpic -mcmodel=large"
412   export FCFLAGS="-O2 -ip -fpic -mcmodel=large"
413   export CC=icc
414   export CFLAGS="-O2 -ip -fpic -mcmodel=large"
415   export CXX=icpc
416   export CXXFLAGS="-O2 -ip -fpic -mcmodel=large"
[3375]417   export fpp_flags="-P -traditional"
[1590]418   compile_with_fcm=1
[3044]419
[2031]420else
[3088]421   echo unexpected compiler $compiler ; exit
[1588]422fi
[2031]423
[1589]424OPTIMGCM="$OPTIM $OPTPREC"
[1588]425
426hostname=`hostname`
427
428##########################################################################
[1731]429# If installing on know machines such as IBM x3750 (Ada)
[1708]430# at IDRIS, don't check for available software and don"t install netcdf
[1777]431if [ ${hostname:0:5} = ada33 ] ; then
[1731]432  netcdf=0 # no need to recompile netcdf, alreday available
433  check_linux=0
434  pclinux=0
[3044]435  ioipsl=1 # no need to recompile ioipsl, already available
[1731]436  #netcdf="/smplocal/pub/NetCDF/4.1.3"
[3088]437  compiler="ifort"
[1731]438  fmod='module '
[3044]439  if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi
[1731]440  OPTIM="-O2 -fp-model strict -ip -axAVX,SSE4.2 -align all "
441  OPTIMGCM="$OPTIM $OPTPREC"
[1588]442fi
443##########################################################################
444
445
[3044]446
[1588]447mkdir -p $MODEL
448echo $MODEL
[1708]449MODEL=`( cd $MODEL ; pwd )` # to get absolute path, if necessary
[1588]450
451
452
[1708]453# Option -fendian=big is only to be used with ARPEGE1D.
454# The -r8 should probably be avoided if running on 32 bit machines
455# Option r8 is not mandatory and generates larger executables.
456# It is however mandatory if using ARPEGE1D
457# Better optimization options might be a better choice (e.g. -O3)
[1588]458
459
460echo '################################################################'
461if [ "$check_linux" = 1 ] ; then
[1708]462echo   Check if required software is available
[1588]463echo '################################################################'
464
465#### Ehouarn: test if ksh and/or bash are available
466use_shell="ksh" # default: use ksh
467if [ "`which ksh`" = "" ] ; then
[1708]468  echo "no ksh ... we will use bash"
[1588]469  use_shell="bash"
470  if [ "`which bash`" = "" ] ; then
[1708]471    echo "ksh (or bash) needed!! Install it!"
[1588]472  fi
473fi
474
475
[3088]476for logiciel in csh wget tar gzip make $compiler gcc ; do
[1588]477if [ "`which $logiciel`" = "" ] ; then
[1708]478echo You must first install $logiciel on your system
[1588]479exit
480fi
481done
482
483if [ $pclinux = 1 ] ; then
484cd $MODEL
[2030]485cat <<eod > tt.f90
[1588]486print*,'coucou'
487end
488eod
[3088]489$compiler tt.f90 -o a.out
[1588]490./a.out >| tt
491if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then
[3088]492echo problem installing with compiler $compiler ; exit ; fi
[1588]493\rm tt a.out tt.f90
494fi
495fi
496
497###########################################################################
498if [ $getlmdzor = 1 ] ; then
499echo '##########################################################'
[1708]500echo  Download a slightly modified version of  LMDZ
[1588]501echo '##########################################################'
502cd $MODEL
[3076]503myget src/modipsl.$version.tar.gz
[3044]504echo install.sh wget_OK `date`
505gunzip modipsl.$version.tar.gz
506tar xvf modipsl.$version.tar
507\rm modipsl.$version.tar
[1588]508
509fi
510
511echo OK1
512
513if [ $netcdf = 1 ] ; then
[3091]514cd $MODEL
515netcdflog=`pwd`/netcdf.log
[1588]516echo '##########################################################'
[1708]517echo Compiling the Netcdf library
[1588]518echo '##########################################################'
[3091]519echo log file : $netcdflog
[3056]520if [ "$with_xios" = "n" ] ; then
521  # keep it simple
522  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/netcdf-4.0.1.tar.gz
[3076]523  myget import/netcdf-4.0.1.tar.gz
[3056]524  gunzip netcdf-4.0.1.tar.gz
525  tar xvf netcdf-4.0.1.tar
526  \rm -f netcdf-4.0.1.tar
[1588]527
[3056]528  cd netcdf-4.0.1
[1588]529
[3056]530  # seds to possibly use gfortran44 obsolete nowdays (Ehouarn: 10/2017)
531  #sed -e 's/gfortran/'$gfortran'/g' configure >| tmp ; mv -f tmp configure ; chmod +x configure
532  localdir=`pwd -P`
533  ./configure --prefix=$localdir --enable-shared --disable-cxx
534  #sed -e 's/gfortran/'$gfortran'/g' Makefile >| tmp ; mv -f tmp Makefile
[3091]535  $make check > $netcdflog 2>&1
536  $make install >> $netcdflog 2>&1
[3056]537else
538  # download and compile hdf5 and netcdf, etc. using the install_netcdf4_hdf5.bash script
539  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_netcdf4_hdf5.bash
[3076]540  myget import/install_netcdf4_hdf5.bash
[3056]541  chmod u=rwx install_netcdf4_hdf5.bash
[3088]542  if [ "$compiler" = "gfortran" ] ; then
[3056]543  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC gcc -FC gfortran -CXX g++ -MPI $root_mpi
[3088]544  elif [ "$compiler" = "ifort" ] ; then
[3056]545  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC icc -FC ifort -CXX icpc -MPI $root_mpi
[3088]546  elif [ "$compiler" = "pgf90" ] ; then
[3056]547  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC pgcc -FC pgf90 -CXX pgCC -MPI $root_mpi
548  else
[3088]549    echo "unexpected compiler $compiler" ; exit
[3056]550  fi
551fi  # of if [ "$with_xios" = "n" ]
[2030]552echo install.sh netcdf_OK `date`
[1731]553fi # of if [ $netcdf = 1 ]
[1588]554
[2030]555
[1800]556#=======================================================================================
[1588]557echo OK2 ioipsl=$ioipsl
558echo '##########################################################'
[1731]559echo 'Installing MODIPSL, the installation package manager for the '
560echo 'IPSL models and tools'
[1588]561echo '##########################################################'
562
563if [ $netcdf = 0 -o $netcdf = 1 ] ; then
[3056]564  if [ "$with_xios" = "y" ] ; then
565  ncdfdir=$MODEL/netcdf4_hdf5
566  else
567  ncdfdir=$MODEL/netcdf-4.0.1
568  fi
[1588]569else
[3056]570  ncdfdir=$netcdf
[1588]571fi
572
573if [ $ioipsl = 1 ] ; then
[1731]574  cd $MODEL/modipsl
[2030]575  \rm -rf lib/*
[2031]576
[1731]577  cd util
[1588]578
[1731]579  cp AA_make.gdef AA_make.orig
[3088]580  F_C="$compiler -c " ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then F_C="$compiler -c -cpp " ; fi
581  if [ "$compiler" = "pgf90" ] ; then F_C="$compiler -c -Mpreprocess" ; fi
[1731]582  sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
[3088]583  sed -e "s:F_L = g95:F_L = $compiler:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \
[1731]584  -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
585  -e 's:g95.*.NCDF_INC.*.$:g95      NCDF_INC= '"$ncdfdir"'/include:' \
[3044]586  -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \
[3063]587  -e 's:g95      L_O =:g95      L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \
[1731]588  -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
589  -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
590  tmp >| AA_make.gdef
[1588]591
[3375]592  if [ $pcmac == 1 ]
593  then
594      cp AA_make.gdef tmp
595      sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef
596  fi
597 
[1588]598
[3044]599# We use lines for g95 even for the other compilers to run ins_make
[1731]600  if [ "$use_shell" = "ksh" ] ; then
[3044]601    ./ins_make $o_ins_make
[1731]602  else # bash
603    sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash
[3044]604    if [ "`grep ada AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar
605        \cp -f ~rdzt401/bin/AA_make.gdef .
606    fi
[3375]607   
[1731]608    chmod u=rwx ins_make.bash
[3044]609    ./ins_make.bash $o_ins_make
[1731]610  fi # of if [ "$use_shell" = "ksh" ]
611
[2031]612#=======================================================================================
[3091]613  cd $MODEL/modipsl/modeles/IOIPSL/src
[3092]614  ioipsllog=`pwd`/ioipsl.log
[1731]615  echo '##########################################################'
616  echo 'Compiling IOIPSL, the interface library with Netcdf'
617  echo '##########################################################'
[3091]618  echo log file : $ioipsllog
[1731]619
620  if [ "$use_shell" = "bash" ] ; then
621    cp Makefile Makefile.ksh
622    sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
[1588]623  fi
[3044]624# if [ "$pclinux" = 1 ] ; then
[1731]625    # Build IOIPSL modules and library
[3044]626    $make clean
[3091]627    $make > $ioipsllog 2>&1
[3088]628    if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then # copy module files to lib
[1731]629      cp -f *.mod ../../../lib
630    fi
631    # Build IOIPSL tools (ie: "rebuild", if present)
632    if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then
633      cd $MODEL/modipsl/modeles/IOIPSL/tools
634      # adapt Makefile & rebuild script if in bash
635      if [ "$use_shell" = "bash" ] ; then
636        cp Makefile Makefile.ksh
637        sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
638        cp rebuild rebuild.ksh
639        sed -e 's:/bin/ksh:/bin/bash:g' \
640            -e 's:print -u2:echo:g' \
641            -e 's:print:echo:g' rebuild.ksh > rebuild
642      fi
[3044]643      $make clean
[3091]644      $make > $ioipsllog 2>&1
[1731]645    fi
[3044]646# fi # of if [ "$pclinux" = 1 ]
[1588]647
[1731]648else # of if [ $ioipsl = 1 ]
[1777]649  if [ ${hostname:0:5} = ada33 ] ; then
[1731]650    cd $MODEL/modipsl
651    cd util
[1588]652
[1731]653    cp AA_make.gdef AA_make.orig
654    sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
[3088]655    sed -e "s:F_L = g95:F_L = $compiler:" -e "s:F_C = g95 -c:F_C = $compiler -c": \
[1731]656    -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
657    -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:' \
658    -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L/smplocal/pub/NetCDF/4.1.3/lib -lnetcdff -lnetcdf:' \
659    -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
660    -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
661    tmp >| AA_make.gdef
662
[3044]663    ./ins_make $o_ins_make # We use lines for g95 even for the other compilers
[1731]664
665    # on Ada, IOIPSL is already installed in ~rpsl035/IOIPSL_PLUS
666    # so link it to current settings
667    cd $MODEL/modipsl/modeles/
668    \rm -r -f IOIPSL
669    ln -s ~rpsl035/IOIPSL_PLUS IOIPSL
670    cd ..
[3044]671    ln -s ~rpsl035/IOIPSL_PLUS/modipsl_Tagv2_2_3/bin/* bin/
672    ln -s ~rpsl035/IOIPSL_PLUS/modipsl_Tagv2_2_3/lib/* lib/
[1731]673
[1777]674  fi # of if [ ${hostname:0:5} = ada33 ]
[2030]675  echo install.sh ioipsl_OK `date`
[1731]676fi # of if [ $ioipsl = 1 ]
[3044]677# Saving ioipsl lib for possible parallel compile
678  cd $MODEL/modipsl
679  tar cf ioipsl.tar lib/ bin/
[1731]680
[3056]681#===========================================================================
682if [ "$with_xios" = "y" ] ; then
683  echo '##########################################################'
684  echo 'Compiling XIOS'
685  echo '##########################################################'
686  cd $MODEL/modipsl/modeles
[3375]687  xioslog=`pwd`/xios.log
688  echo "log file: $xioslog"
[3056]689  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_xios.bash
[3076]690  myget import/install_xios.bash
[3056]691  chmod u=rwx install_xios.bash
[3375]692  if [ ${hostname:0:5} = ada33 ] ; then
693    ./install_xios.bash \
694    -prefix /workgpfs/rech/gzi/rgzi027/LMDZ20180221.trunk/modipsl/modeles \
695    -netcdf /smplocal/pub/NetCDF/4.1.3/mpi -hdf5 /smplocal/pub/HDF5/1.8.9/par \
696    -MPI /smplocal/intel/compilers_and_libraries_2017.2.174/linux/mpi/intel64/ \
697    -arch X64_ADA > xios.log 2>&1
698   else
699     ./install_xios.bash -prefix $MODEL/modipsl/modeles \
[3056]700                      -netcdf ${ncdfdir} -hdf5 ${ncdfdir} \
[3375]701                      -MPI $root_mpi -arch $arch > xios.log 2>&1
702   fi
703   if [ -f XIOS/lib/libxios.a ] ; then
704     echo "OK, XIOS library successfully generated"
705   fi
[3056]706fi
707
[1800]708#============================================================================
[1837]709veget_version=false
[1731]710if [ "$veget" = 1 ] ; then
[3091]711  cd $MODEL/modipsl/modeles/ORCHIDEE
712  orchideelog=`pwd`/orchidee.log
[1731]713  echo '########################################################'
714  echo 'Compiling ORCHIDEE, the continental surfaces model '
715  echo '########################################################'
[3091]716  echo log file : $orchideelog
[2430]717  export ORCHPATH=`pwd`
718  if [ -d tools ] ; then
[3386]719###################################################################
720# Pour les experts qui voudraient changer de version d'orchidee.
721# Attention : necessite d'avoir le password pour orchidee
722      set +e ; svn upgrade ; set -e
723      if [ "$orchidee_rev" != "" ] ; then
724         set +e ; svn update -r $orchidee_rev ; set -e
725      fi
726###################################################################
[1837]727     veget_version=orchidee2.0
[3044]728      cd arch
[3088]729      sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
730     -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
[2430]731     -e s:"%FPP_FLAGS       .*.$":"%FPP_FLAGS           $fpp_flags":1 \
732     -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
733     -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
734     -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
[3044]735     -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
736     -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
[3076]737     -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
[2430]738     arch-gfortran.fcm > arch-local.fcm
[3044]739     echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
[2430]740     echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path
741     echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path
742     echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path
[3375]743     echo 'XIOS_INCDIR=${ORCHDIR}/../XIOS/inc' >> arch-local.path
744     echo 'XIOS_LIBDIR="${ORCHDIR}/../XIOS/lib -lxios"' >> arch-local.path
[3044]745     cd ../
[2430]746# compiling ORCHIDEE sequential mode
[3091]747     ./makeorchidee_fcm -j 8 -noxios -prod -parallel none -arch $arch > $orchideelog 2>&1
[3044]748     echo ./makeorchidee_fcm -j 8 -noxios -prod -parallel none -arch $arch
749     echo Fin de la premiere compilation orchidee ; pwd
[1800]750  else
[2430]751     if [ -d src_parallel ] ; then
752       liste_src="parallel parameters global stomate sechiba driver"
753       veget_version=orchidee2.0
754     else
755       # Obsolete, for ORCHIDEE_beton only
756       liste_src="parameters stomate sechiba "
757       # A trick to compile ORCHIDEE depending on if we are using real*4 or real*8
758       cd src_parameters ; \cp reqdprec.$real reqdprec.f90 ; cd ..
759       veget_version=orchidee1.9
760     fi
761     for d in $liste_src ; do src_d=src_$d
762        echo src_d $src_d
763        echo ls ; ls
764        if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi
[3044]765        cd $src_d ; \rm -f *.mod make ; $make clean
[3091]766        $make > $orchideelog 2>&1 ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi
[2430]767        cd ..
768     done
[1800]769  fi
[2030]770  echo install.sh orchidee_OK `date`
[1731]771fi # of if [ "$veget" = 1 ]
[1588]772
[2030]773
[1800]774#============================================================================
[1588]775# Ehouarn: it may be directory LMDZ4 or LMDZ5 depending on tar file...
[3044]776if [ -d $MODEL/modipsl/modeles/LMD* ] ; then
[1588]777  echo '##########################################################'
[1800]778  echo 'Compiling LMDZ'
[1588]779  echo '##########################################################'
[3044]780  cd $MODEL/modipsl/modeles/LMD*
781  LMDZPATH=`pwd`
[1588]782else
[3044]783  echo "ERROR: No LMD* directory !!!"
[1800]784  exit
[1588]785fi
786
787###########################################################
[1708]788# For those who want to use fcm to compile via :
[1588]789#  makelmdz_fcm -arch local .....
790############################################################
791
[2031]792if [ "$pclinux" = "1" ] ; then
793
[1708]794# create local 'arch' files (if on Linux PC):
[1588]795cd arch
[1708]796# arch-local.path file
[3044]797echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
[1590]798echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path
[1588]799echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path
800echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
[3044]801echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path
802echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path
[1588]803echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path
804echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
[3044]805
[3375]806if [ $pcmac == 1 ] ; then
807    BASE_LD="$BASE_LD -Wl,-rpath,${ncdfdir}/lib"
808else
809    BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib"
810fi
811# Arch-local.fcm file (adapted from arch-linux-32bit.fcm)
[2031]812
813if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi
[3088]814sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
815    -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
[2031]816    -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
817    -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
818    -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
819    -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
[2203]820    -e s:"%FPP_DEF         .*.$":"%FPP_DEF             $FPP_DEF":1 \
[3044]821    -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
[3076]822    -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
[2031]823    arch-linux-32bit.fcm > arch-local.fcm
824
[1588]825cd ..
[1708]826### Adapt "bld.cfg" (add the shell):
[1588]827whereisthatshell=$(which ${use_shell})
828echo "bld::tool::SHELL   $whereisthatshell" >> bld.cfg
829
[1731]830fi # of if [ "$pclinux" = 1 ]
831
832
[3056]833cd $MODEL/modipsl/modeles/LMDZ*
[3093]834lmdzlog=`pwd`/lmdz.log
[1731]835
[1588]836##################################################################
[3056]837# Possibly update LMDZ if a specific svn release is requested
[3044]838##################################################################
839
[3386]840set +e ; svn upgrade ; set -e
[3044]841if [ "$svn" = "last" ] ; then svnopt="" ; else svnopt="-r $svn" ; fi
[3386]842if [ "$svn" != "" ] ; then svn update $svnopt ; fi
[3044]843
[3091]844echo '##################################################################'
845echo Compile LMDZ
846echo '##################################################################'
847echo log file : $lmdzlog
[3044]848
[2030]849echo install.sh avant_compilation `date`
[3044]850if [ $compile_with_fcm = 1 ] ; then makelmdz="makelmdz_fcm -arch $arch -j 8" ; else makelmdz="makelmdz -arch $arch" ; fi
[2031]851
[3044]852# use the orchidee interface that has no z0h
853if [ "$no_z0h_orc" = 1 ] ; then
854veget_version="$veget_version -cpp ORCHIDEE_NOZ0H"
855fi
856
857# sequential compilation and bench
858if [ "$sequential" = 1 ] ; then
[3375]859echo "./$makelmdz $OPT_MAKELMDZ -rrtm true $opt_cosp -d ${grid_resolution} -v $veget_version gcm " >> compile.sh
860chmod +x ./compile.sh
861if [ $bench != 0 ] ; then ./compile.sh > $lmdzlog 2>&1 ; fi
[2030]862echo install.sh apres_compilation `date`
[1588]863
[2030]864
[3044]865fi # fin sequential
866
867
868
869# compiling in parallel mode
870if [ $parallel != "none" ] ; then
[3056]871  echo '##########################################################'
872  echo ' Parallel compile '
873  echo '##########################################################'
874  # saving the sequential libs and binaries
875  cd $MODEL/modipsl
876  tar cf sequential.tar bin/ lib/
877  \rm -rf bin/ lib/
878  tar xf ioipsl.tar
879  #
880  # Orchidee
881  #
882  cd $ORCHPATH
[3386]883  if [ -d src_parallel -a $veget = 1 ] ; then
[3044]884     cd arch
885     sed  \
886     -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
887     -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
888     -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
889     -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
890     -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
891     -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
892     arch-local.fcm > tmp.fcm
893
894     mv tmp.fcm arch-local.fcm
895     cd ../
[3091]896     echo compiling ORCHIDEE parallel mode
897     echo logfile $orchideelog
898     ./makeorchidee_fcm -j 8 -clean -noxios -prod -parallel $parallel -arch $arch > $orchideelog 2>&1
899     ./makeorchidee_fcm -j 8 -noxios -prod -parallel $parallel -arch $arch >> $orchideelog 2>&1
[3044]900     echo ./makeorchidee_fcm -j 8 -clean -noxios -prod -parallel $parallel -arch $arch
901     echo ./makeorchidee_fcm -j 8 -noxios -prod -parallel $parallel -arch $arch
[3386]902  elif [ $veget = 1 ] ; then
[3056]903    echo '##########################################################'
904    echo ' Orchidee version too old                                 '
905    echo ' Please update to new version                             '
906    echo '##########################################################'
907    exit
908  fi # of if [ -d src_parallel ]
909  # LMDZ
910  cd $LMDZPATH
911  if [ $arch = local ] ; then
912    cd arch
913    sed -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
914    -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
915    -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
916    -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
[3076]917    -e s:"%ARFLAGS.*.$":"%ARFLAGS          $ARFLAGS":1 \
[3056]918    -e s@"%BASE_LD.*.$"@"%BASE_LD             -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \
919    -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
920    -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
921    arch-local.fcm > tmp.fcm
922    mv tmp.fcm arch-local.fcm
923    cd ../
924  fi
925  rm -f compile.sh
926  if [ ${hostname:0:5} = ada33 ] ; then echo "module load intel/2013.0" > compile.sh ; fi
927  echo resol=${grid_resolution} >> compile.sh
[3375]928  echo ./$makelmdz $OPT_MAKELMDZ -rrtm true $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
929  chmod +x ./compile.sh
930  if [ $bench != 0 ] ; then ./compile.sh > $lmdzlog 2>&1 ; fi
[1588]931
[3056]932  echo "Compilation finished"
933 
934fi # of if [ $parallel != "none" ]
[3044]935
936echo LLLLLLLLLLLLLLLLLLLLLLLLLLL
937if [ "$gfortran" = "gfortran44" ] ; then
938    echo Your gfortran compiler was too old so that the model was automatically
939    echo compiled with gfortran44 instead. It can not be used in parallel mode.
940    echo You can change the compiler at the begining of the install.sh
941    echo script and reinstall.
942fi
943
[1588]944##################################################################
[3044]945# Verification du succes de la compilation
[1588]946##################################################################
[3044]947
948# Recherche de l'executable dont le nom a change au fil du temps ...
949gcm=""
950for exe in gcm.e bin/gcm_${grid_resolution}_phylmd_seq_orch.e bin/gcm_${grid_resolution}_phylmd_seq.e bin/gcm_${grid_resolution}_phylmd_para_mem_orch.e ; do
951   if [ -f $exe ] ; then gcm=$exe ; fi
952done
953
954if [ "$gcm" = "" ] ; then
955   echo 'Compilation failed !!'
[3056]956   # Ehouarn : temporary, do not exit and let job finish (to set up bench case)
957   #exit
958   set +e
[3044]959else
960   echo '##########################################################'
961   echo 'Compilation successfull !! '
962   echo '##########################################################'
963   echo The executable is $gcm
[1588]964fi
965
[3044]966##################################################################
967# Below, we run a benchmark test (if bench=0)
968##################################################################
969
970if [ $bench != 0 ] ; then
971
[1588]972echo '##########################################################'
[1731]973echo ' Running a test run '
[1588]974echo '##########################################################'
975
[2030]976\rm -rf BENCH${grid_resolution}
[1588]977bench=bench_lmdz_${grid_resolution}
[2030]978echo install.sh avant_chargement_bench  `date`
[3044]979#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz
[3076]980myget 3DBenchs/$bench.tar.gz
[3044]981echo install.sh after bench download  `date`
982tar xvf $bench.tar.gz
[1588]983
[3386]984if [ "$cosp" = 1 -o "$cosp2" = 1 ] ; then
985  cd BENCH${grid_resolution}
986# copier les fichiers namelist input et output our COSP
987  cp ../DefLists/cosp_input_nl.txt .
988  cp ../DefLists/cosp_output_nl.txt .
989# Activer la cles ok_cosp pour tourner avec COSP
990  sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp
991   \mv -f tmp config.def
992  cd ..
993fi 
994
[3056]995if [ "$with_xios" = "y" ] ; then
996  cd BENCH${grid_resolution}
997  cp ../DefLists/iodef.xml .
998  cp ../DefLists/context_lmdz.xml .
999  cp ../DefLists/field_def_lmdz.xml .
1000  cp ../DefLists/file_def_hist*xml .
1001  # adapt iodef.xml to use attached mode
1002  sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp
1003  \mv -f tmp iodef.xml
[3386]1004
[3056]1005  # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE.
1006  # except for histday
1007  for histfile in file_def_hist*xml
1008  do
1009    if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then
1010    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
1011    else
1012    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile
1013    fi
1014  done
1015  # and add option "ok_all_xml=y" in config.def
1016  echo "### XIOS outputs" >> config.def
1017  echo 'ok_all_xml=.true.' >> config.def
1018  cd ..
1019fi
1020
[3044]1021cp $gcm BENCH${grid_resolution}/gcm.e
[1588]1022
1023cd BENCH${grid_resolution}
[3044]1024# On cree le fichier bench.sh au besoin
1025# Dans le cas 48x36x39 le bench.sh existe deja en parallele
[1588]1026
[3044]1027if [ "$grid_resolution" = "48x36x39" ] ; then
1028   echo On ne touche pas au bench.sh
1029   # But we have to adapt "run_local.sh" for $mpirun
1030   sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp
1031   mv -f tmp run_local.sh
1032   chmod u=rwx run_local.sh
1033elif [ "${parallel:0:3}" = "mpi" ] ; then
1034   # Lancement avec deux procs mpi et 2 openMP
1035   echo "export OMP_STACKSIZE=800M" > bench.sh
1036   if [ "${parallel:4:3}" = "omp" ] ; then
1037     echo "export OMP_NUM_THREADS=2" >> bench.sh
1038   fi
1039   echo "ulimit -s unlimited" >> bench.sh
1040   echo "$mpirun -np 2 gcm.e > listing  2>&1" >> bench.sh
1041else
1042   echo "./gcm.e > listing  2>&1" > bench.sh
1043fi
1044echo EXECUTION DU BENCH
[3076]1045set +e
[3044]1046date ; ./bench.sh > out.bench 2>&1 ; date
[3076]1047set -e
[3044]1048tail listing
[2030]1049
[1588]1050
1051echo '##########################################################'
[1708]1052echo 'Simulation finished in' `pwd`
[3044]1053   echo 'You have compiled with:'
1054   cat ../compile.sh
1055if [ $parallel = "none" ] ; then
1056  echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e'
1057  echo 'or ./bench.sh'
1058else
1059  echo 'You may re-run it with : '
1060  echo 'cd ' `pwd` '; ./bench.sh'
1061  echo 'ulimit -s unlimited'
1062  echo 'export OMP_NUM_THREADS=2'
1063  echo 'export OMP_STACKSIZE=800M'
1064  echo "$mpirun -np 2 gcm.e "
1065fi
[1588]1066echo '##########################################################'
[2030]1067
1068fi
[3044]1069
1070
1071#################################################################
1072# Installation eventuelle du 1D
1073#################################################################
1074
1075if [ $SCM = 1 ] ; then
1076cd $MODEL
1077#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/1D.tar.gz
[3076]1078myget 1D/1D.tar.gz
[3044]1079tar xvf 1D.tar.gz
1080cd 1D
1081./run.sh
1082fi
Note: See TracBrowser for help on using the repository browser.