source: BOL/script_install/install_lmdz.sh @ 3573

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

Inclusion of jean-zay, the new idris machine
LF

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