source: BOL/script_install/install_lmdz.sh @ 3062

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

Correction pour compilation parallele avec openmpi sous ubuntu

File size: 33.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  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:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
505  -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
506  tmp >| AA_make.gdef
507
508
509# We use lines for g95 even for the other compilers to run ins_make
510  if [ "$use_shell" = "ksh" ] ; then
511    ./ins_make $o_ins_make
512  else # bash
513    sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash
514    if [ "`grep ada AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar
515        \cp -f ~rdzt401/bin/AA_make.gdef .
516    fi
517    chmod u=rwx ins_make.bash
518    ./ins_make.bash $o_ins_make
519  fi # of if [ "$use_shell" = "ksh" ]
520
521#=======================================================================================
522  echo '##########################################################'
523  echo 'Compiling IOIPSL, the interface library with Netcdf'
524  echo '##########################################################'
525
526  cd $MODEL/modipsl/modeles/IOIPSL/src
527  if [ "$use_shell" = "bash" ] ; then
528    cp Makefile Makefile.ksh
529    sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
530  fi
531# if [ "$pclinux" = 1 ] ; then
532    # Build IOIPSL modules and library
533echo EOEOFOOEOOOOOOOOOOOOOOOOOOOOOOOOOOOO
534    $make clean
535    $make
536    if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then # copy module files to lib
537      cp -f *.mod ../../../lib
538    fi
539    # Build IOIPSL tools (ie: "rebuild", if present)
540    if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then
541      cd $MODEL/modipsl/modeles/IOIPSL/tools
542      # adapt Makefile & rebuild script if in bash
543      if [ "$use_shell" = "bash" ] ; then
544        cp Makefile Makefile.ksh
545        sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
546        cp rebuild rebuild.ksh
547        sed -e 's:/bin/ksh:/bin/bash:g' \
548            -e 's:print -u2:echo:g' \
549            -e 's:print:echo:g' rebuild.ksh > rebuild
550      fi
551      $make clean
552      $make
553    fi
554# fi # of if [ "$pclinux" = 1 ]
555
556else # of if [ $ioipsl = 1 ]
557  if [ ${hostname:0:5} = ada33 ] ; then
558    cd $MODEL/modipsl
559    cd util
560
561    cp AA_make.gdef AA_make.orig
562    sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
563    sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c:F_C = $compilo -c": \
564    -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
565    -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:' \
566    -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L/smplocal/pub/NetCDF/4.1.3/lib -lnetcdff -lnetcdf:' \
567    -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
568    -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
569    tmp >| AA_make.gdef
570
571    ./ins_make $o_ins_make # We use lines for g95 even for the other compilers
572
573    # on Ada, IOIPSL is already installed in ~rpsl035/IOIPSL_PLUS
574    # so link it to current settings
575    cd $MODEL/modipsl/modeles/
576    \rm -r -f IOIPSL
577    ln -s ~rpsl035/IOIPSL_PLUS IOIPSL
578    cd ..
579    ln -s ~rpsl035/IOIPSL_PLUS/modipsl_Tagv2_2_3/bin/* bin/
580    ln -s ~rpsl035/IOIPSL_PLUS/modipsl_Tagv2_2_3/lib/* lib/
581
582  fi # of if [ ${hostname:0:5} = ada33 ]
583  echo install.sh ioipsl_OK `date`
584fi # of if [ $ioipsl = 1 ]
585# Saving ioipsl lib for possible parallel compile
586  cd $MODEL/modipsl
587  tar cf ioipsl.tar lib/ bin/
588
589#===========================================================================
590if [ "$with_xios" = "y" ] ; then
591  echo '##########################################################'
592  echo 'Compiling XIOS'
593  echo '##########################################################'
594  cd $MODEL/modipsl/modeles
595  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_xios.bash
596  myget install_xios.bash
597  chmod u=rwx install_xios.bash
598  ./install_xios.bash -prefix $MODEL/modipsl/modeles \
599                      -netcdf ${ncdfdir} -hdf5 ${ncdfdir} \
600                      -MPI $root_mpi -arch $arch
601fi
602
603#============================================================================
604veget_version=false
605if [ "$veget" = 1 ] ; then
606  echo '########################################################'
607  echo 'Compiling ORCHIDEE, the continental surfaces model '
608  echo '########################################################'
609  cd $MODEL/modipsl/modeles/ORCHIDEE
610  export ORCHPATH=`pwd`
611  if [ -d tools ] ; then
612     orchidee_rev=2247 
613     veget_version=orchidee2.0
614      cd arch
615      sed -e s:"%COMPILER        .*.$":"%COMPILER            $compilo":1 \
616     -e s:"%LINK            .*.$":"%LINK                $compilo":1 \
617     -e s:"%FPP_FLAGS       .*.$":"%FPP_FLAGS           $fpp_flags":1 \
618     -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
619     -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
620     -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
621     -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
622     -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
623     arch-gfortran.fcm > arch-local.fcm
624     echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
625     echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path
626     echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path
627     echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path
628     cd ../
629# compiling ORCHIDEE sequential mode
630     ./makeorchidee_fcm -j 8 -noxios -prod -parallel none -arch $arch
631     echo ./makeorchidee_fcm -j 8 -noxios -prod -parallel none -arch $arch
632     echo Fin de la premiere compilation orchidee ; pwd
633  else
634     if [ -d src_parallel ] ; then
635       liste_src="parallel parameters global stomate sechiba driver"
636       veget_version=orchidee2.0
637     else
638       # Obsolete, for ORCHIDEE_beton only
639       liste_src="parameters stomate sechiba "
640       # A trick to compile ORCHIDEE depending on if we are using real*4 or real*8
641       cd src_parameters ; \cp reqdprec.$real reqdprec.f90 ; cd ..
642       veget_version=orchidee1.9
643     fi
644     for d in $liste_src ; do src_d=src_$d
645        echo src_d $src_d
646        echo ls ; ls
647        if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi
648        cd $src_d ; \rm -f *.mod make ; $make clean
649        $make ; if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi
650        cd ..
651     done
652  fi
653  echo install.sh orchidee_OK `date`
654fi # of if [ "$veget" = 1 ]
655
656
657#============================================================================
658# Ehouarn: it may be directory LMDZ4 or LMDZ5 depending on tar file...
659if [ -d $MODEL/modipsl/modeles/LMD* ] ; then
660  echo '##########################################################'
661  echo 'Compiling LMDZ'
662  echo '##########################################################'
663  cd $MODEL/modipsl/modeles/LMD*
664  LMDZPATH=`pwd`
665else
666  echo "ERROR: No LMD* directory !!!"
667  exit
668fi
669
670###########################################################
671# For those who want to use fcm to compile via :
672#  makelmdz_fcm -arch local .....
673############################################################
674
675if [ "$pclinux" = "1" ] ; then
676
677# create local 'arch' files (if on Linux PC):
678cd arch
679# arch-local.path file
680echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
681echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path
682echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path
683echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
684echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path
685echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path
686echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path
687echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
688
689BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib"
690# arch-local.fcm file (adapted from arch-linux-32bit.fcm)
691
692if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi
693sed -e s:"%COMPILER        .*.$":"%COMPILER            $compilo":1 \
694    -e s:"%LINK            .*.$":"%LINK                $compilo":1 \
695    -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
696    -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
697    -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
698    -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
699    -e s:"%FPP_DEF         .*.$":"%FPP_DEF             $FPP_DEF":1 \
700    -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
701    arch-linux-32bit.fcm > arch-local.fcm
702
703cd ..
704### Adapt "bld.cfg" (add the shell):
705whereisthatshell=$(which ${use_shell})
706echo "bld::tool::SHELL   $whereisthatshell" >> bld.cfg
707
708fi # of if [ "$pclinux" = 1 ]
709
710
711cd $MODEL/modipsl/modeles/LMDZ*
712
713##################################################################
714# Possibly update LMDZ if a specific svn release is requested
715##################################################################
716
717if [ "$svn" = "last" ] ; then svnopt="" ; else svnopt="-r $svn" ; fi
718if [ "$svn" != "" ] ; then set +e ; svn upgrade ; set -e ; svn update $svnopt ; fi
719
720##################################################################
721# Compile LMDZ
722##################################################################
723
724echo install.sh avant_compilation `date`
725if [ $compile_with_fcm = 1 ] ; then makelmdz="makelmdz_fcm -arch $arch -j 8" ; else makelmdz="makelmdz -arch $arch" ; fi
726
727# use the orchidee interface that has no z0h
728if [ "$no_z0h_orc" = 1 ] ; then
729veget_version="$veget_version -cpp ORCHIDEE_NOZ0H"
730fi
731
732# sequential compilation and bench
733if [ "$sequential" = 1 ] ; then
734echo "./$makelmdz $OPT_MAKELMDZ -rrtm true -d ${grid_resolution} -v $veget_version gcm" >> compile.sh
735chmod +x ./compile.sh ; ./compile.sh
736echo install.sh apres_compilation `date`
737
738
739fi # fin sequential
740
741
742
743# compiling in parallel mode
744if [ $parallel != "none" ] ; then
745  echo '##########################################################'
746  echo ' Parallel compile '
747  echo '##########################################################'
748  # saving the sequential libs and binaries
749  cd $MODEL/modipsl
750  tar cf sequential.tar bin/ lib/
751  \rm -rf bin/ lib/
752  tar xf ioipsl.tar
753  #
754  # Orchidee
755  #
756  cd $ORCHPATH
757  if [ -d src_parallel ] ; then
758     cd arch
759     sed  \
760     -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
761     -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
762     -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
763     -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
764     -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
765     -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
766     arch-local.fcm > tmp.fcm
767
768     mv tmp.fcm arch-local.fcm
769     cd ../
770     # compiling ORCHIDEE parallel mode
771     ./makeorchidee_fcm -j 8 -clean -noxios -prod -parallel $parallel -arch $arch
772     ./makeorchidee_fcm -j 8 -noxios -prod -parallel $parallel -arch $arch
773     echo ./makeorchidee_fcm -j 8 -clean -noxios -prod -parallel $parallel -arch $arch
774     echo ./makeorchidee_fcm -j 8 -noxios -prod -parallel $parallel -arch $arch
775     echo deuxieme compilation orchidee ; pwd
776  else
777    echo '##########################################################'
778    echo ' Orchidee version too old                                 '
779    echo ' Please update to new version                             '
780    echo '##########################################################'
781    exit
782  fi # of if [ -d src_parallel ]
783  # LMDZ
784  cd $LMDZPATH
785  if [ $arch = local ] ; then
786    cd arch
787    sed -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
788    -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
789    -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
790    -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
791    -e s@"%BASE_LD.*.$"@"%BASE_LD             -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \
792    -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
793    -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
794    arch-local.fcm > tmp.fcm
795    mv tmp.fcm arch-local.fcm
796    cd ../
797  fi
798  rm -f compile.sh
799  if [ ${hostname:0:5} = ada33 ] ; then echo "module load intel/2013.0" > compile.sh ; fi
800  echo resol=${grid_resolution} >> compile.sh
801  echo ./$makelmdz $OPT_MAKELMDZ -rrtm true $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
802  chmod +x ./compile.sh ; ./compile.sh
803
804  echo "Compilation finished"
805 
806fi # of if [ $parallel != "none" ]
807
808echo LLLLLLLLLLLLLLLLLLLLLLLLLLL
809if [ "$gfortran" = "gfortran44" ] ; then
810    echo Your gfortran compiler was too old so that the model was automatically
811    echo compiled with gfortran44 instead. It can not be used in parallel mode.
812    echo You can change the compiler at the begining of the install.sh
813    echo script and reinstall.
814fi
815
816##################################################################
817# Verification du succes de la compilation
818##################################################################
819
820# Recherche de l'executable dont le nom a change au fil du temps ...
821gcm=""
822for 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
823   if [ -f $exe ] ; then gcm=$exe ; fi
824done
825
826if [ "$gcm" = "" ] ; then
827   echo 'Compilation failed !!'
828   # Ehouarn : temporary, do not exit and let job finish (to set up bench case)
829   #exit
830   set +e
831else
832   echo '##########################################################'
833   echo 'Compilation successfull !! '
834   echo '##########################################################'
835   echo The executable is $gcm
836fi
837
838##################################################################
839# Below, we run a benchmark test (if bench=0)
840##################################################################
841
842if [ $bench != 0 ] ; then
843
844echo '##########################################################'
845echo ' Running a test run '
846echo '##########################################################'
847
848\rm -rf BENCH${grid_resolution}
849bench=bench_lmdz_${grid_resolution}
850echo install.sh avant_chargement_bench  `date`
851#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz
852myget $bench.tar.gz
853echo install.sh after bench download  `date`
854tar xvf $bench.tar.gz
855
856if [ "$with_xios" = "y" ] ; then
857  cd BENCH${grid_resolution}
858  cp ../DefLists/iodef.xml .
859  cp ../DefLists/context_lmdz.xml .
860  cp ../DefLists/field_def_lmdz.xml .
861  cp ../DefLists/file_def_hist*xml .
862  # adapt iodef.xml to use attached mode
863  sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp
864  \mv -f tmp iodef.xml
865  # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE.
866  # except for histday
867  for histfile in file_def_hist*xml
868  do
869    if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then
870    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
871    else
872    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile
873    fi
874  done
875  # and add option "ok_all_xml=y" in config.def
876  echo "### XIOS outputs" >> config.def
877  echo 'ok_all_xml=.true.' >> config.def
878  cd ..
879fi
880
881cp $gcm BENCH${grid_resolution}/gcm.e
882
883cd BENCH${grid_resolution}
884# On cree le fichier bench.sh au besoin
885# Dans le cas 48x36x39 le bench.sh existe deja en parallele
886
887if [ "$grid_resolution" = "48x36x39" ] ; then
888   echo On ne touche pas au bench.sh
889   # But we have to adapt "run_local.sh" for $mpirun
890   sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp
891   mv -f tmp run_local.sh
892   chmod u=rwx run_local.sh
893elif [ "${parallel:0:3}" = "mpi" ] ; then
894   # Lancement avec deux procs mpi et 2 openMP
895   echo "export OMP_STACKSIZE=800M" > bench.sh
896   if [ "${parallel:4:3}" = "omp" ] ; then
897     echo "export OMP_NUM_THREADS=2" >> bench.sh
898   fi
899   echo "ulimit -s unlimited" >> bench.sh
900   echo "$mpirun -np 2 gcm.e > listing  2>&1" >> bench.sh
901else
902   echo "./gcm.e > listing  2>&1" > bench.sh
903fi
904echo EXECUTION DU BENCH
905date ; ./bench.sh > out.bench 2>&1 ; date
906tail listing
907
908
909echo '##########################################################'
910echo 'Simulation finished in' `pwd`
911   echo 'You have compiled with:'
912   cat ../compile.sh
913if [ $parallel = "none" ] ; then
914  echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e'
915  echo 'or ./bench.sh'
916else
917  echo 'You may re-run it with : '
918  echo 'cd ' `pwd` '; ./bench.sh'
919  echo 'ulimit -s unlimited'
920  echo 'export OMP_NUM_THREADS=2'
921  echo 'export OMP_STACKSIZE=800M'
922  echo "$mpirun -np 2 gcm.e "
923fi
924echo '##########################################################'
925
926fi
927
928
929#################################################################
930# Installation eventuelle du 1D
931#################################################################
932
933if [ $SCM = 1 ] ; then
934cd $MODEL
935#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/1D.tar.gz
936myget 1D.tar.gz
937tar xvf 1D.tar.gz
938cd 1D
939./run.sh
940fi
Note: See TracBrowser for help on using the repository browser.