[1279] | 1 | #!/bin/bash |
---|
| 2 | # $Id: makelmdz_fcm 5192 2024-09-16 12:27:18Z fhourdin $ |
---|
| 3 | # This is a script in Bash. |
---|
| 4 | |
---|
[5089] | 5 | # FH : on ne crée plus le fichier arch.mk qui est supposé exister par |
---|
[783] | 6 | # FH : ailleurs. |
---|
[5089] | 7 | # FH : ulterieurement, ce fichier sera pré-existant pour une série |
---|
| 8 | # FH : de configurations en versions optimisées et debug qui seront |
---|
| 9 | # FH : liés (ln -s) avec arch.mk en fonction de l'architecture. |
---|
| 10 | # FH : Pour le moment, cette version est en test et on peut créer les |
---|
| 11 | # FH : arch.mk en lançant une première fois makegcm. |
---|
[783] | 12 | # |
---|
[5089] | 13 | set -eu |
---|
[783] | 14 | |
---|
[5089] | 15 | function init_vars() { |
---|
| 16 | ######################################################################## |
---|
| 17 | # options par defaut pour la commande make |
---|
| 18 | ######################################################################## |
---|
[783] | 19 | |
---|
[5089] | 20 | dim="96x72x19" |
---|
| 21 | physique=lmd |
---|
| 22 | filtre=filtrez |
---|
| 23 | couple=false |
---|
| 24 | veget=false |
---|
| 25 | inlandsis=false |
---|
| 26 | rad="oldrad" |
---|
| 27 | dust=false |
---|
| 28 | strataer=false |
---|
| 29 | chimie=false |
---|
| 30 | parallel=none |
---|
| 31 | paramem="mem" |
---|
| 32 | compil_mod=prod |
---|
| 33 | io=ioipsl |
---|
| 34 | cosp=false |
---|
| 35 | cosp2=false |
---|
| 36 | cospv2=false |
---|
| 37 | job=1 |
---|
| 38 | full='' |
---|
| 39 | libphy=false |
---|
| 40 | isotopes=false |
---|
| 41 | isoverif=false |
---|
| 42 | diagiso=false |
---|
| 43 | isotrac=false |
---|
| 44 | force_compile=false |
---|
| 45 | cplocninca=false |
---|
[2743] | 46 | |
---|
[5089] | 47 | arch_defined="FALSE" |
---|
| 48 | arch_path="arch" |
---|
| 49 | arch_default_path="arch" |
---|
[783] | 50 | |
---|
[5091] | 51 | LMDGCM=$(pwd) |
---|
[5089] | 52 | LIBOGCM=$LMDGCM/libo |
---|
| 53 | LIBFGCM=$LMDGCM/libf |
---|
| 54 | DYN_COMMON_PATH=$LIBFGCM/dyn3d_common |
---|
| 55 | # path for optional packages, but default set to ".void_dir" |
---|
| 56 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
| 57 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
| 58 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
| 59 | PHY_COMMON_PATH=$LMDGCM/.void_dir |
---|
| 60 | RAD_PATH=$LMDGCM/.void_dir |
---|
| 61 | INLANDSIS_PATH=$LMDGCM/.void_dir |
---|
| 62 | DUST_PATH=$LMDGCM/.void_dir |
---|
| 63 | STRATAER_PATH=$LMDGCM/.void_dir |
---|
| 64 | COSP_PATH=$LMDGCM/.void_dir |
---|
| 65 | fcm_path=$LMDGCM/tools/fcm/bin |
---|
[783] | 66 | |
---|
[5089] | 67 | ######################################################################## |
---|
| 68 | # Quelques initialisations de variables du shell. |
---|
| 69 | ######################################################################## |
---|
[783] | 70 | |
---|
[5089] | 71 | CPP_KEY="IN_LMDZ" |
---|
| 72 | INCLUDE="" |
---|
| 73 | LIB="" |
---|
| 74 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
| 75 | PARA_FFLAGS="" |
---|
| 76 | PARA_LD="" |
---|
| 77 | EXT_SRC="" |
---|
| 78 | } |
---|
[783] | 79 | |
---|
[5089] | 80 | function read_cmdline_options() { |
---|
| 81 | |
---|
| 82 | ######################################################################## |
---|
| 83 | # lecture des options de mymake |
---|
| 84 | ######################################################################## |
---|
| 85 | |
---|
| 86 | while (($# > 0)) |
---|
| 87 | do |
---|
| 88 | case $1 in |
---|
| 89 | "-h") cat <<fin |
---|
| 90 | Usage : |
---|
| 91 | makelmdz_fcm [options] -arch nom_arch exec |
---|
| 92 | [-h] : brief help |
---|
| 93 | [-d [[IMx]JMx]LM] : IM, JM, LM are the dimensions in x, y, z (default: $dim) |
---|
| 94 | [-p PHYS] : set of physical parametrizations (in libf/phyPHYS), (default: lmd) |
---|
| 95 | [-prod / -dev / -debug] : compilation mode production (default) / developement / debug |
---|
| 96 | [-c false/MPI1/OMCT] : coupling with ocean model : MPI1/OMCT/false (default: false) |
---|
| 97 | [-v false/orchideetrunk/orchidee2.1/orchidee2.0/orchidee1.9] : version of the vegetation model to include (default: false) |
---|
| 98 | false : no vegetation model |
---|
| 99 | orchideetrunk : compile using ORCHIDEE trunk from revision 7757 or higher |
---|
| 100 | orchidee2.1 : compile using ORCHIDEE 2.1 until 4.1 included or until revision 7757 on the trunk |
---|
| 101 | orchidee2.0 : compile using ORCHIDEE 2.0 |
---|
| 102 | orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6 |
---|
| 103 | true : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6 |
---|
| 104 | [-chimie INCA/false] : with INCA chemistry model or without (default: false) |
---|
| 105 | [-cplocninca ] : allow transfer of species from PISCES to INCA (default: false) |
---|
| 106 | [-cosp true/false] : compile with/without cosp package (default: false) |
---|
| 107 | [-cosp2 true/false] : compile with/without cosp2 package (default: false) |
---|
| 108 | [-cospv2 true/false] : compile with/without cospv2 package (default: false) |
---|
| 109 | [-inlandsis true/false] : compile with/without inlandsis package (default: false) |
---|
| 110 | [-rrtm true/false] : compile with/without rrtm package (default: false) |
---|
| 111 | [-rad oldrad/rrtm/ecrad] : compile with oldrad/rrtm/ecrad radiatif code (default: oldrad) |
---|
| 112 | [-dust true/false] : compile with/without the dust package by Boucher and co (default: false) |
---|
| 113 | [-strataer true/false] : compile with/without the strat aer package by Boucher and co (default: false) |
---|
| 114 | [-isotopes true/false] : compile with/without water isotopes in the physics |
---|
| 115 | [-isoverif true/false] : compile with/without verifications for water isotopes in the physics |
---|
| 116 | [-diagiso true/false] : compile with/without special diagnostics for water isotopes in the physics |
---|
| 117 | [-isotrac true/false] : compile with/without tracers of water isotopes in the physics |
---|
| 118 | [-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp |
---|
| 119 | [-io ioipsl/mix/xios] : Input/Output library (default: ioipsl) |
---|
| 120 | [-include INCLUDES] : extra include path to add |
---|
| 121 | [-cpp CPP_KEY] : additional preprocessing definitions |
---|
| 122 | [-mem] : reduced memory dynamics (obsolete flag; always on in parallel mode) |
---|
| 123 | [-filtre NOMFILTRE] : use filtre from libf/NOMFILTRE (default: filtrez) |
---|
| 124 | [-link LINKS] : additional links with other libraries |
---|
| 125 | [-j n] : active parallel compiling on ntask |
---|
| 126 | [-full] : full recompiling |
---|
| 127 | [-libphy] : only compile physics package (no dynamics or main program) |
---|
| 128 | [-fcm_path path] : path to the fcm tool (default: tools/fcm/bin) |
---|
| 129 | [-ext_src path] : path to an additional set of routines to compile with the model |
---|
| 130 | [-arch_path path] : path to architecture files (default: $arch_default_path) |
---|
| 131 | [-force_compile] : recompile although there seems to be an on-going compilation |
---|
| 132 | -arch nom_arch : target architecture |
---|
| 133 | exec : executable to build |
---|
[783] | 134 | fin |
---|
[5089] | 135 | exit 2;; |
---|
[783] | 136 | |
---|
[5089] | 137 | "-d") |
---|
| 138 | dim=$2; shift; shift;; |
---|
[783] | 139 | |
---|
[5089] | 140 | "-p") |
---|
| 141 | physique="$2"; shift; shift;; |
---|
[783] | 142 | |
---|
[5089] | 143 | "-c") |
---|
| 144 | couple="$2"; shift; shift;; |
---|
[1002] | 145 | |
---|
[5089] | 146 | "-prod") |
---|
| 147 | compil_mod="prod"; shift;; |
---|
[1002] | 148 | |
---|
[5089] | 149 | "-dev") |
---|
| 150 | compil_mod="dev"; shift;; |
---|
[1002] | 151 | |
---|
[5089] | 152 | "-debug") |
---|
| 153 | compil_mod="debug"; shift;; |
---|
[783] | 154 | |
---|
[5089] | 155 | "-io") |
---|
| 156 | io="$2"; shift; shift;; |
---|
[783] | 157 | |
---|
[5089] | 158 | "-v") |
---|
| 159 | veget="$2"; shift; shift;; |
---|
[3793] | 160 | |
---|
[5089] | 161 | "-inlandsis") |
---|
| 162 | inlandsis="$2"; shift; shift;; |
---|
[1990] | 163 | |
---|
[5089] | 164 | "-rrtm") |
---|
| 165 | if [ "$2" = "false" ]; then rad="oldrad"; else rad="rrtm"; fi; shift; shift;; |
---|
[3908] | 166 | |
---|
[5089] | 167 | "-rad") |
---|
| 168 | rad="$2"; shift; shift;; |
---|
[2631] | 169 | |
---|
[5089] | 170 | "-dust") |
---|
| 171 | dust="$2"; shift; shift;; |
---|
[2690] | 172 | |
---|
[5089] | 173 | "-strataer") |
---|
| 174 | strataer="$2"; shift; shift;; |
---|
[783] | 175 | |
---|
[5089] | 176 | "-chimie") |
---|
| 177 | chimie="$2"; shift; shift;; |
---|
[4247] | 178 | |
---|
[5089] | 179 | "-cplocninca") |
---|
| 180 | cplocninca=TRUE; shift;; |
---|
[3924] | 181 | |
---|
[5089] | 182 | "-isotopes") |
---|
| 183 | isotopes="$2"; shift; shift;; |
---|
[3924] | 184 | |
---|
[5089] | 185 | "-isoverif") |
---|
| 186 | isoverif="$2"; shift; shift;; |
---|
[3924] | 187 | |
---|
[5089] | 188 | "-diagiso") |
---|
| 189 | diagiso="$2"; shift; shift;; |
---|
[3924] | 190 | |
---|
[5089] | 191 | "-isotrac") |
---|
| 192 | isotrac="$2"; shift; shift;; |
---|
[783] | 193 | |
---|
[5089] | 194 | "-parallel") |
---|
| 195 | parallel="$2"; shift; shift;; |
---|
[1132] | 196 | |
---|
[5089] | 197 | "-include") |
---|
| 198 | INCLUDE="$INCLUDE -I$2"; shift; shift;; |
---|
[783] | 199 | |
---|
[5089] | 200 | "-cpp") |
---|
| 201 | CPP_KEY="$CPP_KEY $2"; shift; shift;; |
---|
[3358] | 202 | |
---|
[5089] | 203 | "-cosp") |
---|
| 204 | cosp="$2"; shift; shift;; |
---|
[3491] | 205 | |
---|
[5089] | 206 | "-cosp2") |
---|
| 207 | cosp2="$2"; shift; shift;; |
---|
[783] | 208 | |
---|
[5089] | 209 | "-cospv2") |
---|
| 210 | cospv2="$2"; shift; shift;; |
---|
[783] | 211 | |
---|
[5089] | 212 | "-mem") |
---|
| 213 | echo "option -mem is obsolete (now always on in parallel)" |
---|
| 214 | paramem="mem"; shift;; |
---|
[1136] | 215 | |
---|
[5089] | 216 | "-filtre") |
---|
| 217 | filtre=$2; shift; shift;; |
---|
[783] | 218 | |
---|
[5089] | 219 | "-link") |
---|
| 220 | LIB="$LIB $2"; shift; shift;; |
---|
[2358] | 221 | |
---|
[5089] | 222 | "-fcm_path") |
---|
| 223 | fcm_path=$2; shift; shift;; |
---|
[2358] | 224 | |
---|
[5089] | 225 | "-ext_src") |
---|
| 226 | EXT_SRC=$2; shift; shift;; |
---|
[783] | 227 | |
---|
[5089] | 228 | "-j") |
---|
| 229 | job=$2; shift; shift;; |
---|
[2358] | 230 | |
---|
[5089] | 231 | "-full") |
---|
| 232 | full="-full"; shift;; |
---|
[783] | 233 | |
---|
[5089] | 234 | "-libphy") |
---|
| 235 | libphy="true"; shift;; |
---|
[2743] | 236 | |
---|
[5089] | 237 | "-arch") |
---|
| 238 | arch=$2; arch_defined="TRUE"; shift; shift;; |
---|
[4096] | 239 | |
---|
[5089] | 240 | "-arch_path") |
---|
| 241 | arch_path=$2; shift; shift;; |
---|
[1279] | 242 | |
---|
[5089] | 243 | "-force_compile") |
---|
| 244 | force_compile=true; shift;; |
---|
[783] | 245 | |
---|
[5089] | 246 | *) |
---|
| 247 | code="$1"; shift;; |
---|
| 248 | esac |
---|
| 249 | done |
---|
[1757] | 250 | |
---|
[5089] | 251 | ############################################################### |
---|
| 252 | # path to fcm |
---|
| 253 | ############################################################### |
---|
| 254 | # handle case when provided path to fcm was given as a relative |
---|
| 255 | # path (from makelmdz_fcm script directory) and not an absolute path |
---|
| 256 | if [[ ${fcm_path:0:1} != "/" ]]; then |
---|
| 257 | # prepend with makelmdz_fcm location |
---|
| 258 | fcm_path="$(cd "$(dirname "$0")"; pwd)/$fcm_path" |
---|
| 259 | fi |
---|
[1136] | 260 | |
---|
[5089] | 261 | # add fcm_path to PATH |
---|
| 262 | export PATH=$fcm_path:$PATH |
---|
| 263 | echo "Path to fcm: $fcm_path" |
---|
| 264 | } |
---|
[783] | 265 | |
---|
[5089] | 266 | function init_arch() { |
---|
| 267 | ############################################################### |
---|
| 268 | # lecture des chemins propres à l'architecture de la machine # |
---|
| 269 | ############################################################### |
---|
| 270 | rm -f .void_file |
---|
| 271 | touch .void_file |
---|
| 272 | rm -rf .void_dir |
---|
| 273 | mkdir .void_dir |
---|
[2743] | 274 | |
---|
[5091] | 275 | if [[ "$arch_defined" = "TRUE" ]]; then |
---|
[5089] | 276 | local i |
---|
| 277 | for i in "path" "fcm" "env"; do |
---|
| 278 | rm -f "arch.$i" |
---|
[2743] | 279 | |
---|
[5089] | 280 | if [[ -f "$arch_path/arch-$arch.$i" ]]; then |
---|
| 281 | ln -s "$arch_path/arch-$arch.$i" "arch.$i" |
---|
| 282 | elif [[ -f "$arch_default_path/arch-$arch.$i" ]]; then |
---|
| 283 | ln -s "$arch_default_path/arch-$arch.$i" "arch.$i" |
---|
| 284 | elif [[ $i = "env" ]]; then |
---|
| 285 | ln -s .void_file arch.env |
---|
| 286 | fi |
---|
| 287 | done |
---|
| 288 | |
---|
| 289 | # source architecture PATH and ENV files |
---|
| 290 | source arch.env |
---|
| 291 | source arch.path |
---|
[2743] | 292 | else |
---|
[5089] | 293 | echo "STOP: You must define a target architecture"; exit 1 |
---|
[2743] | 294 | fi |
---|
[5089] | 295 | } |
---|
[2743] | 296 | |
---|
[5089] | 297 | function cpp_keys_and_include_mod_path() { |
---|
| 298 | ######################################################################## |
---|
| 299 | # Definition des clefs CPP, des chemins des includes et modules |
---|
| 300 | # et des libraries |
---|
| 301 | ######################################################################## |
---|
[783] | 302 | |
---|
[5089] | 303 | if [[ $compil_mod = "prod" ]]; then |
---|
| 304 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
| 305 | elif [[ $compil_mod = "dev" ]]; then |
---|
| 306 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
| 307 | elif [[ $compil_mod = "debug" ]]; then |
---|
| 308 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
| 309 | fi |
---|
[2250] | 310 | |
---|
[5089] | 311 | phys_root=$physique |
---|
| 312 | if [[ ${physique:0:3} = "lmd" ]]; then phys_root=lmd; fi |
---|
| 313 | if [[ ${physique:0:4} = "mars" ]]; then phys_root=mars; fi |
---|
| 314 | if [[ ${physique:0:3} = "std" ]]; then phys_root=std; fi |
---|
| 315 | if [[ ${physique:0:5} = "venus" ]]; then phys_root=venus; fi |
---|
| 316 | if [[ ${physique:0:5} = "titan" ]]; then phys_root=titan; fi |
---|
| 317 | if [[ ${physique:0:3} = "dev" ]]; then phys_root=dev; fi |
---|
[783] | 318 | |
---|
[5089] | 319 | if [[ $physique != "nophys" ]]; then |
---|
| 320 | #We'll use some physics |
---|
| 321 | CPP_KEY="$CPP_KEY CPP_PHYS" |
---|
| 322 | # set physics common utilities path |
---|
| 323 | PHY_COMMON_PATH="${LIBFGCM}/phy_common" |
---|
| 324 | # set the dyn/phys interface path |
---|
| 325 | DYN_PHYS_PATH="${LIBFGCM}/dynphy_lonlat" |
---|
| 326 | DYN_PHYS_SUB_PATH="${LIBFGCM}/dynphy_lonlat/phy${phys_root}" |
---|
| 327 | fi |
---|
[2239] | 328 | |
---|
[5091] | 329 | if [[ $filtre = "filtrez" ]]; then |
---|
[5089] | 330 | FILTRE_PATH=${LIBFGCM}/$filtre |
---|
| 331 | fi |
---|
[783] | 332 | |
---|
[5091] | 333 | if [[ $chimie = "INCA" ]]; then |
---|
[5089] | 334 | CPP_KEY="$CPP_KEY INCA" |
---|
| 335 | INCLUDE="$INCLUDE ${INCA_INCDIR}" |
---|
| 336 | LIB="$LIB ${INCA_LIBDIR} ${INCA_LIB}" |
---|
| 337 | fi |
---|
[3924] | 338 | |
---|
[5091] | 339 | if [[ $isotopes = "true" ]]; then |
---|
[5089] | 340 | CPP_KEY="$CPP_KEY ISO" |
---|
| 341 | fi |
---|
[3924] | 342 | |
---|
[5091] | 343 | if [[ $isoverif = "true" ]]; then |
---|
[5089] | 344 | CPP_KEY="$CPP_KEY ISOVERIF" |
---|
| 345 | fi |
---|
[3924] | 346 | |
---|
[5091] | 347 | if [[ $diagiso = "true" ]]; then |
---|
[5089] | 348 | CPP_KEY="$CPP_KEY DIAGISO" |
---|
| 349 | fi |
---|
[3924] | 350 | |
---|
[5091] | 351 | if [[ $isotrac = "true" ]]; then |
---|
[5089] | 352 | CPP_KEY="$CPP_KEY ISOTRAC" |
---|
| 353 | fi |
---|
[783] | 354 | |
---|
[5091] | 355 | if [[ $couple != "false" ]]; then |
---|
| 356 | if [[ $couple = "MPI1" ]]; then |
---|
[5089] | 357 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
| 358 | export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1 |
---|
| 359 | export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib |
---|
| 360 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
| 361 | LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.MPI1 -lmpp_io" |
---|
| 362 | else |
---|
| 363 | CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT" |
---|
| 364 | INCLUDE="$INCLUDE ${OASIS_INCDIR}" |
---|
| 365 | LIB="$LIB ${OASIS_LIBDIR} -lpsmile.MPI1 -lscrip -lmct -lmpeu" |
---|
| 366 | fi |
---|
| 367 | fi |
---|
[783] | 368 | |
---|
[5091] | 369 | if [[ $parallel = "mpi" ]]; then |
---|
[5089] | 370 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
| 371 | PARA_FFLAGS="%MPI_FFLAGS" |
---|
| 372 | PARA_LD="%MPI_LD" |
---|
[5091] | 373 | elif [[ $parallel = "omp" ]]; then |
---|
[5089] | 374 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
| 375 | PARA_FFLAGS="%OMP_FFLAGS" |
---|
| 376 | PARA_LD="%OMP_LD" |
---|
[5091] | 377 | elif [[ $parallel = "mpi_omp" ]]; then |
---|
[5089] | 378 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
| 379 | PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS" |
---|
| 380 | PARA_LD="%MPI_LD %OMP_LD" |
---|
| 381 | fi |
---|
[783] | 382 | |
---|
[5091] | 383 | if [[ ( $parallel = "omp" || $parallel = "mpi_omp" ) && $compil_mod = "debug" ]]; then |
---|
[5089] | 384 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
| 385 | echo "We suggest switching to \"-dev\"." |
---|
| 386 | fi |
---|
| 387 | |
---|
[5122] | 388 | if [[ $veget = "true" || $veget = "orchidee1.9" || $veget = "orchidee2.0" \ |
---|
[5091] | 389 | || $veget = "orchidee2.1" || $veget = "orchideetrunk" ]]; then |
---|
[4426] | 390 | echo "doing orchidee" |
---|
[1811] | 391 | #NB: option 'true': for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6 |
---|
| 392 | # For this case, cpp flag ORCHIDEE_NOOPENMP must be added to the makelmdz_fcm arguments |
---|
| 393 | # option orchidee1.9 : Compile with ORCHIDEE version up to the inclusion of OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6 |
---|
[4426] | 394 | INCLUDE="${INCLUDE} ${ORCH_INCDIR}" |
---|
[1772] | 395 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
[5122] | 396 | # temporary, for Orchidee versions 1.9.* (before openmp activatmodion) |
---|
[5091] | 397 | if [[ "$veget" = "orchidee1.9" ]]; then |
---|
[1811] | 398 | CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP" |
---|
[5089] | 399 | fi |
---|
| 400 | if [[ "$veget" = "orchidee2.0" ]]; then |
---|
[4426] | 401 | orch_libs="-lsechiba -lparameters -lstomate -lparallel -lorglob -lorchidee" |
---|
[3435] | 402 | CPP_KEY="$CPP_KEY ORCHIDEE_NOUNSTRUCT" |
---|
[5089] | 403 | elif [[ "$veget" = "orchidee2.1" ]]; then |
---|
[4283] | 404 | CPP_KEY="$CPP_KEY ORCHIDEE_NOLIC" |
---|
[4426] | 405 | orch_libs="-lsechiba -lparameters -lstomate -lparallel -lorglob -lorchidee" |
---|
[5089] | 406 | elif [[ "$veget" = "orchideetrunk" ]]; then |
---|
[4426] | 407 | orch_libs="-lorchidee" |
---|
[5089] | 408 | else |
---|
[4426] | 409 | orch_libs="-lsechiba -lparameters -lstomate -lparallel -lorglob" |
---|
[5089] | 410 | fi |
---|
| 411 | LIB="${LIB} ${ORCH_LIBDIR} ${orch_libs}" |
---|
| 412 | echo "orchidee lib" |
---|
| 413 | echo "${LIB}" |
---|
[5091] | 414 | elif [[ $veget != "false" ]]; then |
---|
[5089] | 415 | echo "Option -v $veget does not exist" |
---|
| 416 | echo "Use ./makelmdz_fcm -h for more information" |
---|
| 417 | exit 1 |
---|
| 418 | fi |
---|
[783] | 419 | |
---|
[5103] | 420 | INLANDSIS_PATH="$LIBFGCM/phy${physique}/inlandsis" |
---|
[5091] | 421 | if [[ $inlandsis = "true" ]]; then |
---|
[5089] | 422 | CPP_KEY="$CPP_KEY CPP_INLANDSIS" |
---|
| 423 | fi |
---|
[3793] | 424 | |
---|
[5091] | 425 | if [[ $rad = "rrtm" ]]; then |
---|
[5089] | 426 | CPP_KEY="$CPP_KEY CPP_RRTM" |
---|
| 427 | RAD_PATH="$LIBFGCM/phy${physique}/rrtm" |
---|
[5091] | 428 | elif [[ $rad = "ecrad" ]]; then |
---|
[5089] | 429 | CPP_KEY="$CPP_KEY CPP_ECRAD" |
---|
| 430 | RAD_PATH="$LIBFGCM/phy${physique}/ecrad" |
---|
| 431 | fi |
---|
[1990] | 432 | |
---|
[5099] | 433 | DUST_PATH="$LIBFGCM/phy${physique}/Dust" |
---|
[5091] | 434 | if [[ $dust = "true" ]]; then |
---|
[5089] | 435 | CPP_KEY="$CPP_KEY CPP_Dust" |
---|
| 436 | fi |
---|
[2631] | 437 | |
---|
[5098] | 438 | STRATAER_PATH="$LIBFGCM/phy${physique}/StratAer" |
---|
[5091] | 439 | if [[ $strataer = "true" ]]; then |
---|
[5089] | 440 | CPP_KEY="$CPP_KEY CPP_StratAer" |
---|
| 441 | fi |
---|
[2690] | 442 | |
---|
[5089] | 443 | INCLUDE="$INCLUDE ${NETCDF95_INCDIR}" |
---|
| 444 | LIB="$LIB ${NETCDF95_LIBDIR} ${NETCDF95_LIB}" |
---|
[4489] | 445 | |
---|
[5091] | 446 | if [[ $io = "ioipsl" ]]; then |
---|
[5089] | 447 | INCLUDE="$INCLUDE ${IOIPSL_INCDIR}" |
---|
| 448 | LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB}" |
---|
[5091] | 449 | elif [[ $io = "mix" ]]; then |
---|
[5130] | 450 | CPP_KEY="$CPP_KEY CPP_XIOS" |
---|
[5089] | 451 | INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}" |
---|
| 452 | LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}" |
---|
[5091] | 453 | elif [[ $io = "xios" ]]; then |
---|
[5130] | 454 | CPP_KEY="$CPP_KEY CPP_XIOS CPP_IOIPSL_NO_OUTPUT" |
---|
[5089] | 455 | INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}" |
---|
| 456 | LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}" |
---|
| 457 | fi |
---|
[1897] | 458 | |
---|
[5091] | 459 | if [[ $cosp = "true" ]]; then |
---|
[5089] | 460 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
| 461 | COSP_PATH="$LIBFGCM/phylmd/cosp" |
---|
| 462 | fi |
---|
[783] | 463 | |
---|
[5091] | 464 | if [[ $cosp2 = "true" ]]; then |
---|
[5089] | 465 | CPP_KEY="$CPP_KEY CPP_COSP2" |
---|
| 466 | COSP_PATH="$LIBFGCM/phylmd/cosp2" |
---|
| 467 | fi |
---|
[3358] | 468 | |
---|
[5091] | 469 | if [[ $cospv2 = "true" ]]; then |
---|
[5089] | 470 | CPP_KEY="$CPP_KEY CPP_COSPV2" |
---|
| 471 | COSP_PATH="$LIBFGCM/phylmd/cospv2" |
---|
| 472 | fi |
---|
[3358] | 473 | |
---|
[5091] | 474 | if [[ $cplocninca = "TRUE" ]]; then |
---|
[5089] | 475 | CPP_KEY="${CPP_KEY} CPP_CPLOCNINCA" |
---|
| 476 | fi |
---|
[3491] | 477 | |
---|
| 478 | |
---|
[5089] | 479 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
| 480 | LIB="$LIB ${NETCDF_LIBDIR} ${NETCDF_LIB}" |
---|
| 481 | } |
---|
[1551] | 482 | |
---|
[5091] | 483 | function handle_dimension() { |
---|
| 484 | ######################################################################## |
---|
| 485 | # calcul du nombre de dimensions |
---|
| 486 | ######################################################################## |
---|
[5089] | 487 | |
---|
[5091] | 488 | dim_full=$dim |
---|
| 489 | dim=$(echo "$dim" | sed -e 's/[^0-9]/ /g') |
---|
| 490 | dimc=$(awk -F" " '{print NF}' <<< "$dim") |
---|
| 491 | echo "calcul de la dimension: dim=$dim, dimc=$dimc" |
---|
| 492 | |
---|
| 493 | ######################################################################## |
---|
| 494 | # Gestion des dimensions du modele. |
---|
| 495 | # on cree ou remplace le fichier des dimensions |
---|
| 496 | ######################################################################## |
---|
| 497 | |
---|
| 498 | cd "$LIBFGCM/grid" |
---|
[5159] | 499 | if [[ -f lmdz_dimensions.f90 ]]; then |
---|
[5091] | 500 | if [[ $force_compile = "true" ]]; then |
---|
[5159] | 501 | rm -f "$LIBFGCM/grid/lmdz_dimensions.f90" |
---|
[5091] | 502 | else |
---|
| 503 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
| 504 | echo "Wait until the first compilation is finished before launching this one." |
---|
| 505 | echo "If you are sure that you are not compiling elsewhere, " |
---|
| 506 | echo "If you are sure that you are not compiling elsewhere, then" |
---|
[5159] | 507 | echo "rm -f \"$LIBFGCM/grid/lmdz_dimensions.f90\"" |
---|
[5091] | 508 | echo "before reruning the compilation" |
---|
| 509 | echo "or run makelmdz_fcm with option -force_compile" |
---|
| 510 | exit 1 |
---|
| 511 | fi |
---|
| 512 | fi |
---|
| 513 | |
---|
| 514 | cd "$LIBFGCM/grid/dimension" |
---|
| 515 | # shellcheck disable=SC2086 |
---|
| 516 | ./makdim $dim |
---|
[5159] | 517 | cat "$LIBFGCM/grid/lmdz_dimensions.f90" |
---|
[5091] | 518 | cd "$LMDGCM" |
---|
| 519 | } |
---|
[5089] | 520 | |
---|
[5091] | 521 | function different_dynamics() { |
---|
| 522 | ######################################################################## |
---|
| 523 | # Differentes dynamiques (3d, 2d, 1d) |
---|
| 524 | ######################################################################## |
---|
| 525 | if [[ $dimc = 1 ]]; then |
---|
[5192] | 526 | ## no filtre in 1d: |
---|
| 527 | FILTRE_PATH="$LMDGCM/.void_dir" |
---|
[5091] | 528 | ## no need to compile all routines in dyn3d_common either: |
---|
| 529 | DYN_COMMON_PATH="$LMDGCM/.void_dir" |
---|
| 530 | ## no need to compile all routines in dynlmdz_phy...; |
---|
| 531 | ## (because key ones are included in 1D main program) |
---|
| 532 | DYN_PHYS_PATH="$LMDGCM/.void_dir" |
---|
| 533 | DYN_PHYS_SUB_PATH="$LMDGCM/.void_dir" |
---|
| 534 | fi |
---|
[783] | 535 | |
---|
[5091] | 536 | ###################################################################### |
---|
| 537 | # Gestion du filtre qui n'existe qu'en 3d. |
---|
| 538 | ###################################################################### |
---|
| 539 | if [[ $dimc -gt 2 ]]; then |
---|
| 540 | filtre="FILTRE=$filtre" |
---|
| 541 | else |
---|
| 542 | filtre="FILTRE= L_FILTRE= " |
---|
| 543 | fi |
---|
| 544 | echo "MACRO FILTRE $filtre (dimc=$dimc)" |
---|
| 545 | } |
---|
[783] | 546 | |
---|
[5091] | 547 | function create_config_suffix() { |
---|
| 548 | ###################################################################### |
---|
| 549 | # Creation du suffixe de la configuration |
---|
| 550 | ###################################################################### |
---|
[783] | 551 | |
---|
[5091] | 552 | SUFF_NAME=_${dim_full} |
---|
| 553 | SUFF_NAME=${SUFF_NAME}_phy${physique}_${rad} |
---|
| 554 | |
---|
| 555 | if [[ $parallel != "none" ]]; then |
---|
| 556 | SUFF_NAME=${SUFF_NAME}_para |
---|
| 557 | DYN=dyn${dimc}d${paramem} |
---|
| 558 | if [[ $paramem = "mem" ]]; then |
---|
| 559 | SUFF_NAME=${SUFF_NAME}_${paramem} |
---|
[4096] | 560 | else |
---|
[5091] | 561 | echo "The version of the dynamics in dyn3dpar is no longer updated." |
---|
| 562 | echo "You should use option \"-mem\"." |
---|
[5048] | 563 | exit 1 |
---|
[4096] | 564 | fi |
---|
[5091] | 565 | else |
---|
| 566 | SUFF_NAME=${SUFF_NAME}_seq |
---|
| 567 | if [[ $dimc = 1 ]]; then |
---|
| 568 | # dynamics-related routines in"dyn1d" subdirectory of phy${physique} |
---|
| 569 | DYN=phy${physique}/dyn1d |
---|
| 570 | else |
---|
| 571 | DYN=dyn${dimc}d |
---|
| 572 | fi |
---|
| 573 | fi |
---|
[1695] | 574 | |
---|
[5091] | 575 | if [[ $veget != "false" ]]; then |
---|
| 576 | SUFF_NAME=${SUFF_NAME}_orch |
---|
| 577 | fi |
---|
[1695] | 578 | |
---|
[5091] | 579 | if [[ $dust = "true" ]]; then |
---|
| 580 | SUFF_NAME=${SUFF_NAME}_spla |
---|
| 581 | fi |
---|
[5048] | 582 | |
---|
[5091] | 583 | if [[ $couple != "false" ]]; then |
---|
| 584 | SUFF_NAME=${SUFF_NAME}_couple |
---|
| 585 | fi |
---|
[783] | 586 | |
---|
[5091] | 587 | if [[ $chimie = "INCA" ]]; then |
---|
| 588 | SUFF_NAME=${SUFF_NAME}_inca |
---|
| 589 | fi |
---|
[783] | 590 | |
---|
[5091] | 591 | if [[ "$isotopes" = "true" ]]; then |
---|
| 592 | SUFF_NAME=${SUFF_NAME}_iso |
---|
| 593 | fi |
---|
| 594 | if [[ "$isoverif" = "true" ]]; then |
---|
| 595 | SUFF_NAME=${SUFF_NAME}_isoverif |
---|
| 596 | fi |
---|
| 597 | if [[ "$isotrac" = "true" ]]; then |
---|
| 598 | SUFF_NAME=${SUFF_NAME}_isotrac |
---|
| 599 | fi |
---|
| 600 | if [[ "$diagiso" = "true" ]]; then |
---|
| 601 | SUFF_NAME=${SUFF_NAME}_diagiso |
---|
| 602 | fi |
---|
[783] | 603 | |
---|
[5091] | 604 | if [[ $libphy = "true" ]]; then |
---|
| 605 | # special case where we compile only the physics |
---|
| 606 | DYN=$LMDGCM/.void_dir |
---|
| 607 | DYN_COMMON_PATH=$LMDGCM/.void_dir |
---|
| 608 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
| 609 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
| 610 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
| 611 | #and there is no main program to generate |
---|
| 612 | code="" |
---|
| 613 | SUFF_NAME="" |
---|
| 614 | else |
---|
| 615 | SUFF_NAME=${SUFF_NAME}.e |
---|
| 616 | fi |
---|
| 617 | } |
---|
[783] | 618 | |
---|
[5091] | 619 | function create_fcm_conf() { |
---|
| 620 | cd "$LMDGCM" |
---|
| 621 | config_fcm="config.fcm" |
---|
| 622 | rm -f "bin/${code}${SUFF_NAME}.e" |
---|
| 623 | rm -f arch.fcm |
---|
| 624 | rm -f arch.opt |
---|
[783] | 625 | |
---|
[5091] | 626 | { |
---|
| 627 | echo "%ARCH $arch" |
---|
| 628 | echo "%INCDIR $INCLUDE" |
---|
| 629 | echo "%LIB $LIB" |
---|
| 630 | echo "%ROOT_PATH $PWD" |
---|
| 631 | echo "%LIBF $LIBFGCM" |
---|
| 632 | echo "%LIBO $LIBOGCM" |
---|
| 633 | echo "%DYN $DYN" |
---|
| 634 | echo "%DYN_COMMON $DYN_COMMON_PATH" |
---|
| 635 | echo "%PHY_COMMON $PHY_COMMON_PATH" |
---|
| 636 | echo "%FILTRE $FILTRE_PATH" |
---|
| 637 | echo "%PHYS phy${physique}" |
---|
| 638 | echo "%DYN_PHYS $DYN_PHYS_PATH" |
---|
| 639 | echo "%DYN_PHYS_SUB $DYN_PHYS_SUB_PATH" |
---|
| 640 | echo "%RAD $RAD_PATH" |
---|
| 641 | echo "%DUST $DUST_PATH" |
---|
| 642 | echo "%STRATAER $STRATAER_PATH" |
---|
| 643 | echo "%INLANDSIS $INLANDSIS_PATH" |
---|
| 644 | echo "%COSP $COSP_PATH" |
---|
| 645 | echo "%CPP_KEY $CPP_KEY" |
---|
| 646 | echo "%EXEC $code" |
---|
| 647 | echo "%SUFF_NAME $SUFF_NAME" |
---|
| 648 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" |
---|
| 649 | echo "%PARA_FFLAGS $PARA_FFLAGS" |
---|
| 650 | echo "%PARA_LD $PARA_LD" |
---|
| 651 | echo "%EXT_SRC $EXT_SRC" |
---|
| 652 | } > $config_fcm |
---|
[2239] | 653 | |
---|
[5091] | 654 | # ecrad conf |
---|
| 655 | if [[ $rad = "ecrad" ]]; then |
---|
| 656 | cp bld.cfg.ecrad bld.cfg |
---|
[2202] | 657 | else |
---|
[5091] | 658 | cp bld.cfg.rrtm bld.cfg |
---|
[1680] | 659 | fi |
---|
[5091] | 660 | |
---|
| 661 | # arch.fcm and arch.opt |
---|
| 662 | ln -s "arch/arch-$arch.fcm" arch.fcm |
---|
| 663 | if [[ -f arch/arch-$arch.opt && $compil_mod = "prod" ]]; then |
---|
| 664 | ln -s "arch/arch-$arch.opt" arch.opt |
---|
[2239] | 665 | else |
---|
[5091] | 666 | ln -s .void_file arch.opt |
---|
[2239] | 667 | fi |
---|
[5091] | 668 | } |
---|
[783] | 669 | |
---|
[5091] | 670 | function build_gcm() { |
---|
| 671 | set +e |
---|
[783] | 672 | |
---|
[5091] | 673 | rm -f "$LIBOGCM/$arch$SUFF_NAME/.config/fcm.bld.lock" |
---|
| 674 | ./build_gcm "$fcm_path" -j "$job" $full |
---|
| 675 | build_status=$? |
---|
[3804] | 676 | |
---|
[5093] | 677 | rm -rf tmp_src config |
---|
[5091] | 678 | ln -s "$LIBOGCM/$arch$SUFF_NAME/.config" config |
---|
| 679 | ln -s "$LIBOGCM/$arch$SUFF_NAME/.config/ppsrc" tmp_src |
---|
[5093] | 680 | cp -r "$LIBOGCM/$arch$SUFF_NAME/.config/bin" . |
---|
[783] | 681 | |
---|
[5159] | 682 | if [[ -r $LIBFGCM/grid/lmdz_dimensions.f90 ]]; then |
---|
| 683 | # Cleanup: remove dimensionlmdz_dimensions.f90 file |
---|
| 684 | rm -f "$LIBFGCM/grid/lmdz_dimensions.f90" |
---|
[5091] | 685 | fi |
---|
[783] | 686 | |
---|
[5091] | 687 | # build netcdf95 library necessary for the makelmdz script |
---|
| 688 | if [[ $build_status = 0 ]]; then |
---|
| 689 | if [[ ! -d tools/netcdf95/include ]]; then |
---|
| 690 | mkdir tools/netcdf95/include tools/netcdf95/lib |
---|
| 691 | cp config/inc/netcdf95.mod config/inc/nf95_*mod tools/netcdf95/include |
---|
| 692 | cp config/obj/netcdf95.o config/obj/nf95_*o config/obj/check_start_count_m.o tools/netcdf95/lib |
---|
| 693 | cd tools/netcdf95/lib; ar rv libnetcdf95.a -- *.o; ranlib libnetcdf95.a |
---|
| 694 | cd - |
---|
| 695 | fi |
---|
| 696 | fi |
---|
[3924] | 697 | |
---|
[5091] | 698 | exit $build_status |
---|
| 699 | } |
---|
[2358] | 700 | |
---|
[5091] | 701 | init_vars |
---|
| 702 | read_cmdline_options "$@" |
---|
| 703 | init_arch |
---|
| 704 | cpp_keys_and_include_mod_path |
---|
| 705 | handle_dimension |
---|
| 706 | different_dynamics |
---|
| 707 | create_config_suffix |
---|
| 708 | create_fcm_conf |
---|
| 709 | build_gcm |
---|