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