source: BOL/script_install/install_lmdz.sh @ 3375

Last change on this file since 3375 was 3375, checked in by fhourdin, 6 years ago

Commit recent updates in the install_lmdz.sh script

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