source: BOL/script_install/install_lmdz.sh @ 4018

Last change on this file since 4018 was 4018, checked in by Laurent Fairhead, 3 years ago

Rajout de commentaire par Adriana

File size: 47.5 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#
[3922]7# bash installation script of the LMDZ model on different computer types :
8# Linux PC, "mesocentre" (IPSL-UPMC, IPSL-X), super-computer (IDRIS)
9#
10# The model is downloaded in the following directory tree
[1588]11# $MODEL/modipsl/modeles/...
[1708]12# using the "modipsl" infrastructure created by the "IPSL"
13# for coupled (atmosphere/ocean/vegetation/chemistry) climate modeling
14# activities.
15# Here we only download atmospheric (LMDZ) and vegetation (ORCHIDEE)
16# components.
[1588]17#
[1708]18# The sources of the models can be found in the "modeles" directory.
[3922]19# In the present case, LMDZ, ORCHIDEE, and IOIPSL or XIOS (handling of input-outputs
20# using the NetCDF library).
[1588]21#
[1708]22# The script downloads various source files (including a version of NetCDF)
23# and utilities, compiles the model, and runs a test simulation in a
[3922]24# minimal configuration.
[1588]25#
[3922]26# Prerequisites : pgf90/gfortran, bash or ksh, wget , gunzip, tar, ...
[1588]27#
[1589]28# Modif 18/11/2011
[1708]29#    changes for option real 8.
[3922]30#      We compile with -r8 (or equivalent) and -DNC_DOUBLE for the GCM
[1708]31#      but with -r4 for netcdf. Variable real must be set to
32#      r4 or r8 at the beginning of the script below.
[1589]33#
[1588]34###########################################################################
35
[4018]36echo install_lmdz.sh DEBUT `date`
[2031]37
[1911]38set -e
39
[3044]40################################################################
41# Choice of installation options
42################################################################
[1588]43
[3044]44# A function to fetch files either locally or on the internet
45function myget { #1st and only argument should be file name
46  # Path on local computer where to look for the datafile
[3076]47  if [ -f /u/lmdz/WWW/LMDZ/pub/$1 ] ; then
48    \cp -f -p /u/lmdz/WWW/LMDZ/pub/$1 .
49  elif [ -f ~/LMDZ/pub/$1 ] ; then
50    \cp -f -p ~/LMDZ/pub/$1 .
[3044]51  else
[3375]52    wget -nv http://www.lmd.jussieu.fr/~lmdz/pub/$1
[3076]53    #dir=~/LMDZ/pub/`dirname $1` ; mkdir -p $dir ; cp -r `basename $1` $dir
[3044]54  fi
55}
[1588]56
[3922]57# 04_2021 : tester si r4 marche encore !
[1590]58#real=r4
[1589]59real=r8
60
[3044]61#########################################################################
62# Valeur par défaut des parametres
63#########################################################################
64svn=""
[3922]65#version=trunk
[3983]66version=20210730.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
74bench=1
75pclinux=1
[3375]76pcmac=0 # default: not on a Mac
[3088]77compiler=gfortran
[3044]78SCM=0
[3922]79# surface/vegetation scheme treatment
80# controlled by the single variable veget which can have the following values
81# - NONE: bucket scheme (default)
82# - CMIP6: orchidee version used in CMIP exercise, rev 5661
[4018]83# - number: orchidee version number
[3922]84veget=NONE
[2031]85# choose the resolution for the bench runs
[3044]86# grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE)
87#                  96x71x19  standard configuration
88grid_resolution=144x142x79
[3610]89grid_resolution=96x95x39
[2409]90grid_resolution=48x36x19
[3610]91grid_resolution=32x32x39
[3646]92# choose the physiq version you want to test
93#physiq=NPv6.0.14splith
94physiq=
[1693]95
[3044]96## parallel can take the values none/mpi/omp/mpi_omp
97parallel=mpi_omp
[3783]98parallel=none
[3573]99idris_acct=lmd
[3044]100OPT_GPROF=""
101OPT_MAKELMDZ=""
102MODEL=""
[2031]103
[3056]104## also compile XIOS? (and more recent NetCDF/HDF5 libraries) Default=no
105with_xios="n"
106opt_makelmdz_xios=""
[3645]107
[3943]108## compile with old/rrtm/ecrad radiatif code (Default=rrtm)
109rad=rrtm
110
[3375]111## compile_with_fcm=1 : use makelmdz_fcm (1) or makelmdz (0)
112compile_with_fcm=1
[3983]113
114#Compilation with Cosp (cosp=NONE/v1/v2 ; default=NONE)
115cosp=NONE
[3386]116opt_cosp=""
[3056]117
[3375]118# Check if on a Mac
119if [ `uname` = "Darwin" ]
120then
121    pcmac=1
122    export MAKE=make
123fi
124#echo "pcmac="$pcmac
125
[3645]126env_file=""
127
[3044]128#########################################################################
129#  Options interactives
130#########################################################################
131while (($# > 0))
132   do
133   case $1 in
134     "-h") cat <<........fin
135    $0 [ -v version ] [ -r svn_release ]
136           [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ]
[3943]137           [-name LOCAL_MODEL_NAME] [-gprof] [-opt_makelmdz] [-rad RADIATIF]
[2031]138
[3044]139    -v       "version" like 20150828.trunk
140             see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk
[2404]141
[3044]142    -r       "svn_release" : either the svn release number or "last"
[3088]143   
144    -compiler gfortran|ifort|pgf90 (default: gfortran)
[2404]145
[3044]146    -parallel PARA : can be mpi_omp (mpi with openMP) or none (for sequential)
[2404]147
[3044]148    -d        GRID_RESOLUTION should be among the available benchs if -bench 1
149              among which : 48x36x19, 48x36x39
150              if wanting to run a bench simulation in addition to compilation
151              default : 48x36x19
152
153    -bench     activating the bench or not (0/1). Default 1
154
155    -name      LOCAL_MODEL_NAME : default = LMDZversion.release
156
[3056]157    -netcdf    PATH : full path to an existing installed NetCDF library
158               (without -netcdf: also download and install the NetCDF library) 
159   
160    -xios      also download and compile the XIOS library
161               (requires the NetCDF4-HDF5 library, also installed by default)
162               (requires to also have -parallel mpi_omp)
163
[3044]164    -gprof     to compile with -pg to enable profiling with gprof
[3056]165
[3983]166    -cosp      to run without our with cospv1 or cospv2 [none/v1/v2]
[3386]167 
[3983]168    -rad RADIATIF can be old, rrtm or ecrad radiatif code
[3375]169
170    -nofcm     to compile without fcm
171
[3044]172    -SCM        install 1D version automatically
[3056]173
[3610]174    -debug      compile everything in debug mode
175
[3044]176    -opt_makelmdz     to call makelmdz or makelmdz_fcm with additional options
[3645]177
[3646]178    -physiq    to choose which physics package to use
179
[3645]180    -env_file  specify an arch.env file to overwrite the existing one
[3646]181
[3922]182    -veget surface model to run [NONE/CMIP6/xxxx]
[3646]183
[3044]184........fin
185     exit ;;
186     "-v") version=$2 ; shift ; shift ;;
187     "-r") svn=$2 ; shift ; shift ;;
[3088]188     "-compiler") compiler=$2
189                  case $compiler in
190                    "gfortran"|"ifort"|"pgf90") compiler=$2 ; shift ; shift ;;
191                    *) echo "Only gfortran , ifort or pgf90 for the compiler option" ; exit
192                  esac ;;
[3044]193     "-d") grid_resolution=$2 ; shift ; shift ;;
194     "-gprof") OPT_GPROF="-pg" ; shift ;;
[3983]195     "-cosp") cosp=$2 
196              case $cosp in
197                  "none"|"v1"|"v2") cosp=$2 ; shift ; shift ;;
198                  *) echo Only none v1 v2 for cosp option ; exit
199              esac ;;
[3375]200     "-nofcm") compile_with_fcm=0 ; shift ;;
[3044]201     "-SCM") SCM=1 ; shift ;;
202     "-opt_makelmdz") OPT_MAKELMDZ="$2" ; shift ; shift ;;
[3943]203     "-rad") rad=$2
204             case $rad in
205                "old"|"rrtm"|"ecrad") rad=$2 ; shift ; shift ;;
206                *) echo Only old rrtm ecrad for rad option ; exit
207             esac ;;
[3044]208     "-parallel") parallel=$2
209                  case $parallel in
[3064]210                    "none"|"mpi"|"omp"|"mpi_omp") parallel=$2 ; shift ; shift ;;
211                    *) echo Only none mpi omp mpi_omp for the parallel option ; exit
[3044]212                  esac ;;
213     "-bench") bench=$2 ; shift ; shift ;;
[3610]214     "-debug") optim=-debug ; shift ;;
[3044]215     "-name") MODEL=$2 ; shift ; shift ;;
[3056]216     "-netcdf") netcdf=$2 ; shift ; shift ;;
[3646]217     "-physiq") physiq=$2 ; shift ; shift ;;
[3056]218     "-xios") with_xios="y" ; shift ;;
[3645]219     "-env_file") env_file=$2 ; shift ; shift ;;
[3922]220     "-veget") veget=$2 ; shift ; shift ;;
[3044]221     *) ./install_lmdz.sh -h ; exit
222   esac
223done
224
[3943]225#Option de compilation en fonction du code radiatif (-rad rrtm/ecrad)
226if [ $rad = rrtm ] ; then
227   opt_rad="-rad rrtm"
228elif [ $rad = ecrad ] ; then
229   opt_rad="-rad ecrad"
230else
231   opt_rad=""
232fi
233
[3983]234if [ $cosp = v1 ] ; then
235    opt_cosp="-cosp true"
236elif [ $cosp = v2 ] ; then
237    opt_cosp="-cospv2 true"
238else
239    opt_cosp=""
240fi
241 
[3922]242# Check on veget version
243#if [ "$veget" != 'NONE'  -a "$veget" != "CMIP6" -a "$veget" != +([0-9]) ] ; then
244if [ $veget != 'NONE'   -a $veget != "CMIP6" ] ; then
245    re='^[0-9]+$'
246    if ! [[ $veget =~ $re ]] ; then
247        echo 'Valeur de l option veget non valable' 
248        exit
249    fi
250fi
[3044]251
[3922]252#Define veget-related suffix for gcm name
253if [ "$veget" = 'NONE' ] ; then
254    suff_orc=''
255    #For use with tutorial, orchidee_rev is also defined (will be written in surface_env at the end of the script)
256    orchidee_rev=''
257else 
258    suff_orc='_orch' 
259fi
260
261
262if [ $parallel = none ] ; then sequential=1; suff_exe='_seq' ; else sequential=0; suff_exe='_para_mem' ; fi 
263
[3044]264#Chemin pour placer le modele
[3610]265if [ "$MODEL" = "" ] ; then MODEL=./LMDZ$version$svn$optim ; fi
[3044]266
267
268arch=local
269
270
[3088]271if [ $compiler = g95 ] ; then echo g95 is not supported anymore ; exit ; fi
[3044]272
273################################################################
274# Specificite des machines
275################################################################
276
277hostname=`hostname`
278if [ "$pclinux" = 1 ] ; then o_ins_make="-t g95" ; else o_ins_make="" ; fi
279
280case ${hostname:0:5} in
281
[3573]282   jean-)   compiler="mpiifort" ;
283            par_comp="mpiifort" ;
284            o_ins_make="-t jeanzay" ;
285            make=gmake ;
[3610]286            module purge
[3573]287            module load intel-compilers/19.0.4 ;
[3645]288            #module load intel-mpi/19.0.4 ;
289            #module load intel-mkl/19.0.4 ;
290            module load hdf5/1.10.5-mpi ;
291            module load netcdf/4.7.2-mpi ;
292            module load netcdf-fortran/4.5.2-mpi ;
293            module load subversion/1.9.7 ;
[3573]294            export NETCDF_LIBDIR=./
295            export NETCDFFORTRAN_INCDIR=./
296            export NETCDFFORTRAN_LIBDIR=./
297            arch=X64_JEANZAY ;;
298
[3375]299   cicla|camel)   compiler="gfortran" ;
[3056]300            if [ $parallel != none ] ; then
[3375]301              module load openmpi/1.6.5-gfortran ;
[3056]302              root_mpi=$MPI_HOME ;
303              path_mpi=$root_mpi/bin ;
304              par_comp=${path_mpi}/mpif90 ;
305              mpirun=${path_mpi}/mpirun ;
306            fi ;
307            arch=local  ;
308            make=make ;
309            o_ins_make="-t g95" ;;
310           
[3922]311   *)       if [ $parallel = none -o -f /usr/bin/mpif90 ] ; then
[3076]312                path_mpi=`which mpif90 | sed -e s:/mpif90::` ;
[3056]313                if [ -d /usr/lib64/openmpi ] ; then
314                  root_mpi="/usr/lib64/openmpi"
315                else
316                  root_mpi="/usr"
317                fi
[3922]318            # For Scientifique Linux with gfortran at LMD :
319            elif [ -f /usr/lib64/openmpi/1.4.5-gfortran/bin/mpif90 -a $compiler = "gfortran" ] ; then
320                path_mpi=/usr/lib64/openmpi/1.4.5-gfortran/bin ;
321                root_mpi=/usr/lib64/openmpi/1.4.5-gfortran ;
322                export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
323            # For Scientifique Linux with ifort at LMD :
324            elif [ -f /usr/lib64/openmpi/1.4.5-ifort/bin/mpif90 -a $compiler = "ifort" ] ; then
325                path_mpi=/usr/lib64/openmpi/1.4.5-ifort/bin ;
326                root_mpi=/usr/lib64/openmpi/1.4.5-ifort ;
327                export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
328            # For Scientifique Linux with pgf90 at LMD :
329            elif [ -f /usr/lib64/openmpi/1.4.5-ifort/bin/mpif90 -a $compiler = "pgf90" ] ; then
330                path_mpi=/usr/lib64/openmpi/1.4.5-pgf/bin ;
331                root_mpi=/usr/lib64/openmpi/1.4.5-pgf ;
332                export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
[3044]333            else
[3922]334               echo "Cannot find mpif90" ;
335               if [ $parallel = none ] ; then exit ; fi ;
[3044]336            fi ;
[3056]337            par_comp=${path_mpi}/mpif90 ;
338            mpirun=${path_mpi}/mpirun ;
[3044]339            arch=local  ;
340            make=make ;
341            o_ins_make="-t g95"
342esac
343
[3088]344# Flags for parallelism:
345if [ $parallel != none ] ; then
346  # MPI_LD are the flags needed for linking with MPI
347  MPI_LD="-L${root_mpi}/lib -lmpi"
348  if [ "$compiler" = "gfortran" ] ; then
349    # MPI_FLAGS are the flags needed for compilation with MPI
350    MPI_FLAGS="-fcray-pointer"
351    # OMP_FLAGS are the flags needed for compilation with OpenMP
352    OMP_FLAGS="-fopenmp -fcray-pointer"
353    # OMP_LD are the flags needed for linking with OpenMP
354    OMP_LD="-fopenmp"
355  elif [ "$compiler" = "ifort" ] ; then
356    MPI_FLAGS=""
357    OMP_FLAGS="-openmp"
358    OMP_LD="-openmp"
359  else # pgf90
360    MPI_FLAGS=""
361    OMP_FLAGS="-mp"
362    OMP_LD="-mp"
363  fi
364fi
[3044]365
[1693]366#####################################################################
367# Test for old gfortran compilers
[2030]368# If the compiler is too old (older than 4.3.x) we test if the
369# temporary gfortran44 patch is available on the computer in which
370# case the compiler is changed from gfortran to gfortran44
371# Must be aware than parallelism can not be activated in this case
372#####################################################################
373
[3088]374if [ "$compiler" = "gfortran" ] ; then
[2030]375   gfortran=gfortran
[1693]376   gfortranv=`gfortran --version | \
377   head -1 | awk ' { print $NF } ' | awk -F. ' { print $1 * 10 + $2 } '`
378   if [ $gfortranv -le 43 ] ; then
[1708]379       echo ERROR : Your gfortran compiler is too old
[3044]380       echo 'Please choose a new one (ifort) and change the line'
[3088]381       echo compiler=xxx
[4018]382       echo in the install_lmdz.sh script and rerun it
[2030]383       if [ `which gfortran44 | wc -w` -ne 0 ] ; then
384          gfortran=gfortran44
385       else
386          echo gfotran trop vieux ; exit
387       fi
[1693]388   fi
[3088]389   compiler=$gfortran
[1693]390fi
391#####################################################################
392
[3056]393## if also compiling XIOS, parallel must be mpi_omp
394if [ "$with_xios" = "y" -a "$parallel" != "mpi_omp" ] ; then 
395  echo "Error, you must set -parallel mpi_omp if you want XIOS"
396  exit
397fi
[3386]398
[3417]399if [ "$with_xios" = "y" ] ; then
[3056]400  opt_makelmdz_xios="-io xios"
401fi
[1693]402
[3983]403if [ "$cosp" = "v2" -a "$with_xios" = "n" ] ; then
[3735]404  echo "Error, Cospv2 cannot run without Xios"
405  exit
406fi
407
[1588]408echo '################################################################'
409echo  Choix des options de compilation
410echo '################################################################'
[1589]411
[3088]412export FC=$compiler
413export F90=$compiler
414export F77=$compiler
[2031]415export CPPFLAGS=
[3044]416OPTIMNC=$OPTIM
417BASE_LD="$OPT_GPROF"
418OPTPREC="$OPT_GPROF"
[3076]419ARFLAGS="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]420
[3076]421
422
[3088]423if [ "$compiler" = "$gfortran" ] ; then
[2031]424   OPTIM='-O3'
[3044]425   OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=nan"
[2031]426   OPTDEV="-Wall -fbounds-check"
427   fmod='I '
[3044]428   OPTPREC="$OPTPREC -cpp -ffree-line-length-0"
[2409]429   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE" ; fi
[2031]430   export F90FLAGS=" -ffree-form $OPTIMNC"
431   export FFLAGS=" $OPTIMNC"
432   export CC=gcc
433   export CXX=g++
[3044]434   export fpp_flags="-P -C -traditional -ffreestanding"
435
[3088]436elif [ $compiler = mpif90 ] ; then
[1589]437   OPTIM='-O3'
[3044]438   OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all"
[2031]439   OPTDEV="-Wall -fbounds-check"
[3044]440   BASE_LD="$BASE_LD -lblas"
[2031]441   fmod='I '
[3044]442   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer" ; fi
[2031]443   export F90FLAGS=" -ffree-form $OPTIMNC"
444   export FFLAGS=" $OPTIMNC"
445   export CC=gcc
446   export CXX=g++
[3044]447
[3088]448elif [ $compiler = pgf90 ] ; then
[2203]449   OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align'
450   OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback'
451   OPTDEV='-g -Mbounds -Ktrap=fp -traceback'
[2031]452   fmod='module '
[3044]453   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE" ; fi
[2203]454   export CPPFLAGS="-DpgiFortran"
[2031]455   export CC=pgcc
[2203]456   export CFLAGS="-O2 -Msignextend"
[2031]457   export CXX=pgCC
[2203]458   export CXXFLAGS="-O2 -Msignextend"
459   export FFLAGS="-O2 $OPTIMNC"
460   export F90FLAGS="-O2 $OPTIMNC"
[1590]461   compile_with_fcm=1
[3044]462
[3088]463elif [ $compiler = ifort ] ; then
[2031]464   OPTIM="-O2 -fp-model strict -ip -align all "
465   OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check"
466   OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check"
467   fmod='module '
[3044]468   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi
[2031]469   export CPP="icc -E"
470   export FFLAGS="-O2 -ip -fpic -mcmodel=large"
471   export FCFLAGS="-O2 -ip -fpic -mcmodel=large"
472   export CC=icc
473   export CFLAGS="-O2 -ip -fpic -mcmodel=large"
474   export CXX=icpc
475   export CXXFLAGS="-O2 -ip -fpic -mcmodel=large"
[3375]476   export fpp_flags="-P -traditional"
[3610]477   # Pourquoi forcer la compilation fcm. Marche mieux sans
478   #compile_with_fcm=1
[3044]479
[3573]480elif [ $compiler = mpiifort ] ; then
[3610]481   echo on ne fait rien la
482   # Pourquoi forcer la compilation fcm. Marche mieux sans
483   #compile_with_fcm=1
[3573]484
[2031]485else
[3088]486   echo unexpected compiler $compiler ; exit
[1588]487fi
[2031]488
[1589]489OPTIMGCM="$OPTIM $OPTPREC"
[1588]490
491hostname=`hostname`
492
493##########################################################################
[3922]494# If installing on known machines such as Jean-Zay at IDRIS,
495# don't check for available software and don't install netcdf
[3573]496if [ ${hostname:0:5} = jean- ] ; then
497  netcdf=0 # no need to recompile netcdf, alreday available
498  check_linux=0
499  pclinux=0
500  ioipsl=0 # no need to recompile ioipsl, already available
501  #netcdf="/smplocal/pub/NetCDF/4.1.3"
502  compiler="mpiifort"
503  fmod='module '
504  if [ $real = r8 ] ; then OPTPREC="$OPTPREC -i4 -r8 -DNC_DOUBLE" ; fi
505  OPTIM="-auto -align all -O2 -fp-model strict -xHost "
506  OPTIMGCM="$OPTIM $OPTPREC"
507fi
[1588]508##########################################################################
509
510
511mkdir -p $MODEL
512echo $MODEL
[1708]513MODEL=`( cd $MODEL ; pwd )` # to get absolute path, if necessary
[1588]514
515
516echo '################################################################'
517if [ "$check_linux" = 1 ] ; then
[1708]518echo   Check if required software is available
[1588]519echo '################################################################'
520
[3922]521#### Ehouarn: test if the required shell is available
522#### Maj FH-LF-AS 2021-04 : default=bash ; if bash missing, use ksh
523use_shell="bash" # default
524if [ "`which bash`" = "" ] ; then
525  echo "no bash ; we will use ksh"
526  use_shell="ksh"
527  if [ "`which ksh`" = "" ] ; then
528    echo "bash (or ksh) needed!! Install it!"
529    exit
[1588]530  fi
[3922]531fi
[1588]532
[3610]533for logiciel in wget tar gzip make $compiler gcc ; do
[1588]534if [ "`which $logiciel`" = "" ] ; then
[1708]535echo You must first install $logiciel on your system
[1588]536exit
537fi
538done
539
540if [ $pclinux = 1 ] ; then
541cd $MODEL
[2030]542cat <<eod > tt.f90
[1588]543print*,'coucou'
544end
545eod
[3088]546$compiler tt.f90 -o a.out
[1588]547./a.out >| tt
548if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then
[3088]549echo problem installing with compiler $compiler ; exit ; fi
[1588]550\rm tt a.out tt.f90
551fi
552fi
553
554###########################################################################
555if [ $getlmdzor = 1 ] ; then
556echo '##########################################################'
[1708]557echo  Download a slightly modified version of  LMDZ
[1588]558echo '##########################################################'
559cd $MODEL
[3922]560myget src/modipsl_orc_cmip6.$version.tar.gz
[4018]561echo install_lmdz.sh wget_OK `date`
[3922]562gunzip modipsl_orc_cmip6.$version.tar.gz
563tar xvf modipsl_orc_cmip6.$version.tar
564\rm modipsl_orc_cmip6.$version.tar
[1588]565fi
566
567if [ $netcdf = 1 ] ; then
[3091]568cd $MODEL
569netcdflog=`pwd`/netcdf.log
[1588]570echo '##########################################################'
[1708]571echo Compiling the Netcdf library
[1588]572echo '##########################################################'
[3091]573echo log file : $netcdflog
[3056]574if [ "$with_xios" = "n" ] ; then
575  # keep it simple
576  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/netcdf-4.0.1.tar.gz
[3076]577  myget import/netcdf-4.0.1.tar.gz
[3056]578  gunzip netcdf-4.0.1.tar.gz
579  tar xvf netcdf-4.0.1.tar
580  \rm -f netcdf-4.0.1.tar
[1588]581
[3056]582  cd netcdf-4.0.1
[1588]583
[3056]584  localdir=`pwd -P`
585  ./configure --prefix=$localdir --enable-shared --disable-cxx
586  #sed -e 's/gfortran/'$gfortran'/g' Makefile >| tmp ; mv -f tmp Makefile
[3091]587  $make check > $netcdflog 2>&1
588  $make install >> $netcdflog 2>&1
[3921]589#LF rajout d'une verrue, pour une raison non encore expliquee, la librairie est parfois rangée dans lib64
590#   et non dans lib par certains compilateurs
591  if [ ! -e lib -a -d lib64 ] ; then ln -s lib64 lib; fi
[3056]592else
593  # download and compile hdf5 and netcdf, etc. using the install_netcdf4_hdf5.bash script
594  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_netcdf4_hdf5.bash
[3076]595  myget import/install_netcdf4_hdf5.bash
[3056]596  chmod u=rwx install_netcdf4_hdf5.bash
[3088]597  if [ "$compiler" = "gfortran" ] ; then
[3560]598  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC gcc -FC gfortran -CXX g++ -MPI $root_mpi  > $netcdflog 2>&1
[3088]599  elif [ "$compiler" = "ifort" ] ; then
[3560]600  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC icc -FC ifort -CXX icpc -MPI $root_mpi  > $netcdflog 2>&1
[3088]601  elif [ "$compiler" = "pgf90" ] ; then
[3560]602  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC pgcc -FC pgf90 -CXX pgCC -MPI $root_mpi  > $netcdflog 2>&1
[3056]603  else
[3088]604    echo "unexpected compiler $compiler" ; exit
[3056]605  fi
606fi  # of if [ "$with_xios" = "n" ]
[4018]607echo install_lmdz.sh netcdf_OK `date`
[1731]608fi # of if [ $netcdf = 1 ]
[1588]609
[3783]610#======================================================================================
[4018]611echo OK ioipsl=$ioipsl
[1588]612echo '##########################################################'
[1731]613echo 'Installing MODIPSL, the installation package manager for the '
614echo 'IPSL models and tools'
[1588]615echo '##########################################################'
[4018]616echo `date`
[1588]617
618if [ $netcdf = 0 -o $netcdf = 1 ] ; then
[3056]619  if [ "$with_xios" = "y" ] ; then
620  ncdfdir=$MODEL/netcdf4_hdf5
621  else
622  ncdfdir=$MODEL/netcdf-4.0.1
623  fi
[1588]624else
[3056]625  ncdfdir=$netcdf
[1588]626fi
627
628if [ $ioipsl = 1 ] ; then
[1731]629  cd $MODEL/modipsl
[2030]630  \rm -rf lib/*
[2031]631
[1731]632  cd util
[1588]633
[1731]634  cp AA_make.gdef AA_make.orig
[3088]635  F_C="$compiler -c " ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then F_C="$compiler -c -cpp " ; fi
636  if [ "$compiler" = "pgf90" ] ; then F_C="$compiler -c -Mpreprocess" ; fi
[1731]637  sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
[3088]638  sed -e "s:F_L = g95:F_L = $compiler:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \
[1731]639  -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
640  -e 's:g95.*.NCDF_INC.*.$:g95      NCDF_INC= '"$ncdfdir"'/include:' \
[3044]641  -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \
[3063]642  -e 's:g95      L_O =:g95      L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \
[1731]643  -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
644  -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
645  tmp >| AA_make.gdef
[1588]646
[3375]647  if [ $pcmac == 1 ]
648  then
649      cp AA_make.gdef tmp
650      sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef
651  fi
652 
[1588]653
[3044]654# We use lines for g95 even for the other compilers to run ins_make
[1731]655  if [ "$use_shell" = "ksh" ] ; then
[3044]656    ./ins_make $o_ins_make
[1731]657  else # bash
658    sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash
[3645]659    #if [ "`grep ada AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar
660    #    \cp -f ~rdzt401/bin/AA_make.gdef .
661    #fi
[3573]662    if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar
663        echo 'Warning jean-zay not in AA_make.gdef'
664        echo 'Think about updating'
665        exit 1
666    fi
[3375]667   
[1731]668    chmod u=rwx ins_make.bash
[3044]669    ./ins_make.bash $o_ins_make
[1731]670  fi # of if [ "$use_shell" = "ksh" ]
671
[4018]672echo install_lmdz.sh MODIPSL_OK `date`
[2031]673#=======================================================================================
[3091]674  cd $MODEL/modipsl/modeles/IOIPSL/src
[3092]675  ioipsllog=`pwd`/ioipsl.log
[1731]676  echo '##########################################################'
677  echo 'Compiling IOIPSL, the interface library with Netcdf'
678  echo '##########################################################'
[4018]679  echo `date`
[3091]680  echo log file : $ioipsllog
[1731]681
682  if [ "$use_shell" = "bash" ] ; then
683    cp Makefile Makefile.ksh
684    sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
[1588]685  fi
[3044]686# if [ "$pclinux" = 1 ] ; then
[1731]687    # Build IOIPSL modules and library
[3044]688    $make clean
[3091]689    $make > $ioipsllog 2>&1
[3088]690    if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then # copy module files to lib
[1731]691      cp -f *.mod ../../../lib
692    fi
693    # Build IOIPSL tools (ie: "rebuild", if present)
694    if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then
695      cd $MODEL/modipsl/modeles/IOIPSL/tools
696      # adapt Makefile & rebuild script if in bash
697      if [ "$use_shell" = "bash" ] ; then
698        cp Makefile Makefile.ksh
699        sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
700        cp rebuild rebuild.ksh
701        sed -e 's:/bin/ksh:/bin/bash:g' \
702            -e 's:print -u2:echo:g' \
703            -e 's:print:echo:g' rebuild.ksh > rebuild
704      fi
[3044]705      $make clean
[3091]706      $make > $ioipsllog 2>&1
[1731]707    fi
[3044]708# fi # of if [ "$pclinux" = 1 ]
[1588]709
[1731]710else # of if [ $ioipsl = 1 ]
[3645]711  if [ ${hostname:0:5} = jean- ] ; then
[3573]712     cd $MODEL/modipsl
713     cd util
[3645]714       if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then
[3573]715        echo 'Warning jean-zay not in AA_make.gdef'
716        echo 'Think about updating'
717        exit 1
718       fi
719       ./ins_make $o_ins_make
720# Compile IOIPSL on jean-zay
721       cd $MODEL/modipsl/modeles/IOIPSL/src
[3610]722       gmake > ioipsl.log
723       cd $MODEL/modipsl/modeles/IOIPSL/tools
724       gmake > ioipsl.log
[3573]725   
[3645]726  fi
[4018]727  echo install_lmdz.sh ioipsl_OK `date`
[1731]728fi # of if [ $ioipsl = 1 ]
[3044]729# Saving ioipsl lib for possible parallel compile
730  cd $MODEL/modipsl
731  tar cf ioipsl.tar lib/ bin/
[1731]732
[3056]733#===========================================================================
734if [ "$with_xios" = "y" ] ; then
735  echo '##########################################################'
736  echo 'Compiling XIOS'
737  echo '##########################################################'
738  cd $MODEL/modipsl/modeles
[3375]739  xioslog=`pwd`/xios.log
[3056]740  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_xios.bash
[3076]741  myget import/install_xios.bash
[3056]742  chmod u=rwx install_xios.bash
[4018]743  if [ ${hostname:0:5} = jean- ] ; then
744     svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5 XIOS
745     cd XIOS/arch
746     svn update
747     cd ..
748     echo "Compiling XIOS, start" `date` "(it takes about 20 min on Jean-Zay)"
749     echo "log file: $xioslog"
750     ./make_xios --prod --arch $arch --job 4 > xios.log 2>&1
751  else
[3375]752     ./install_xios.bash -prefix $MODEL/modipsl/modeles \
[3056]753                      -netcdf ${ncdfdir} -hdf5 ${ncdfdir} \
[3375]754                      -MPI $root_mpi -arch $arch > xios.log 2>&1
[4018]755  fi # of case Jean-Zay
756  if [ -f XIOS/lib/libxios.a ] ; then
757     echo "XIOS library successfully generated"
758     echo install_lmdz.sh XIOS_OK `date`
759  fi
[3056]760fi
761
[1800]762#============================================================================
[1837]763veget_version=false
[3922]764if [ "$veget" != 'NONE' ] ; then
[3091]765  cd $MODEL/modipsl/modeles/ORCHIDEE
[3922]766  set +e ; svn upgrade ; set -e
767  if [ "$veget" = "CMIP6" ] ; then
768    veget_version=orchidee2.0 
769    orchidee_rev=6592
[3972]770  else # specific orchidee revision newer than CMIP6, on 2_1 or 2_2 branches
771    veget_version=orchidee2.1
772    orchidee_rev=$veget
773     if [ $veget -lt 4465 ] ; then
774             echo 'Stopping, ORCHIDEE version too old, script needs work on the CPP flags to pass to makelmdz'
775             exit 1
776     fi
[3922]777     set +e
[3972]778     # which branch is my version on?
779     orcbranch=`svn log -v -q svn://forge.ipsl.jussieu.fr/orchidee/ -r $veget |grep ORCHIDEE |head -1| sed -e 's:ORCHIDEE/.*$:ORCHIDEE:' | awk '{print $2}'`
780     # switch to that branch
[4018]781     echo IF YOU INSTALL ORCHIDEE THE VERY FIRST TIME, ASK for PASSWORD at orchidee-help@listes.ipsl.fr
[3972]782     svn switch -r $veget --accept theirs-full svn://forge.ipsl.jussieu.fr/orchidee/$orcbranch
[3922]783     svn log -r $veget | grep  $veget
784     if [  $? -gt 0 ] ; then
785          echo 'Cannot update ORCHIDEE as not on the right branch for ORCHIDEE'
786          exit
787      fi
788      set -e
789      set +e ; svn update -r $veget ; set -e 
[3646]790  fi
[3610]791  # Correctif suite debug Jean-Zay
792  sed -i -e 's/9010  FORMAT(A52,F17.14)/9010  FORMAT(A52,F20.14)/' src_stomate/stomate.f90
793  opt_orc="-prod" ; if [ "$optim" = "-debug" ] ; then opt_orc="-debug" ; fi
794
[3091]795  orchideelog=`pwd`/orchidee.log
[1731]796  echo '########################################################'
[4018]797  echo 'Compiling ORCHIDEE, the continental surface model '
[1731]798  echo '########################################################'
[4018]799  echo Start of the first compilation of orchidee, in sequential mode: `date`
[3091]800  echo log file : $orchideelog
[4018]801
[2430]802  export ORCHPATH=`pwd`
[3973]803  xios_orchid="-noxios"
804  if [ "$with_xios" = "y" ] ; then
805    xios_orchid="-xios"
806  fi
[2430]807  if [ -d tools ] ; then
[3386]808###################################################################
809# Pour les experts qui voudraient changer de version d'orchidee.
810# Attention : necessite d'avoir le password pour orchidee
[3922]811
[3610]812      # Correctif suite debug Jean-Zay
813      if [ -f src_global/time.f90 ] ; then sed -i -e 's/CALL tlen2itau/\!CALL tlen2itau/' src_global/time.f90 ; fi
[3386]814###################################################################
[3646]815     if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi
[3044]816      cd arch
[3088]817      sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
818     -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
[2430]819     -e s:"%FPP_FLAGS       .*.$":"%FPP_FLAGS           $fpp_flags":1 \
820     -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
821     -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
822     -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
[3044]823     -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
824     -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
[3076]825     -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
[2430]826     arch-gfortran.fcm > arch-local.fcm
[3044]827     echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
[2430]828     echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path
829     echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path
830     echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path
[3375]831     echo 'XIOS_INCDIR=${ORCHDIR}/../XIOS/inc' >> arch-local.path
832     echo 'XIOS_LIBDIR="${ORCHDIR}/../XIOS/lib -lxios"' >> arch-local.path
[3044]833     cd ../
[4018]834
835     echo ./makeorchidee_fcm -j $xios_orchid $opt_orc -parallel none -arch $arch
[3973]836     ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel none -arch $arch > $orchideelog 2>&1
[4018]837     pwd
838  else # of "if [ -d tools ]"
[2430]839     if [ -d src_parallel ] ; then
840       liste_src="parallel parameters global stomate sechiba driver"
[3646]841       if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi
[2430]842     fi
843     for d in $liste_src ; do src_d=src_$d
844        echo src_d $src_d
845        echo ls ; ls
846        if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi
[3044]847        cd $src_d ; \rm -f *.mod make ; $make clean
[3091]848        $make > $orchideelog 2>&1 ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi
[2430]849        cd ..
850     done
[4018]851  fi # of "if [ -d tools ]"
852  echo install_lmdz.sh orchidee_compil_seq_OK `date`
853fi # of if [ "$veget" != 'NONE' ]
[1588]854
[2030]855
[1800]856#============================================================================
[3922]857# Ehouarn: the directory name LMDZ* depends on version/tar file...
[3044]858if [ -d $MODEL/modipsl/modeles/LMD* ] ; then
[4018]859  echo '###############################################################'
860  echo 'Preparing LMDZ compilation : arch file, svn switch if needed...'
861  echo '###############################################################'
[3044]862  cd $MODEL/modipsl/modeles/LMD*
863  LMDZPATH=`pwd`
[1588]864else
[3044]865  echo "ERROR: No LMD* directory !!!"
[1800]866  exit
[1588]867fi
868
869###########################################################
[1708]870# For those who want to use fcm to compile via :
[1588]871#  makelmdz_fcm -arch local .....
872############################################################
873
[2031]874if [ "$pclinux" = "1" ] ; then
875
[1708]876# create local 'arch' files (if on Linux PC):
[1588]877cd arch
[1708]878# arch-local.path file
[3044]879echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
[1590]880echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path
[1588]881echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path
882echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
[3044]883echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path
884echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path
[1588]885echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path
886echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
[3044]887
[3375]888if [ $pcmac == 1 ] ; then
889    BASE_LD="$BASE_LD -Wl,-rpath,${ncdfdir}/lib"
890else
891    BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib"
892fi
893# Arch-local.fcm file (adapted from arch-linux-32bit.fcm)
[2031]894
895if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi
[3088]896sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
897    -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
[2031]898    -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
899    -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
900    -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
901    -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
[2203]902    -e s:"%FPP_DEF         .*.$":"%FPP_DEF             $FPP_DEF":1 \
[3044]903    -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
[3076]904    -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
[2031]905    arch-linux-32bit.fcm > arch-local.fcm
906
[1588]907cd ..
[1708]908### Adapt "bld.cfg" (add the shell):
[1588]909whereisthatshell=$(which ${use_shell})
910echo "bld::tool::SHELL   $whereisthatshell" >> bld.cfg
911
[1731]912fi # of if [ "$pclinux" = 1 ]
913
914
[3056]915cd $MODEL/modipsl/modeles/LMDZ*
[3093]916lmdzlog=`pwd`/lmdz.log
[1731]917
[1588]918##################################################################
[3056]919# Possibly update LMDZ if a specific svn release is requested
[3044]920##################################################################
921
[3922]922
923set +e ; svn upgrade ; set -e
[3044]924if [ "$svn" = "last" ] ; then svnopt="" ; else svnopt="-r $svn" ; fi
[3783]925if [ "$svn" != "" ] ; then
926    svn info | grep -q 'http:'
927    if [ $? = 0 ] ; then
928        svn switch --relocate http://svn.lmd.jussieu.fr/LMDZ https://svn.lmd.jussieu.fr/LMDZ
929    fi
930    svn update $svnopt
931fi
932set -e
[3044]933
[3091]934echo '##################################################################'
[4018]935echo "Preparing script compile.sh for LMDZ compilation" 
936echo "It will only be run automatically if bench=1" 
937echo Here bench=$bench
[3091]938echo '##################################################################'
[3044]939
[3645]940if [ "$env_file" != "" ] ; then mv arch/arch-${arch}.env arch/arch-${arch}.orig ; \cp -f $env_file arch/arch-${arch}.env ; fi
941
[3610]942if [ $compile_with_fcm = 1 ] ; then makelmdz="makelmdz_fcm $optim -arch $arch -j 8 " ; else makelmdz="makelmdz $optim -arch $arch" ; fi
[2031]943
[4018]944# sequential compilation
[3044]945if [ "$sequential" = 1 ] ; then
[4018]946  echo Sequential compilation command, saved in compile.sh:
947  echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp -d ${grid_resolution} -v $veget_version gcm "
948  echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp -d ${grid_resolution} -v $veget_version gcm " >> compile.sh
949  chmod +x ./compile.sh
950  if [ $bench != 0 ] ; then 
951    echo install_lmdz.sh start_lmdz_seq_compilation `date`
952    echo log file: $lmdzlog
953    ./compile.sh > $lmdzlog 2>&1 
954    echo install_lmdz.sh end_lmdz_seq_compilation `date`
955  fi
[3044]956fi # fin sequential
957
958# compiling in parallel mode
959if [ $parallel != "none" ] ; then
[3056]960  echo '##########################################################'
961  echo ' Parallel compile '
962  echo '##########################################################'
[4018]963  echo "(after saving the sequential libs and binaries)"
[3056]964  cd $MODEL/modipsl
965  tar cf sequential.tar bin/ lib/
966  \rm -rf bin/ lib/
967  tar xf ioipsl.tar
968  #
969  # Orchidee
970  #
971  cd $ORCHPATH
[3922]972  if [ -d src_parallel -a $veget != 'NONE' ] ; then
[3044]973     cd arch
974     sed  \
975     -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
976     -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
977     -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
978     -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
979     -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
980     -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
981     arch-local.fcm > tmp.fcm
982
983     mv tmp.fcm arch-local.fcm
984     cd ../
[4018]985     echo Compiling ORCHIDEE in parallel mode `date`
[3091]986     echo logfile $orchideelog
[4018]987     echo "NOTE : to recompile it when necessary, use ./compile_orc.sh in modipsl/modeles/ORCHIDEE"
988     echo ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc -parallel $parallel -arch $arch > compile_orc.sh
989     echo ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel $parallel -arch $arch >> compile_orc.sh
990     echo echo Now you must also recompile LMDZ, by running ./compile.sh in modeles/LMDZ >> compile_orc.sh
991     chmod u+x compile_orc.sh
[3973]992     ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc -parallel $parallel -arch $arch > $orchideelog 2>&1
993     ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel $parallel -arch $arch >> $orchideelog 2>&1
[4018]994     echo End of ORCHIDEE compilation in parallel mode `date`
[3922]995  elif [ $veget != 'NONE' ] ; then
[3056]996    echo '##########################################################'
997    echo ' Orchidee version too old                                 '
998    echo ' Please update to new version                             '
999    echo '##########################################################'
1000    exit
[4018]1001  fi # of [ -d src_parallel -a $veget != 'NONE' ]
1002
[3056]1003  # LMDZ
1004  cd $LMDZPATH
1005  if [ $arch = local ] ; then
1006    cd arch
1007    sed -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
1008    -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
1009    -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
1010    -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
[3076]1011    -e s:"%ARFLAGS.*.$":"%ARFLAGS          $ARFLAGS":1 \
[3056]1012    -e s@"%BASE_LD.*.$"@"%BASE_LD             -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \
1013    -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
1014    -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
1015    arch-local.fcm > tmp.fcm
1016    mv tmp.fcm arch-local.fcm
1017    cd ../
1018  fi
1019  rm -f compile.sh
1020  echo resol=${grid_resolution} >> compile.sh
[3983]1021  if [ ${hostname:0:5} = jean- -a "$cosp" = "v2" ] ; then
[4018]1022 
1023  echo LMDZ compilation command in parallel mode, saved in compile.sh, is :
1024  echo "(ATTENTION le probleme de cospv2 sur jean-zay en mode prod n est pas corrige ! )"
[3983]1025# ATTENTION le probleme de cospv2 sur jean-zay en mode prod n est pas corrige
[3943]1026     echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
1027     echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm
[3736]1028  else   
[3943]1029    echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
1030    echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm
[3736]1031  fi 
[3375]1032  chmod +x ./compile.sh
[1588]1033
[4018]1034  if [ $bench != 0 ] ; then 
1035    echo Compiling LMDZ in parallel mode `date`
1036    echo LMDZ log file: $lmdzlog
1037    ./compile.sh > $lmdzlog 2>&1
1038  fi
[3056]1039 
1040fi # of if [ $parallel != "none" ]
[3044]1041
1042
[1588]1043##################################################################
[3044]1044# Verification du succes de la compilation
[1588]1045##################################################################
[3044]1046
1047# Recherche de l'executable dont le nom a change au fil du temps ...
1048gcm=""
[3922]1049#for 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 bin/gcm_${grid_resolution}_phylmd_para_mem.e  ; do
1050for exe in gcm.e bin/gcm_${grid_resolution}_phylmd${suff_exe}${suff_orc}.e ; do   if [ -f $exe ] ; then gcm=$exe ; fi
[3044]1051done
1052
1053if [ "$gcm" = "" ] ; then
[3573]1054  if [ $bench != 0 ] ; then
1055    echo 'Compilation failed !! Cannot run the benchmark;'
1056    exit
1057  else
1058    echo 'Compilation not done (only done when bench=1)'
1059  fi
[3044]1060else
1061   echo '##########################################################'
[4018]1062   echo 'Compilation successfull !! ' `date`
[3044]1063   echo '##########################################################'
1064   echo The executable is $gcm
[1588]1065fi
1066
[3044]1067##################################################################
1068# Below, we run a benchmark test (if bench=0)
1069##################################################################
1070
1071if [ $bench != 0 ] ; then
1072
[1588]1073echo '##########################################################'
[1731]1074echo ' Running a test run '
[1588]1075echo '##########################################################'
1076
[2030]1077\rm -rf BENCH${grid_resolution}
[1588]1078bench=bench_lmdz_${grid_resolution}
[4018]1079echo install_lmdz.sh before bench download  `date`
[3044]1080#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz
[3076]1081myget 3DBenchs/$bench.tar.gz
[4018]1082echo install_lmdz.sh after bench download  `date`
[3044]1083tar xvf $bench.tar.gz
[1588]1084
[3983]1085if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then
[3386]1086  cd BENCH${grid_resolution}
1087# copier les fichiers namelist input et output our COSP
[3735]1088  cp ../DefLists/cosp*_input_nl.txt .
1089  cp ../DefLists/cosp*_output_nl.txt .
[3386]1090# Activer la cles ok_cosp pour tourner avec COSP
1091  sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp
1092   \mv -f tmp config.def
1093  cd ..
1094fi 
1095
[3646]1096if [ -n "$physiq" ]; then
1097  cd BENCH${grid_resolution}
1098  if [ -f physiq.def_${physiq} ]; then
1099    cp physiq.def_${physiq} physiq.def
1100    echo using physiq.def_${physiq}
1101  else
1102    echo using standard physiq.def
1103  fi
1104  cd ..
1105else
1106  echo using standard physiq.def
1107fi
1108
[3056]1109if [ "$with_xios" = "y" ] ; then
1110  cd BENCH${grid_resolution}
1111  cp ../DefLists/iodef.xml .
1112  cp ../DefLists/context_lmdz.xml .
1113  cp ../DefLists/field_def_lmdz.xml .
[3983]1114# A raffiner par la suite
1115  echo A FAIRE : Copier les *xml en fonction de l option cosp
[3733]1116  cp ../DefLists/field_def_cosp*.xml .
[3056]1117  cp ../DefLists/file_def_hist*xml .
1118  # adapt iodef.xml to use attached mode
1119  sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp
1120  \mv -f tmp iodef.xml
[3386]1121
[3056]1122  # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE.
1123  # except for histday
1124  for histfile in file_def_hist*xml
1125  do
1126    if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then
1127    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
[3560]1128    sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
1129    sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
[3056]1130    else
1131    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile
1132    fi
1133  done
1134  # and add option "ok_all_xml=y" in config.def
1135  echo "### XIOS outputs" >> config.def
1136  echo 'ok_all_xml=.true.' >> config.def
[3733]1137
1138  #activer les sorties pour Cosp
[3983]1139  if [ "$cosp" = "v1" ] ; then 
[3733]1140   histfile=file_def_histdayCOSP_lmdz.xml
1141   sed -e 's@enabled=".FALSE."@enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
1142   sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
1143   sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
1144  fi
[3983]1145  if [ "$cosp" = "v2" ] ; then
[3735]1146   histfile=file_def_histdayCOSPv2_lmdz.xml
1147   sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
1148   contextfile=context_lmdz.xml
1149   sed -e 's@src="./file_def_histdayCOSP_lmdz.xml"@src="./file_def_histdayCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
[3983]1150   sed -e 's@src="./file_def_histmthCOSP_lmdz.xml"@src="./file_def_histmthCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
1151   sed -e 's@src="./file_def_histhfCOSP_lmdz.xml"@src="./file_def_histhfCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
[3735]1152   fieldfile=field_def_lmdz.xml
1153   sed -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' $fieldfile > tmp ; \mv -f tmp $fieldfile
1154  fi
1155
[3056]1156  cd ..
1157fi
1158
[3943]1159# Cas Bensh avec ecrad
1160if [ "$rad" = "ecrad" ] ; then
1161  cd BENCH${grid_resolution}
1162  cp  ../DefLists/namelist_ecrad .
1163  cp -r ../libf/phylmd/ecrad/data .
1164# Attention au cas ou ne 1
1165  sed -e 's@iflag_rrtm=1@iflag_rrtm=2@' physiq.def > tmp
1166   \mv -f tmp physiq.def
1167  cd ..
1168fi
1169
[3044]1170cp $gcm BENCH${grid_resolution}/gcm.e
[1588]1171
1172cd BENCH${grid_resolution}
[3044]1173# On cree le fichier bench.sh au besoin
1174# Dans le cas 48x36x39 le bench.sh existe deja en parallele
[1588]1175
[3044]1176if [ "$grid_resolution" = "48x36x39" ] ; then
1177   echo On ne touche pas au bench.sh
1178   # But we have to adapt "run_local.sh" for $mpirun
1179   sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp
1180   mv -f tmp run_local.sh
1181   chmod u=rwx run_local.sh
1182elif [ "${parallel:0:3}" = "mpi" ] ; then
1183   # Lancement avec deux procs mpi et 2 openMP
1184   echo "export OMP_STACKSIZE=800M" > bench.sh
1185   if [ "${parallel:4:3}" = "omp" ] ; then
1186     echo "export OMP_NUM_THREADS=2" >> bench.sh
1187   fi
[3983]1188   if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then 
[3736]1189      if [ ${hostname:0:5} = jean- ] ; then   
1190        chmod +x ../arch.env
1191        ../arch.env     
1192        echo "ulimit -s 2000000" >> bench.sh
1193      else
1194        echo "ulimit -s 200000" >> bench.sh           
1195      fi       
[3735]1196   else
1197      echo "ulimit -s unlimited" >> bench.sh
1198   fi
[3573]1199   if [ ${hostname:0:5} = jean- ] ; then
[3922]1200     . ../arch/arch-${arch}.env 
[3573]1201     echo "srun -n 2 -A $idris_acct@cpu gcm.e > listing  2>&1" >> bench.sh
1202   else
1203     echo "$mpirun -np 2 gcm.e > listing  2>&1" >> bench.sh
1204   fi
[3920]1205   # Add rebuild, using reb.sh if it is there
1206   echo 'if [ -f reb.sh ] ; then' >> bench.sh
[3922]1207   echo '  ./reb.sh histday ; ./reb.sh histmth ; ./reb.sh histhf ; ./reb.sh histins ; ./reb.sh stomate_history ; ./reb.sh sechiba_history ; ./reb.sh sechiba_out_2 ' >> bench.sh
[3920]1208   echo 'fi' >> bench.sh
[3044]1209else
1210   echo "./gcm.e > listing  2>&1" > bench.sh
1211fi
[3922]1212# Getting orchidee stuff
1213if [ $veget == 'CMIP6' ] ; then
1214    #echo 'myget 3DBenchs/BENCHorch11.tar.gz'
1215    #myget 3DBenchs/BENCHorch11.tar.gz
1216    #tar xvzf BENCHorch11.tar.gz
1217    echo 'myget 3DBenchs/BENCHCMIP6.tar.gz'
1218    myget 3DBenchs/BENCHCMIP6.tar.gz
1219    tar xvzf BENCHCMIP6.tar.gz
1220    sed -e "s:VEGET=n:VEGET=y:" config.def > tmp
1221    mv -f tmp config.def
[3973]1222    if [ "$with_xios" = "y" ] ; then
1223      cp ../../ORCHIDEE/src_xml/context_orchidee.xml .
1224      echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
1225      cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml .
1226      cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml .
1227      cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml .
1228      if [ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ] ; then
1229        cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml .
1230        echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
1231      fi
1232      sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp
1233      mv tmp iodef.xml
1234      sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
1235      sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
1236      sed -e 's@output_level="_AUTO_"@output_level="1"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
1237      sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
1238      sed -e 's@compression_level="4"@compression_level="0"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
1239      sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' orchidee.def > tmp ; \mv -f tmp orchidee.def
1240    fi
[3922]1241fi
[3044]1242echo EXECUTION DU BENCH
[3076]1243set +e
[3044]1244date ; ./bench.sh > out.bench 2>&1 ; date
[3076]1245set -e
[3044]1246tail listing
[2030]1247
[1588]1248
1249echo '##########################################################'
[1708]1250echo 'Simulation finished in' `pwd`
[3044]1251   echo 'You have compiled with:'
1252   cat ../compile.sh
1253if [ $parallel = "none" ] ; then
1254  echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e'
1255  echo 'or ./bench.sh'
1256else
1257  echo 'You may re-run it with : '
1258  echo 'cd ' `pwd` '; ./bench.sh'
[3573]1259#  echo 'ulimit -s unlimited'
1260#  echo 'export OMP_NUM_THREADS=2'
1261#  echo 'export OMP_STACKSIZE=800M'
1262#  echo "$mpirun -np 2 gcm.e "
[3044]1263fi
[1588]1264echo '##########################################################'
[2030]1265
[3922]1266fi # bench
[3044]1267
1268
1269#################################################################
1270# Installation eventuelle du 1D
1271#################################################################
1272
1273if [ $SCM = 1 ] ; then
1274cd $MODEL
1275#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/1D.tar.gz
[3076]1276myget 1D/1D.tar.gz
[3044]1277tar xvf 1D.tar.gz
1278cd 1D
[3943]1279./run.sh -rad $rad
[3044]1280fi
[3922]1281set -vx
1282
1283#################################################################
1284# sauvegarde des options veget pour utilisation eventuelle tutorial_prod
1285#################################################################
1286cd $MODEL/modipsl/modeles
1287echo surface_env file created in $MODEL
1288echo 'veget='$veget > surface_env
1289#opt_veget="-v $veget_version"
1290#echo 'opt_veget="'$opt_veget\" >> surface_env
1291echo 'opt_veget="'-v $veget_version\" >> surface_env
1292echo 'orchidee_rev='$orchidee_rev >> surface_env
1293echo 'suforch='$suff_orc >> surface_env
1294   
1295
1296
1297
Note: See TracBrowser for help on using the repository browser.