source: BOL/script_install/install_lmdz.sh @ 3076

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

New version of the install_lmdz.sh script which uses the new repository paths (pub/*) framework.

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