source: BOL/script_install/install_lmdz.sh @ 3093

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

correction

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