source: BOL/script_install/install_lmdz.sh @ 3802

Last change on this file since 3802 was 3785, checked in by Ehouarn Millour, 4 years ago

Update du script install_lmdz.sh pour plus proprement faire la recherche de la librairie MPI.
EM

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