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