source: BOL/script_install/install_lmdz.sh @ 3983

Last change on this file since 3983 was 3983, checked in by idelkadi, 3 years ago

Modification of the option to use the Cosp simulator in the install_lmdz.sh script:
Use of option "-cosp none / v1 / v2" instead of "-cosp true / -cospv2 true".
./install_lmdz.sh ... -cosp none/v1/v2 :

  • "none": without Cosp
  • "v1": with version Cospv1
  • "v2": with the Cosp v2 version

Default option: none

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