| 1 | #!/bin/bash |
|---|
| 2 | set -eu # error on command failure, and on unset variables |
|---|
| 3 | export LC_ALL=C # standardize awk format |
|---|
| 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. |
|---|
| 21 | # In the present case, LMDZ, ORCHIDEE, and IOIPSL or XIOS (handling of |
|---|
| 22 | # input-outputs using the NetCDF library). |
|---|
| 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 | ### Functions |
|---|
| 39 | |
|---|
| 40 | function myget { # Get a file from LMDZ repository |
|---|
| 41 | local url=$1 |
|---|
| 42 | |
|---|
| 43 | local filename |
|---|
| 44 | filename=$(basename "$url") |
|---|
| 45 | |
|---|
| 46 | wget --no-check-certificate -nv "http://lmdz.lmd.jussieu.fr/pub/$url" |
|---|
| 47 | if [[ $filename =~ .*\.(ba)?sh ]]; then chmod +x "$filename"; fi |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | function set_default_params { |
|---|
| 51 | # Valeur par défaut des parametres |
|---|
| 52 | svn="" |
|---|
| 53 | version="20231022.trunk" |
|---|
| 54 | |
|---|
| 55 | netcdf=1 |
|---|
| 56 | bench=1 |
|---|
| 57 | pcmac=0 # default: not on a Mac |
|---|
| 58 | SCM=0 |
|---|
| 59 | veget="none" |
|---|
| 60 | grid_resolution="32x32x39" |
|---|
| 61 | physiq="" |
|---|
| 62 | |
|---|
| 63 | xios_branch="2.6" |
|---|
| 64 | xios_rev="2568" |
|---|
| 65 | |
|---|
| 66 | parallel="none" |
|---|
| 67 | trusting="testing" |
|---|
| 68 | MODEL="" |
|---|
| 69 | |
|---|
| 70 | with_xios=0 |
|---|
| 71 | opt_makelmdz_xios="" |
|---|
| 72 | |
|---|
| 73 | rad="rrtm" |
|---|
| 74 | |
|---|
| 75 | compile_with_fcm=1 |
|---|
| 76 | |
|---|
| 77 | cosp="none" |
|---|
| 78 | opt_cosp="" |
|---|
| 79 | |
|---|
| 80 | make_j=8 |
|---|
| 81 | |
|---|
| 82 | # Check if on a Mac |
|---|
| 83 | if [[ $(uname) = "Darwin" ]]; then |
|---|
| 84 | pcmac=1 |
|---|
| 85 | export MAKE="make" |
|---|
| 86 | fi |
|---|
| 87 | |
|---|
| 88 | optim_debug="" |
|---|
| 89 | arch="local" |
|---|
| 90 | |
|---|
| 91 | local mpi_file |
|---|
| 92 | mpi_file=$(readlink -f "$(which mpif90)") |
|---|
| 93 | path_mpi=$(dirname "$mpi_file") |
|---|
| 94 | root_mpi=$(dirname "$path_mpi") |
|---|
| 95 | |
|---|
| 96 | arch="local-gfortran" |
|---|
| 97 | arch_dir="" |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | function read_cmdline_args { |
|---|
| 101 | while (($# > 0)); do |
|---|
| 102 | case $1 in |
|---|
| 103 | "-h") cat <<........fin |
|---|
| 104 | $0 [ -v version ] [ -r svn_release ] |
|---|
| 105 | [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ] |
|---|
| 106 | [-name LOCAL_MODEL_NAME] [-gprof] [-opt_makelmdz] [-rad RADIATIF] |
|---|
| 107 | |
|---|
| 108 | -v "version" like 20150828.trunk, see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk (default <$version>) |
|---|
| 109 | |
|---|
| 110 | -r "svn_release" : either the svn release number or "last" (default <$svn>) |
|---|
| 111 | |
|---|
| 112 | -parallel parallel support: mpi, omp, mpi_omp (mpi with openMP) or none (default: <$parallel>) |
|---|
| 113 | |
|---|
| 114 | -d "grid resolution": should be among the available benchs if -bench 1 (valid values: 48x36x19, 48x36x39) (default : <$grid_resolution>) |
|---|
| 115 | |
|---|
| 116 | -bench activating the bench or not (0/1) (default: <$bench>) |
|---|
| 117 | |
|---|
| 118 | -testing/unstable |
|---|
| 119 | |
|---|
| 120 | -name name of the folder to install to (default <$MODEL>) |
|---|
| 121 | |
|---|
| 122 | -netcdf 0, 1 or PATH. 0: do not download NetCDF, look for it in standard locations (/usr); 1: download and compile NetCDF; PATH: full path to an existing installed NetCDF library (default: <$netcdf>) |
|---|
| 123 | |
|---|
| 124 | -xios use (download and compile) the XIOS library (will compile the parallel NetCDF4-HDF5 library) (requires to also have -parallel mpi_omp) |
|---|
| 125 | |
|---|
| 126 | -cosp to run with cospv1 or cospv2 [none/v1/v2] (default <$cosp>) |
|---|
| 127 | |
|---|
| 128 | -rad radiative code: oldrad, rrtm or ecrad (default <$rad>) |
|---|
| 129 | |
|---|
| 130 | -nofcm to compile without fcm |
|---|
| 131 | |
|---|
| 132 | -SCM install 1D version automatically |
|---|
| 133 | |
|---|
| 134 | -debug compile everything in debug mode |
|---|
| 135 | |
|---|
| 136 | -physiq to choose which physics package to use (default <$physiq>) |
|---|
| 137 | |
|---|
| 138 | -veget surface/vegetation scheme treatment controlled by the single variable veget which can have the following values: none: bucket scheme (default); CMIP6 | veget2.0: orchidee version used in CMIP exercise, rev 5661; veget2.2: orchidee branch 2.2, rev 8529 (bundled); number: orchidee version number (default $veget) |
|---|
| 139 | |
|---|
| 140 | -arch name of the arch to use (default <$arch>) |
|---|
| 141 | |
|---|
| 142 | -arch_dir where to find the arch files (default <$arch_dir>) |
|---|
| 143 | |
|---|
| 144 | -make_j number of processes to parallelize installations (default <$make_j>) |
|---|
| 145 | |
|---|
| 146 | ........fin |
|---|
| 147 | exit 1;; |
|---|
| 148 | "-v") version=$2; shift; shift;; |
|---|
| 149 | "-r") svn=$2; shift; shift;; |
|---|
| 150 | "-d") grid_resolution=$2; shift; shift;; |
|---|
| 151 | "-unstable"|"-testing") trusting=$(echo "$1" | cut -c2-); shift;; |
|---|
| 152 | "-cosp") cosp=$2 |
|---|
| 153 | case $cosp in |
|---|
| 154 | "none"|"v1"|"v2") cosp=$2; shift; shift;; |
|---|
| 155 | *) echo "Only none v1 v2 for cosp option"; exit 1 |
|---|
| 156 | esac;; |
|---|
| 157 | "-nofcm") compile_with_fcm=0; echo "This option will be reactivated soon (promesse du 8dec2022)"; exit 1; shift;; |
|---|
| 158 | "-SCM") SCM=1; shift;; |
|---|
| 159 | "-rad") rad=$2 |
|---|
| 160 | case $rad in |
|---|
| 161 | "oldrad"|"rrtm"|"ecrad") rad=$2; shift; shift;; |
|---|
| 162 | *) echo "Only oldrad rrtm ecrad for rad option"; exit 1 |
|---|
| 163 | esac;; |
|---|
| 164 | "-parallel") parallel=$2 |
|---|
| 165 | case $parallel in |
|---|
| 166 | "none"|"mpi"|"omp"|"mpi_omp") parallel=$2; shift; shift;; |
|---|
| 167 | *) echo "Only none mpi omp mpi_omp for the parallel option"; exit 1 |
|---|
| 168 | esac;; |
|---|
| 169 | "-bench") bench=$2; shift; shift;; |
|---|
| 170 | "-debug") optim_debug=-debug; shift;; |
|---|
| 171 | "-name") MODEL=$2; shift; shift;; |
|---|
| 172 | "-netcdf") netcdf=$2; shift; shift;; |
|---|
| 173 | "-physiq") physiq=$2; shift; shift;; |
|---|
| 174 | "-xios") with_xios=1; shift;; |
|---|
| 175 | "-arch") arch=$2; shift; shift;; |
|---|
| 176 | "-arch_dir") arch_dir=$2; shift; shift;; |
|---|
| 177 | "-veget") veget=$2; shift; shift;; |
|---|
| 178 | "-make_j") make_j=$2; shift; shift;; |
|---|
| 179 | *) bash install_lmdz.sh -h; exit 1 |
|---|
| 180 | esac |
|---|
| 181 | done |
|---|
| 182 | |
|---|
| 183 | # Option de compilation pour Cosp |
|---|
| 184 | case $cosp in |
|---|
| 185 | v1) opt_cosp="-cosp true";; |
|---|
| 186 | v2) opt_cosp="-cospv2 true";; |
|---|
| 187 | *) opt_cosp="" |
|---|
| 188 | esac |
|---|
| 189 | |
|---|
| 190 | # Check on veget version |
|---|
| 191 | if [[ $veget != 'none' && $veget != "CMIP6" && $veget != "orch2.0" && $veget != "orch2.2" ]]; then |
|---|
| 192 | re='^[0-9]+$' |
|---|
| 193 | if ! [[ $veget =~ $re ]]; then |
|---|
| 194 | echo 'Valeur de l option veget non valable'; exit 1 |
|---|
| 195 | fi |
|---|
| 196 | fi |
|---|
| 197 | |
|---|
| 198 | #Define veget-related suffix for gcm name |
|---|
| 199 | if [[ $veget = 'none' ]]; then |
|---|
| 200 | suff_orc='' |
|---|
| 201 | else |
|---|
| 202 | suff_orc='_orch' |
|---|
| 203 | fi |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | if [[ $parallel = "none" ]]; then |
|---|
| 207 | suff_exe='_seq' |
|---|
| 208 | else |
|---|
| 209 | suff_exe='_para_mem' |
|---|
| 210 | fi |
|---|
| 211 | |
|---|
| 212 | #Chemin pour placer le modele |
|---|
| 213 | if [[ $MODEL = "" ]]; then MODEL="./LMDZ$version$svn$optim_debug"; fi |
|---|
| 214 | |
|---|
| 215 | ## if also compiling XIOS, parallel must be mpi_omp |
|---|
| 216 | if [[ $with_xios = 1 && $parallel != "mpi_omp" ]]; then |
|---|
| 217 | echo "Error, you must set -parallel mpi_omp if you want XIOS"; exit 1 |
|---|
| 218 | fi |
|---|
| 219 | |
|---|
| 220 | if [[ $with_xios = 1 ]]; then |
|---|
| 221 | opt_makelmdz_xios="-io xios" |
|---|
| 222 | fi |
|---|
| 223 | |
|---|
| 224 | if [[ $cosp = "v2" && $with_xios = 0 ]]; then |
|---|
| 225 | echo "Error, Cospv2 cannot run without Xios"; exit 1 |
|---|
| 226 | fi |
|---|
| 227 | |
|---|
| 228 | if [[ $arch_dir = "" ]]; then |
|---|
| 229 | arch_dir="$MODEL/modipsl/config/IPSLCM7/ARCH/" |
|---|
| 230 | fi |
|---|
| 231 | arch_dir=$(readlink -f "$arch_dir") # full path |
|---|
| 232 | } |
|---|
| 233 | |
|---|
| 234 | function check_available_software { |
|---|
| 235 | echo "################################################################" |
|---|
| 236 | echo "Check if required software is available" |
|---|
| 237 | echo "################################################################" |
|---|
| 238 | for logiciel in wget tar gzip make gcc cmake m4 c++; do |
|---|
| 239 | if [[ $(which "$logiciel") = "" ]]; then |
|---|
| 240 | echo "You must first install $logiciel on your system"; exit 1 |
|---|
| 241 | fi |
|---|
| 242 | done |
|---|
| 243 | |
|---|
| 244 | cat <<eod > tt.f90 |
|---|
| 245 | print*,'coucou' |
|---|
| 246 | end |
|---|
| 247 | eod |
|---|
| 248 | $compiler tt.f90 || a.out |
|---|
| 249 | ./a.out >| tt |
|---|
| 250 | if [[ $(< tt sed -e 's/ //g' ) != "coucou" ]]; then |
|---|
| 251 | echo "problem installing with compiler $compiler"; exit 1 |
|---|
| 252 | fi |
|---|
| 253 | \rm tt a.out tt.f90 |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | function download_model { |
|---|
| 257 | mkdir -p "$MODEL" |
|---|
| 258 | MODEL=$(readlink -f "$MODEL"); echo "$MODEL" # absolute path |
|---|
| 259 | |
|---|
| 260 | rm -rf "$MODEL/modipsl" |
|---|
| 261 | |
|---|
| 262 | echo "##########################################################" |
|---|
| 263 | echo "Download a slightly modified version of LMDZ" |
|---|
| 264 | echo "##########################################################" |
|---|
| 265 | cd "$MODEL" |
|---|
| 266 | getlog="$(pwd)/get.log" |
|---|
| 267 | echo "logfile : $getlog" |
|---|
| 268 | myget "src_archives/$trusting/modipsl.$version.tar.gz" >> get.log 2>&1 |
|---|
| 269 | echo "install_lmdz.sh wget_OK $(date)" |
|---|
| 270 | gunzip "modipsl.$version.tar.gz" >> get.log 2>&1 |
|---|
| 271 | tar xf "modipsl.$version.tar" >> get.log 2>&1 |
|---|
| 272 | \rm "modipsl.$version.tar" |
|---|
| 273 | |
|---|
| 274 | if [[ $svn != "" ]]; then |
|---|
| 275 | mysvn=$svn |
|---|
| 276 | else |
|---|
| 277 | mysvn="$(grep 'Revision: [0-9]' "$MODEL"/Read*.md | awk ' { print $2 } ' 2>/dev/null)" |
|---|
| 278 | fi |
|---|
| 279 | echo "SVN revision used: $mysvn" |
|---|
| 280 | } |
|---|
| 281 | |
|---|
| 282 | function download_model_AMAURY { # TODO TEMP while waiting for tar: we copy the base from a local path = IPSLCM7 + ORCH2.2 8504 |
|---|
| 283 | if [[ ! -d ../MODEL_REF ]]; then |
|---|
| 284 | cd .. |
|---|
| 285 | mkdir MODEL_REF |
|---|
| 286 | cd MODEL_REF |
|---|
| 287 | svn co --username icmc_users https://forge.ipsl.fr/igcmg/svn/modipsl/trunk modipsl |
|---|
| 288 | cd modipsl/util |
|---|
| 289 | ./model IPSLCM7_work |
|---|
| 290 | rm -rf ../oasis3-mct |
|---|
| 291 | cd ../modeles |
|---|
| 292 | rm -rf ICOSA_LMDZ ORCHIDEE_4 ORCHIDEE_2_2 NEMO DYNAMICO XIOS INCA |
|---|
| 293 | svn co svn://forge.ipsl.fr/orchidee/branches/ORCHIDEE_2_2/ORCHIDEE -r 8504 |
|---|
| 294 | cd ../../../script_install |
|---|
| 295 | fi |
|---|
| 296 | |
|---|
| 297 | if [[ ! -d "$MODEL" ]]; then |
|---|
| 298 | \cp -r ../MODEL_REF . |
|---|
| 299 | mv MODEL_REF "$MODEL" |
|---|
| 300 | fi |
|---|
| 301 | MODEL=$(readlink -f "$MODEL"); echo "$MODEL" # absolute path |
|---|
| 302 | |
|---|
| 303 | if [[ $svn != "" ]]; then |
|---|
| 304 | mysvn=$svn |
|---|
| 305 | else |
|---|
| 306 | mysvn="$(grep 'Revision: [0-9]' "$MODEL"/Read*.md | awk ' { print $2 } ' 2>/dev/null)" |
|---|
| 307 | fi |
|---|
| 308 | echo "SVN revision used: $mysvn" |
|---|
| 309 | } |
|---|
| 310 | |
|---|
| 311 | function init_arch { |
|---|
| 312 | if [[ ! -d $arch_dir ]]; then |
|---|
| 313 | echo "Error: no arch dir $arch_dir"; exit 1 |
|---|
| 314 | elif [[ ! -f $arch_dir/arch-$arch.path ]]; then |
|---|
| 315 | echo "Error: no arch-$arch.path in $arch_dir"; exit 1 |
|---|
| 316 | fi |
|---|
| 317 | |
|---|
| 318 | local fcm_path |
|---|
| 319 | if [[ -f $arch_dir/arch-$arch.fcm ]]; then |
|---|
| 320 | fcm_path="$arch_dir/arch-$arch.fcm" |
|---|
| 321 | else |
|---|
| 322 | fcm_path="$MODEL/modipsl/modeles/LMDZ/arch/arch-$arch.fcm" |
|---|
| 323 | if [[ ! -f $fcm_path ]]; then |
|---|
| 324 | echo "Error: no $fcm_path"; exit 1 |
|---|
| 325 | fi |
|---|
| 326 | fi |
|---|
| 327 | |
|---|
| 328 | # check compiler |
|---|
| 329 | compiler=$(< "$fcm_path" grep "%COMPILER" | sed -e "s/%COMPILER\s*//") |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | function install_arch { |
|---|
| 333 | local component=$1 |
|---|
| 334 | |
|---|
| 335 | if [[ ! -f "$MODEL/modipsl/modeles/$component/arch/arch-$arch.fcm" ]]; then |
|---|
| 336 | \cp -f "$arch_dir/arch-$arch.fcm" "$MODEL/modipsl/modeles/$component/arch" |
|---|
| 337 | \cp -f "$arch_dir/arch-$arch.path" "$MODEL/modipsl/modeles/$component/arch" |
|---|
| 338 | |
|---|
| 339 | if [[ $component = "XIOS" ]]; then |
|---|
| 340 | # Adapt for XIOS, which uses different naming conventions |
|---|
| 341 | sed -i'' -e "s/%COMPILER/%FCOMPILER/" -e "s/%LINK/%LINKER/" -e "s/-fdefault-real-8//" "$MODEL/modipsl/modeles/XIOS/arch/arch-$arch.fcm" |
|---|
| 342 | elif [[ $component = "ORCHIDEE" ]]; then |
|---|
| 343 | if [[ $orcbranch = "/tags/ORCHIDEE_2_0/ORCHIDEE" ]]; then # 2.0 and before have a different fcm convention |
|---|
| 344 | sed -i'' -e "s/-I//" -e "s/-L//" "$MODEL/modipsl/modeles/ORCHIDEE/arch/arch-$arch.path" # /!\ we only replace first occurence on purpose |
|---|
| 345 | fi |
|---|
| 346 | fi |
|---|
| 347 | fi |
|---|
| 348 | } |
|---|
| 349 | |
|---|
| 350 | function install_netcdf { |
|---|
| 351 | echo "Installing Netcdf" |
|---|
| 352 | local ncdf_compiler="$compiler" |
|---|
| 353 | |
|---|
| 354 | if [[ $netcdf = 0 ]]; then |
|---|
| 355 | ncdfdir=$(nc-config --prefix) |
|---|
| 356 | else |
|---|
| 357 | cd "$MODEL" |
|---|
| 358 | |
|---|
| 359 | # Convert non-basic compiler |
|---|
| 360 | case $compiler in # TODO check if it works with other base compilers |
|---|
| 361 | mpif90) ncdf_compiler=$($compiler --help | head -n 1 | cut -f 2 -d " ") |
|---|
| 362 | esac |
|---|
| 363 | |
|---|
| 364 | case $ncdf_compiler in |
|---|
| 365 | gfortran) opt1="-compiler gnu"; opt2="-CC gcc -FC gfortran -CXX g++";; |
|---|
| 366 | ifort) opt1="-compiler intel"; opt2="-CC icc -FC ifort -CXX icpc";; |
|---|
| 367 | pgf90) opt1="-compiler pgf90"; opt2="-CC pgcc -FC pgf90 -CXX pgCC";; |
|---|
| 368 | *) echo "unexpected compiler $ncdf_compiler for netcdf"; exit 1 |
|---|
| 369 | esac |
|---|
| 370 | |
|---|
| 371 | case $with_xios in |
|---|
| 372 | 0) script_install_netcdf="install_netcdf4_hdf5_seq.bash" |
|---|
| 373 | ncdfdir="netcdf4_hdf5_seq" |
|---|
| 374 | opt_="$opt1";; |
|---|
| 375 | 1) script_install_netcdf="install_netcdf4_hdf5.bash" |
|---|
| 376 | ncdfdir="netcdf4_hdf5" |
|---|
| 377 | opt_="$opt2 -MPI $root_mpi";; |
|---|
| 378 | *) echo "with_xios=$with_xios, should be 0 or 1"; exit 1 |
|---|
| 379 | esac |
|---|
| 380 | if [[ $netcdf = 1 ]]; then |
|---|
| 381 | ncdfdir="$MODEL/$ncdfdir" |
|---|
| 382 | else |
|---|
| 383 | mkdir -p "$netcdf"; ncdfdir="$netcdf/$ncdfdir" |
|---|
| 384 | fi |
|---|
| 385 | |
|---|
| 386 | echo "Repertoire netcdf $ncdfdir" |
|---|
| 387 | if [[ ! -d $ncdfdir ]]; then |
|---|
| 388 | netcdflog=$(pwd)/netcdf.log |
|---|
| 389 | echo "----------------------------------------------------------" |
|---|
| 390 | echo "Compiling the Netcdf library" |
|---|
| 391 | echo "----------------------------------------------------------" |
|---|
| 392 | echo "log file : $netcdflog" |
|---|
| 393 | myget script_install/$script_install_netcdf >> "$netcdflog" 2>&1 |
|---|
| 394 | chmod u=rwx $script_install_netcdf |
|---|
| 395 | # shellcheck disable=SC2086 |
|---|
| 396 | ./$script_install_netcdf -prefix "$ncdfdir" $opt_ >> "$netcdflog" 2>&1 |
|---|
| 397 | fi |
|---|
| 398 | |
|---|
| 399 | # Add to path |
|---|
| 400 | export PATH="$ncdfdir/bin:$PATH" |
|---|
| 401 | |
|---|
| 402 | #---------------------------------------------------------------------------- |
|---|
| 403 | # LF rajout d'une verrue, pour une raison non encore expliquee, |
|---|
| 404 | # la librairie est parfois rangée dans lib64 et non dans lib |
|---|
| 405 | # par certains compilateurs |
|---|
| 406 | if [[ ! -e lib && -d lib64 ]]; then ln -s lib64 lib; fi |
|---|
| 407 | #---------------------------------------------------------------------------- |
|---|
| 408 | |
|---|
| 409 | echo "install_lmdz.sh netcdf_OK $(date)" |
|---|
| 410 | fi |
|---|
| 411 | |
|---|
| 412 | cat >test_netcdf90.f90 <<EOF |
|---|
| 413 | use netcdf |
|---|
| 414 | print *, "NetCDF library version: ", nf90_inq_libvers() |
|---|
| 415 | end |
|---|
| 416 | EOF |
|---|
| 417 | |
|---|
| 418 | if $ncdf_compiler -I"$ncdfdir"/include test_netcdf90.f90 -L"$ncdfdir"/lib -lnetcdff \ |
|---|
| 419 | -lnetcdf -Wl,-rpath="$ncdfdir"/lib && ./a.out |
|---|
| 420 | then |
|---|
| 421 | \rm test_netcdf90.f90 a.out |
|---|
| 422 | else |
|---|
| 423 | cat <<EOF |
|---|
| 424 | Failed test program using NetCDF-Fortran. You can: |
|---|
| 425 | - check that you have NetCDF-Fortran installed in your system |
|---|
| 426 | - or specify an installation directory with option -netcdf of install_lmdz.sh |
|---|
| 427 | - or download and compile NetCDF-Fortran with option -netcdf 1 of nstall_lmdz.sh |
|---|
| 428 | EOF |
|---|
| 429 | exit 1 |
|---|
| 430 | fi |
|---|
| 431 | |
|---|
| 432 | # Compile NetCDF95 |
|---|
| 433 | cd "$MODEL/modipsl/modeles/LMD"* |
|---|
| 434 | echo "Installing NetCDF95" |
|---|
| 435 | cd "$MODEL" |
|---|
| 436 | myget src_archives/netcdf/NetCDF95-0.3.tar.gz |
|---|
| 437 | tar -xf NetCDF95-0.3.tar.gz |
|---|
| 438 | \rm NetCDF95-0.3.tar.gz |
|---|
| 439 | cd NetCDF95-0.3 |
|---|
| 440 | mkdir -p build && cd build |
|---|
| 441 | netCDF_INCLUDE_DIR=$(nc-config --includedir) netCDF_LIBRARY=$(nc-config --libdir) cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$ncdfdir" -DCMAKE_INSTALL_PREFIX="$MODEL/modipsl" |
|---|
| 442 | make install |
|---|
| 443 | } |
|---|
| 444 | |
|---|
| 445 | function install_IOIPSL { |
|---|
| 446 | install_arch "IOIPSL" |
|---|
| 447 | |
|---|
| 448 | cd "$MODEL/modipsl/modeles/IOIPSL" |
|---|
| 449 | ioipsllog="$(pwd)/ioipsl.log" |
|---|
| 450 | echo "Compiling IOIPSL, the interface library with Netcdf $(date) (log: $ioipsllog)" |
|---|
| 451 | |
|---|
| 452 | if ! ./makeioipsl_fcm -arch "$arch" -job 8 > "$ioipsllog" 2>&1; then |
|---|
| 453 | echo "IOIPSL compile failed, exiting"; exit 1 |
|---|
| 454 | fi |
|---|
| 455 | |
|---|
| 456 | # Link to modipsl/bin |
|---|
| 457 | cp -f bin/* ../../bin |
|---|
| 458 | |
|---|
| 459 | echo "IOIPSL compiled $(date)" |
|---|
| 460 | |
|---|
| 461 | IOIPSL_LIBDIR_="$MODEL/modipsl/modeles/IOIPSL/lib" |
|---|
| 462 | IOIPSL_INCDIR_="$MODEL/modipsl/modeles/IOIPSL/inc" |
|---|
| 463 | } |
|---|
| 464 | |
|---|
| 465 | function install_XIOS { |
|---|
| 466 | if [[ $with_xios = 1 ]]; then |
|---|
| 467 | cd "$MODEL/modipsl/modeles" |
|---|
| 468 | xioslog="$(pwd)/XIOS/xios.log" |
|---|
| 469 | echo "##########################################################" |
|---|
| 470 | echo "Compiling XIOS (log $xioslog) $(date)" |
|---|
| 471 | echo "##########################################################" |
|---|
| 472 | |
|---|
| 473 | # Download XIOS |
|---|
| 474 | case $xios_branch in |
|---|
| 475 | "trunk") |
|---|
| 476 | xios_http="http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/trunk";; |
|---|
| 477 | "2.5") |
|---|
| 478 | xios_http="http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5";; |
|---|
| 479 | "2.6") |
|---|
| 480 | xios_http="http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS2/branches/xios-2.6";; |
|---|
| 481 | *) echo "XIOS: Error, bad argument for -branch ! Did not expect $xios_branch"; exit;; |
|---|
| 482 | esac |
|---|
| 483 | |
|---|
| 484 | cd "$MODEL/modipsl/modeles" |
|---|
| 485 | set +e; svn co --revision $xios_rev $xios_http XIOS; set -e |
|---|
| 486 | |
|---|
| 487 | cd XIOS |
|---|
| 488 | |
|---|
| 489 | install_arch "XIOS" |
|---|
| 490 | |
|---|
| 491 | echo "Starting XIOS compilation" |
|---|
| 492 | if ! ./make_xios --arch "$arch" --job 8 > "$xioslog" 2>&1; then |
|---|
| 493 | echo "XIOS compilation failed, exiting"; exit 1 |
|---|
| 494 | fi |
|---|
| 495 | |
|---|
| 496 | echo "Compiled XIOS $(date)" |
|---|
| 497 | fi |
|---|
| 498 | |
|---|
| 499 | XIOS_LIBDIR_="$MODEL/modipsl/modeles/XIOS/lib" |
|---|
| 500 | XIOS_INCDIR_="$MODEL/modipsl/modeles/XIOS/inc" |
|---|
| 501 | } |
|---|
| 502 | |
|---|
| 503 | function get_orchidee_version { # Set / Check ORCHIDEE version |
|---|
| 504 | local fetch_rev="" |
|---|
| 505 | orcbranch="" |
|---|
| 506 | case $veget in |
|---|
| 507 | "none") fcm_veget_version="false";; |
|---|
| 508 | "orch2.0" | "CMIP6") fcm_veget_version=orchidee2.0; fetch_rev=6592;; |
|---|
| 509 | "orch2.2") fcm_veget_version=orchidee2.1; orcbranch="ORCHIDEE_2_2" ;; # the bundled version |
|---|
| 510 | *) fetch_rev=$veget |
|---|
| 511 | esac |
|---|
| 512 | |
|---|
| 513 | if [[ -n $fetch_rev ]]; then |
|---|
| 514 | echo "Fetching orch $fetch_rev from the repository" |
|---|
| 515 | orcbranch=$(svn log -v -q svn://forge.ipsl.jussieu.fr/orchidee/ -r "$fetch_rev" |grep ORCHIDEE |head -1| sed -e 's:ORCHIDEE/.*$:ORCHIDEE:' | awk '{print $2}') |
|---|
| 516 | echo "branch is $orcbranch" |
|---|
| 517 | if [[ $fetch_rev -lt 4465 ]]; then echo 'ORCHIDEE version must be >=4465, exiting'; exit 1; fi |
|---|
| 518 | \rm -rf "$MODEL/modipsl/modeles/ORCHIDEE" |
|---|
| 519 | echo "IF YOU INSTALL ORCHIDEE THE VERY FIRST TIME, ASK for PASSWORD at orchidee-help@listes.ipsl.fr" |
|---|
| 520 | cd "$MODEL/modipsl/modeles" |
|---|
| 521 | set +e |
|---|
| 522 | svn co -r "$fetch_rev" "svn://forge.ipsl.jussieu.fr/orchidee/$orcbranch" |
|---|
| 523 | set -e |
|---|
| 524 | cd - |
|---|
| 525 | fi |
|---|
| 526 | } |
|---|
| 527 | |
|---|
| 528 | function compile_orchidee { |
|---|
| 529 | get_orchidee_version |
|---|
| 530 | install_arch "ORCHIDEE" |
|---|
| 531 | |
|---|
| 532 | if [[ $veget != "none" ]]; then |
|---|
| 533 | cd "$MODEL/modipsl/modeles/ORCHIDEE" |
|---|
| 534 | |
|---|
| 535 | orchideelog="$(pwd)/orchidee.log" |
|---|
| 536 | echo "Compiling ORCHIDEE, the continental surface model (log $orchideelog) $(date)" |
|---|
| 537 | |
|---|
| 538 | local xios_orchid opt_orc |
|---|
| 539 | if [[ $with_xios = 1 ]]; then |
|---|
| 540 | xios_orchid="-xios"; |
|---|
| 541 | else |
|---|
| 542 | xios_orchid="-noxios" |
|---|
| 543 | fi |
|---|
| 544 | if [[ $optim_debug = "-debug" ]]; then |
|---|
| 545 | opt_orc="-debug"; |
|---|
| 546 | else |
|---|
| 547 | opt_orc="-prod" |
|---|
| 548 | fi |
|---|
| 549 | |
|---|
| 550 | local varenv="IOIPSL_LIBDIR_=$IOIPSL_LIBDIR_ IOIPSL_INCDIR_=$IOIPSL_INCDIR_ XIOS_INCDIR_=$XIOS_INCDIR_ XIOS_LIBDIR_=$XIOS_LIBDIR_" |
|---|
| 551 | if [[ $parallel = "none" ]]; then |
|---|
| 552 | echo "$varenv ./makeorchidee_fcm $xios_orchid $opt_orc -parallel none -arch $arch -j $make_j" > compile.sh |
|---|
| 553 | else |
|---|
| 554 | if [[ ! -d src_parallel ]]; then |
|---|
| 555 | echo "Orchidee version too old for parallel support"; exit 1 |
|---|
| 556 | fi |
|---|
| 557 | { |
|---|
| 558 | echo "$varenv ./makeorchidee_fcm -j $make_j -clean $xios_orchid $opt_orc -parallel $parallel -arch $arch" |
|---|
| 559 | echo "$varenv ./makeorchidee_fcm -j $make_j $xios_orchid $opt_orc -parallel $parallel -arch $arch" |
|---|
| 560 | } > compile.sh |
|---|
| 561 | fi |
|---|
| 562 | chmod +x compile.sh |
|---|
| 563 | echo "Compiling ORCHIDEE using $(\cat compile.sh)" |
|---|
| 564 | if ! ./compile.sh > "$orchideelog" 2>&1; then |
|---|
| 565 | echo "ORCHIDEE compilation failed, exiting"; exit 1 |
|---|
| 566 | fi |
|---|
| 567 | echo "Compiled ORCHIDEE $(date)" |
|---|
| 568 | fi |
|---|
| 569 | |
|---|
| 570 | ORCH_INCDIR_="$MODEL/modipsl/modeles/ORCHIDEE/inc" |
|---|
| 571 | ORCH_LIBDIR_="$MODEL/modipsl/modeles/ORCHIDEE/lib" |
|---|
| 572 | } |
|---|
| 573 | |
|---|
| 574 | function get_lmdz_version { |
|---|
| 575 | LMDZPATH=$(readlink -f "$MODEL/modipsl/modeles/LMD"*) |
|---|
| 576 | cd "$LMDZPATH" |
|---|
| 577 | lmdzlog="$(pwd)/lmdz.log" |
|---|
| 578 | |
|---|
| 579 | set +e |
|---|
| 580 | svn upgrade |
|---|
| 581 | if [[ $svn = "last" ]]; then |
|---|
| 582 | svnopt="" |
|---|
| 583 | else |
|---|
| 584 | svnopt="-r $svn" |
|---|
| 585 | fi |
|---|
| 586 | if [[ $svn != "" ]]; then |
|---|
| 587 | if svn info | grep -q 'https:'; then svn switch --relocate https://svn.lmd.jussieu.fr/LMDZ http://svn.lmd.jussieu.fr/LMDZ; fi |
|---|
| 588 | svn update "$svnopt" |
|---|
| 589 | fi |
|---|
| 590 | mysvn=$(svnversion . | grep -E -o "[0-9]+" 2>/dev/null) |
|---|
| 591 | set -e |
|---|
| 592 | |
|---|
| 593 | if [[ $mysvn = "" ]]; then mysvn=$(grep 'Revision: [0-9]' "$MODEL"/Read*.md | awk ' { print $2 } ' 2>/dev/null); fi |
|---|
| 594 | if [[ $mysvn = "" ]]; then mysvn=4190; fi |
|---|
| 595 | } |
|---|
| 596 | |
|---|
| 597 | function compile_lmdz { |
|---|
| 598 | get_lmdz_version |
|---|
| 599 | install_arch "LMDZ" |
|---|
| 600 | |
|---|
| 601 | exe_name="bin/gcm_${grid_resolution}_phylmd_${rad}${suff_exe}${suff_orc}.e" |
|---|
| 602 | |
|---|
| 603 | local opt_rad |
|---|
| 604 | case $rad in |
|---|
| 605 | oldrad) iflag_rrtm=0; NSW=2; opt_rad="";; |
|---|
| 606 | rrtm) iflag_rrtm=1; NSW=6 |
|---|
| 607 | if [[ $mysvn -le 4185 ]]; then |
|---|
| 608 | opt_rad="-rrtm true" |
|---|
| 609 | else |
|---|
| 610 | opt_rad="-rad rrtm" |
|---|
| 611 | fi;; |
|---|
| 612 | ecrad) iflag_rrtm=2; NSW=6; opt_rad="-rad ecrad";; |
|---|
| 613 | *) echo "Only oldrad rrtm ecrad for rad option"; exit 1 |
|---|
| 614 | esac |
|---|
| 615 | if [[ $mysvn -le 4185 && $rad = "ecrad" ]]; then |
|---|
| 616 | echo "ecrad only available for LMDZ rev starting with 4186 "; exit 1 |
|---|
| 617 | fi |
|---|
| 618 | |
|---|
| 619 | # Compile |
|---|
| 620 | local varenv="IOIPSL_LIBDIR_=\"$IOIPSL_LIBDIR_\" IOIPSL_INCDIR_=\"$IOIPSL_INCDIR_\" ORCH_INCDIR_=\"$ORCH_INCDIR_\" ORCH_LIBDIR_=\"$ORCH_LIBDIR_\" XIOS_INCDIR_=\"$XIOS_INCDIR_\" XIOS_LIBDIR_=\"$XIOS_LIBDIR_\"" |
|---|
| 621 | makelmdz="makelmdz_fcm $optim_debug -arch $arch -j $make_j" |
|---|
| 622 | if [[ $parallel = "none" ]]; then |
|---|
| 623 | echo "$varenv ./$makelmdz $opt_rad $opt_cosp -d ${grid_resolution} -v $fcm_veget_version gcm " > compile.sh |
|---|
| 624 | else |
|---|
| 625 | echo "$varenv ./$makelmdz $opt_rad $opt_cosp $opt_makelmdz_xios -d ${grid_resolution} -v $fcm_veget_version -mem -parallel $parallel gcm" > compile.sh |
|---|
| 626 | fi |
|---|
| 627 | echo "Compiling lmdz using $(\cat compile.sh) (log: $lmdzlog) $(date)" |
|---|
| 628 | chmod +x ./compile.sh |
|---|
| 629 | if ! ./compile.sh > "$lmdzlog" 2>&1; then |
|---|
| 630 | echo "LMDZ compilation failed, exiting"; exit 1 |
|---|
| 631 | fi |
|---|
| 632 | echo "Finished LMDZ compilation $(date)" |
|---|
| 633 | |
|---|
| 634 | # Check executable |
|---|
| 635 | # TODO $mysev -ge 4186 => other name convention ! check original install |
|---|
| 636 | if [[ ! -f $exe_name ]]; then |
|---|
| 637 | echo "Compilation failed, can't find the executable"; exit 1 |
|---|
| 638 | else |
|---|
| 639 | echo "Compilation successfull, the executable is $exe_name $(date)" |
|---|
| 640 | fi |
|---|
| 641 | } |
|---|
| 642 | |
|---|
| 643 | function run_bench { |
|---|
| 644 | cd "$MODEL/modipsl/modeles/LMDZ"* |
|---|
| 645 | |
|---|
| 646 | if [[ $bench = "tuto" ]]; then |
|---|
| 647 | myget "Training/tutorial.tar"; tar xf tutorial.tar; cd TUTORIAL |
|---|
| 648 | ./init.sh |
|---|
| 649 | elif [[ $bench = 1 ]]; then |
|---|
| 650 | \rm -rf "BENCH${grid_resolution}" |
|---|
| 651 | local bench=bench_lmdz_${grid_resolution} |
|---|
| 652 | myget "3DBenchs/$bench.tar.gz" |
|---|
| 653 | tar xf "$bench.tar.gz" |
|---|
| 654 | |
|---|
| 655 | if [[ $cosp = "v1" || $cosp = "v2" ]]; then |
|---|
| 656 | cd "BENCH${grid_resolution}" |
|---|
| 657 | # copier les fichiers namelist input et output our COSP |
|---|
| 658 | cp ../DefLists/cosp*_input_nl.txt . |
|---|
| 659 | cp ../DefLists/cosp*_output_nl.txt . |
|---|
| 660 | # Activer la cles ok_cosp pour tourner avec COSP |
|---|
| 661 | sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp |
|---|
| 662 | \mv -f tmp config.def |
|---|
| 663 | cd .. |
|---|
| 664 | fi |
|---|
| 665 | |
|---|
| 666 | if [[ -n "$physiq" ]]; then |
|---|
| 667 | cd "BENCH${grid_resolution}" |
|---|
| 668 | if [[ -f "physiq.def_${physiq}" ]]; then |
|---|
| 669 | cp "physiq.def_${physiq}" physiq.def |
|---|
| 670 | echo "using physiq.def_${physiq}" |
|---|
| 671 | else |
|---|
| 672 | echo "using standard physiq.def" |
|---|
| 673 | fi |
|---|
| 674 | cd .. |
|---|
| 675 | else |
|---|
| 676 | echo "using standard physiq.def" |
|---|
| 677 | fi |
|---|
| 678 | |
|---|
| 679 | if [[ $with_xios = 1 ]]; then |
|---|
| 680 | cd "BENCH${grid_resolution}" |
|---|
| 681 | cp ../DefLists/iodef.xml . |
|---|
| 682 | cp ../DefLists/context_lmdz.xml . |
|---|
| 683 | cp ../DefLists/field_def_lmdz.xml . |
|---|
| 684 | # A raffiner par la suite |
|---|
| 685 | echo "A FAIRE : Copier les *xml en fonction de l option cosp" |
|---|
| 686 | cp ../DefLists/field_def_cosp*.xml . |
|---|
| 687 | cp ../DefLists/file_def_hist*xml . |
|---|
| 688 | # adapt iodef.xml to use attached mode |
|---|
| 689 | sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' \ |
|---|
| 690 | iodef.xml > tmp |
|---|
| 691 | \mv -f tmp iodef.xml |
|---|
| 692 | |
|---|
| 693 | # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE. |
|---|
| 694 | # except for histday |
|---|
| 695 | for histfile in file_def_hist*xml |
|---|
| 696 | do |
|---|
| 697 | if [[ "$histfile" = "file_def_histday_lmdz.xml" ]]; then |
|---|
| 698 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' \ |
|---|
| 699 | "$histfile" > tmp |
|---|
| 700 | \mv -f tmp "$histfile" |
|---|
| 701 | sed -e 's@output_level="_AUTO_"@output_level="5"@' "$histfile" \ |
|---|
| 702 | > tmp |
|---|
| 703 | \mv -f tmp "$histfile" |
|---|
| 704 | sed -e 's@compression_level="2"@compression_level="0"@' \ |
|---|
| 705 | "$histfile" > tmp |
|---|
| 706 | \mv -f tmp "$histfile" |
|---|
| 707 | else |
|---|
| 708 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' \ |
|---|
| 709 | "$histfile" > tmp |
|---|
| 710 | \mv -f tmp "$histfile" |
|---|
| 711 | fi |
|---|
| 712 | done |
|---|
| 713 | # and add option "ok_all_xml=y" in config.def |
|---|
| 714 | echo "### XIOS outputs" >> config.def |
|---|
| 715 | echo 'ok_all_xml=.true.' >> config.def |
|---|
| 716 | |
|---|
| 717 | #activer les sorties pour Cosp |
|---|
| 718 | if [[ "$cosp" = "v1" ]]; then |
|---|
| 719 | sed -i'' -e 's@enabled=".FALSE."@enabled=".TRUE."@' \ |
|---|
| 720 | -e 's@output_level="_AUTO_"@output_level="5"@' \ |
|---|
| 721 | -e 's@compression_level="2"@compression_level="0"@' \ |
|---|
| 722 | file_def_histdayCOSP_lmdz.xml |
|---|
| 723 | fi |
|---|
| 724 | if [[ "$cosp" = "v2" ]]; then |
|---|
| 725 | sed -e 's@compression_level="2"@compression_level="0"@' file_def_histdayCOSPv2_lmdz.xml |
|---|
| 726 | for type_ in hf day mth; do |
|---|
| 727 | file=file_def_hist${type_}COSP |
|---|
| 728 | sed -i'' -e 's@src="./'${file}'_lmdz.xml"@src="./'${file}'v2_lmdz.xml"@' context_lmdz.xml |
|---|
| 729 | done |
|---|
| 730 | sed -i '' -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' field_def_lmdz.xml |
|---|
| 731 | fi |
|---|
| 732 | |
|---|
| 733 | cd .. |
|---|
| 734 | fi |
|---|
| 735 | |
|---|
| 736 | # Cas Bench avec ecrad |
|---|
| 737 | if [[ $rad = "ecrad" ]]; then |
|---|
| 738 | cd "BENCH${grid_resolution}" |
|---|
| 739 | cp ../DefLists/namelist_ecrad . |
|---|
| 740 | cp -r ../libf/phylmd/ecrad/data . |
|---|
| 741 | cd .. |
|---|
| 742 | fi |
|---|
| 743 | |
|---|
| 744 | # Adjusting bench physiq.def to radiative code chosen |
|---|
| 745 | cd "BENCH${grid_resolution}" |
|---|
| 746 | sed -e 's/iflag_rrtm=.*.$/iflag_rrtm='$iflag_rrtm'/' \ |
|---|
| 747 | -e 's/NSW=.*.$/NSW='$NSW'/' physiq.def > tmpdef |
|---|
| 748 | \mv tmpdef physiq.def |
|---|
| 749 | cd .. |
|---|
| 750 | |
|---|
| 751 | cp "$exe_name" "BENCH${grid_resolution}/gcm.e" |
|---|
| 752 | cd "BENCH${grid_resolution}" |
|---|
| 753 | |
|---|
| 754 | if [[ ${parallel:0:3} = "mpi" ]]; then |
|---|
| 755 | # Lancement avec deux procs mpi et 2 openMP |
|---|
| 756 | echo "export OMP_STACKSIZE=800M" > bench.sh |
|---|
| 757 | if [[ "${parallel:4:3}" = "omp" ]]; then |
|---|
| 758 | echo "export OMP_NUM_THREADS=2" >> bench.sh |
|---|
| 759 | fi |
|---|
| 760 | if [[ "$cosp" = "v1" || "$cosp" = "v2" ]]; then |
|---|
| 761 | echo "ulimit -s 200000" >> bench.sh |
|---|
| 762 | else |
|---|
| 763 | echo "ulimit -s unlimited" >> bench.sh |
|---|
| 764 | fi |
|---|
| 765 | echo "mpirun -np 2 gcm.e > listing 2>&1" >> bench.sh |
|---|
| 766 | # Add rebuild, using reb.sh if it is there |
|---|
| 767 | cat <<EOF >> bench.sh |
|---|
| 768 | if [[ -f reb.sh ]]; then |
|---|
| 769 | ./reb.sh histday; ./reb.sh histmth; ./reb.sh histhf; |
|---|
| 770 | ./reb.sh histins; ./reb.sh stomate_history; |
|---|
| 771 | ./reb.sh sechiba_history; ./reb.sh sechiba_out_2 |
|---|
| 772 | fi |
|---|
| 773 | EOF |
|---|
| 774 | else |
|---|
| 775 | echo "./gcm.e > listing 2>&1" > bench.sh |
|---|
| 776 | fi |
|---|
| 777 | # Getting orchidee stuff |
|---|
| 778 | if [[ $veget = 'CMIP6' ]]; then |
|---|
| 779 | echo 'myget 3DBenchs/BENCHCMIP6.tar.gz' |
|---|
| 780 | myget 3DBenchs/BENCHCMIP6.tar.gz |
|---|
| 781 | tar xvzf BENCHCMIP6.tar.gz |
|---|
| 782 | sed -e "s:VEGET=n:VEGET=y:" config.def > tmp |
|---|
| 783 | mv -f tmp config.def |
|---|
| 784 | if [[ $with_xios = 1 ]]; then |
|---|
| 785 | cp ../../ORCHIDEE/src_xml/context_orchidee.xml . |
|---|
| 786 | echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp |
|---|
| 787 | cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml . |
|---|
| 788 | cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml . |
|---|
| 789 | cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml . |
|---|
| 790 | if [[ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ]]; then |
|---|
| 791 | cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml . |
|---|
| 792 | echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp |
|---|
| 793 | fi |
|---|
| 794 | sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp |
|---|
| 795 | mv tmp iodef.xml |
|---|
| 796 | sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' \ |
|---|
| 797 | file_def_orchidee.xml > tmp |
|---|
| 798 | \mv -f tmp file_def_orchidee.xml |
|---|
| 799 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' \ |
|---|
| 800 | file_def_orchidee.xml > tmp |
|---|
| 801 | \mv -f tmp file_def_orchidee.xml |
|---|
| 802 | sed -e 's@output_level="_AUTO_"@output_level="1"@' \ |
|---|
| 803 | file_def_orchidee.xml > tmp |
|---|
| 804 | \mv -f tmp file_def_orchidee.xml |
|---|
| 805 | sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' \ |
|---|
| 806 | file_def_orchidee.xml > tmp |
|---|
| 807 | \mv -f tmp file_def_orchidee.xml |
|---|
| 808 | sed -e 's@compression_level="4"@compression_level="0"@' \ |
|---|
| 809 | file_def_orchidee.xml > tmp |
|---|
| 810 | \mv -f tmp file_def_orchidee.xml |
|---|
| 811 | sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' \ |
|---|
| 812 | orchidee.def > tmp |
|---|
| 813 | \mv -f tmp orchidee.def |
|---|
| 814 | fi |
|---|
| 815 | fi |
|---|
| 816 | |
|---|
| 817 | if [[ -f ../arch.env ]]; then source ../arch.env; fi |
|---|
| 818 | |
|---|
| 819 | echo "EXECUTION DU BENCH" |
|---|
| 820 | date |
|---|
| 821 | if (! ./bench.sh > out.bench 2>&1) || ! (tail -n 1 listing | grep "Everything is cool"); then |
|---|
| 822 | tail listing |
|---|
| 823 | echo "Bench FAILED, exiting"; exit 1 |
|---|
| 824 | fi |
|---|
| 825 | date |
|---|
| 826 | tail listing |
|---|
| 827 | fi |
|---|
| 828 | |
|---|
| 829 | # 1D case |
|---|
| 830 | if [[ $SCM = 1 ]]; then |
|---|
| 831 | cd "$MODEL" |
|---|
| 832 | myget 1D/1D.tar.gz |
|---|
| 833 | tar xf 1D.tar.gz |
|---|
| 834 | cd 1D |
|---|
| 835 | if [[ $rad = "oldrad" ]]; then |
|---|
| 836 | sed -i'' -e 's/^rad=.*$/rad=oldrad/' run.sh |
|---|
| 837 | sed -i'' -e 's/^rad=.*$/rad=oldrad/' bin/compile |
|---|
| 838 | fi |
|---|
| 839 | echo "Running 1D/run.sh, log in $(pwd)/run1d.log" |
|---|
| 840 | ./run.sh > "$(pwd)/run1d.log" 2>&1 |
|---|
| 841 | fi |
|---|
| 842 | } |
|---|
| 843 | |
|---|
| 844 | echo "install_lmdz.sh DEBUT $(date)" |
|---|
| 845 | |
|---|
| 846 | set_default_params |
|---|
| 847 | read_cmdline_args "$@" |
|---|
| 848 | #download_model |
|---|
| 849 | download_model_AMAURY |
|---|
| 850 | init_arch |
|---|
| 851 | check_available_software |
|---|
| 852 | install_netcdf |
|---|
| 853 | install_IOIPSL |
|---|
| 854 | install_XIOS |
|---|
| 855 | compile_orchidee |
|---|
| 856 | compile_lmdz |
|---|
| 857 | run_bench |
|---|