source: BOL/script_install/install_lmdz.sh @ 3619

Last change on this file since 3619 was 3610, checked in by Laurent Fairhead, 5 years ago

Rajout d'une option debug + modif pour jean-zay
FH

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