source: BOL/script_install/install_lmdz.sh @ 3516

Last change on this file since 3516 was 3417, checked in by fhourdin, 6 years ago

Minor update of install_lmdz.sh to better handle checking of cosp and xios combination.
EM

File size: 38.2 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
[3417]334if [ "$with_xios" = "y" ] ; then
335  if [ ! "$cosp" = 1 -o "$cosp2" = 1 ] ; then
[3386]336   echo "Error, you must use -cosp option when compiling with -xios"
337   echo "You need to call Cosp in physical first step to define axis variables"
338   exit
[3417]339  fi
[3056]340  opt_makelmdz_xios="-io xios"
341fi
[1693]342
[1588]343echo '################################################################'
344echo  Choix des options de compilation
345echo '################################################################'
[1589]346
[3088]347export FC=$compiler
348export F90=$compiler
349export F77=$compiler
[2031]350export CPPFLAGS=
[3044]351OPTIMNC=$OPTIM
352BASE_LD="$OPT_GPROF"
353OPTPREC="$OPT_GPROF"
[3076]354ARFLAGS="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]355
[3076]356
357
[3088]358if [ "$compiler" = "$gfortran" ] ; then
[2031]359   OPTIM='-O3'
[3044]360   OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=nan"
[2031]361   OPTDEV="-Wall -fbounds-check"
362   fmod='I '
[3044]363   OPTPREC="$OPTPREC -cpp -ffree-line-length-0"
[2409]364   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE" ; fi
[2031]365   export F90FLAGS=" -ffree-form $OPTIMNC"
366   export FFLAGS=" $OPTIMNC"
367   export CC=gcc
368   export CXX=g++
[3044]369   export fpp_flags="-P -C -traditional -ffreestanding"
370
[3088]371elif [ $compiler = mpif90 ] ; then
[1589]372   OPTIM='-O3'
[3044]373   OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all"
[2031]374   OPTDEV="-Wall -fbounds-check"
[3044]375   BASE_LD="$BASE_LD -lblas"
[2031]376   fmod='I '
[3044]377   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer" ; fi
[2031]378   export F90FLAGS=" -ffree-form $OPTIMNC"
379   export FFLAGS=" $OPTIMNC"
380   export CC=gcc
381   export CXX=g++
[3044]382
[3088]383elif [ $compiler = pgf90 ] ; then
[2203]384   OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align'
385   OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback'
386   OPTDEV='-g -Mbounds -Ktrap=fp -traceback'
[2031]387   fmod='module '
[3044]388   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE" ; fi
[2203]389   export CPPFLAGS="-DpgiFortran"
[2031]390   export CC=pgcc
[2203]391   export CFLAGS="-O2 -Msignextend"
[2031]392   export CXX=pgCC
[2203]393   export CXXFLAGS="-O2 -Msignextend"
394   export FFLAGS="-O2 $OPTIMNC"
395   export F90FLAGS="-O2 $OPTIMNC"
[1590]396   compile_with_fcm=1
[3044]397
[3088]398elif [ $compiler = ifort ] ; then
[2031]399   OPTIM="-O2 -fp-model strict -ip -align all "
400   OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check"
401   OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check"
402   fmod='module '
[3044]403   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi
[2031]404   export CPP="icc -E"
405   export FFLAGS="-O2 -ip -fpic -mcmodel=large"
406   export FCFLAGS="-O2 -ip -fpic -mcmodel=large"
407   export CC=icc
408   export CFLAGS="-O2 -ip -fpic -mcmodel=large"
409   export CXX=icpc
410   export CXXFLAGS="-O2 -ip -fpic -mcmodel=large"
[3375]411   export fpp_flags="-P -traditional"
[1590]412   compile_with_fcm=1
[3044]413
[2031]414else
[3088]415   echo unexpected compiler $compiler ; exit
[1588]416fi
[2031]417
[1589]418OPTIMGCM="$OPTIM $OPTPREC"
[1588]419
420hostname=`hostname`
421
422##########################################################################
[1731]423# If installing on know machines such as IBM x3750 (Ada)
[1708]424# at IDRIS, don't check for available software and don"t install netcdf
[1777]425if [ ${hostname:0:5} = ada33 ] ; then
[1731]426  netcdf=0 # no need to recompile netcdf, alreday available
427  check_linux=0
428  pclinux=0
[3044]429  ioipsl=1 # no need to recompile ioipsl, already available
[1731]430  #netcdf="/smplocal/pub/NetCDF/4.1.3"
[3088]431  compiler="ifort"
[1731]432  fmod='module '
[3044]433  if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi
[1731]434  OPTIM="-O2 -fp-model strict -ip -axAVX,SSE4.2 -align all "
435  OPTIMGCM="$OPTIM $OPTPREC"
[1588]436fi
437##########################################################################
438
439
[3044]440
[1588]441mkdir -p $MODEL
442echo $MODEL
[1708]443MODEL=`( cd $MODEL ; pwd )` # to get absolute path, if necessary
[1588]444
445
446
[1708]447# Option -fendian=big is only to be used with ARPEGE1D.
448# The -r8 should probably be avoided if running on 32 bit machines
449# Option r8 is not mandatory and generates larger executables.
450# It is however mandatory if using ARPEGE1D
451# Better optimization options might be a better choice (e.g. -O3)
[1588]452
453
454echo '################################################################'
455if [ "$check_linux" = 1 ] ; then
[1708]456echo   Check if required software is available
[1588]457echo '################################################################'
458
459#### Ehouarn: test if ksh and/or bash are available
460use_shell="ksh" # default: use ksh
461if [ "`which ksh`" = "" ] ; then
[1708]462  echo "no ksh ... we will use bash"
[1588]463  use_shell="bash"
464  if [ "`which bash`" = "" ] ; then
[1708]465    echo "ksh (or bash) needed!! Install it!"
[1588]466  fi
467fi
468
469
[3088]470for logiciel in csh wget tar gzip make $compiler gcc ; do
[1588]471if [ "`which $logiciel`" = "" ] ; then
[1708]472echo You must first install $logiciel on your system
[1588]473exit
474fi
475done
476
477if [ $pclinux = 1 ] ; then
478cd $MODEL
[2030]479cat <<eod > tt.f90
[1588]480print*,'coucou'
481end
482eod
[3088]483$compiler tt.f90 -o a.out
[1588]484./a.out >| tt
485if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then
[3088]486echo problem installing with compiler $compiler ; exit ; fi
[1588]487\rm tt a.out tt.f90
488fi
489fi
490
491###########################################################################
492if [ $getlmdzor = 1 ] ; then
493echo '##########################################################'
[1708]494echo  Download a slightly modified version of  LMDZ
[1588]495echo '##########################################################'
496cd $MODEL
[3076]497myget src/modipsl.$version.tar.gz
[3044]498echo install.sh wget_OK `date`
499gunzip modipsl.$version.tar.gz
500tar xvf modipsl.$version.tar
501\rm modipsl.$version.tar
[1588]502
503fi
504
505echo OK1
506
507if [ $netcdf = 1 ] ; then
[3091]508cd $MODEL
509netcdflog=`pwd`/netcdf.log
[1588]510echo '##########################################################'
[1708]511echo Compiling the Netcdf library
[1588]512echo '##########################################################'
[3091]513echo log file : $netcdflog
[3056]514if [ "$with_xios" = "n" ] ; then
515  # keep it simple
516  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/netcdf-4.0.1.tar.gz
[3076]517  myget import/netcdf-4.0.1.tar.gz
[3056]518  gunzip netcdf-4.0.1.tar.gz
519  tar xvf netcdf-4.0.1.tar
520  \rm -f netcdf-4.0.1.tar
[1588]521
[3056]522  cd netcdf-4.0.1
[1588]523
[3056]524  # seds to possibly use gfortran44 obsolete nowdays (Ehouarn: 10/2017)
525  #sed -e 's/gfortran/'$gfortran'/g' configure >| tmp ; mv -f tmp configure ; chmod +x configure
526  localdir=`pwd -P`
527  ./configure --prefix=$localdir --enable-shared --disable-cxx
528  #sed -e 's/gfortran/'$gfortran'/g' Makefile >| tmp ; mv -f tmp Makefile
[3091]529  $make check > $netcdflog 2>&1
530  $make install >> $netcdflog 2>&1
[3056]531else
532  # download and compile hdf5 and netcdf, etc. using the install_netcdf4_hdf5.bash script
533  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_netcdf4_hdf5.bash
[3076]534  myget import/install_netcdf4_hdf5.bash
[3056]535  chmod u=rwx install_netcdf4_hdf5.bash
[3088]536  if [ "$compiler" = "gfortran" ] ; then
[3056]537  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC gcc -FC gfortran -CXX g++ -MPI $root_mpi
[3088]538  elif [ "$compiler" = "ifort" ] ; then
[3056]539  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC icc -FC ifort -CXX icpc -MPI $root_mpi
[3088]540  elif [ "$compiler" = "pgf90" ] ; then
[3056]541  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC pgcc -FC pgf90 -CXX pgCC -MPI $root_mpi
542  else
[3088]543    echo "unexpected compiler $compiler" ; exit
[3056]544  fi
545fi  # of if [ "$with_xios" = "n" ]
[2030]546echo install.sh netcdf_OK `date`
[1731]547fi # of if [ $netcdf = 1 ]
[1588]548
[2030]549
[1800]550#=======================================================================================
[1588]551echo OK2 ioipsl=$ioipsl
552echo '##########################################################'
[1731]553echo 'Installing MODIPSL, the installation package manager for the '
554echo 'IPSL models and tools'
[1588]555echo '##########################################################'
556
557if [ $netcdf = 0 -o $netcdf = 1 ] ; then
[3056]558  if [ "$with_xios" = "y" ] ; then
559  ncdfdir=$MODEL/netcdf4_hdf5
560  else
561  ncdfdir=$MODEL/netcdf-4.0.1
562  fi
[1588]563else
[3056]564  ncdfdir=$netcdf
[1588]565fi
566
567if [ $ioipsl = 1 ] ; then
[1731]568  cd $MODEL/modipsl
[2030]569  \rm -rf lib/*
[2031]570
[1731]571  cd util
[1588]572
[1731]573  cp AA_make.gdef AA_make.orig
[3088]574  F_C="$compiler -c " ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then F_C="$compiler -c -cpp " ; fi
575  if [ "$compiler" = "pgf90" ] ; then F_C="$compiler -c -Mpreprocess" ; fi
[1731]576  sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
[3088]577  sed -e "s:F_L = g95:F_L = $compiler:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \
[1731]578  -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
579  -e 's:g95.*.NCDF_INC.*.$:g95      NCDF_INC= '"$ncdfdir"'/include:' \
[3044]580  -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \
[3063]581  -e 's:g95      L_O =:g95      L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \
[1731]582  -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
583  -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
584  tmp >| AA_make.gdef
[1588]585
[3375]586  if [ $pcmac == 1 ]
587  then
588      cp AA_make.gdef tmp
589      sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef
590  fi
591 
[1588]592
[3044]593# We use lines for g95 even for the other compilers to run ins_make
[1731]594  if [ "$use_shell" = "ksh" ] ; then
[3044]595    ./ins_make $o_ins_make
[1731]596  else # bash
597    sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash
[3044]598    if [ "`grep ada AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar
599        \cp -f ~rdzt401/bin/AA_make.gdef .
600    fi
[3375]601   
[1731]602    chmod u=rwx ins_make.bash
[3044]603    ./ins_make.bash $o_ins_make
[1731]604  fi # of if [ "$use_shell" = "ksh" ]
605
[2031]606#=======================================================================================
[3091]607  cd $MODEL/modipsl/modeles/IOIPSL/src
[3092]608  ioipsllog=`pwd`/ioipsl.log
[1731]609  echo '##########################################################'
610  echo 'Compiling IOIPSL, the interface library with Netcdf'
611  echo '##########################################################'
[3091]612  echo log file : $ioipsllog
[1731]613
614  if [ "$use_shell" = "bash" ] ; then
615    cp Makefile Makefile.ksh
616    sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
[1588]617  fi
[3044]618# if [ "$pclinux" = 1 ] ; then
[1731]619    # Build IOIPSL modules and library
[3044]620    $make clean
[3091]621    $make > $ioipsllog 2>&1
[3088]622    if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then # copy module files to lib
[1731]623      cp -f *.mod ../../../lib
624    fi
625    # Build IOIPSL tools (ie: "rebuild", if present)
626    if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then
627      cd $MODEL/modipsl/modeles/IOIPSL/tools
628      # adapt Makefile & rebuild script if in bash
629      if [ "$use_shell" = "bash" ] ; then
630        cp Makefile Makefile.ksh
631        sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
632        cp rebuild rebuild.ksh
633        sed -e 's:/bin/ksh:/bin/bash:g' \
634            -e 's:print -u2:echo:g' \
635            -e 's:print:echo:g' rebuild.ksh > rebuild
636      fi
[3044]637      $make clean
[3091]638      $make > $ioipsllog 2>&1
[1731]639    fi
[3044]640# fi # of if [ "$pclinux" = 1 ]
[1588]641
[1731]642else # of if [ $ioipsl = 1 ]
[1777]643  if [ ${hostname:0:5} = ada33 ] ; then
[1731]644    cd $MODEL/modipsl
645    cd util
[1588]646
[1731]647    cp AA_make.gdef AA_make.orig
648    sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
[3088]649    sed -e "s:F_L = g95:F_L = $compiler:" -e "s:F_C = g95 -c:F_C = $compiler -c": \
[1731]650    -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
651    -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:' \
652    -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L/smplocal/pub/NetCDF/4.1.3/lib -lnetcdff -lnetcdf:' \
653    -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
654    -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
655    tmp >| AA_make.gdef
656
[3044]657    ./ins_make $o_ins_make # We use lines for g95 even for the other compilers
[1731]658
659    # on Ada, IOIPSL is already installed in ~rpsl035/IOIPSL_PLUS
660    # so link it to current settings
661    cd $MODEL/modipsl/modeles/
662    \rm -r -f IOIPSL
663    ln -s ~rpsl035/IOIPSL_PLUS IOIPSL
664    cd ..
[3044]665    ln -s ~rpsl035/IOIPSL_PLUS/modipsl_Tagv2_2_3/bin/* bin/
666    ln -s ~rpsl035/IOIPSL_PLUS/modipsl_Tagv2_2_3/lib/* lib/
[1731]667
[1777]668  fi # of if [ ${hostname:0:5} = ada33 ]
[2030]669  echo install.sh ioipsl_OK `date`
[1731]670fi # of if [ $ioipsl = 1 ]
[3044]671# Saving ioipsl lib for possible parallel compile
672  cd $MODEL/modipsl
673  tar cf ioipsl.tar lib/ bin/
[1731]674
[3056]675#===========================================================================
676if [ "$with_xios" = "y" ] ; then
677  echo '##########################################################'
678  echo 'Compiling XIOS'
679  echo '##########################################################'
680  cd $MODEL/modipsl/modeles
[3375]681  xioslog=`pwd`/xios.log
682  echo "log file: $xioslog"
[3056]683  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_xios.bash
[3076]684  myget import/install_xios.bash
[3056]685  chmod u=rwx install_xios.bash
[3375]686  if [ ${hostname:0:5} = ada33 ] ; then
687    ./install_xios.bash \
688    -prefix /workgpfs/rech/gzi/rgzi027/LMDZ20180221.trunk/modipsl/modeles \
689    -netcdf /smplocal/pub/NetCDF/4.1.3/mpi -hdf5 /smplocal/pub/HDF5/1.8.9/par \
690    -MPI /smplocal/intel/compilers_and_libraries_2017.2.174/linux/mpi/intel64/ \
691    -arch X64_ADA > xios.log 2>&1
692   else
693     ./install_xios.bash -prefix $MODEL/modipsl/modeles \
[3056]694                      -netcdf ${ncdfdir} -hdf5 ${ncdfdir} \
[3375]695                      -MPI $root_mpi -arch $arch > xios.log 2>&1
696   fi
697   if [ -f XIOS/lib/libxios.a ] ; then
698     echo "OK, XIOS library successfully generated"
699   fi
[3056]700fi
701
[1800]702#============================================================================
[1837]703veget_version=false
[1731]704if [ "$veget" = 1 ] ; then
[3091]705  cd $MODEL/modipsl/modeles/ORCHIDEE
706  orchideelog=`pwd`/orchidee.log
[1731]707  echo '########################################################'
708  echo 'Compiling ORCHIDEE, the continental surfaces model '
709  echo '########################################################'
[3091]710  echo log file : $orchideelog
[2430]711  export ORCHPATH=`pwd`
712  if [ -d tools ] ; then
[3386]713###################################################################
714# Pour les experts qui voudraient changer de version d'orchidee.
715# Attention : necessite d'avoir le password pour orchidee
716      set +e ; svn upgrade ; set -e
717      if [ "$orchidee_rev" != "" ] ; then
718         set +e ; svn update -r $orchidee_rev ; set -e
719      fi
720###################################################################
[1837]721     veget_version=orchidee2.0
[3044]722      cd arch
[3088]723      sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
724     -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
[2430]725     -e s:"%FPP_FLAGS       .*.$":"%FPP_FLAGS           $fpp_flags":1 \
726     -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
727     -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
728     -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
[3044]729     -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
730     -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
[3076]731     -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
[2430]732     arch-gfortran.fcm > arch-local.fcm
[3044]733     echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
[2430]734     echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path
735     echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path
736     echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path
[3375]737     echo 'XIOS_INCDIR=${ORCHDIR}/../XIOS/inc' >> arch-local.path
738     echo 'XIOS_LIBDIR="${ORCHDIR}/../XIOS/lib -lxios"' >> arch-local.path
[3044]739     cd ../
[2430]740# compiling ORCHIDEE sequential mode
[3091]741     ./makeorchidee_fcm -j 8 -noxios -prod -parallel none -arch $arch > $orchideelog 2>&1
[3044]742     echo ./makeorchidee_fcm -j 8 -noxios -prod -parallel none -arch $arch
[3417]743     echo End of the first compilation of orchidee ; pwd
[1800]744  else
[2430]745     if [ -d src_parallel ] ; then
746       liste_src="parallel parameters global stomate sechiba driver"
747       veget_version=orchidee2.0
748     else
749       # Obsolete, for ORCHIDEE_beton only
750       liste_src="parameters stomate sechiba "
751       # A trick to compile ORCHIDEE depending on if we are using real*4 or real*8
752       cd src_parameters ; \cp reqdprec.$real reqdprec.f90 ; cd ..
753       veget_version=orchidee1.9
754     fi
755     for d in $liste_src ; do src_d=src_$d
756        echo src_d $src_d
757        echo ls ; ls
758        if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi
[3044]759        cd $src_d ; \rm -f *.mod make ; $make clean
[3091]760        $make > $orchideelog 2>&1 ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi
[2430]761        cd ..
762     done
[1800]763  fi
[2030]764  echo install.sh orchidee_OK `date`
[1731]765fi # of if [ "$veget" = 1 ]
[1588]766
[2030]767
[1800]768#============================================================================
[1588]769# Ehouarn: it may be directory LMDZ4 or LMDZ5 depending on tar file...
[3044]770if [ -d $MODEL/modipsl/modeles/LMD* ] ; then
[1588]771  echo '##########################################################'
[1800]772  echo 'Compiling LMDZ'
[1588]773  echo '##########################################################'
[3044]774  cd $MODEL/modipsl/modeles/LMD*
775  LMDZPATH=`pwd`
[1588]776else
[3044]777  echo "ERROR: No LMD* directory !!!"
[1800]778  exit
[1588]779fi
780
781###########################################################
[1708]782# For those who want to use fcm to compile via :
[1588]783#  makelmdz_fcm -arch local .....
784############################################################
785
[2031]786if [ "$pclinux" = "1" ] ; then
787
[1708]788# create local 'arch' files (if on Linux PC):
[1588]789cd arch
[1708]790# arch-local.path file
[3044]791echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
[1590]792echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path
[1588]793echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path
794echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
[3044]795echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path
796echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path
[1588]797echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path
798echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
[3044]799
[3375]800if [ $pcmac == 1 ] ; then
801    BASE_LD="$BASE_LD -Wl,-rpath,${ncdfdir}/lib"
802else
803    BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib"
804fi
805# Arch-local.fcm file (adapted from arch-linux-32bit.fcm)
[2031]806
807if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi
[3088]808sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
809    -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
[2031]810    -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
811    -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
812    -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
813    -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
[2203]814    -e s:"%FPP_DEF         .*.$":"%FPP_DEF             $FPP_DEF":1 \
[3044]815    -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
[3076]816    -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
[2031]817    arch-linux-32bit.fcm > arch-local.fcm
818
[1588]819cd ..
[1708]820### Adapt "bld.cfg" (add the shell):
[1588]821whereisthatshell=$(which ${use_shell})
822echo "bld::tool::SHELL   $whereisthatshell" >> bld.cfg
823
[1731]824fi # of if [ "$pclinux" = 1 ]
825
826
[3056]827cd $MODEL/modipsl/modeles/LMDZ*
[3093]828lmdzlog=`pwd`/lmdz.log
[1731]829
[1588]830##################################################################
[3056]831# Possibly update LMDZ if a specific svn release is requested
[3044]832##################################################################
833
[3386]834set +e ; svn upgrade ; set -e
[3044]835if [ "$svn" = "last" ] ; then svnopt="" ; else svnopt="-r $svn" ; fi
[3386]836if [ "$svn" != "" ] ; then svn update $svnopt ; fi
[3044]837
[3091]838echo '##################################################################'
839echo Compile LMDZ
840echo '##################################################################'
841echo log file : $lmdzlog
[3044]842
[2030]843echo install.sh avant_compilation `date`
[3044]844if [ $compile_with_fcm = 1 ] ; then makelmdz="makelmdz_fcm -arch $arch -j 8" ; else makelmdz="makelmdz -arch $arch" ; fi
[2031]845
[3044]846# use the orchidee interface that has no z0h
847if [ "$no_z0h_orc" = 1 ] ; then
848veget_version="$veget_version -cpp ORCHIDEE_NOZ0H"
849fi
850
851# sequential compilation and bench
852if [ "$sequential" = 1 ] ; then
[3375]853echo "./$makelmdz $OPT_MAKELMDZ -rrtm true $opt_cosp -d ${grid_resolution} -v $veget_version gcm " >> compile.sh
854chmod +x ./compile.sh
855if [ $bench != 0 ] ; then ./compile.sh > $lmdzlog 2>&1 ; fi
[2030]856echo install.sh apres_compilation `date`
[1588]857
[2030]858
[3044]859fi # fin sequential
860
861
862
863# compiling in parallel mode
864if [ $parallel != "none" ] ; then
[3056]865  echo '##########################################################'
866  echo ' Parallel compile '
867  echo '##########################################################'
868  # saving the sequential libs and binaries
869  cd $MODEL/modipsl
870  tar cf sequential.tar bin/ lib/
871  \rm -rf bin/ lib/
872  tar xf ioipsl.tar
873  #
874  # Orchidee
875  #
876  cd $ORCHPATH
[3386]877  if [ -d src_parallel -a $veget = 1 ] ; then
[3044]878     cd arch
879     sed  \
880     -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
881     -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
882     -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
883     -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
884     -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
885     -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
886     arch-local.fcm > tmp.fcm
887
888     mv tmp.fcm arch-local.fcm
889     cd ../
[3091]890     echo compiling ORCHIDEE parallel mode
891     echo logfile $orchideelog
892     ./makeorchidee_fcm -j 8 -clean -noxios -prod -parallel $parallel -arch $arch > $orchideelog 2>&1
893     ./makeorchidee_fcm -j 8 -noxios -prod -parallel $parallel -arch $arch >> $orchideelog 2>&1
[3044]894     echo ./makeorchidee_fcm -j 8 -clean -noxios -prod -parallel $parallel -arch $arch
895     echo ./makeorchidee_fcm -j 8 -noxios -prod -parallel $parallel -arch $arch
[3386]896  elif [ $veget = 1 ] ; then
[3056]897    echo '##########################################################'
898    echo ' Orchidee version too old                                 '
899    echo ' Please update to new version                             '
900    echo '##########################################################'
901    exit
902  fi # of if [ -d src_parallel ]
903  # LMDZ
904  cd $LMDZPATH
905  if [ $arch = local ] ; then
906    cd arch
907    sed -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
908    -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
909    -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
910    -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
[3076]911    -e s:"%ARFLAGS.*.$":"%ARFLAGS          $ARFLAGS":1 \
[3056]912    -e s@"%BASE_LD.*.$"@"%BASE_LD             -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \
913    -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
914    -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
915    arch-local.fcm > tmp.fcm
916    mv tmp.fcm arch-local.fcm
917    cd ../
918  fi
919  rm -f compile.sh
920  if [ ${hostname:0:5} = ada33 ] ; then echo "module load intel/2013.0" > compile.sh ; fi
921  echo resol=${grid_resolution} >> compile.sh
[3375]922  echo ./$makelmdz $OPT_MAKELMDZ -rrtm true $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
923  chmod +x ./compile.sh
924  if [ $bench != 0 ] ; then ./compile.sh > $lmdzlog 2>&1 ; fi
[1588]925
[3056]926  echo "Compilation finished"
927 
928fi # of if [ $parallel != "none" ]
[3044]929
[3417]930#echo LLLLLLLLLLLLLLLLLLLLLLLLLLL
[3044]931if [ "$gfortran" = "gfortran44" ] ; then
932    echo Your gfortran compiler was too old so that the model was automatically
933    echo compiled with gfortran44 instead. It can not be used in parallel mode.
934    echo You can change the compiler at the begining of the install.sh
935    echo script and reinstall.
936fi
937
[1588]938##################################################################
[3044]939# Verification du succes de la compilation
[1588]940##################################################################
[3044]941
942# Recherche de l'executable dont le nom a change au fil du temps ...
943gcm=""
944for 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
945   if [ -f $exe ] ; then gcm=$exe ; fi
946done
947
948if [ "$gcm" = "" ] ; then
949   echo 'Compilation failed !!'
[3056]950   # Ehouarn : temporary, do not exit and let job finish (to set up bench case)
951   #exit
952   set +e
[3044]953else
954   echo '##########################################################'
955   echo 'Compilation successfull !! '
956   echo '##########################################################'
957   echo The executable is $gcm
[1588]958fi
959
[3044]960##################################################################
961# Below, we run a benchmark test (if bench=0)
962##################################################################
963
964if [ $bench != 0 ] ; then
965
[1588]966echo '##########################################################'
[1731]967echo ' Running a test run '
[1588]968echo '##########################################################'
969
[2030]970\rm -rf BENCH${grid_resolution}
[1588]971bench=bench_lmdz_${grid_resolution}
[3417]972echo install.sh before bench download  `date`
[3044]973#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz
[3076]974myget 3DBenchs/$bench.tar.gz
[3044]975echo install.sh after bench download  `date`
976tar xvf $bench.tar.gz
[1588]977
[3386]978if [ "$cosp" = 1 -o "$cosp2" = 1 ] ; then
979  cd BENCH${grid_resolution}
980# copier les fichiers namelist input et output our COSP
981  cp ../DefLists/cosp_input_nl.txt .
982  cp ../DefLists/cosp_output_nl.txt .
983# Activer la cles ok_cosp pour tourner avec COSP
984  sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp
985   \mv -f tmp config.def
986  cd ..
987fi 
988
[3056]989if [ "$with_xios" = "y" ] ; then
990  cd BENCH${grid_resolution}
991  cp ../DefLists/iodef.xml .
992  cp ../DefLists/context_lmdz.xml .
993  cp ../DefLists/field_def_lmdz.xml .
994  cp ../DefLists/file_def_hist*xml .
995  # adapt iodef.xml to use attached mode
996  sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp
997  \mv -f tmp iodef.xml
[3386]998
[3056]999  # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE.
1000  # except for histday
1001  for histfile in file_def_hist*xml
1002  do
1003    if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then
1004    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
1005    else
1006    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile
1007    fi
1008  done
1009  # and add option "ok_all_xml=y" in config.def
1010  echo "### XIOS outputs" >> config.def
1011  echo 'ok_all_xml=.true.' >> config.def
1012  cd ..
1013fi
1014
[3044]1015cp $gcm BENCH${grid_resolution}/gcm.e
[1588]1016
1017cd BENCH${grid_resolution}
[3044]1018# On cree le fichier bench.sh au besoin
1019# Dans le cas 48x36x39 le bench.sh existe deja en parallele
[1588]1020
[3044]1021if [ "$grid_resolution" = "48x36x39" ] ; then
1022   echo On ne touche pas au bench.sh
1023   # But we have to adapt "run_local.sh" for $mpirun
1024   sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp
1025   mv -f tmp run_local.sh
1026   chmod u=rwx run_local.sh
1027elif [ "${parallel:0:3}" = "mpi" ] ; then
1028   # Lancement avec deux procs mpi et 2 openMP
1029   echo "export OMP_STACKSIZE=800M" > bench.sh
1030   if [ "${parallel:4:3}" = "omp" ] ; then
1031     echo "export OMP_NUM_THREADS=2" >> bench.sh
1032   fi
1033   echo "ulimit -s unlimited" >> bench.sh
1034   echo "$mpirun -np 2 gcm.e > listing  2>&1" >> bench.sh
1035else
1036   echo "./gcm.e > listing  2>&1" > bench.sh
1037fi
1038echo EXECUTION DU BENCH
[3076]1039set +e
[3044]1040date ; ./bench.sh > out.bench 2>&1 ; date
[3076]1041set -e
[3044]1042tail listing
[2030]1043
[1588]1044
1045echo '##########################################################'
[1708]1046echo 'Simulation finished in' `pwd`
[3044]1047   echo 'You have compiled with:'
1048   cat ../compile.sh
1049if [ $parallel = "none" ] ; then
1050  echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e'
1051  echo 'or ./bench.sh'
1052else
1053  echo 'You may re-run it with : '
1054  echo 'cd ' `pwd` '; ./bench.sh'
1055  echo 'ulimit -s unlimited'
1056  echo 'export OMP_NUM_THREADS=2'
1057  echo 'export OMP_STACKSIZE=800M'
1058  echo "$mpirun -np 2 gcm.e "
1059fi
[1588]1060echo '##########################################################'
[2030]1061
1062fi
[3044]1063
1064
1065#################################################################
1066# Installation eventuelle du 1D
1067#################################################################
1068
1069if [ $SCM = 1 ] ; then
1070cd $MODEL
1071#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/1D.tar.gz
[3076]1072myget 1D/1D.tar.gz
[3044]1073tar xvf 1D.tar.gz
1074cd 1D
1075./run.sh
1076fi
Note: See TracBrowser for help on using the repository browser.