source: BOL/script_install/install_lmdz.sh @ 3610

Last change on this file since 3610 was 3610, checked in by Laurent Fairhead, 4 years ago

Rajout d'une option debug + modif pour jean-zay
FH

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