source: BOL/script_install/install_lmdz.sh @ 3063

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

Add an "-Wl,-rpath=" to the netcdf library for the "flio_rbld" program used by the "rebuild" script.
EM

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