source: BOL/script_install/install_lmdz.sh @ 3733

Last change on this file since 3733 was 3733, checked in by idelkadi, 4 years ago

Updating xml files in order to run simulations with the Cosp simulator

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