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