source: BOL/script_install/install_lmdz.sh @ 4208

Last change on this file since 4208 was 4208, checked in by lguez, 2 years ago

Do not run the bench again if it is already there

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