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