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