[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 | # |
---|
| 28 | # Prerequisites : pgf90/gfortran, bash or ksh, wget , gunzip, tar, ... |
---|
| 29 | # |
---|
| 30 | # Modif 18/11/2011 |
---|
| 31 | # changes for option real 8. |
---|
| 32 | # We compile with -r8 (or equivalent) and -DNC_DOUBLE for the GCM |
---|
| 33 | # but with -r4 for netcdf. Variable real must be set to |
---|
| 34 | # r4 or r8 at the beginning of the script below. |
---|
| 35 | # |
---|
| 36 | ########################################################################### |
---|
| 37 | |
---|
[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 |
---|
[4210] | 52 | |
---|
[4862] | 53 | # 04_2021 : tester si r4 marche encore ! |
---|
| 54 | real="r8" # ou "r4" |
---|
[4210] | 55 | |
---|
[4862] | 56 | svn="" |
---|
| 57 | version="20231022.trunk" |
---|
[4210] | 58 | |
---|
[4862] | 59 | netcdf=1 # 1: for automatic installation; |
---|
| 60 | # or 0: do not install NetCDF and look for it in standard locations; |
---|
| 61 | # or absolute path: look for NetCDF there |
---|
| 62 | bench=1 |
---|
| 63 | pclinux=1 |
---|
| 64 | pcmac=0 # default: not on a Mac |
---|
| 65 | SCM=0 |
---|
| 66 | # surface/vegetation scheme treatment |
---|
| 67 | # controlled by the single variable veget which can have the following values |
---|
[4890] | 68 | # - none: bucket scheme (default) |
---|
[4862] | 69 | # - CMIP6: orchidee version used in CMIP exercise, rev 5661 |
---|
| 70 | # - number: orchidee version number |
---|
[4890] | 71 | veget="none" |
---|
[4862] | 72 | # choose the resolution for the bench runs |
---|
| 73 | # grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE) |
---|
| 74 | # 96x71x19 standard configuration |
---|
| 75 | grid_resolution="32x32x39" # "48x36x19", "96x95x39", "144x142x79" |
---|
| 76 | # choose the physiq version you want to test |
---|
| 77 | #physiq=NPv6.0.14splith |
---|
| 78 | physiq="" |
---|
[4210] | 79 | |
---|
[4873] | 80 | xios_branch="2.6" |
---|
| 81 | xios_rev="2568" |
---|
| 82 | |
---|
[4862] | 83 | ## parallel can take the values none/mpi/omp/mpi_omp |
---|
| 84 | parallel="none" # "mpi_omp" |
---|
| 85 | idris_acct="lmd" |
---|
| 86 | trusting="testing" |
---|
| 87 | MODEL="" |
---|
[4210] | 88 | |
---|
[4862] | 89 | ## also compile XIOS? (and more recent NetCDF/HDF5 libraries) Default=no |
---|
| 90 | with_xios="n" |
---|
| 91 | opt_makelmdz_xios="" |
---|
[4210] | 92 | |
---|
[4862] | 93 | ## compile with oldrad/rrtm/ecrad radiatif code (Default=rrtm) |
---|
| 94 | rad="rrtm" |
---|
[4210] | 95 | |
---|
[4862] | 96 | ## compile_with_fcm=1 : use makelmdz_fcm (1) or makelmdz (0) |
---|
| 97 | compile_with_fcm=1 |
---|
[4210] | 98 | |
---|
[4890] | 99 | #Compilation with Cosp (cosp=none/v1/v2; default=none) |
---|
| 100 | cosp="none" |
---|
[4862] | 101 | opt_cosp="" |
---|
[4210] | 102 | |
---|
[4862] | 103 | # Check if on a Mac |
---|
| 104 | if [[ $(uname) = "Darwin" ]]; then |
---|
| 105 | pcmac=1 |
---|
| 106 | export MAKE="make" |
---|
| 107 | fi |
---|
[4210] | 108 | |
---|
[4862] | 109 | env_file="" |
---|
[4873] | 110 | optim_debug="" |
---|
[4862] | 111 | arch="local" |
---|
[4210] | 112 | |
---|
[4862] | 113 | local mpi_file |
---|
| 114 | mpi_file=$(readlink -f "$(which mpif90)") |
---|
| 115 | path_mpi=$(dirname "$mpi_file") |
---|
| 116 | root_mpi=$(dirname "$path_mpi") |
---|
[4873] | 117 | |
---|
| 118 | arch="local-gfortran" |
---|
| 119 | arch_dir="" |
---|
[4862] | 120 | } |
---|
[4210] | 121 | |
---|
[4862] | 122 | function read_cmdline_args { |
---|
| 123 | while (($# > 0)); do |
---|
| 124 | case $1 in |
---|
| 125 | "-h") cat <<........fin |
---|
| 126 | $0 [ -v version ] [ -r svn_release ] |
---|
| 127 | [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ] |
---|
| 128 | [-name LOCAL_MODEL_NAME] [-gprof] [-opt_makelmdz] [-rad RADIATIF] |
---|
[4210] | 129 | |
---|
[4873] | 130 | -v "version" like 20150828.trunk, see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk (default <$version>) |
---|
[4210] | 131 | |
---|
[4873] | 132 | -r "svn_release" : either the svn release number or "last" (default <$svn>) |
---|
[4210] | 133 | |
---|
[4873] | 134 | -parallel parallel support: mpi, omp, mpi_omp (mpi with openMP) or none (default: <$parallel>) |
---|
[4210] | 135 | |
---|
[4873] | 136 | -d "grid resolution": should be among the available benchs if -bench 1 (valid values: 48x36x19, 48x36x39) (default : <$grid_resolution>) |
---|
[4210] | 137 | |
---|
[4873] | 138 | -bench activating the bench or not (0/1) (default: <$bench>) |
---|
[4210] | 139 | |
---|
[4862] | 140 | -testing/unstable |
---|
[4210] | 141 | |
---|
[4873] | 142 | -name name of the folder to install to (default <$MODEL>) |
---|
[4210] | 143 | |
---|
[4873] | 144 | -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] | 145 | |
---|
[4873] | 146 | -xios use (download and compile) the XIOS library (will compile the parallel NetCDF4-HDF5 library) (requires to also have -parallel mpi_omp) |
---|
[4210] | 147 | |
---|
[4873] | 148 | -cosp to run with cospv1 or cospv2 [none/v1/v2] (default <$cosp>) |
---|
[4210] | 149 | |
---|
[4873] | 150 | -rad radiative code: oldrad, rrtm or ecrad (default <$rad>) |
---|
[4210] | 151 | |
---|
[4873] | 152 | -nofcm to compile without fcm |
---|
[4210] | 153 | |
---|
[4862] | 154 | -SCM install 1D version automatically |
---|
[4210] | 155 | |
---|
[4862] | 156 | -debug compile everything in debug mode |
---|
[4210] | 157 | |
---|
[4873] | 158 | -physiq to choose which physics package to use (default <$physiq>) |
---|
[4210] | 159 | |
---|
[4873] | 160 | -veget surface/vegetation scheme treatment controlled by the single variable veget which can have the following values: none: bucket scheme (default); CMIP6: orchidee version used in CMIP exercise, rev 5661; number: orchidee version number (default $veget) |
---|
[4210] | 161 | |
---|
[4873] | 162 | -arch name of the arch to use (default <$arch>) |
---|
[4210] | 163 | |
---|
[4873] | 164 | -arch_dir where to find the arch files (default <$arch_dir>) |
---|
[4862] | 165 | |
---|
[4210] | 166 | ........fin |
---|
[4862] | 167 | exit 1;; |
---|
| 168 | "-v") version=$2; shift; shift;; |
---|
| 169 | "-r") svn=$2; shift; shift;; |
---|
| 170 | "-d") grid_resolution=$2; shift; shift;; |
---|
[4873] | 171 | "-unstable"|"-testing") trusting=$(echo "$1" | cut -c2-); shift;; |
---|
[4862] | 172 | "-cosp") cosp=$2 |
---|
| 173 | case $cosp in |
---|
| 174 | "none"|"v1"|"v2") cosp=$2; shift; shift;; |
---|
| 175 | *) echo "Only none v1 v2 for cosp option"; exit 1 |
---|
[4849] | 176 | esac;; |
---|
[4862] | 177 | "-nofcm") compile_with_fcm=0; echo "This option will be reactivated soon (promesse du 8dec2022)"; exit 1; shift;; |
---|
| 178 | "-SCM") SCM=1; shift;; |
---|
| 179 | "-rad") rad=$2 |
---|
| 180 | case $rad in |
---|
| 181 | "oldrad"|"rrtm"|"ecrad") rad=$2; shift; shift;; |
---|
| 182 | *) echo "Only oldrad rrtm ecrad for rad option"; exit 1 |
---|
| 183 | esac;; |
---|
| 184 | "-parallel") parallel=$2 |
---|
| 185 | case $parallel in |
---|
| 186 | "none"|"mpi"|"omp"|"mpi_omp") parallel=$2; shift; shift;; |
---|
| 187 | *) echo "Only none mpi omp mpi_omp for the parallel option"; exit 1 |
---|
| 188 | esac;; |
---|
| 189 | "-bench") bench=$2; shift; shift;; |
---|
[4873] | 190 | "-debug") optim_debug=-debug; shift;; |
---|
[4862] | 191 | "-name") MODEL=$2; shift; shift;; |
---|
| 192 | "-netcdf") netcdf=$2; shift; shift;; |
---|
| 193 | "-physiq") physiq=$2; shift; shift;; |
---|
| 194 | "-xios") with_xios="y"; shift;; |
---|
[4873] | 195 | "-arch") arch=$2; shift; shift;; |
---|
| 196 | "-arch_dir") arch_dir=$2; shift; shift;; |
---|
[4862] | 197 | "-veget") veget=$2; shift; shift;; |
---|
| 198 | *) bash install_lmdz.sh -h; exit 1 |
---|
| 199 | esac |
---|
| 200 | done |
---|
| 201 | |
---|
| 202 | # Option de compilation pour Cosp |
---|
| 203 | case $cosp in |
---|
| 204 | v1) opt_cosp="-cosp true";; |
---|
| 205 | v2) opt_cosp="-cospv2 true";; |
---|
| 206 | *) opt_cosp="" |
---|
[4215] | 207 | esac |
---|
[4210] | 208 | |
---|
[4862] | 209 | # Check on veget version |
---|
[4890] | 210 | if [[ $veget != 'none' && $veget != "CMIP6" ]]; then |
---|
[4862] | 211 | re='^[0-9]+$' |
---|
| 212 | if ! [[ $veget =~ $re ]]; then |
---|
| 213 | echo 'Valeur de l option veget non valable'; exit 1 |
---|
| 214 | fi |
---|
| 215 | fi |
---|
[4218] | 216 | |
---|
[4862] | 217 | #Define veget-related suffix for gcm name |
---|
[4890] | 218 | if [[ $veget = 'none' ]]; then |
---|
[4862] | 219 | suff_orc='' |
---|
| 220 | #For use with tutorial, orchidee_rev is also defined (will be |
---|
| 221 | #written in surface_env at the end of the script) |
---|
| 222 | orchidee_rev='' |
---|
| 223 | else |
---|
| 224 | suff_orc='_orch' |
---|
| 225 | fi |
---|
[4210] | 226 | |
---|
[4807] | 227 | |
---|
[4862] | 228 | if [[ $parallel = "none" ]]; then |
---|
| 229 | sequential=1; suff_exe='_seq' |
---|
| 230 | else |
---|
| 231 | sequential=0; suff_exe='_para_mem' |
---|
[4210] | 232 | fi |
---|
| 233 | |
---|
[4862] | 234 | #Chemin pour placer le modele |
---|
[4873] | 235 | if [[ $MODEL = "" ]]; then MODEL="./LMDZ$version$svn$optim_debug"; fi |
---|
[4210] | 236 | |
---|
[4862] | 237 | ## if also compiling XIOS, parallel must be mpi_omp |
---|
| 238 | if [[ $with_xios = "y" && $parallel != "mpi_omp" ]]; then |
---|
| 239 | echo "Error, you must set -parallel mpi_omp if you want XIOS"; exit 1 |
---|
| 240 | fi |
---|
[4210] | 241 | |
---|
[4862] | 242 | if [[ $with_xios = "y" ]]; then |
---|
| 243 | opt_makelmdz_xios="-io xios" |
---|
| 244 | fi |
---|
[4210] | 245 | |
---|
[4862] | 246 | if [[ $cosp = "v2" && $with_xios = "n" ]]; then |
---|
| 247 | echo "Error, Cospv2 cannot run without Xios"; exit 1 |
---|
[4215] | 248 | fi |
---|
[4873] | 249 | |
---|
| 250 | if [[ $arch_dir = "" ]]; then |
---|
| 251 | arch_dir="$MODEL/modipsl/config/IPSLCM7/ARCH/" |
---|
| 252 | fi |
---|
| 253 | arch_dir=$(readlink -f "$arch_dir") # full path |
---|
[4862] | 254 | } |
---|
[4210] | 255 | |
---|
[4862] | 256 | function check_available_software { |
---|
[4873] | 257 | echo "################################################################" |
---|
| 258 | echo "Check if required software is available" |
---|
| 259 | echo "################################################################" |
---|
| 260 | for logiciel in wget tar gzip make gcc cmake m4 c++; do |
---|
| 261 | if [[ $(which "$logiciel") = "" ]]; then |
---|
| 262 | echo "You must first install $logiciel on your system"; exit 1 |
---|
| 263 | fi |
---|
| 264 | done |
---|
[4210] | 265 | |
---|
[4873] | 266 | cat <<eod > tt.f90 |
---|
| 267 | print*,'coucou' |
---|
| 268 | end |
---|
[4862] | 269 | eod |
---|
[4873] | 270 | $compiler tt.f90 || a.out |
---|
| 271 | ./a.out >| tt |
---|
| 272 | if [[ $(< tt sed -e 's/ //g' ) != "coucou" ]]; then |
---|
| 273 | echo "problem installing with compiler $compiler"; exit 1 |
---|
[4218] | 274 | fi |
---|
[4873] | 275 | \rm tt a.out tt.f90 |
---|
[4862] | 276 | } |
---|
[4210] | 277 | |
---|
[4862] | 278 | function download_model { |
---|
| 279 | mkdir -p "$MODEL" |
---|
| 280 | MODEL=$(readlink -f "$MODEL"); echo "$MODEL" # absolute path |
---|
[4210] | 281 | |
---|
[4873] | 282 | rm -rf "$MODEL/modipsl" |
---|
| 283 | |
---|
| 284 | echo "##########################################################" |
---|
| 285 | echo "Download a slightly modified version of LMDZ" |
---|
| 286 | echo "##########################################################" |
---|
| 287 | cd "$MODEL" |
---|
| 288 | getlog="$(pwd)/get.log" |
---|
| 289 | echo "logfile : $getlog" |
---|
| 290 | myget "src_archives/$trusting/modipsl.$version.tar.gz" >> get.log 2>&1 |
---|
| 291 | echo "install_lmdz.sh wget_OK $(date)" |
---|
| 292 | gunzip "modipsl.$version.tar.gz" >> get.log 2>&1 |
---|
| 293 | tar xf "modipsl.$version.tar" >> get.log 2>&1 |
---|
| 294 | \rm "modipsl.$version.tar" |
---|
| 295 | |
---|
| 296 | if [[ $svn != "" ]]; then |
---|
| 297 | mysvn=$svn |
---|
| 298 | else |
---|
| 299 | mysvn="$(grep 'Revision: [0-9]' "$MODEL"/Read*.md | awk ' { print $2 } ' 2>/dev/null)" |
---|
[4218] | 300 | fi |
---|
[4873] | 301 | echo "SVN revision used: $mysvn" |
---|
| 302 | } |
---|
[4871] | 303 | |
---|
[4890] | 304 | function download_model_AMAURY { # TODO |
---|
[4873] | 305 | MODEL=$(readlink -f "$MODEL"); echo "$MODEL" # absolute path |
---|
| 306 | |
---|
[4871] | 307 | if [[ $svn != "" ]]; then |
---|
| 308 | mysvn=$svn |
---|
| 309 | else |
---|
| 310 | mysvn="$(grep 'Revision: [0-9]' "$MODEL"/Read*.md | awk ' { print $2 } ' 2>/dev/null)" |
---|
| 311 | fi |
---|
| 312 | echo "SVN revision used: $mysvn" |
---|
[4862] | 313 | } |
---|
[4210] | 314 | |
---|
[4890] | 315 | function install_arch { |
---|
[4873] | 316 | # TODO if [[ $(gfortran -dumpversion | cut -d. -f1) -ge 10 ]]; then allow_arg_mismatch="-fallow-argument-mismatch"; fi |
---|
[4871] | 317 | |
---|
[4873] | 318 | if [[ ! -d $arch_dir ]]; then |
---|
| 319 | echo "Error: no arch dir $arch_dir"; exit 1 |
---|
| 320 | elif [[ ! -f $arch_dir/arch-$arch.path ]]; then |
---|
| 321 | echo "Error: no arch-$arch.path in $arch_dir"; exit 1 |
---|
| 322 | fi |
---|
[4871] | 323 | |
---|
[4873] | 324 | local fcm_path |
---|
| 325 | if [[ -f $arch_dir/arch-$arch.fcm ]]; then |
---|
| 326 | fcm_path="$arch_dir/arch-$arch.fcm" |
---|
| 327 | else |
---|
| 328 | fcm_path="$MODEL/modipsl/modeles/LMDZ/arch/arch-$arch.fcm" |
---|
| 329 | if [[ ! -f $fcm_path ]]; then |
---|
| 330 | echo "Error: no $fcm_path"; exit 1 |
---|
| 331 | fi |
---|
| 332 | fi |
---|
| 333 | |
---|
| 334 | # check compiler |
---|
| 335 | compiler=$(< "$fcm_path" grep "%COMPILER" | sed -e "s/%COMPILER\s*//") |
---|
[4890] | 336 | |
---|
| 337 | # Copy arch to different components |
---|
| 338 | # TODO check that this doesn't error if the source and destination are the same |
---|
| 339 | \cp -f "$arch_dir/arch-$arch.fcm" "$MODEL/modipsl/modeles/IOIPSL/arch" |
---|
| 340 | \cp -f "$arch_dir/arch-$arch.path" "$MODEL/modipsl/modeles/IOIPSL/arch" |
---|
| 341 | \cp -f "$arch_dir/arch-$arch.fcm" "$MODEL/modipsl/modeles/ORCHIDEE/arch" |
---|
| 342 | \cp -f "$arch_dir/arch-$arch.path" "$MODEL/modipsl/modeles/ORCHIDEE/arch" |
---|
| 343 | |
---|
| 344 | # TODO TEMP compat w/ old orch version - make a proper case later |
---|
| 345 | sed -i'' -e "s/-I//" -e "s/-L//" "$MODEL/modipsl/modeles/ORCHIDEE/arch/arch-$arch.path" # /!\ we only replace first occurence on purpose |
---|
[4871] | 346 | } |
---|
| 347 | |
---|
[4862] | 348 | function install_netcdf { |
---|
| 349 | echo "Installing Netcdf" |
---|
[4210] | 350 | |
---|
[4862] | 351 | if [[ $netcdf = 0 ]]; then |
---|
| 352 | ncdfdir=$(nc-config --prefix) |
---|
| 353 | else |
---|
| 354 | cd "$MODEL" |
---|
[4210] | 355 | |
---|
[4862] | 356 | case $compiler in |
---|
| 357 | gfortran) opt1="-compiler gnu"; opt2="-CC gcc -FC gfortran -CXX g++";; |
---|
| 358 | ifort) opt1="-compiler intel"; opt2="-CC icc -FC ifort -CXX icpc";; |
---|
| 359 | pgf90) opt1="-compiler pgf90"; opt2="-CC pgcc -FC pgf90 -CXX pgCC";; |
---|
[4890] | 360 | *) echo "unexpected compiler $compiler for netcdf"; exit 1 |
---|
[4862] | 361 | esac |
---|
[4210] | 362 | |
---|
[4862] | 363 | case $with_xios in |
---|
| 364 | n) script_install_netcdf="install_netcdf4_hdf5_seq.bash" |
---|
| 365 | ncdfdir="netcdf4_hdf5_seq" |
---|
| 366 | opt_="$opt1";; |
---|
| 367 | y) script_install_netcdf="install_netcdf4_hdf5.bash" |
---|
| 368 | ncdfdir="netcdf4_hdf5" |
---|
| 369 | opt_="$opt2 -MPI $root_mpi";; |
---|
| 370 | *) echo "with_xios=$with_xios, should be n or y"; exit 1 |
---|
| 371 | esac |
---|
| 372 | if [[ $netcdf = 1 ]]; then |
---|
| 373 | ncdfdir="$MODEL/$ncdfdir" |
---|
| 374 | else |
---|
| 375 | mkdir -p "$netcdf"; ncdfdir="$netcdf/$ncdfdir" |
---|
| 376 | fi |
---|
[4210] | 377 | |
---|
[4862] | 378 | echo "Repertoire netcdf $ncdfdir" |
---|
| 379 | if [[ ! -d $ncdfdir ]]; then |
---|
| 380 | netcdflog=$(pwd)/netcdf.log |
---|
| 381 | echo "----------------------------------------------------------" |
---|
| 382 | echo "Compiling the Netcdf library" |
---|
| 383 | echo "----------------------------------------------------------" |
---|
| 384 | echo "log file : $netcdflog" |
---|
| 385 | myget script_install/$script_install_netcdf >> "$netcdflog" 2>&1 |
---|
| 386 | chmod u=rwx $script_install_netcdf |
---|
| 387 | # shellcheck disable=SC2086 |
---|
| 388 | ./$script_install_netcdf -prefix "$ncdfdir" $opt_ >> "$netcdflog" 2>&1 |
---|
[4405] | 389 | fi |
---|
[4210] | 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 | |
---|
[4862] | 407 | if $compiler -I"$ncdfdir"/include test_netcdf90.f90 -L"$ncdfdir"/lib -lnetcdff \ |
---|
| 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 |
---|
[4862] | 420 | } |
---|
[4405] | 421 | |
---|
[4862] | 422 | function install_IOIPSL { # via fcm |
---|
| 423 | cd "$MODEL/modipsl/modeles/IOIPSL" |
---|
| 424 | ioipsllog="$(pwd)/ioipsl.log" |
---|
| 425 | echo "Compiling IOIPSL, the interface library with Netcdf $(date) (log: $ioipsllog)" |
---|
[4405] | 426 | |
---|
[4890] | 427 | if ! ./makeioipsl_fcm -arch "$arch" -job 8 > "$ioipsllog" 2>&1; then |
---|
| 428 | echo "IOIPSL compile failed, exiting"; exit 1 |
---|
[4862] | 429 | fi |
---|
| 430 | cp lib/* ../../lib |
---|
| 431 | echo "IOIPSL compiled $(date)" |
---|
[4873] | 432 | |
---|
| 433 | export IOIPSL_LIBDIR="$MODEL/modipsl/modeles/IOIPSL/lib" |
---|
| 434 | export IOIPSL_INCDIR="$MODEL/modipsl/modeles/IOIPSL/inc" |
---|
[4862] | 435 | } |
---|
[4210] | 436 | |
---|
[4871] | 437 | function install_XIOS { |
---|
[4873] | 438 | if [[ $with_xios = "y" ]]; then |
---|
[4871] | 439 | cd "$MODEL/modipsl/modeles" |
---|
| 440 | xioslog="$(pwd)/xios.log" |
---|
| 441 | echo "##########################################################" |
---|
| 442 | echo "Compiling XIOS (log $xioslog) $(date)" |
---|
| 443 | echo "##########################################################" |
---|
| 444 | |
---|
[4873] | 445 | # Download XIOS |
---|
| 446 | case $xios_branch in |
---|
| 447 | "trunk") |
---|
| 448 | xios_http="http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/trunk";; |
---|
| 449 | "2.5") |
---|
| 450 | xios_http="http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5";; |
---|
| 451 | "2.6") |
---|
| 452 | xios_http="http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS2/branches/xios-2.6";; |
---|
| 453 | *) echo "XIOS: Error, bad argument for -branch ! Did not expect $xios_branch"; exit;; |
---|
| 454 | esac |
---|
| 455 | |
---|
| 456 | cd "$MODEL/modipsl/modeles" |
---|
| 457 | set +e; svn co --revision $xios_rev $xios_http XIOS; set -e |
---|
| 458 | |
---|
| 459 | cd XIOS |
---|
| 460 | if ! ./make_xios --arch "$arch" --job 8 --arch_path "$arch_dir" > "$xioslog" 2>&1; then |
---|
[4871] | 461 | echo "XIOS compilation failed, exiting"; exit 1 |
---|
| 462 | fi |
---|
| 463 | |
---|
| 464 | echo "Compiled XIOS $(date)" |
---|
| 465 | fi |
---|
| 466 | } |
---|
| 467 | |
---|
[4873] | 468 | function get_orchidee_version { # Set / Check ORCHIDEE version |
---|
[4890] | 469 | if [[ $veget = "none" ]]; then |
---|
[4873] | 470 | veget_version="false" |
---|
| 471 | elif [[ $veget = "CMIP6" ]]; then |
---|
| 472 | veget_version=orchidee2.0 |
---|
| 473 | orchidee_rev=6592 |
---|
| 474 | else # specific orchidee revision newer than CMIP6, on 2_1 or 2_2 branches |
---|
| 475 | veget_version=orchidee2.1 |
---|
| 476 | orchidee_rev="$veget" |
---|
| 477 | if [[ $veget -lt 4465 ]]; then |
---|
| 478 | echo 'ORCHIDEE version must be >=4465, exiting' |
---|
| 479 | exit 1 |
---|
| 480 | fi |
---|
| 481 | |
---|
| 482 | set +e |
---|
| 483 | svn upgrade |
---|
| 484 | local orcbranch |
---|
| 485 | orcbranch=$(svn log -v -q svn://forge.ipsl.jussieu.fr/orchidee/ -r "$veget" |grep ORCHIDEE |head -1| sed -e 's:ORCHIDEE/.*$:ORCHIDEE:' | awk '{print $2}') |
---|
| 486 | echo "IF YOU INSTALL ORCHIDEE THE VERY FIRST TIME, ASK for PASSWORD at orchidee-help@listes.ipsl.fr" |
---|
| 487 | svn switch -r "$veget" --accept theirs-full "svn://forge.ipsl.jussieu.fr/orchidee/$orcbranch" |
---|
| 488 | svn log -r "$veget" | grep "$veget" |
---|
| 489 | if ! svn log -r "$veget" | grep "$veget"; then |
---|
| 490 | echo 'Cannot update ORCHIDEE as not on the right branch for ORCHIDEE' |
---|
| 491 | exit 1 |
---|
| 492 | fi |
---|
| 493 | svn update -r "$veget" |
---|
| 494 | set -e |
---|
| 495 | fi |
---|
| 496 | } |
---|
| 497 | |
---|
| 498 | function compile_orchidee_seq { |
---|
| 499 | get_orchidee_version |
---|
| 500 | |
---|
[4890] | 501 | if [[ $veget != "none" ]]; then |
---|
[4873] | 502 | cd "$MODEL/modipsl/modeles/ORCHIDEE" |
---|
| 503 | |
---|
| 504 | orchideelog="$(pwd)/orchidee.log" |
---|
| 505 | echo "Compiling ORCHIDEE, the continental surface model (log $orchideelog)" |
---|
| 506 | echo "Start of the first compilation of orchidee, in sequential mode: $(date)" |
---|
| 507 | |
---|
| 508 | ORCHPATH=$(pwd) |
---|
| 509 | export ORCHPATH=$ORCHPATH |
---|
| 510 | |
---|
| 511 | local xios_orchid opt_orc |
---|
| 512 | if [[ $with_xios = "y" ]]; then |
---|
| 513 | xios_orchid="-xios"; |
---|
| 514 | else |
---|
| 515 | xios_orchid="-noxios" |
---|
| 516 | fi |
---|
| 517 | if [[ $optim_debug = "-debug" ]]; then |
---|
| 518 | opt_orc="-debug"; |
---|
| 519 | else |
---|
| 520 | opt_orc="-prod" |
---|
| 521 | fi |
---|
| 522 | |
---|
[4890] | 523 | if ! ./makeorchidee_fcm "$xios_orchid" "$opt_orc" -parallel none -arch "$arch" > "$orchideelog" 2>&1; then |
---|
[4873] | 524 | echo "ORCHIDEE seq compilation failed, exiting"; exit 1 |
---|
| 525 | fi |
---|
| 526 | echo "Compiled ORCHIDEE seq $(date)" |
---|
| 527 | fi |
---|
| 528 | } |
---|
| 529 | |
---|
[4862] | 530 | echo "install_lmdz.sh DEBUT $(date)" |
---|
[4210] | 531 | |
---|
[4862] | 532 | set_default_params |
---|
| 533 | read_cmdline_args "$@" |
---|
[4873] | 534 | #download_model |
---|
| 535 | download_model_AMAURY |
---|
[4890] | 536 | install_arch |
---|
[4862] | 537 | check_available_software |
---|
| 538 | install_netcdf |
---|
| 539 | install_IOIPSL |
---|
[4873] | 540 | #install_XIOS # TODO disabled for now, did not decide which flags/arch to use for compile |
---|
| 541 | compile_orchidee_seq |
---|
[4238] | 542 | |
---|
[4871] | 543 | exit 0 |
---|
[4238] | 544 | |
---|
[4210] | 545 | |
---|
| 546 | |
---|
[4871] | 547 | |
---|
[4862] | 548 | ################################################################ |
---|
| 549 | # Specificite des machines |
---|
| 550 | ################################################################ |
---|
[4210] | 551 | |
---|
[4862] | 552 | hostname=$(hostname) |
---|
| 553 | #case ${hostname:0:5} in |
---|
| 554 | # *) if [[ $parallel = none || -f /usr/bin/mpif90 ]]; then |
---|
| 555 | # path_mpi=$(which mpif90 | sed -e s:/mpif90::); |
---|
| 556 | # if [[ -d /usr/lib64/openmpi ]]; then |
---|
| 557 | # root_mpi="/usr/lib64/openmpi" |
---|
| 558 | # else |
---|
| 559 | # root_mpi="/usr" |
---|
| 560 | # fi |
---|
| 561 | # else |
---|
| 562 | # echo "Cannot find mpif90"; |
---|
| 563 | # if [[ $parallel = none ]]; then exit 1; fi; |
---|
| 564 | # fi; |
---|
| 565 | # if [[ $parallel != none ]]; then |
---|
| 566 | # root_mpi=$(which mpif90 | sed -e s:/bin/mpif90::) |
---|
| 567 | # path_mpi=$(which mpif90 | sed -e s:/mpif90::) |
---|
| 568 | # export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH |
---|
| 569 | # fi |
---|
| 570 | # par_comp=${path_mpi}/mpif90; |
---|
| 571 | # mpirun=${path_mpi}/mpirun; |
---|
[4873] | 572 | # arch="local"; |
---|
[4862] | 573 | # make="make"; |
---|
| 574 | # o_ins_make="-t g95" |
---|
| 575 | #esac |
---|
[4210] | 576 | |
---|
[4862] | 577 | ## Flags for parallelism: |
---|
| 578 | #if [[ $parallel != none ]]; then |
---|
| 579 | # # MPI_LD are the flags needed for linking with MPI |
---|
| 580 | # MPI_LD="-L${root_mpi}/lib -lmpi" |
---|
| 581 | # if [[ $compiler = "gfortran" ]]; then |
---|
| 582 | # # MPI_FLAGS are the flags needed for compilation with MPI |
---|
| 583 | # MPI_FLAGS="-fcray-pointer" |
---|
| 584 | # # OMP_FLAGS are the flags needed for compilation with OpenMP |
---|
| 585 | # OMP_FLAGS="-fopenmp -fcray-pointer" |
---|
| 586 | # # OMP_LD are the flags needed for linking with OpenMP |
---|
| 587 | # OMP_LD="-fopenmp" |
---|
| 588 | # elif [[ $compiler = "ifort" ]]; then |
---|
| 589 | # MPI_FLAGS="" |
---|
| 590 | # OMP_FLAGS="-openmp" |
---|
| 591 | # OMP_LD="-openmp" |
---|
| 592 | # else # pgf90 |
---|
| 593 | # MPI_FLAGS="" |
---|
| 594 | # OMP_FLAGS="-mp" |
---|
| 595 | # OMP_LD="-mp" |
---|
| 596 | # fi |
---|
| 597 | #fi |
---|
| 598 | # |
---|
| 599 | # |
---|
| 600 | #echo "################################################################" |
---|
| 601 | #echo "Choix des options de compilation" |
---|
| 602 | #echo "################################################################" |
---|
| 603 | # |
---|
| 604 | #export FC=$compiler |
---|
| 605 | #export F90=$compiler |
---|
| 606 | #export F77=$compiler |
---|
| 607 | #export CPPFLAGS= |
---|
| 608 | #OPTIMNC="" |
---|
| 609 | #BASE_LD="$OPT_GPROF" |
---|
| 610 | #OPTPREC="$OPT_GPROF" |
---|
| 611 | #ARFLAGS="rs" |
---|
| 612 | #if [[ $(lsb_release -i -s) = "Ubuntu" ]]; then |
---|
| 613 | # if [[ $(lsb_release -r -s | cut -d. -f1) -ge 16 ]]; then |
---|
| 614 | # ARFLAGS="rU" |
---|
| 615 | # fi |
---|
| 616 | #fi |
---|
| 617 | # |
---|
| 618 | #if [[ $compiler = "gfortran" ]]; then |
---|
| 619 | # OPTIM="-O3 $allow_arg_mismatch" |
---|
| 620 | # OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=snan $allow_arg_mismatch" |
---|
| 621 | # OPTDEV="-Wall -fbounds-check $allow_arg_mismatch" |
---|
| 622 | # fmod="I " |
---|
| 623 | # OPTPREC="$OPTPREC -cpp -ffree-line-length-0" |
---|
| 624 | # if [[ $real = r8 ]]; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE"; fi |
---|
| 625 | # export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
| 626 | # export FFLAGS=" $OPTIMNC" |
---|
| 627 | # export CC=gcc |
---|
| 628 | # export CXX=g++ |
---|
| 629 | # export fpp_flags="-P -C -traditional -ffreestanding" |
---|
| 630 | # |
---|
| 631 | #elif [[ $compiler = mpif90 ]]; then |
---|
| 632 | # OPTIM="-O3" |
---|
| 633 | # OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all" |
---|
| 634 | # OPTDEV="-Wall -fbounds-check" |
---|
| 635 | # BASE_LD="$BASE_LD -lblas" |
---|
| 636 | # fmod="I " |
---|
| 637 | # if [[ $real = r8 ]]; then |
---|
| 638 | # OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer" |
---|
| 639 | # fi |
---|
| 640 | # export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
| 641 | # export FFLAGS=" $OPTIMNC" |
---|
| 642 | # export CC=gcc |
---|
| 643 | # export CXX=g++ |
---|
| 644 | # |
---|
| 645 | #elif [[ $compiler = pgf90 ]]; then |
---|
| 646 | # OPTIM="-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align" |
---|
| 647 | # OPTDEB="-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback" |
---|
| 648 | # OPTDEV="-g -Mbounds -Ktrap=fp -traceback" |
---|
| 649 | # fmod="module " |
---|
| 650 | # if [[ $real = r8 ]]; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE"; fi |
---|
| 651 | # export CPPFLAGS="-DpgiFortran" |
---|
| 652 | # export CC=pgcc |
---|
| 653 | # export CFLAGS="-O2 -Msignextend" |
---|
| 654 | # export CXX=pgCC |
---|
| 655 | # export CXXFLAGS="-O2 -Msignextend" |
---|
| 656 | # export FFLAGS="-O2 $OPTIMNC" |
---|
| 657 | # export F90FLAGS="-O2 $OPTIMNC" |
---|
| 658 | # compile_with_fcm=1 |
---|
| 659 | # |
---|
| 660 | #elif [[ $compiler = ifort || $compiler = mpiifort ]]; then |
---|
| 661 | # OPTIM="-O2 -fp-model strict -ip -align all " |
---|
| 662 | # OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check" |
---|
| 663 | # OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check" |
---|
| 664 | # fmod='module ' |
---|
| 665 | # if [[ $real = r8 ]]; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE"; fi |
---|
| 666 | # export CPP="icc -E" |
---|
| 667 | # export FFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 668 | # export FCFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 669 | # export CC=icc |
---|
| 670 | # export CFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 671 | # export CXX=icpc |
---|
| 672 | # export CXXFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 673 | # export fpp_flags="-P -traditional" |
---|
| 674 | # # Pourquoi forcer la compilation fcm. Marche mieux sans |
---|
| 675 | # #compile_with_fcm=1 |
---|
| 676 | #else |
---|
| 677 | # echo "unexpected compiler $compiler"; exit 1 |
---|
| 678 | #fi |
---|
| 679 | # |
---|
| 680 | #OPTIMGCM="$OPTIM $OPTPREC" |
---|
[4210] | 681 | |
---|
| 682 | |
---|
| 683 | veget_version=false |
---|
[4890] | 684 | if [[ $veget != 'none' ]]; then |
---|
[4849] | 685 | cd "$MODEL/modipsl/modeles/ORCHIDEE" |
---|
[4210] | 686 | |
---|
[4873] | 687 | opt_orc="-prod"; if [[ "$optim_debug" = "-debug" ]]; then opt_orc="-debug"; fi |
---|
| 688 | |
---|
[4849] | 689 | orchideelog=$(pwd)/orchidee.log |
---|
[4215] | 690 | echo '########################################################' |
---|
| 691 | echo 'Compiling ORCHIDEE, the continental surface model ' |
---|
| 692 | echo '########################################################' |
---|
[4849] | 693 | echo "Start of the first compilation of orchidee, in sequential mode: $(date)" |
---|
| 694 | echo "log file : $orchideelog" |
---|
[4210] | 695 | |
---|
[4849] | 696 | ORCHPATH=$(pwd) |
---|
| 697 | export ORCHPATH=$ORCHPATH |
---|
[4215] | 698 | xios_orchid="-noxios" |
---|
[4849] | 699 | if [[ "$with_xios" = "y" ]]; then |
---|
[4405] | 700 | xios_orchid="-xios" |
---|
[4215] | 701 | fi |
---|
[4849] | 702 | if [[ -d tools ]]; then |
---|
[4405] | 703 | ################################################################### |
---|
| 704 | # Pour les experts qui voudraient changer de version d'orchidee. |
---|
| 705 | # Attention : necessite d'avoir le password pour orchidee |
---|
| 706 | ################################################################### |
---|
[4849] | 707 | if [[ "$veget_version" == "false" ]]; then |
---|
[4405] | 708 | veget_version=orchidee2.0 |
---|
| 709 | fi |
---|
| 710 | cd arch |
---|
[4849] | 711 | sed -e s:"%COMPILER .*.$:%COMPILER $compiler":1 \ |
---|
| 712 | -e s:"%LINK .*.$:%LINK $compiler":1 \ |
---|
| 713 | -e s:"%FPP_FLAGS .*.$:%FPP_FLAGS $fpp_flags":1 \ |
---|
| 714 | -e s:"%PROD_FFLAGS .*.$:%PROD_FFLAGS $OPTIM":1 \ |
---|
| 715 | -e s:"%DEV_FFLAGS .*.$:%DEV_FFLAGS $OPTDEV":1 \ |
---|
| 716 | -e s:"%DEBUG_FFLAGS .*.$:%DEBUG_FFLAGS $OPTDEB":1 \ |
---|
| 717 | -e s:"%BASE_FFLAGS .*.$:%BASE_FFLAGS $OPTPREC":1 \ |
---|
| 718 | -e s:"%BASE_LD .*.$:%BASE_LD $BASE_LD":1 \ |
---|
| 719 | -e s:"%ARFLAGS .*.$:%ARFLAGS $ARFLAGS":1 \ |
---|
[4405] | 720 | arch-gfortran.fcm > arch-local.fcm |
---|
[4849] | 721 | cat <<EOF > arch-local.path |
---|
| 722 | NETCDF_LIBDIR="-L$ncdfdir/lib -lnetcdff -lnetcdf" |
---|
| 723 | NETCDF_INCDIR="$ncdfdir/include" |
---|
| 724 | IOIPSL_INCDIR="$ORCHPATH/../../lib" |
---|
| 725 | IOIPSL_LIBDIR="$ORCHPATH/../../lib" |
---|
| 726 | XIOS_INCDIR="\$ORCHDIR/../XIOS/inc" |
---|
| 727 | XIOS_LIBDIR="\$ORCHDIR/../XIOS/lib -lxios" |
---|
| 728 | EOF |
---|
[4405] | 729 | cd ../ |
---|
[4210] | 730 | |
---|
[4405] | 731 | echo ./makeorchidee_fcm -j $xios_orchid $opt_orc -parallel none \ |
---|
| 732 | -arch $arch |
---|
| 733 | ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel none \ |
---|
[4849] | 734 | -arch $arch > "$orchideelog" 2>&1 |
---|
[4405] | 735 | pwd |
---|
[4849] | 736 | else # of "if [[ -d tools ]]" |
---|
| 737 | if [[ -d src_parallel ]]; then |
---|
[4405] | 738 | liste_src="parallel parameters global stomate sechiba driver" |
---|
[4849] | 739 | if [[ "$veget_version" == "false" ]]; then |
---|
[4405] | 740 | veget_version=orchidee2.0 |
---|
| 741 | fi |
---|
| 742 | fi |
---|
[4849] | 743 | for d in $liste_src; do |
---|
[4405] | 744 | src_d=src_$d |
---|
[4849] | 745 | echo src_d "$src_d" |
---|
| 746 | echo ls; ls |
---|
| 747 | if [[ ! -d $src_d ]]; then |
---|
| 748 | echo "Problem orchidee : no $src_d"; exit 1 |
---|
[4405] | 749 | fi |
---|
[4849] | 750 | cd "$src_d"; \rm -f -- *.mod make; $make clean |
---|
| 751 | $make > "$orchideelog" 2>&1 |
---|
[4861] | 752 | if [[ "$compiler" = "gfortran" || "$compiler" = "mpif90" ]]; then |
---|
[4849] | 753 | cp -f -- *.mod ../../../lib |
---|
[4405] | 754 | fi |
---|
| 755 | cd .. |
---|
| 756 | done |
---|
[4849] | 757 | fi # of "if [[ -d tools ]]" |
---|
| 758 | echo "install_lmdz.sh orchidee_compil_seq_OK $(date)" |
---|
[4890] | 759 | fi # of if [[ "$veget" != 'none' ]] |
---|
[4210] | 760 | |
---|
| 761 | |
---|
| 762 | #============================================================================ |
---|
| 763 | # Ehouarn: the directory name LMDZ* depends on version/tar file... |
---|
[4861] | 764 | if find . -name "$MODEL/modipsl/modeles/LMD*"; then |
---|
[4215] | 765 | echo '###############################################################' |
---|
| 766 | echo 'Preparing LMDZ compilation : arch file, svn switch if needed...' |
---|
| 767 | echo '###############################################################' |
---|
[4849] | 768 | cd "$MODEL/modipsl/modeles/"LMD* |
---|
| 769 | LMDZPATH=$(pwd) |
---|
[4210] | 770 | else |
---|
[4215] | 771 | echo "ERROR: No LMD* directory !!!" |
---|
[4849] | 772 | exit 1 |
---|
[4210] | 773 | fi |
---|
| 774 | |
---|
[4861] | 775 | |
---|
[4210] | 776 | ########################################################### |
---|
| 777 | # For those who want to use fcm to compile via : |
---|
| 778 | # makelmdz_fcm -arch local ..... |
---|
| 779 | ############################################################ |
---|
| 780 | |
---|
| 781 | |
---|
| 782 | |
---|
[4849] | 783 | cd "$MODEL/modipsl/modeles"/LMDZ* |
---|
| 784 | lmdzlog=$(pwd)/lmdz.log |
---|
[4210] | 785 | |
---|
| 786 | ################################################################## |
---|
| 787 | # Possibly update LMDZ if a specific svn release is requested |
---|
| 788 | ################################################################## |
---|
| 789 | |
---|
[4849] | 790 | set +e; svn upgrade; set -e |
---|
[4210] | 791 | |
---|
[4849] | 792 | if [[ $svn = "last" ]]; then svnopt=""; else svnopt="-r $svn"; fi |
---|
| 793 | if [[ $svn != "" ]]; then |
---|
| 794 | if set +e; svn info | grep -q 'https:'; then |
---|
[4634] | 795 | svn switch --relocate https://svn.lmd.jussieu.fr/LMDZ \ |
---|
| 796 | http://svn.lmd.jussieu.fr/LMDZ |
---|
[4210] | 797 | fi |
---|
[4849] | 798 | svn update "$svnopt" |
---|
[4372] | 799 | set -e |
---|
[4210] | 800 | fi |
---|
| 801 | |
---|
[4372] | 802 | #--------------------------------------------------------------------- |
---|
[4218] | 803 | # Retrieve the final svn release number, and adjust compilation |
---|
| 804 | # options accordingly |
---|
[4372] | 805 | # If svn not available, will use the svn writen in $MODEL/Readm*md |
---|
| 806 | # For old version it assumes that it is before 4185 (the version |
---|
| 807 | # for which the test was introduced |
---|
| 808 | #--------------------------------------------------------------------- |
---|
[4210] | 809 | |
---|
[4849] | 810 | set +e; mysvn=$(svnversion . | grep -E || "[0-9]+" 2>/dev/null); set -e |
---|
| 811 | if [[ "$mysvn" = "" ]]; then mysvn=$(grep 'Revision: [0-9]' "$MODEL"/Read*.md | awk ' { print $2 } ' 2>/dev/null); fi |
---|
| 812 | if [[ "$mysvn" = "" ]]; then mysvn=4190; fi |
---|
[4372] | 813 | |
---|
[4849] | 814 | if [[ "$pclinux" = "1" && ! -f arch/arch-local.path ]]; then |
---|
[4427] | 815 | |
---|
| 816 | # create local 'arch' files (if on Linux PC): |
---|
| 817 | cd arch |
---|
| 818 | # arch-local.path file |
---|
| 819 | # test for version as arch.pth file changed format with rev 4426 |
---|
[4849] | 820 | if [[ "$mysvn" -gt 4425 ]]; then |
---|
| 821 | cat <<EOF > arch-local.path |
---|
| 822 | NETCDF_LIBDIR="-L$ncdfdir/lib" |
---|
[4861] | 823 | NETCDF_LIB="-lnetcdff -lnetcdf" |
---|
[4849] | 824 | NETCDF_INCDIR=-I$ncdfdir/include |
---|
| 825 | NETCDF95_INCDIR=-I\$LMDGCM/../../include |
---|
| 826 | NETCDF95_LIBDIR=-L\$LMDGCM/../../lib |
---|
| 827 | NETCDF95_LIB=-lnetcdf95 |
---|
| 828 | IOIPSL_INCDIR=-I\$LMDGCM/../../lib |
---|
| 829 | IOIPSL_LIBDIR=-L\$LMDGCM/../../lib |
---|
| 830 | IOIPSL_LIB=-lioipsl |
---|
| 831 | XIOS_INCDIR=-I\$LMDGCM/../XIOS/inc |
---|
| 832 | XIOS_LIBDIR=-L\$LMDGCM/../XIOS/lib |
---|
| 833 | XIOS_LIB="-lxios -lstdc++" |
---|
| 834 | ORCH_INCDIR=-I\$LMDGCM/../../lib |
---|
| 835 | ORCH_LIBDIR=-L\$LMDGCM/../../lib |
---|
| 836 | EOF |
---|
[4427] | 837 | else |
---|
[4849] | 838 | cat <<EOF > arch-local.path |
---|
| 839 | NETCDF_LIBDIR="-L$ncdfdir/lib -lnetcdff -lnetcdf" |
---|
| 840 | NETCDF_INCDIR=-I$ncdfdir/include |
---|
| 841 | NETCDF95_INCDIR=\$LMDGCM/../../include |
---|
| 842 | NETCDF95_LIBDIR=\$LMDGCM/../../lib |
---|
| 843 | IOIPSL_INCDIR=\$LMDGCM/../../lib |
---|
| 844 | IOIPSL_LIBDIR=\$LMDGCM/../../lib |
---|
| 845 | XIOS_INCDIR=\$LMDGCM/../XIOS/inc |
---|
| 846 | XIOS_LIBDIR=\$LMDGCM/../XIOS/lib |
---|
| 847 | ORCH_INCDIR=\$LMDGCM/../../lib |
---|
| 848 | ORCH_LIBDIR=\$LMDGCM/../../lib |
---|
| 849 | EOF |
---|
[4427] | 850 | fi |
---|
| 851 | |
---|
[4849] | 852 | if [[ $pcmac == 1 ]]; then |
---|
[4427] | 853 | BASE_LD="$BASE_LD -Wl,-rpath,${ncdfdir}/lib" |
---|
| 854 | else |
---|
| 855 | BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib" |
---|
| 856 | fi |
---|
| 857 | # Arch-local.fcm file (adapted from arch-linux-32bit.fcm) |
---|
| 858 | |
---|
[4849] | 859 | if [[ $real = r8 ]]; then FPP_DEF=NC_DOUBLE; else FPP_DEF=""; fi |
---|
| 860 | sed -e s:"%COMPILER .*.$:%COMPILER $compiler":1 \ |
---|
| 861 | -e s:"%LINK .*.$:%LINK $compiler":1 \ |
---|
| 862 | -e s:"%PROD_FFLAGS .*.$:%PROD_FFLAGS $OPTIM":1 \ |
---|
| 863 | -e s:"%DEV_FFLAGS .*.$:%DEV_FFLAGS $OPTDEV":1 \ |
---|
| 864 | -e s:"%DEBUG_FFLAGS .*.$:%DEBUG_FFLAGS $OPTDEB":1 \ |
---|
| 865 | -e s:"%BASE_FFLAGS .*.$:%BASE_FFLAGS $OPTPREC":1 \ |
---|
| 866 | -e s:"%FPP_DEF .*.$:%FPP_DEF $FPP_DEF":1 \ |
---|
| 867 | -e s:"%BASE_LD .*.$:%BASE_LD $BASE_LD":1 \ |
---|
| 868 | -e s:"%ARFLAGS .*.$:%ARFLAGS $ARFLAGS":1 \ |
---|
[4427] | 869 | arch-linux-32bit.fcm > arch-local.fcm |
---|
| 870 | |
---|
| 871 | cd .. |
---|
| 872 | ### Adapt "bld.cfg" (add the shell): |
---|
| 873 | #whereisthatshell=$(which ${use_shell}) |
---|
| 874 | #echo "bld::tool::SHELL $whereisthatshell" >> bld.cfg |
---|
| 875 | |
---|
[4849] | 876 | fi # of if [[ "$pclinux" = 1 ]] |
---|
[4372] | 877 | #--------------------------------------------------------------------- |
---|
[4210] | 878 | # Option de compilation du rayonnement : depend de $mysvn ><= r4185 |
---|
[4372] | 879 | #--------------------------------------------------------------------- |
---|
[4210] | 880 | opt_rad="" |
---|
| 881 | |
---|
| 882 | case $rad in |
---|
[4849] | 883 | oldrad) iflag_rrtm=0; NSW=2; opt_rad="";; |
---|
| 884 | rrtm) iflag_rrtm=1; NSW=6 |
---|
| 885 | if [[ $mysvn -le 4185 ]]; then |
---|
[4405] | 886 | opt_rad="-rrtm true" |
---|
| 887 | else |
---|
| 888 | opt_rad="-rad rrtm" |
---|
[4849] | 889 | fi;; |
---|
| 890 | ecrad) iflag_rrtm=2; NSW=6; opt_rad="-rad ecrad";; |
---|
| 891 | *) echo "Only oldrad rrtm ecrad for rad option"; exit 1 |
---|
[4210] | 892 | esac |
---|
| 893 | |
---|
[4849] | 894 | if [[ $mysvn -le 4185 && $rad = "ecrad" ]]; then |
---|
| 895 | echo "ecrad only available for LMDZ rev starting with 4186 "; exit 1 |
---|
[4218] | 896 | fi |
---|
[4210] | 897 | |
---|
| 898 | ################################################################## |
---|
| 899 | |
---|
[4213] | 900 | |
---|
[4849] | 901 | if [[ ! -f libf/misc/netcdf95.F90 && ! -d $MODEL/NetCDF95-0.3 ]]; then |
---|
| 902 | cd "$MODEL" |
---|
[4577] | 903 | myget src_archives/netcdf/NetCDF95-0.3.tar.gz |
---|
| 904 | tar -xf NetCDF95-0.3.tar.gz |
---|
| 905 | rm NetCDF95-0.3.tar.gz |
---|
| 906 | cd NetCDF95-0.3 |
---|
[4213] | 907 | mkdir build |
---|
| 908 | cd build |
---|
[4849] | 909 | cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$ncdfdir" \ |
---|
| 910 | -DCMAKE_INSTALL_PREFIX="$MODEL/modipsl" |
---|
[4213] | 911 | make install |
---|
[4849] | 912 | cd "$MODEL/modipsl/modeles/"LMDZ* |
---|
[4213] | 913 | fi |
---|
| 914 | |
---|
[4210] | 915 | echo '##################################################################' |
---|
| 916 | echo "Preparing script compile.sh for LMDZ compilation" |
---|
| 917 | echo "It will only be run automatically if bench=1/tuto" |
---|
[4849] | 918 | echo "Here bench=$bench" |
---|
[4210] | 919 | echo '##################################################################' |
---|
| 920 | |
---|
[4849] | 921 | if [[ $env_file != "" ]]; then |
---|
[4218] | 922 | mv arch/arch-${arch}.env arch/arch-${arch}.orig |
---|
[4849] | 923 | \cp -f "$env_file" arch/arch-${arch}.env |
---|
[4218] | 924 | fi |
---|
[4210] | 925 | |
---|
[4849] | 926 | if [[ $compile_with_fcm = 1 ]]; then |
---|
[4873] | 927 | makelmdz="makelmdz_fcm $optim_debug -arch $arch -j 8 " |
---|
[4218] | 928 | else |
---|
[4873] | 929 | makelmdz="makelmdz $optim_debug -arch $arch" |
---|
[4218] | 930 | fi |
---|
[4210] | 931 | |
---|
| 932 | # sequential compilation |
---|
[4849] | 933 | if [[ "$sequential" = 1 ]]; then |
---|
[4215] | 934 | echo Sequential compilation command, saved in compile.sh: |
---|
[4873] | 935 | echo "./$makelmdz $optim_debug $OPT_MAKELMDZ $optim_debug $opt_rad $opt_cosp " \ |
---|
[4405] | 936 | "-d ${grid_resolution} -v $veget_version gcm " |
---|
[4873] | 937 | echo "./$makelmdz $optim_debug $OPT_MAKELMDZ $optim_debug $opt_rad $opt_cosp " \ |
---|
[4405] | 938 | "-d ${grid_resolution} -v $veget_version gcm " > compile.sh |
---|
[4215] | 939 | chmod +x ./compile.sh |
---|
[4849] | 940 | if [[ $bench = 1 ]]; then |
---|
| 941 | echo "install_lmdz.sh start_lmdz_seq_compilation $(date)" |
---|
| 942 | echo "log file: $lmdzlog" |
---|
| 943 | ./compile.sh > "$lmdzlog" 2>&1 |
---|
| 944 | echo "install_lmdz.sh end_lmdz_seq_compilation $(date)" |
---|
[4215] | 945 | fi |
---|
[4210] | 946 | fi # fin sequential |
---|
| 947 | |
---|
| 948 | # compiling in parallel mode |
---|
[4849] | 949 | if [[ $parallel != "none" ]]; then |
---|
[4210] | 950 | echo '##########################################################' |
---|
[4215] | 951 | echo ' Parallel compile ' |
---|
[4210] | 952 | echo '##########################################################' |
---|
[4215] | 953 | echo "(after saving the sequential libs and binaries)" |
---|
[4849] | 954 | cd "$MODEL/modipsl" |
---|
[4215] | 955 | tar cf sequential.tar bin/ lib/ |
---|
| 956 | # |
---|
| 957 | # Orchidee |
---|
| 958 | # |
---|
[4849] | 959 | cd "$ORCHPATH" |
---|
[4890] | 960 | if [[ -d src_parallel && $veget != 'none' ]]; then |
---|
[4405] | 961 | cd arch |
---|
| 962 | sed \ |
---|
[4849] | 963 | -e s:"%COMPILER.*.$:%COMPILER $par_comp":1 \ |
---|
| 964 | -e s:"%LINK.*.$:%LINK $par_comp":1 \ |
---|
| 965 | -e s:"%MPI_FFLAG.*.$:%MPI_FFLAGS $MPI_FLAGS":1 \ |
---|
| 966 | -e s:"%OMP_FFLAG.*.$:%OMP_FFLAGS $OMP_FLAGS":1 \ |
---|
| 967 | -e s:"%MPI_LD.*.$:%MPI_LD $MPI_LD":1 \ |
---|
| 968 | -e s:"%OMP_LD.*.$:%OMP_LD $OMP_LD":1 \ |
---|
[4405] | 969 | arch-local.fcm > tmp.fcm |
---|
[4210] | 970 | |
---|
[4405] | 971 | mv tmp.fcm arch-local.fcm |
---|
| 972 | cd ../ |
---|
[4849] | 973 | echo "Compiling ORCHIDEE in parallel mode $(date)" |
---|
| 974 | echo "logfile $orchideelog" |
---|
[4405] | 975 | echo "NOTE : to recompile it when necessary, use ./compile_orc.sh " \ |
---|
| 976 | "in modipsl/modeles/ORCHIDEE" |
---|
| 977 | echo ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc \ |
---|
[4849] | 978 | -parallel "$parallel" -arch $arch > compile_orc.sh |
---|
[4405] | 979 | echo ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc \ |
---|
[4849] | 980 | -parallel "$parallel" -arch $arch >> compile_orc.sh |
---|
[4405] | 981 | echo echo Now you must also recompile LMDZ, by running ./compile.sh \ |
---|
| 982 | in modeles/LMDZ >> compile_orc.sh |
---|
| 983 | chmod u+x compile_orc.sh |
---|
| 984 | ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc \ |
---|
[4849] | 985 | -parallel "$parallel" -arch $arch > "$orchideelog" 2>&1 |
---|
| 986 | ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel "$parallel" \ |
---|
| 987 | -arch $arch >> "$orchideelog" 2>&1 |
---|
| 988 | echo "End of ORCHIDEE compilation in parallel mode $(date)" |
---|
[4890] | 989 | elif [[ $veget != 'none' ]]; then |
---|
[4405] | 990 | echo '##########################################################' |
---|
| 991 | echo ' Orchidee version too old ' |
---|
| 992 | echo ' Please update to new version ' |
---|
| 993 | echo '##########################################################' |
---|
[4849] | 994 | exit 1 |
---|
[4890] | 995 | fi #�of [ -d src_parallel && $veget != 'none' ] |
---|
[4210] | 996 | |
---|
[4215] | 997 | # LMDZ |
---|
[4849] | 998 | cd "$LMDZPATH" |
---|
| 999 | if [[ $arch = local ]]; then |
---|
[4405] | 1000 | cd arch |
---|
[4849] | 1001 | sed -e s:"%COMPILER.*.$:%COMPILER $par_comp":1 \ |
---|
| 1002 | -e s:"%LINK.*.$:%LINK $par_comp":1 \ |
---|
| 1003 | -e s:"%MPI_FFLAG.*.$:%MPI_FFLAGS $MPI_FLAGS":1 \ |
---|
| 1004 | -e s:"%OMP_FFLAG.*.$:%OMP_FFLAGS $OMP_FLAGS":1 \ |
---|
| 1005 | -e s:"%ARFLAGS.*.$:%ARFLAGS $ARFLAGS":1 \ |
---|
| 1006 | -e "s§%BASE_LD.*.$§%BASE_LD -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib§1" \ |
---|
| 1007 | -e s:"%MPI_LD.*.$:%MPI_LD $MPI_LD":1 \ |
---|
| 1008 | -e s:"%OMP_LD.*.$:%OMP_LD $OMP_LD":1 \ |
---|
[4405] | 1009 | arch-local.fcm > tmp.fcm |
---|
| 1010 | mv tmp.fcm arch-local.fcm |
---|
| 1011 | cd ../ |
---|
[4215] | 1012 | fi |
---|
| 1013 | rm -f compile.sh |
---|
[4849] | 1014 | echo resol="$grid_resolution" >> compile.sh |
---|
| 1015 | if [[ ${hostname:0:5} = jean- && "$cosp" = "v2" ]]; then |
---|
[4210] | 1016 | |
---|
[4849] | 1017 | echo "LMDZ compilation command in parallel mode, saved in compile.sh, is :" |
---|
[4405] | 1018 | echo "(ATTENTION le probleme de cospv2 sur jean-zay en mode prod " \ |
---|
| 1019 | "n est pas corrige ! )" |
---|
| 1020 | # ATTENTION le probleme de cospv2 sur jean-zay en mode prod n |
---|
| 1021 | # est pas corrige |
---|
[4873] | 1022 | echo ./"$makelmdz" -dev $optim_debug "$OPT_MAKELMDZ" "$opt_rad" "$opt_cosp" \ |
---|
[4849] | 1023 | "$opt_makelmdz_xios" -d \$resol -v $veget_version -mem \ |
---|
| 1024 | -parallel "$parallel" gcm >> compile.sh |
---|
[4873] | 1025 | echo ./"$makelmdz" -dev $optim_debug "$OPT_MAKELMDZ" "$opt_rad" "$opt_cosp" \ |
---|
[4849] | 1026 | "$opt_makelmdz_xios" -d \$resol -v $veget_version -mem \ |
---|
| 1027 | -parallel "$parallel" gcm |
---|
[4215] | 1028 | else |
---|
[4873] | 1029 | echo ./"$makelmdz" $optim_debug "$OPT_MAKELMDZ" "$opt_rad" "$opt_cosp" \ |
---|
[4849] | 1030 | "$opt_makelmdz_xios" -d \$resol -v $veget_version -mem \ |
---|
| 1031 | -parallel "$parallel" gcm >> compile.sh |
---|
[4873] | 1032 | echo ./"$makelmdz" $optim_debug "$OPT_MAKELMDZ" "$opt_rad" "$opt_cosp" \ |
---|
[4849] | 1033 | "$opt_makelmdz_xios" -d \$resol -v $veget_version -mem \ |
---|
| 1034 | -parallel "$parallel" gcm |
---|
[4215] | 1035 | fi |
---|
| 1036 | chmod +x ./compile.sh |
---|
[4210] | 1037 | |
---|
[4849] | 1038 | if [[ $bench = 1 ]]; then |
---|
| 1039 | echo "Compiling LMDZ in parallel mode $(date), LMDZ log file: $lmdzlog" |
---|
| 1040 | ./compile.sh > "$lmdzlog" 2>&1 |
---|
[4215] | 1041 | fi |
---|
| 1042 | |
---|
[4849] | 1043 | fi # of if [[ $parallel != "none" ]] |
---|
[4210] | 1044 | |
---|
| 1045 | |
---|
| 1046 | ################################################################## |
---|
| 1047 | # Verification du succes de la compilation |
---|
| 1048 | ################################################################## |
---|
| 1049 | |
---|
| 1050 | # Recherche de l'executable dont le nom a change au fil du temps ... |
---|
| 1051 | # suffix contains radiative option starting with revision 4186 |
---|
[4849] | 1052 | if [[ $mysvn -ge 4186 ]]; then suff_exe=_${rad}${suff_exe}; fi |
---|
[4210] | 1053 | gcm="" |
---|
[4219] | 1054 | |
---|
[4218] | 1055 | for exe in gcm.e bin/gcm_${grid_resolution}_phylmd${suff_exe}${suff_orc}.e |
---|
| 1056 | do |
---|
[4849] | 1057 | if [[ -f $exe ]]; then gcm=$exe; fi |
---|
[4210] | 1058 | done |
---|
| 1059 | |
---|
[4849] | 1060 | if [[ "$gcm" = "" ]]; then |
---|
| 1061 | if [[ $bench = 1 ]]; then |
---|
[4405] | 1062 | echo 'Compilation failed !! Cannot run the benchmark;' |
---|
[4849] | 1063 | exit 1 |
---|
[4215] | 1064 | else |
---|
[4405] | 1065 | echo 'Compilation not done (only done when bench=1)' |
---|
[4215] | 1066 | fi |
---|
[4210] | 1067 | else |
---|
[4215] | 1068 | echo '##########################################################' |
---|
[4849] | 1069 | echo "Compilation successfull !! $(date)" |
---|
[4215] | 1070 | echo '##########################################################' |
---|
[4849] | 1071 | echo "The executable is $gcm" |
---|
[4210] | 1072 | fi |
---|
| 1073 | |
---|
| 1074 | ################################################################## |
---|
| 1075 | # Below, we run a benchmark if bench=1 or tuto |
---|
| 1076 | ################################################################## |
---|
| 1077 | |
---|
[4849] | 1078 | if [[ $bench = tuto ]]; then |
---|
| 1079 | myget Training/tutorial.tar; tar xf tutorial.tar; cd TUTORIAL |
---|
[4218] | 1080 | ./init.sh |
---|
[4210] | 1081 | |
---|
[4849] | 1082 | elif [[ $bench = 1 && ! -d BENCH${grid_resolution} ]]; then |
---|
[4215] | 1083 | # TOUTE CETTE SECTION DEVRAIT DISPARAITRE POUR UNE COMMANDE |
---|
| 1084 | # OU DES BENCHS PAR MOTS CLES COMME tuto |
---|
[4210] | 1085 | |
---|
[4215] | 1086 | echo '##########################################################' |
---|
| 1087 | echo ' Running a test run ' |
---|
| 1088 | echo '##########################################################' |
---|
[4210] | 1089 | |
---|
[4849] | 1090 | \rm -rf "BENCH${grid_resolution}" |
---|
[4215] | 1091 | bench=bench_lmdz_${grid_resolution} |
---|
[4849] | 1092 | echo "install_lmdz.sh before bench download $(date)" |
---|
[4215] | 1093 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz |
---|
[4849] | 1094 | myget "3DBenchs/$bench.tar.gz" |
---|
| 1095 | echo "install_lmdz.sh after bench download $(date)" |
---|
| 1096 | tar xf "$bench.tar.gz" |
---|
[4210] | 1097 | |
---|
[4849] | 1098 | if [[ "$cosp" = "v1" || "$cosp" = "v2" ]]; then |
---|
| 1099 | cd "BENCH${grid_resolution}" |
---|
[4405] | 1100 | # copier les fichiers namelist input et output our COSP |
---|
| 1101 | cp ../DefLists/cosp*_input_nl.txt . |
---|
| 1102 | cp ../DefLists/cosp*_output_nl.txt . |
---|
| 1103 | # Activer la cles ok_cosp pour tourner avec COSP |
---|
| 1104 | sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp |
---|
| 1105 | \mv -f tmp config.def |
---|
| 1106 | cd .. |
---|
[4215] | 1107 | fi |
---|
[4210] | 1108 | |
---|
[4849] | 1109 | if [[ -n "$physiq" ]]; then |
---|
| 1110 | cd "BENCH${grid_resolution}" |
---|
| 1111 | if [[ -f "physiq.def_${physiq}" ]]; then |
---|
| 1112 | cp "physiq.def_${physiq}" physiq.def |
---|
| 1113 | echo using "physiq.def_${physiq}" |
---|
[4405] | 1114 | else |
---|
| 1115 | echo using standard physiq.def |
---|
| 1116 | fi |
---|
| 1117 | cd .. |
---|
[4215] | 1118 | else |
---|
[4405] | 1119 | echo using standard physiq.def |
---|
[4215] | 1120 | fi |
---|
[4210] | 1121 | |
---|
[4849] | 1122 | if [[ "$with_xios" = "y" ]]; then |
---|
| 1123 | cd "BENCH${grid_resolution}" |
---|
[4405] | 1124 | cp ../DefLists/iodef.xml . |
---|
| 1125 | cp ../DefLists/context_lmdz.xml . |
---|
| 1126 | cp ../DefLists/field_def_lmdz.xml . |
---|
| 1127 | # A raffiner par la suite |
---|
[4849] | 1128 | echo "A FAIRE : Copier les *xml en fonction de l option cosp" |
---|
[4405] | 1129 | cp ../DefLists/field_def_cosp*.xml . |
---|
| 1130 | cp ../DefLists/file_def_hist*xml . |
---|
| 1131 | # adapt iodef.xml to use attached mode |
---|
| 1132 | sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' \ |
---|
| 1133 | iodef.xml > tmp |
---|
| 1134 | \mv -f tmp iodef.xml |
---|
[4210] | 1135 | |
---|
[4405] | 1136 | # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE. |
---|
| 1137 | # except for histday |
---|
| 1138 | for histfile in file_def_hist*xml |
---|
| 1139 | do |
---|
[4849] | 1140 | if [[ "$histfile" = "file_def_histday_lmdz.xml" ]]; then |
---|
[4405] | 1141 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' \ |
---|
[4849] | 1142 | "$histfile" > tmp |
---|
| 1143 | \mv -f tmp "$histfile" |
---|
| 1144 | sed -e 's@output_level="_AUTO_"@output_level="5"@' "$histfile" \ |
---|
[4405] | 1145 | > tmp |
---|
[4849] | 1146 | \mv -f tmp "$histfile" |
---|
[4405] | 1147 | sed -e 's@compression_level="2"@compression_level="0"@' \ |
---|
[4849] | 1148 | "$histfile" > tmp |
---|
| 1149 | \mv -f tmp "$histfile" |
---|
[4405] | 1150 | else |
---|
| 1151 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' \ |
---|
[4849] | 1152 | "$histfile" > tmp |
---|
| 1153 | \mv -f tmp "$histfile" |
---|
[4405] | 1154 | fi |
---|
| 1155 | done |
---|
| 1156 | # and add option "ok_all_xml=y" in config.def |
---|
| 1157 | echo "### XIOS outputs" >> config.def |
---|
| 1158 | echo 'ok_all_xml=.true.' >> config.def |
---|
[4210] | 1159 | |
---|
[4405] | 1160 | #activer les sorties pour Cosp |
---|
[4849] | 1161 | if [[ "$cosp" = "v1" ]]; then |
---|
[4807] | 1162 | sed -i'' -e 's@enabled=".FALSE."@enabled=".TRUE."@' \ |
---|
| 1163 | -e 's@output_level="_AUTO_"@output_level="5"@' \ |
---|
| 1164 | -e 's@compression_level="2"@compression_level="0"@' \ |
---|
| 1165 | file_def_histdayCOSP_lmdz.xml |
---|
[4405] | 1166 | fi |
---|
[4849] | 1167 | if [[ "$cosp" = "v2" ]]; then |
---|
[4807] | 1168 | sed -e 's@compression_level="2"@compression_level="0"@' file_def_histdayCOSPv2_lmdz.xml |
---|
[4849] | 1169 | for type_ in hf day mth; do |
---|
[4807] | 1170 | file=file_def_hist${type_}COSP |
---|
| 1171 | sed -i'' -e 's@src="./'${file}'_lmdz.xml"@src="./'${file}'v2_lmdz.xml"@' context_lmdz.xml |
---|
| 1172 | done |
---|
| 1173 | sed -i '' -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' field_def_lmdz.xml |
---|
[4405] | 1174 | fi |
---|
[4210] | 1175 | |
---|
[4405] | 1176 | cd .. |
---|
[4215] | 1177 | fi |
---|
[4210] | 1178 | |
---|
[4215] | 1179 | # Cas Bensh avec ecrad |
---|
[4849] | 1180 | if [[ "$rad" = "ecrad" ]]; then |
---|
| 1181 | cd "BENCH${grid_resolution}" |
---|
[4405] | 1182 | cp ../DefLists/namelist_ecrad . |
---|
| 1183 | cp -r ../libf/phylmd/ecrad/data . |
---|
| 1184 | cd .. |
---|
[4215] | 1185 | fi |
---|
[4210] | 1186 | |
---|
[4215] | 1187 | # Adjusting bench physiq.def to radiative code chosen |
---|
[4849] | 1188 | cd "BENCH${grid_resolution}" |
---|
[4218] | 1189 | sed -e 's/iflag_rrtm=.*.$/iflag_rrtm='$iflag_rrtm'/' \ |
---|
[4405] | 1190 | -e 's/NSW=.*.$/NSW='$NSW'/' physiq.def > tmpdef |
---|
[4215] | 1191 | \mv tmpdef physiq.def |
---|
| 1192 | cd .. |
---|
[4210] | 1193 | |
---|
[4849] | 1194 | cp "$gcm" "BENCH${grid_resolution}/gcm.e" |
---|
[4210] | 1195 | |
---|
[4849] | 1196 | cd "BENCH${grid_resolution}" |
---|
[4215] | 1197 | # On cree le fichier bench.sh au besoin |
---|
| 1198 | # Dans le cas 48x36x39 le bench.sh existe deja en parallele |
---|
[4210] | 1199 | |
---|
[4849] | 1200 | if [[ "$grid_resolution" = "48x36x39" ]]; then |
---|
[4405] | 1201 | echo On ne touche pas au bench.sh |
---|
| 1202 | # But we have to adapt "run_local.sh" for $mpirun |
---|
| 1203 | sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp |
---|
| 1204 | mv -f tmp run_local.sh |
---|
| 1205 | chmod u=rwx run_local.sh |
---|
[4849] | 1206 | elif [[ "${parallel:0:3}" = "mpi" ]]; then |
---|
[4405] | 1207 | # Lancement avec deux procs mpi et 2 openMP |
---|
| 1208 | echo "export OMP_STACKSIZE=800M" > bench.sh |
---|
[4849] | 1209 | if [[ "${parallel:4:3}" = "omp" ]]; then |
---|
[4215] | 1210 | echo "export OMP_NUM_THREADS=2" >> bench.sh |
---|
[4405] | 1211 | fi |
---|
[4849] | 1212 | if [[ "$cosp" = "v1" || "$cosp" = "v2" ]]; then |
---|
| 1213 | if [[ ${hostname:0:5} = jean- ]]; then |
---|
[4405] | 1214 | chmod +x ../arch.env |
---|
| 1215 | ../arch.env |
---|
| 1216 | echo "ulimit -s 2000000" >> bench.sh |
---|
[4215] | 1217 | else |
---|
[4405] | 1218 | echo "ulimit -s 200000" >> bench.sh |
---|
| 1219 | fi |
---|
| 1220 | else |
---|
[4215] | 1221 | echo "ulimit -s unlimited" >> bench.sh |
---|
[4405] | 1222 | fi |
---|
[4849] | 1223 | if [[ ${hostname:0:5} = jean- ]]; then |
---|
[4215] | 1224 | . ../arch/arch-${arch}.env |
---|
[4849] | 1225 | echo "srun -n 2 && $idris_acct@cpu gcm.e > listing 2>&1" \ |
---|
[4405] | 1226 | >> bench.sh |
---|
| 1227 | else |
---|
[4215] | 1228 | echo "$mpirun -np 2 gcm.e > listing 2>&1" >> bench.sh |
---|
[4405] | 1229 | fi |
---|
| 1230 | # Add rebuild, using reb.sh if it is there |
---|
[4849] | 1231 | cat <<EOF >> bench.sh |
---|
| 1232 | if [[ -f reb.sh ]]; then |
---|
| 1233 | ./reb.sh histday; ./reb.sh histmth; ./reb.sh histhf; |
---|
| 1234 | ./reb.sh histins; ./reb.sh stomate_history; |
---|
| 1235 | ./reb.sh sechiba_history; ./reb.sh sechiba_out_2 |
---|
| 1236 | fi |
---|
| 1237 | EOF |
---|
[4215] | 1238 | else |
---|
[4405] | 1239 | echo "./gcm.e > listing 2>&1" > bench.sh |
---|
[4215] | 1240 | fi |
---|
| 1241 | # Getting orchidee stuff |
---|
[4849] | 1242 | if [[ $veget == 'CMIP6' ]]; then |
---|
[4405] | 1243 | #echo 'myget 3DBenchs/BENCHorch11.tar.gz' |
---|
| 1244 | #myget 3DBenchs/BENCHorch11.tar.gz |
---|
| 1245 | #tar xvzf BENCHorch11.tar.gz |
---|
| 1246 | echo 'myget 3DBenchs/BENCHCMIP6.tar.gz' |
---|
| 1247 | myget 3DBenchs/BENCHCMIP6.tar.gz |
---|
| 1248 | tar xvzf BENCHCMIP6.tar.gz |
---|
| 1249 | sed -e "s:VEGET=n:VEGET=y:" config.def > tmp |
---|
| 1250 | mv -f tmp config.def |
---|
[4849] | 1251 | if [[ "$with_xios" = "y" ]]; then |
---|
[4215] | 1252 | cp ../../ORCHIDEE/src_xml/context_orchidee.xml . |
---|
[4218] | 1253 | echo '<context id="orchidee" src="./context_orchidee.xml"/>' \ |
---|
[4405] | 1254 | > add.tmp |
---|
[4215] | 1255 | cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml . |
---|
| 1256 | cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml . |
---|
| 1257 | cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml . |
---|
[4849] | 1258 | if [[ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ]]; then |
---|
[4405] | 1259 | cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml . |
---|
| 1260 | echo '<context id="orchidee" ' \ |
---|
| 1261 | 'src="./context_input_orchidee.xml"/>' >> add.tmp |
---|
[4215] | 1262 | fi |
---|
| 1263 | sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp |
---|
| 1264 | mv tmp iodef.xml |
---|
[4218] | 1265 | sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' \ |
---|
[4405] | 1266 | file_def_orchidee.xml > tmp |
---|
| 1267 | \mv -f tmp file_def_orchidee.xml |
---|
[4218] | 1268 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' \ |
---|
[4405] | 1269 | file_def_orchidee.xml > tmp |
---|
| 1270 | \mv -f tmp file_def_orchidee.xml |
---|
[4218] | 1271 | sed -e 's@output_level="_AUTO_"@output_level="1"@' \ |
---|
[4405] | 1272 | file_def_orchidee.xml > tmp |
---|
| 1273 | \mv -f tmp file_def_orchidee.xml |
---|
[4218] | 1274 | sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' \ |
---|
[4405] | 1275 | file_def_orchidee.xml > tmp |
---|
| 1276 | \mv -f tmp file_def_orchidee.xml |
---|
[4218] | 1277 | sed -e 's@compression_level="4"@compression_level="0"@' \ |
---|
[4405] | 1278 | file_def_orchidee.xml > tmp |
---|
| 1279 | \mv -f tmp file_def_orchidee.xml |
---|
[4218] | 1280 | sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' \ |
---|
[4405] | 1281 | orchidee.def > tmp |
---|
| 1282 | \mv -f tmp orchidee.def |
---|
| 1283 | fi |
---|
[4215] | 1284 | fi |
---|
[4220] | 1285 | |
---|
| 1286 | if [[ -f ../arch.env ]] |
---|
| 1287 | then |
---|
[4405] | 1288 | source ../arch.env |
---|
[4220] | 1289 | fi |
---|
| 1290 | |
---|
[4215] | 1291 | echo EXECUTION DU BENCH |
---|
| 1292 | set +e |
---|
[4849] | 1293 | date; ./bench.sh > out.bench 2>&1; date |
---|
[4215] | 1294 | set -e |
---|
| 1295 | tail listing |
---|
[4210] | 1296 | |
---|
| 1297 | |
---|
[4849] | 1298 | echo "##########################################################" |
---|
| 1299 | echo "Simulation finished in $(pwd)" |
---|
| 1300 | echo "You have compiled with:" |
---|
[4215] | 1301 | cat ../compile.sh |
---|
[4849] | 1302 | if [[ $parallel = "none" ]]; then |
---|
[4873] | 1303 | echo "You may re-run it with : cd $(pwd); gcm.e" |
---|
[4849] | 1304 | echo "or ./bench.sh" |
---|
[4215] | 1305 | else |
---|
[4849] | 1306 | echo "You may re-run it with : " |
---|
[4873] | 1307 | echo "cd $(pwd); ./bench.sh" |
---|
[4405] | 1308 | # echo 'ulimit -s unlimited' |
---|
| 1309 | # echo 'export OMP_NUM_THREADS=2' |
---|
| 1310 | # echo 'export OMP_STACKSIZE=800M' |
---|
| 1311 | # echo "$mpirun -np 2 gcm.e " |
---|
[4215] | 1312 | fi |
---|
| 1313 | echo '##########################################################' |
---|
[4210] | 1314 | |
---|
| 1315 | fi # bench |
---|
| 1316 | |
---|
| 1317 | |
---|
| 1318 | ################################################################# |
---|
| 1319 | # Installation eventuelle du 1D |
---|
| 1320 | ################################################################# |
---|
| 1321 | |
---|
[4849] | 1322 | if [[ $SCM = 1 ]]; then |
---|
| 1323 | cd "$MODEL" |
---|
[4215] | 1324 | myget 1D/1D.tar.gz |
---|
[4286] | 1325 | tar xf 1D.tar.gz |
---|
[4215] | 1326 | cd 1D |
---|
[4849] | 1327 | if [[ $rad = oldrad ]]; then |
---|
[4422] | 1328 | sed -i'' -e 's/^rad=.*$/rad=oldrad/' run.sh |
---|
| 1329 | sed -i'' -e 's/^rad=.*$/rad=oldrad/' bin/compile |
---|
| 1330 | fi |
---|
[4849] | 1331 | echo "Running 1D/run.sh, log in $(pwd)/run1d.log" |
---|
| 1332 | ./run.sh > "$(pwd)/run1d.log" 2>&1 |
---|
[4210] | 1333 | fi |
---|
| 1334 | |
---|
[4409] | 1335 | |
---|
[4210] | 1336 | ################################################################# |
---|
| 1337 | # sauvegarde des options veget pour utilisation eventuelle tutorial_prod |
---|
| 1338 | ################################################################# |
---|
[4849] | 1339 | cd "$MODEL/modipsl/modeles" |
---|
[4210] | 1340 | #echo surface_env file created in $MODEL |
---|
[4849] | 1341 | cat <<EOF >surface_env |
---|
| 1342 | veget=$veget |
---|
| 1343 | opt_veget="-v $veget_version" |
---|
| 1344 | orchidee_rev=$orchidee_rev |
---|
| 1345 | suforch=$suff_orc |
---|
| 1346 | EOF |
---|