source: BOL/script_install/install_lmdz.sh @ 3928

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

New install with updated CMIP6 vegetation by default
LF/AS

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