source: BOL/script_install/install_lmdz.sh @ 4018

Last change on this file since 4018 was 4018, checked in by Laurent Fairhead, 3 years ago

Rajout de commentaire par Adriana

File size: 47.5 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_lmdz.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
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_lmdz.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_lmdz.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
567if [ $netcdf = 1 ] ; then
568cd $MODEL
569netcdflog=`pwd`/netcdf.log
570echo '##########################################################'
571echo Compiling the Netcdf library
572echo '##########################################################'
573echo log file : $netcdflog
574if [ "$with_xios" = "n" ] ; then
575  # keep it simple
576  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/netcdf-4.0.1.tar.gz
577  myget import/netcdf-4.0.1.tar.gz
578  gunzip netcdf-4.0.1.tar.gz
579  tar xvf netcdf-4.0.1.tar
580  \rm -f netcdf-4.0.1.tar
581
582  cd netcdf-4.0.1
583
584  localdir=`pwd -P`
585  ./configure --prefix=$localdir --enable-shared --disable-cxx
586  #sed -e 's/gfortran/'$gfortran'/g' Makefile >| tmp ; mv -f tmp Makefile
587  $make check > $netcdflog 2>&1
588  $make install >> $netcdflog 2>&1
589#LF rajout d'une verrue, pour une raison non encore expliquee, la librairie est parfois rangée dans lib64
590#   et non dans lib par certains compilateurs
591  if [ ! -e lib -a -d lib64 ] ; then ln -s lib64 lib; fi
592else
593  # download and compile hdf5 and netcdf, etc. using the install_netcdf4_hdf5.bash script
594  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_netcdf4_hdf5.bash
595  myget import/install_netcdf4_hdf5.bash
596  chmod u=rwx install_netcdf4_hdf5.bash
597  if [ "$compiler" = "gfortran" ] ; then
598  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC gcc -FC gfortran -CXX g++ -MPI $root_mpi  > $netcdflog 2>&1
599  elif [ "$compiler" = "ifort" ] ; then
600  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC icc -FC ifort -CXX icpc -MPI $root_mpi  > $netcdflog 2>&1
601  elif [ "$compiler" = "pgf90" ] ; then
602  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC pgcc -FC pgf90 -CXX pgCC -MPI $root_mpi  > $netcdflog 2>&1
603  else
604    echo "unexpected compiler $compiler" ; exit
605  fi
606fi  # of if [ "$with_xios" = "n" ]
607echo install_lmdz.sh netcdf_OK `date`
608fi # of if [ $netcdf = 1 ]
609
610#======================================================================================
611echo OK ioipsl=$ioipsl
612echo '##########################################################'
613echo 'Installing MODIPSL, the installation package manager for the '
614echo 'IPSL models and tools'
615echo '##########################################################'
616echo `date`
617
618if [ $netcdf = 0 -o $netcdf = 1 ] ; then
619  if [ "$with_xios" = "y" ] ; then
620  ncdfdir=$MODEL/netcdf4_hdf5
621  else
622  ncdfdir=$MODEL/netcdf-4.0.1
623  fi
624else
625  ncdfdir=$netcdf
626fi
627
628if [ $ioipsl = 1 ] ; then
629  cd $MODEL/modipsl
630  \rm -rf lib/*
631
632  cd util
633
634  cp AA_make.gdef AA_make.orig
635  F_C="$compiler -c " ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then F_C="$compiler -c -cpp " ; fi
636  if [ "$compiler" = "pgf90" ] ; then F_C="$compiler -c -Mpreprocess" ; fi
637  sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
638  sed -e "s:F_L = g95:F_L = $compiler:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \
639  -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
640  -e 's:g95.*.NCDF_INC.*.$:g95      NCDF_INC= '"$ncdfdir"'/include:' \
641  -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \
642  -e 's:g95      L_O =:g95      L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \
643  -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
644  -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
645  tmp >| AA_make.gdef
646
647  if [ $pcmac == 1 ]
648  then
649      cp AA_make.gdef tmp
650      sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef
651  fi
652 
653
654# We use lines for g95 even for the other compilers to run ins_make
655  if [ "$use_shell" = "ksh" ] ; then
656    ./ins_make $o_ins_make
657  else # bash
658    sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash
659    #if [ "`grep ada AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar
660    #    \cp -f ~rdzt401/bin/AA_make.gdef .
661    #fi
662    if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar
663        echo 'Warning jean-zay not in AA_make.gdef'
664        echo 'Think about updating'
665        exit 1
666    fi
667   
668    chmod u=rwx ins_make.bash
669    ./ins_make.bash $o_ins_make
670  fi # of if [ "$use_shell" = "ksh" ]
671
672echo install_lmdz.sh MODIPSL_OK `date`
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 `date`
680  echo log file : $ioipsllog
681
682  if [ "$use_shell" = "bash" ] ; then
683    cp Makefile Makefile.ksh
684    sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
685  fi
686# if [ "$pclinux" = 1 ] ; then
687    # Build IOIPSL modules and library
688    $make clean
689    $make > $ioipsllog 2>&1
690    if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then # copy module files to lib
691      cp -f *.mod ../../../lib
692    fi
693    # Build IOIPSL tools (ie: "rebuild", if present)
694    if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then
695      cd $MODEL/modipsl/modeles/IOIPSL/tools
696      # adapt Makefile & rebuild script if in bash
697      if [ "$use_shell" = "bash" ] ; then
698        cp Makefile Makefile.ksh
699        sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
700        cp rebuild rebuild.ksh
701        sed -e 's:/bin/ksh:/bin/bash:g' \
702            -e 's:print -u2:echo:g' \
703            -e 's:print:echo:g' rebuild.ksh > rebuild
704      fi
705      $make clean
706      $make > $ioipsllog 2>&1
707    fi
708# fi # of if [ "$pclinux" = 1 ]
709
710else # of if [ $ioipsl = 1 ]
711  if [ ${hostname:0:5} = jean- ] ; then
712     cd $MODEL/modipsl
713     cd util
714       if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then
715        echo 'Warning jean-zay not in AA_make.gdef'
716        echo 'Think about updating'
717        exit 1
718       fi
719       ./ins_make $o_ins_make
720# Compile IOIPSL on jean-zay
721       cd $MODEL/modipsl/modeles/IOIPSL/src
722       gmake > ioipsl.log
723       cd $MODEL/modipsl/modeles/IOIPSL/tools
724       gmake > ioipsl.log
725   
726  fi
727  echo install_lmdz.sh ioipsl_OK `date`
728fi # of if [ $ioipsl = 1 ]
729# Saving ioipsl lib for possible parallel compile
730  cd $MODEL/modipsl
731  tar cf ioipsl.tar lib/ bin/
732
733#===========================================================================
734if [ "$with_xios" = "y" ] ; then
735  echo '##########################################################'
736  echo 'Compiling XIOS'
737  echo '##########################################################'
738  cd $MODEL/modipsl/modeles
739  xioslog=`pwd`/xios.log
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     svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5 XIOS
745     cd XIOS/arch
746     svn update
747     cd ..
748     echo "Compiling XIOS, start" `date` "(it takes about 20 min on Jean-Zay)"
749     echo "log file: $xioslog"
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 # of case Jean-Zay
756  if [ -f XIOS/lib/libxios.a ] ; then
757     echo "XIOS library successfully generated"
758     echo install_lmdz.sh XIOS_OK `date`
759  fi
760fi
761
762#============================================================================
763veget_version=false
764if [ "$veget" != 'NONE' ] ; then
765  cd $MODEL/modipsl/modeles/ORCHIDEE
766  set +e ; svn upgrade ; set -e
767  if [ "$veget" = "CMIP6" ] ; then
768    veget_version=orchidee2.0 
769    orchidee_rev=6592
770  else # specific orchidee revision newer than CMIP6, on 2_1 or 2_2 branches
771    veget_version=orchidee2.1
772    orchidee_rev=$veget
773     if [ $veget -lt 4465 ] ; then
774             echo 'Stopping, ORCHIDEE version too old, script needs work on the CPP flags to pass to makelmdz'
775             exit 1
776     fi
777     set +e
778     # which branch is my version on?
779     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}'`
780     # switch to that branch
781     echo IF YOU INSTALL ORCHIDEE THE VERY FIRST TIME, ASK for PASSWORD at orchidee-help@listes.ipsl.fr
782     svn switch -r $veget --accept theirs-full svn://forge.ipsl.jussieu.fr/orchidee/$orcbranch
783     svn log -r $veget | grep  $veget
784     if [  $? -gt 0 ] ; then
785          echo 'Cannot update ORCHIDEE as not on the right branch for ORCHIDEE'
786          exit
787      fi
788      set -e
789      set +e ; svn update -r $veget ; set -e 
790  fi
791  # Correctif suite debug Jean-Zay
792  sed -i -e 's/9010  FORMAT(A52,F17.14)/9010  FORMAT(A52,F20.14)/' src_stomate/stomate.f90
793  opt_orc="-prod" ; if [ "$optim" = "-debug" ] ; then opt_orc="-debug" ; fi
794
795  orchideelog=`pwd`/orchidee.log
796  echo '########################################################'
797  echo 'Compiling ORCHIDEE, the continental surface model '
798  echo '########################################################'
799  echo Start of the first compilation of orchidee, in sequential mode: `date`
800  echo log file : $orchideelog
801
802  export ORCHPATH=`pwd`
803  xios_orchid="-noxios"
804  if [ "$with_xios" = "y" ] ; then
805    xios_orchid="-xios"
806  fi
807  if [ -d tools ] ; then
808###################################################################
809# Pour les experts qui voudraient changer de version d'orchidee.
810# Attention : necessite d'avoir le password pour orchidee
811
812      # Correctif suite debug Jean-Zay
813      if [ -f src_global/time.f90 ] ; then sed -i -e 's/CALL tlen2itau/\!CALL tlen2itau/' src_global/time.f90 ; fi
814###################################################################
815     if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi
816      cd arch
817      sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
818     -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
819     -e s:"%FPP_FLAGS       .*.$":"%FPP_FLAGS           $fpp_flags":1 \
820     -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
821     -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
822     -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
823     -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
824     -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
825     -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
826     arch-gfortran.fcm > arch-local.fcm
827     echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
828     echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path
829     echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path
830     echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path
831     echo 'XIOS_INCDIR=${ORCHDIR}/../XIOS/inc' >> arch-local.path
832     echo 'XIOS_LIBDIR="${ORCHDIR}/../XIOS/lib -lxios"' >> arch-local.path
833     cd ../
834
835     echo ./makeorchidee_fcm -j $xios_orchid $opt_orc -parallel none -arch $arch
836     ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel none -arch $arch > $orchideelog 2>&1
837     pwd
838  else # of "if [ -d tools ]"
839     if [ -d src_parallel ] ; then
840       liste_src="parallel parameters global stomate sechiba driver"
841       if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi
842     fi
843     for d in $liste_src ; do src_d=src_$d
844        echo src_d $src_d
845        echo ls ; ls
846        if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi
847        cd $src_d ; \rm -f *.mod make ; $make clean
848        $make > $orchideelog 2>&1 ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi
849        cd ..
850     done
851  fi # of "if [ -d tools ]"
852  echo install_lmdz.sh orchidee_compil_seq_OK `date`
853fi # of if [ "$veget" != 'NONE' ]
854
855
856#============================================================================
857# Ehouarn: the directory name LMDZ* depends on version/tar file...
858if [ -d $MODEL/modipsl/modeles/LMD* ] ; then
859  echo '###############################################################'
860  echo 'Preparing LMDZ compilation : arch file, svn switch if needed...'
861  echo '###############################################################'
862  cd $MODEL/modipsl/modeles/LMD*
863  LMDZPATH=`pwd`
864else
865  echo "ERROR: No LMD* directory !!!"
866  exit
867fi
868
869###########################################################
870# For those who want to use fcm to compile via :
871#  makelmdz_fcm -arch local .....
872############################################################
873
874if [ "$pclinux" = "1" ] ; then
875
876# create local 'arch' files (if on Linux PC):
877cd arch
878# arch-local.path file
879echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
880echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path
881echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path
882echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
883echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path
884echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path
885echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path
886echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
887
888if [ $pcmac == 1 ] ; then
889    BASE_LD="$BASE_LD -Wl,-rpath,${ncdfdir}/lib"
890else
891    BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib"
892fi
893# Arch-local.fcm file (adapted from arch-linux-32bit.fcm)
894
895if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi
896sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
897    -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
898    -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
899    -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
900    -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
901    -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
902    -e s:"%FPP_DEF         .*.$":"%FPP_DEF             $FPP_DEF":1 \
903    -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
904    -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
905    arch-linux-32bit.fcm > arch-local.fcm
906
907cd ..
908### Adapt "bld.cfg" (add the shell):
909whereisthatshell=$(which ${use_shell})
910echo "bld::tool::SHELL   $whereisthatshell" >> bld.cfg
911
912fi # of if [ "$pclinux" = 1 ]
913
914
915cd $MODEL/modipsl/modeles/LMDZ*
916lmdzlog=`pwd`/lmdz.log
917
918##################################################################
919# Possibly update LMDZ if a specific svn release is requested
920##################################################################
921
922
923set +e ; svn upgrade ; set -e
924if [ "$svn" = "last" ] ; then svnopt="" ; else svnopt="-r $svn" ; fi
925if [ "$svn" != "" ] ; then
926    svn info | grep -q 'http:'
927    if [ $? = 0 ] ; then
928        svn switch --relocate http://svn.lmd.jussieu.fr/LMDZ https://svn.lmd.jussieu.fr/LMDZ
929    fi
930    svn update $svnopt
931fi
932set -e
933
934echo '##################################################################'
935echo "Preparing script compile.sh for LMDZ compilation" 
936echo "It will only be run automatically if bench=1" 
937echo Here bench=$bench
938echo '##################################################################'
939
940if [ "$env_file" != "" ] ; then mv arch/arch-${arch}.env arch/arch-${arch}.orig ; \cp -f $env_file arch/arch-${arch}.env ; fi
941
942if [ $compile_with_fcm = 1 ] ; then makelmdz="makelmdz_fcm $optim -arch $arch -j 8 " ; else makelmdz="makelmdz $optim -arch $arch" ; fi
943
944# sequential compilation
945if [ "$sequential" = 1 ] ; then
946  echo Sequential compilation command, saved in compile.sh:
947  echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp -d ${grid_resolution} -v $veget_version gcm "
948  echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp -d ${grid_resolution} -v $veget_version gcm " >> compile.sh
949  chmod +x ./compile.sh
950  if [ $bench != 0 ] ; then 
951    echo install_lmdz.sh start_lmdz_seq_compilation `date`
952    echo log file: $lmdzlog
953    ./compile.sh > $lmdzlog 2>&1 
954    echo install_lmdz.sh end_lmdz_seq_compilation `date`
955  fi
956fi # fin sequential
957
958# compiling in parallel mode
959if [ $parallel != "none" ] ; then
960  echo '##########################################################'
961  echo ' Parallel compile '
962  echo '##########################################################'
963  echo "(after saving the sequential libs and binaries)"
964  cd $MODEL/modipsl
965  tar cf sequential.tar bin/ lib/
966  \rm -rf bin/ lib/
967  tar xf ioipsl.tar
968  #
969  # Orchidee
970  #
971  cd $ORCHPATH
972  if [ -d src_parallel -a $veget != 'NONE' ] ; then
973     cd arch
974     sed  \
975     -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
976     -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
977     -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
978     -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
979     -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
980     -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
981     arch-local.fcm > tmp.fcm
982
983     mv tmp.fcm arch-local.fcm
984     cd ../
985     echo Compiling ORCHIDEE in parallel mode `date`
986     echo logfile $orchideelog
987     echo "NOTE : to recompile it when necessary, use ./compile_orc.sh in modipsl/modeles/ORCHIDEE"
988     echo ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc -parallel $parallel -arch $arch > compile_orc.sh
989     echo ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel $parallel -arch $arch >> compile_orc.sh
990     echo echo Now you must also recompile LMDZ, by running ./compile.sh in modeles/LMDZ >> compile_orc.sh
991     chmod u+x compile_orc.sh
992     ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc -parallel $parallel -arch $arch > $orchideelog 2>&1
993     ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel $parallel -arch $arch >> $orchideelog 2>&1
994     echo End of ORCHIDEE compilation in parallel mode `date`
995  elif [ $veget != 'NONE' ] ; then
996    echo '##########################################################'
997    echo ' Orchidee version too old                                 '
998    echo ' Please update to new version                             '
999    echo '##########################################################'
1000    exit
1001  fi # of [ -d src_parallel -a $veget != 'NONE' ]
1002
1003  # LMDZ
1004  cd $LMDZPATH
1005  if [ $arch = local ] ; then
1006    cd arch
1007    sed -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
1008    -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
1009    -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
1010    -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
1011    -e s:"%ARFLAGS.*.$":"%ARFLAGS          $ARFLAGS":1 \
1012    -e s@"%BASE_LD.*.$"@"%BASE_LD             -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \
1013    -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
1014    -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
1015    arch-local.fcm > tmp.fcm
1016    mv tmp.fcm arch-local.fcm
1017    cd ../
1018  fi
1019  rm -f compile.sh
1020  echo resol=${grid_resolution} >> compile.sh
1021  if [ ${hostname:0:5} = jean- -a "$cosp" = "v2" ] ; then
1022 
1023  echo LMDZ compilation command in parallel mode, saved in compile.sh, is :
1024  echo "(ATTENTION le probleme de cospv2 sur jean-zay en mode prod n est pas corrige ! )"
1025# ATTENTION le probleme de cospv2 sur jean-zay en mode prod n est pas corrige
1026     echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
1027     echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm
1028  else   
1029    echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
1030    echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm
1031  fi 
1032  chmod +x ./compile.sh
1033
1034  if [ $bench != 0 ] ; then 
1035    echo Compiling LMDZ in parallel mode `date`
1036    echo LMDZ log file: $lmdzlog
1037    ./compile.sh > $lmdzlog 2>&1
1038  fi
1039 
1040fi # of if [ $parallel != "none" ]
1041
1042
1043##################################################################
1044# Verification du succes de la compilation
1045##################################################################
1046
1047# Recherche de l'executable dont le nom a change au fil du temps ...
1048gcm=""
1049#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
1050for exe in gcm.e bin/gcm_${grid_resolution}_phylmd${suff_exe}${suff_orc}.e ; do   if [ -f $exe ] ; then gcm=$exe ; fi
1051done
1052
1053if [ "$gcm" = "" ] ; then
1054  if [ $bench != 0 ] ; then
1055    echo 'Compilation failed !! Cannot run the benchmark;'
1056    exit
1057  else
1058    echo 'Compilation not done (only done when bench=1)'
1059  fi
1060else
1061   echo '##########################################################'
1062   echo 'Compilation successfull !! ' `date`
1063   echo '##########################################################'
1064   echo The executable is $gcm
1065fi
1066
1067##################################################################
1068# Below, we run a benchmark test (if bench=0)
1069##################################################################
1070
1071if [ $bench != 0 ] ; then
1072
1073echo '##########################################################'
1074echo ' Running a test run '
1075echo '##########################################################'
1076
1077\rm -rf BENCH${grid_resolution}
1078bench=bench_lmdz_${grid_resolution}
1079echo install_lmdz.sh before bench download  `date`
1080#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz
1081myget 3DBenchs/$bench.tar.gz
1082echo install_lmdz.sh after bench download  `date`
1083tar xvf $bench.tar.gz
1084
1085if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then
1086  cd BENCH${grid_resolution}
1087# copier les fichiers namelist input et output our COSP
1088  cp ../DefLists/cosp*_input_nl.txt .
1089  cp ../DefLists/cosp*_output_nl.txt .
1090# Activer la cles ok_cosp pour tourner avec COSP
1091  sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp
1092   \mv -f tmp config.def
1093  cd ..
1094fi 
1095
1096if [ -n "$physiq" ]; then
1097  cd BENCH${grid_resolution}
1098  if [ -f physiq.def_${physiq} ]; then
1099    cp physiq.def_${physiq} physiq.def
1100    echo using physiq.def_${physiq}
1101  else
1102    echo using standard physiq.def
1103  fi
1104  cd ..
1105else
1106  echo using standard physiq.def
1107fi
1108
1109if [ "$with_xios" = "y" ] ; then
1110  cd BENCH${grid_resolution}
1111  cp ../DefLists/iodef.xml .
1112  cp ../DefLists/context_lmdz.xml .
1113  cp ../DefLists/field_def_lmdz.xml .
1114# A raffiner par la suite
1115  echo A FAIRE : Copier les *xml en fonction de l option cosp
1116  cp ../DefLists/field_def_cosp*.xml .
1117  cp ../DefLists/file_def_hist*xml .
1118  # adapt iodef.xml to use attached mode
1119  sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp
1120  \mv -f tmp iodef.xml
1121
1122  # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE.
1123  # except for histday
1124  for histfile in file_def_hist*xml
1125  do
1126    if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then
1127    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
1128    sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
1129    sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
1130    else
1131    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile
1132    fi
1133  done
1134  # and add option "ok_all_xml=y" in config.def
1135  echo "### XIOS outputs" >> config.def
1136  echo 'ok_all_xml=.true.' >> config.def
1137
1138  #activer les sorties pour Cosp
1139  if [ "$cosp" = "v1" ] ; then 
1140   histfile=file_def_histdayCOSP_lmdz.xml
1141   sed -e 's@enabled=".FALSE."@enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
1142   sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
1143   sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
1144  fi
1145  if [ "$cosp" = "v2" ] ; then
1146   histfile=file_def_histdayCOSPv2_lmdz.xml
1147   sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
1148   contextfile=context_lmdz.xml
1149   sed -e 's@src="./file_def_histdayCOSP_lmdz.xml"@src="./file_def_histdayCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
1150   sed -e 's@src="./file_def_histmthCOSP_lmdz.xml"@src="./file_def_histmthCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
1151   sed -e 's@src="./file_def_histhfCOSP_lmdz.xml"@src="./file_def_histhfCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
1152   fieldfile=field_def_lmdz.xml
1153   sed -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' $fieldfile > tmp ; \mv -f tmp $fieldfile
1154  fi
1155
1156  cd ..
1157fi
1158
1159# Cas Bensh avec ecrad
1160if [ "$rad" = "ecrad" ] ; then
1161  cd BENCH${grid_resolution}
1162  cp  ../DefLists/namelist_ecrad .
1163  cp -r ../libf/phylmd/ecrad/data .
1164# Attention au cas ou ne 1
1165  sed -e 's@iflag_rrtm=1@iflag_rrtm=2@' physiq.def > tmp
1166   \mv -f tmp physiq.def
1167  cd ..
1168fi
1169
1170cp $gcm BENCH${grid_resolution}/gcm.e
1171
1172cd BENCH${grid_resolution}
1173# On cree le fichier bench.sh au besoin
1174# Dans le cas 48x36x39 le bench.sh existe deja en parallele
1175
1176if [ "$grid_resolution" = "48x36x39" ] ; then
1177   echo On ne touche pas au bench.sh
1178   # But we have to adapt "run_local.sh" for $mpirun
1179   sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp
1180   mv -f tmp run_local.sh
1181   chmod u=rwx run_local.sh
1182elif [ "${parallel:0:3}" = "mpi" ] ; then
1183   # Lancement avec deux procs mpi et 2 openMP
1184   echo "export OMP_STACKSIZE=800M" > bench.sh
1185   if [ "${parallel:4:3}" = "omp" ] ; then
1186     echo "export OMP_NUM_THREADS=2" >> bench.sh
1187   fi
1188   if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then 
1189      if [ ${hostname:0:5} = jean- ] ; then   
1190        chmod +x ../arch.env
1191        ../arch.env     
1192        echo "ulimit -s 2000000" >> bench.sh
1193      else
1194        echo "ulimit -s 200000" >> bench.sh           
1195      fi       
1196   else
1197      echo "ulimit -s unlimited" >> bench.sh
1198   fi
1199   if [ ${hostname:0:5} = jean- ] ; then
1200     . ../arch/arch-${arch}.env 
1201     echo "srun -n 2 -A $idris_acct@cpu gcm.e > listing  2>&1" >> bench.sh
1202   else
1203     echo "$mpirun -np 2 gcm.e > listing  2>&1" >> bench.sh
1204   fi
1205   # Add rebuild, using reb.sh if it is there
1206   echo 'if [ -f reb.sh ] ; then' >> bench.sh
1207   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
1208   echo 'fi' >> bench.sh
1209else
1210   echo "./gcm.e > listing  2>&1" > bench.sh
1211fi
1212# Getting orchidee stuff
1213if [ $veget == 'CMIP6' ] ; then
1214    #echo 'myget 3DBenchs/BENCHorch11.tar.gz'
1215    #myget 3DBenchs/BENCHorch11.tar.gz
1216    #tar xvzf BENCHorch11.tar.gz
1217    echo 'myget 3DBenchs/BENCHCMIP6.tar.gz'
1218    myget 3DBenchs/BENCHCMIP6.tar.gz
1219    tar xvzf BENCHCMIP6.tar.gz
1220    sed -e "s:VEGET=n:VEGET=y:" config.def > tmp
1221    mv -f tmp config.def
1222    if [ "$with_xios" = "y" ] ; then
1223      cp ../../ORCHIDEE/src_xml/context_orchidee.xml .
1224      echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
1225      cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml .
1226      cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml .
1227      cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml .
1228      if [ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ] ; then
1229        cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml .
1230        echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
1231      fi
1232      sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp
1233      mv tmp iodef.xml
1234      sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
1235      sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
1236      sed -e 's@output_level="_AUTO_"@output_level="1"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
1237      sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
1238      sed -e 's@compression_level="4"@compression_level="0"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
1239      sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' orchidee.def > tmp ; \mv -f tmp orchidee.def
1240    fi
1241fi
1242echo EXECUTION DU BENCH
1243set +e
1244date ; ./bench.sh > out.bench 2>&1 ; date
1245set -e
1246tail listing
1247
1248
1249echo '##########################################################'
1250echo 'Simulation finished in' `pwd`
1251   echo 'You have compiled with:'
1252   cat ../compile.sh
1253if [ $parallel = "none" ] ; then
1254  echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e'
1255  echo 'or ./bench.sh'
1256else
1257  echo 'You may re-run it with : '
1258  echo 'cd ' `pwd` '; ./bench.sh'
1259#  echo 'ulimit -s unlimited'
1260#  echo 'export OMP_NUM_THREADS=2'
1261#  echo 'export OMP_STACKSIZE=800M'
1262#  echo "$mpirun -np 2 gcm.e "
1263fi
1264echo '##########################################################'
1265
1266fi # bench
1267
1268
1269#################################################################
1270# Installation eventuelle du 1D
1271#################################################################
1272
1273if [ $SCM = 1 ] ; then
1274cd $MODEL
1275#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/1D.tar.gz
1276myget 1D/1D.tar.gz
1277tar xvf 1D.tar.gz
1278cd 1D
1279./run.sh -rad $rad
1280fi
1281set -vx
1282
1283#################################################################
1284# sauvegarde des options veget pour utilisation eventuelle tutorial_prod
1285#################################################################
1286cd $MODEL/modipsl/modeles
1287echo surface_env file created in $MODEL
1288echo 'veget='$veget > surface_env
1289#opt_veget="-v $veget_version"
1290#echo 'opt_veget="'$opt_veget\" >> surface_env
1291echo 'opt_veget="'-v $veget_version\" >> surface_env
1292echo 'orchidee_rev='$orchidee_rev >> surface_env
1293echo 'suforch='$suff_orc >> surface_env
1294   
1295
1296
1297
Note: See TracBrowser for help on using the repository browser.