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