source: BOL/script_install/install_lmdz.sh @ 3089

Last change on this file since 3089 was 3089, checked in by fhourdin, 7 years ago

Update install_lmdz.sh script to store successive component compilation outputs in log files.
IM

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