source: BOL/script_install/install_lmdz.sh @ 3573

Last change on this file since 3573 was 3573, checked in by Laurent Fairhead, 5 years ago

Inclusion of jean-zay, the new idris machine
LF

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