source: BOL/script_install/install_lmdz.sh @ 3773

Last change on this file since 3773 was 3736, checked in by idelkadi, 5 years ago

Updating install_lmdz.sh script in order to run simulations with Cosp(v2) simulator.
Note that for the update for Jean-Zay, svn is used to download XIOS and that the model is compiled in dev mode with Cospv2

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