[1279] | 1 | #!/bin/bash |
---|
| 2 | # $Id: makelmdz_fcm 4203 2022-07-19 11:33:28Z 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 |
---|
[4203] | 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 |
---|
[783] | 47 | |
---|
[2743] | 48 | arch_defined="FALSE" |
---|
| 49 | arch_path="arch" |
---|
| 50 | arch_default_path="arch" |
---|
| 51 | |
---|
[1279] | 52 | LMDGCM=`/bin/pwd` |
---|
| 53 | LIBOGCM=$LMDGCM/libo |
---|
| 54 | LIBFGCM=$LMDGCM/libf |
---|
[2239] | 55 | DYN_COMMON_PATH=$LIBFGCM/dyn3d_common |
---|
[2084] | 56 | # path for optional packages, but default set to ".void_dir" |
---|
[2239] | 57 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
| 58 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
[2242] | 59 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
[2326] | 60 | PHY_COMMON_PATH=$LMDGCM/.void_dir |
---|
[3908] | 61 | RAD_PATH=$LMDGCM/.void_dir |
---|
[3901] | 62 | INLANDSIS_PATH=$LMDGCM/.void_dir |
---|
[2631] | 63 | DUST_PATH=$LMDGCM/.void_dir |
---|
[2690] | 64 | STRATAER_PATH=$LMDGCM/.void_dir |
---|
[1327] | 65 | COSP_PATH=$LMDGCM/.void_dir |
---|
[1578] | 66 | fcm_path=$LMDGCM/tools/fcm/bin |
---|
[783] | 67 | |
---|
| 68 | ######################################################################## |
---|
| 69 | # Quelques initialisations de variables du shell. |
---|
| 70 | ######################################################################## |
---|
| 71 | |
---|
[3815] | 72 | CPP_KEY="IN_LMDZ" |
---|
[1279] | 73 | INCLUDE="" |
---|
| 74 | LIB="" |
---|
| 75 | adjnt="" |
---|
| 76 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
| 77 | PARA_FFLAGS="" |
---|
| 78 | PARA_LD="" |
---|
| 79 | EXT_SRC="" |
---|
[783] | 80 | |
---|
| 81 | ######################################################################## |
---|
| 82 | # lecture des options de mymake |
---|
| 83 | ######################################################################## |
---|
| 84 | |
---|
[1279] | 85 | while (($# > 0)) |
---|
| 86 | do |
---|
| 87 | case $1 in |
---|
| 88 | "-h") cat <<fin |
---|
[783] | 89 | Usage : |
---|
[1772] | 90 | makelmdz_fcm [options] -arch nom_arch exec |
---|
| 91 | [-h] : brief help |
---|
| 92 | [-d [[IMx]JMx]LM] : IM, JM, LM are the dimensions in x, y, z (default: $dim) |
---|
| 93 | [-p PHYS] : set of physical parametrizations (in libf/phyPHYS), (default: lmd) |
---|
| 94 | [-prod / -dev / -debug] : compilation mode production (default) / developement / debug |
---|
[1965] | 95 | [-c false/MPI1/OMCT] : coupling with ocean model : MPI1/OMCT/false (default: false) |
---|
[1772] | 96 | [-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false) |
---|
| 97 | false : no vegetation model |
---|
[3435] | 98 | orchidee2.1 : compile using ORCHIDEE 2.1 (or more recent version) |
---|
| 99 | orchidee2.0 : compile using ORCHIDEE 2.0 |
---|
[1772] | 100 | orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6 |
---|
| 101 | true : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6 |
---|
| 102 | [-chimie INCA/false] : with INCA chemistry model or without (default: false) |
---|
[2238] | 103 | [-cosp true/false] : compile with/without cosp package (default: false) |
---|
[3358] | 104 | [-cosp2 true/false] : compile with/without cosp2 package (default: false) |
---|
[3491] | 105 | [-cospv2 true/false] : compile with/without cospv2 package (default: false) |
---|
[3793] | 106 | [-inlandsis true/false] : compile with/without inlandsis package (default: false) |
---|
[2238] | 107 | [-rrtm true/false] : compile with/without rrtm package (default: false) |
---|
[4203] | 108 | [-rad oldrad/rrtm/ecrad] : compile with oldrad/rrtm/ecrad radiatif code (default: oldrad) |
---|
[2631] | 109 | [-dust true/false] : compile with/without the dust package by Boucher and co (default: false) |
---|
[2690] | 110 | [-strataer true/false] : compile with/without the strat aer package by Boucher and co (default: false) |
---|
[3924] | 111 | [-isotopes true/false] : compile with/without water isotopes in the physics |
---|
| 112 | [-isoverif true/false] : compile with/without verifications for water isotopes in the physics |
---|
| 113 | [-diagiso true/false] : compile with/without special diagnostics for water isotopes in the physics |
---|
| 114 | [-isotrac true/false] : compile with/without tracers of water isotopes in the physics |
---|
[1772] | 115 | [-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp |
---|
| 116 | [-g GRI] : grid configuration in dyn3d/GRI_xy.h (default: reg, inclues a zoom) |
---|
[2097] | 117 | [-io ioipsl/mix/xios] : Input/Output library (default: ioipsl) |
---|
[1772] | 118 | [-include INCLUDES] : extra include path to add |
---|
| 119 | [-cpp CPP_KEY] : additional preprocessing definitions |
---|
| 120 | [-adjnt] : adjoint model, not operational ... |
---|
[3997] | 121 | [-mem] : reduced memory dynamics (obsolete flag; always on in parallel mode) |
---|
[1772] | 122 | [-filtre NOMFILTRE] : use filtre from libf/NOMFILTRE (default: filtrez) |
---|
| 123 | [-link LINKS] : additional links with other libraries |
---|
[1802] | 124 | [-j n] : active parallel compiling on ntask |
---|
| 125 | [-full] : full recompiling |
---|
[2358] | 126 | [-libphy] : only compile physics package (no dynamics or main program) |
---|
[1772] | 127 | [-fcm_path path] : path to the fcm tool (default: tools/fcm/bin) |
---|
| 128 | [-ext_src path] : path to an additional set of routines to compile with the model |
---|
[2743] | 129 | [-arch_path path] : path to architecture files (default: $arch_default_path) |
---|
[4096] | 130 | [-force_compile] : recompile although there seems to be an on-going compilation |
---|
[1772] | 131 | -arch nom_arch : target architecture |
---|
| 132 | exec : executable to build |
---|
[783] | 133 | fin |
---|
[1279] | 134 | exit;; |
---|
[783] | 135 | |
---|
[1279] | 136 | "-d") |
---|
| 137 | dim=$2 ; shift ; shift ;; |
---|
| 138 | |
---|
| 139 | "-p") |
---|
| 140 | physique="$2" ; shift ; shift ;; |
---|
[783] | 141 | |
---|
[1279] | 142 | "-g") |
---|
| 143 | grille="$2" ; shift ; shift ;; |
---|
[783] | 144 | |
---|
[1279] | 145 | "-c") |
---|
| 146 | couple="$2" ; shift ; shift ;; |
---|
[783] | 147 | |
---|
[1279] | 148 | "-prod") |
---|
| 149 | compil_mod="prod" ; shift ;; |
---|
[1002] | 150 | |
---|
[1279] | 151 | "-dev") |
---|
| 152 | compil_mod="dev" ; shift ;; |
---|
[1002] | 153 | |
---|
[1279] | 154 | "-debug") |
---|
| 155 | compil_mod="debug" ; shift ;; |
---|
[1002] | 156 | |
---|
[1279] | 157 | "-io") |
---|
| 158 | io="$2" ; shift ; shift ;; |
---|
[783] | 159 | |
---|
[1279] | 160 | "-v") |
---|
| 161 | veget="$2" ; shift ; shift ;; |
---|
[783] | 162 | |
---|
[3793] | 163 | "-inlandsis") |
---|
[3908] | 164 | inlandsis="$2" ; shift ; shift ;; |
---|
[3793] | 165 | |
---|
[1990] | 166 | "-rrtm") |
---|
[4203] | 167 | rrtm="$2" ; if [ "$2" = "false" ] ; then rad="oldrad" ; else rad="rrtm" ; fi ; shift ; shift ;; |
---|
[1990] | 168 | |
---|
[3908] | 169 | "-rad") |
---|
| 170 | rad="$2" ; shift ; shift ;; |
---|
| 171 | |
---|
[2631] | 172 | "-dust") |
---|
| 173 | dust="$2" ; shift ; shift ;; |
---|
| 174 | |
---|
[2690] | 175 | "-strataer") |
---|
| 176 | strataer="$2" ; shift ; shift ;; |
---|
| 177 | |
---|
[1279] | 178 | "-chimie") |
---|
| 179 | chimie="$2" ; shift ; shift ;; |
---|
[783] | 180 | |
---|
[3924] | 181 | "-isotopes") |
---|
| 182 | isotopes="$2" ; shift ; shift ;; |
---|
| 183 | |
---|
| 184 | "-isoverif") |
---|
| 185 | isoverif="$2" ; shift ; shift ;; |
---|
| 186 | |
---|
| 187 | "-diagiso") |
---|
| 188 | diagiso="$2" ; shift ; shift ;; |
---|
| 189 | |
---|
| 190 | "-isotrac") |
---|
| 191 | isotrac="$2" ; shift ; shift ;; |
---|
| 192 | |
---|
[1279] | 193 | "-parallel") |
---|
| 194 | parallel="$2" ; shift ; shift ;; |
---|
| 195 | |
---|
| 196 | "-include") |
---|
| 197 | INCLUDE="$INCLUDE -I$2" ; shift ; shift ;; |
---|
[783] | 198 | |
---|
[1279] | 199 | "-cpp") |
---|
| 200 | CPP_KEY="$CPP_KEY $2" ; shift ; shift ;; |
---|
[1132] | 201 | |
---|
[1279] | 202 | "-adjnt") |
---|
[1772] | 203 | echo "not operational ... work to be done here ";exit |
---|
[1279] | 204 | opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d " |
---|
| 205 | optim="$optim -Dadj" ; shift ;; |
---|
[783] | 206 | |
---|
[1279] | 207 | "-cosp") |
---|
| 208 | cosp="$2" ; shift ; shift ;; |
---|
[3358] | 209 | |
---|
| 210 | "-cosp2") |
---|
| 211 | cosp2="$2" ; shift ; shift ;; |
---|
[3491] | 212 | |
---|
| 213 | "-cospv2") |
---|
| 214 | cospv2="$2" ; shift ; shift ;; |
---|
[1680] | 215 | |
---|
| 216 | "-mem") |
---|
[3997] | 217 | echo "option -mem is obsolete (now always on in parallel)" |
---|
[1680] | 218 | paramem="mem" ; shift ;; |
---|
[783] | 219 | |
---|
[1279] | 220 | "-filtre") |
---|
| 221 | filtre=$2 ; shift ; shift ;; |
---|
[783] | 222 | |
---|
[1279] | 223 | "-link") |
---|
| 224 | LIB="$LIB $2" ; shift ; shift ;; |
---|
[1136] | 225 | |
---|
[1279] | 226 | "-fcm_path") |
---|
| 227 | fcm_path=$2 ; shift ; shift ;; |
---|
[783] | 228 | |
---|
[1279] | 229 | "-ext_src") |
---|
| 230 | EXT_SRC=$2 ; shift ; shift ;; |
---|
[2358] | 231 | |
---|
[1802] | 232 | "-j") |
---|
| 233 | job=$2 ; shift ; shift ;; |
---|
[2358] | 234 | |
---|
[1802] | 235 | "-full") |
---|
| 236 | full="-full" ; shift ;; |
---|
[783] | 237 | |
---|
[2358] | 238 | "-libphy") |
---|
| 239 | libphy="true" ; shift ;; |
---|
| 240 | |
---|
[1279] | 241 | "-arch") |
---|
[2743] | 242 | arch=$2 ; arch_defined="TRUE" ; shift ; shift ;; |
---|
[783] | 243 | |
---|
[2743] | 244 | "-arch_path") |
---|
| 245 | arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; |
---|
| 246 | |
---|
[4096] | 247 | "-force_compile") |
---|
| 248 | force_compile=true ; shift ;; |
---|
| 249 | |
---|
[1279] | 250 | *) |
---|
| 251 | code="$1" ; shift ;; |
---|
| 252 | esac |
---|
| 253 | done |
---|
| 254 | |
---|
[1136] | 255 | ############################################################### |
---|
[1755] | 256 | # path to fcm |
---|
[1136] | 257 | ############################################################### |
---|
[1755] | 258 | # handle case when provided path to fcm was given as a relative |
---|
| 259 | # path (from makelmdz_fcm script directory) and not an absolute path |
---|
| 260 | if [[ ${fcm_path:0:1} != "/" ]] ; then |
---|
| 261 | # prepend with makelmdz_fcm location |
---|
| 262 | fcm_path=$(cd $(dirname $0) ; pwd)"/"${fcm_path} |
---|
| 263 | fi |
---|
[783] | 264 | |
---|
[1757] | 265 | # add fcm_path to PATH |
---|
| 266 | export PATH=${fcm_path}:${PATH} |
---|
| 267 | |
---|
[1755] | 268 | echo "Path to fcm:" |
---|
| 269 | echo ${fcm_path} |
---|
[1136] | 270 | |
---|
[783] | 271 | ############################################################### |
---|
[2098] | 272 | # lecture des chemins propres \`a l'architecture de la machine # |
---|
[783] | 273 | ############################################################### |
---|
[1279] | 274 | rm -f .void_file |
---|
| 275 | echo > .void_file |
---|
[1327] | 276 | rm -rf .void_dir |
---|
| 277 | mkdir .void_dir |
---|
[783] | 278 | |
---|
[2743] | 279 | if [[ "$arch_defined" == "TRUE" ]] |
---|
| 280 | then |
---|
| 281 | rm -f arch.path |
---|
| 282 | rm -f arch.fcm |
---|
| 283 | rm -f arch.env |
---|
| 284 | |
---|
| 285 | if test -f $arch_path/arch-${arch}.path |
---|
| 286 | then |
---|
| 287 | ln -s $arch_path/arch-${arch}.path arch.path |
---|
| 288 | elif test -f $arch_default_path/arch-${arch}.path |
---|
| 289 | then |
---|
| 290 | ln -s $arch_default_path/arch-${arch}.path arch.path |
---|
| 291 | fi |
---|
| 292 | |
---|
| 293 | if test -f $arch_path/arch-${arch}.fcm |
---|
| 294 | then |
---|
| 295 | ln -s $arch_path/arch-${arch}.fcm arch.fcm |
---|
| 296 | elif test -f $arch_default_path/arch-${arch}.fcm |
---|
| 297 | then |
---|
| 298 | ln -s $arch_default_path/arch-${arch}.fcm arch.fcm |
---|
| 299 | fi |
---|
| 300 | |
---|
| 301 | if test -f $arch_path/arch-${arch}.env |
---|
| 302 | then |
---|
| 303 | ln -s $arch_path/arch-${arch}.env arch.env |
---|
| 304 | elif test -f $arch_default_path/arch-${arch}.env |
---|
| 305 | then |
---|
| 306 | ln -s $arch_default_path/arch-${arch}.env arch.env |
---|
| 307 | else |
---|
| 308 | ln -s .void_file arch.env |
---|
| 309 | fi |
---|
| 310 | # source architecture PATH and ENV files |
---|
| 311 | source arch.env |
---|
| 312 | source arch.path |
---|
| 313 | else |
---|
| 314 | echo "You must define a target architecture" |
---|
| 315 | exit 1 |
---|
| 316 | fi |
---|
| 317 | |
---|
[783] | 318 | ######################################################################## |
---|
| 319 | # Definition des clefs CPP, des chemins des includes et modules |
---|
| 320 | # et des libraries |
---|
| 321 | ######################################################################## |
---|
| 322 | |
---|
[1279] | 323 | if [[ "$compil_mod" == "prod" ]] |
---|
| 324 | then |
---|
| 325 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
| 326 | elif [[ "$compil_mod" == "dev" ]] |
---|
| 327 | then |
---|
| 328 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
| 329 | elif [[ "$compil_mod" == "debug" ]] |
---|
| 330 | then |
---|
| 331 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
| 332 | fi |
---|
[783] | 333 | |
---|
[2250] | 334 | phys_root=$physique |
---|
| 335 | if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi |
---|
| 336 | if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi |
---|
| 337 | if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi |
---|
| 338 | if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi |
---|
| 339 | if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi |
---|
| 340 | if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi |
---|
| 341 | |
---|
[1279] | 342 | if [[ "$physique" != "nophys" ]] |
---|
| 343 | then |
---|
[1615] | 344 | #We'll use some physics |
---|
| 345 | CPP_KEY="$CPP_KEY CPP_PHYS" |
---|
[2250] | 346 | if [[ "${phys_root}" == "lmd" ]] |
---|
[1615] | 347 | then |
---|
| 348 | #For lmd physics, default planet type is Earth |
---|
[1279] | 349 | CPP_KEY="$CPP_KEY CPP_EARTH" |
---|
[1615] | 350 | fi |
---|
[2326] | 351 | # set physics common utilities path |
---|
| 352 | PHY_COMMON_PATH="${LIBFGCM}/phy_common" |
---|
[2239] | 353 | # set the dyn/phys interface path |
---|
[2417] | 354 | DYN_PHYS_PATH="${LIBFGCM}/dynphy_lonlat" |
---|
| 355 | DYN_PHYS_SUB_PATH="${LIBFGCM}/dynphy_lonlat/phy${phys_root}" |
---|
[1279] | 356 | fi |
---|
[783] | 357 | |
---|
[2239] | 358 | if [[ "$filtre" == "filtrez" ]] |
---|
| 359 | then |
---|
| 360 | FILTRE_PATH=${LIBFGCM}/$filtre |
---|
| 361 | fi |
---|
| 362 | |
---|
[1279] | 363 | if [[ "$chimie" == "INCA" ]] |
---|
| 364 | then |
---|
| 365 | CPP_KEY="$CPP_KEY INCA" |
---|
| 366 | INCLUDE="$INCLUDE -I${INCA_INCDIR}" |
---|
| 367 | LIB="$LIB -L${INCA_LIBDIR} -lchimie" |
---|
| 368 | fi |
---|
[783] | 369 | |
---|
[3924] | 370 | if [[ "$isotopes" == "true" ]] |
---|
| 371 | then |
---|
| 372 | CPP_KEY="$CPP_KEY ISO" |
---|
| 373 | fi |
---|
| 374 | |
---|
| 375 | if [[ "$isoverif" == "true" ]] |
---|
| 376 | then |
---|
| 377 | CPP_KEY="$CPP_KEY ISOVERIF" |
---|
| 378 | fi |
---|
| 379 | |
---|
| 380 | if [[ "$diagiso" == "true" ]] |
---|
| 381 | then |
---|
| 382 | CPP_KEY="$CPP_KEY DIAGISO" |
---|
| 383 | fi |
---|
| 384 | |
---|
| 385 | if [[ "$isotrac" == "true" ]] |
---|
| 386 | then |
---|
| 387 | CPP_KEY="$CPP_KEY ISOTRAC" |
---|
| 388 | fi |
---|
| 389 | |
---|
[1279] | 390 | if [[ "$couple" != "false" ]] |
---|
| 391 | then |
---|
[1965] | 392 | if [[ "$couple" == "MPI1" ]] |
---|
| 393 | then |
---|
| 394 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
| 395 | export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1 |
---|
| 396 | export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib |
---|
| 397 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
| 398 | LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.MPI1 -lmpp_io" |
---|
| 399 | else |
---|
| 400 | CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT" |
---|
| 401 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
| 402 | LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.MPI1 -lscrip -lmct -lmpeu" |
---|
| 403 | fi |
---|
[1279] | 404 | fi |
---|
[783] | 405 | |
---|
[1279] | 406 | if [[ "$parallel" == "mpi" ]] |
---|
| 407 | then |
---|
| 408 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
| 409 | PARA_FFLAGS="%MPI_FFLAGS" |
---|
| 410 | PARA_LD="%MPI_LD" |
---|
| 411 | elif [[ "$parallel" == "omp" ]] |
---|
| 412 | then |
---|
| 413 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
| 414 | PARA_FFLAGS="%OMP_FFLAGS" |
---|
| 415 | PARA_LD="%OMP_LD" |
---|
| 416 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
| 417 | then |
---|
| 418 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
| 419 | PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS" |
---|
| 420 | PARA_LD="%MPI_LD %OMP_LD" |
---|
| 421 | fi |
---|
[783] | 422 | |
---|
[1279] | 423 | if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \ |
---|
| 424 | && "$compil_mod" == "debug" ]] |
---|
| 425 | then |
---|
| 426 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
| 427 | echo "We suggest switching to \"-dev\"." |
---|
| 428 | fi |
---|
[783] | 429 | |
---|
[3435] | 430 | if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" -o "$veget" = "orchidee2.1" ] |
---|
[1279] | 431 | then |
---|
[1811] | 432 | #NB: option 'true': for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6 |
---|
| 433 | # For this case, cpp flag ORCHIDEE_NOOPENMP must be added to the makelmdz_fcm arguments |
---|
| 434 | # 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] | 435 | INCLUDE="${INCLUDE} -I${ORCH_INCDIR}" |
---|
[1772] | 436 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
[1811] | 437 | # temporary, for Orchidee versions 1.9.* (before openmp activation) |
---|
| 438 | if [[ "$veget" == "orchidee1.9" ]] ; then |
---|
| 439 | CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP" |
---|
| 440 | fi |
---|
| 441 | if [[ "$veget" == "orchidee2.0" ]] ; then |
---|
[1854] | 442 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
[3435] | 443 | CPP_KEY="$CPP_KEY ORCHIDEE_NOUNSTRUCT" |
---|
| 444 | elif [[ "$veget" == "orchidee2.1" ]] ; then |
---|
| 445 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
[1811] | 446 | else |
---|
| 447 | orch_libs="sechiba parameters stomate parallel orglob" |
---|
| 448 | fi |
---|
| 449 | LIB="${LIB} -L${ORCH_LIBDIR}" |
---|
| 450 | for lib in ${orch_libs} ; do |
---|
| 451 | if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then |
---|
| 452 | LIB="${LIB} -l${LIBPREFIX}$lib " |
---|
| 453 | fi |
---|
| 454 | done |
---|
| 455 | elif [[ "$veget" != "false" ]] ; then |
---|
[1772] | 456 | echo "Option -v $veget does not exist" |
---|
| 457 | echo "Use ./makelmdz_fcm -h for more information" |
---|
| 458 | exit |
---|
[1279] | 459 | fi |
---|
[783] | 460 | |
---|
[3793] | 461 | if [[ "$inlandsis" == "true" ]] |
---|
| 462 | then |
---|
| 463 | CPP_KEY="$CPP_KEY CPP_INLANDSIS" |
---|
[3794] | 464 | INLANDSIS_PATH="$LIBFGCM/%PHYS/inlandsis" |
---|
[3793] | 465 | fi |
---|
| 466 | |
---|
| 467 | |
---|
[3908] | 468 | if [[ "$rad" == "rrtm" ]] |
---|
[1990] | 469 | then |
---|
| 470 | CPP_KEY="$CPP_KEY CPP_RRTM" |
---|
[3908] | 471 | RAD_PATH="$LIBFGCM/%PHYS/rrtm" |
---|
[1990] | 472 | fi |
---|
[3908] | 473 | if [[ "$rad" == "ecrad" ]] |
---|
| 474 | then |
---|
| 475 | CPP_KEY="$CPP_KEY CPP_ECRAD" |
---|
| 476 | RAD_PATH="$LIBFGCM/%PHYS/ecrad" |
---|
| 477 | fi |
---|
[1990] | 478 | |
---|
[2631] | 479 | if [[ "$dust" == "true" ]] |
---|
| 480 | then |
---|
| 481 | CPP_KEY="$CPP_KEY CPP_Dust" |
---|
| 482 | DUST_PATH="$LIBFGCM/%PHYS/Dust" |
---|
| 483 | fi |
---|
| 484 | |
---|
[2690] | 485 | if [[ "$strataer" == "true" ]] |
---|
| 486 | then |
---|
| 487 | CPP_KEY="$CPP_KEY CPP_StratAer" |
---|
| 488 | STRATAER_PATH="$LIBFGCM/%PHYS/StratAer" |
---|
| 489 | fi |
---|
| 490 | |
---|
[4201] | 491 | INCLUDE="$INCLUDE -I${NETCDF95_INCDIR}" |
---|
| 492 | LIB="$LIB -L${NETCDF95_LIBDIR} -l${LIBPREFIX}netcdf95" |
---|
| 493 | |
---|
[1279] | 494 | if [[ $io == ioipsl ]] |
---|
| 495 | then |
---|
| 496 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
| 497 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
---|
| 498 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
---|
[2097] | 499 | elif [[ $io == mix ]] |
---|
[1897] | 500 | then |
---|
| 501 | # For now, xios implies also using ioipsl |
---|
| 502 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS" |
---|
| 503 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
[3075] | 504 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios -l${LIBPREFIX}stdc++" |
---|
[2097] | 505 | elif [[ $io == xios ]] |
---|
| 506 | then |
---|
| 507 | # For now, xios implies also using ioipsl |
---|
| 508 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT" |
---|
| 509 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
[3075] | 510 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios -l${LIBPREFIX}stdc++" |
---|
[1279] | 511 | fi |
---|
[1897] | 512 | |
---|
[1279] | 513 | if [[ "$cosp" == "true" ]] |
---|
| 514 | then |
---|
| 515 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
[2239] | 516 | COSP_PATH="$LIBFGCM/phylmd/cosp" |
---|
[1279] | 517 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
| 518 | fi |
---|
[783] | 519 | |
---|
[3358] | 520 | if [[ "$cosp2" == "true" ]] |
---|
| 521 | then |
---|
| 522 | CPP_KEY="$CPP_KEY CPP_COSP2" |
---|
| 523 | COSP_PATH="$LIBFGCM/phylmd/cosp2" |
---|
| 524 | # LIB="${LIB} -l${LIBPREFIX}cosp2" |
---|
| 525 | fi |
---|
| 526 | |
---|
[3491] | 527 | if [[ "$cospv2" == "true" ]] |
---|
| 528 | then |
---|
| 529 | CPP_KEY="$CPP_KEY CPP_COSPV2" |
---|
| 530 | COSP_PATH="$LIBFGCM/phylmd/cospv2" |
---|
| 531 | # LIB="${LIB} -l${LIBPREFIX}cosp2" |
---|
| 532 | fi |
---|
[3358] | 533 | |
---|
[3491] | 534 | |
---|
| 535 | |
---|
[1551] | 536 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
| 537 | LIB="$LIB ${NETCDF_LIBDIR}" |
---|
| 538 | |
---|
[783] | 539 | ######################################################################## |
---|
| 540 | # calcul du nombre de dimensions |
---|
| 541 | ######################################################################## |
---|
| 542 | |
---|
| 543 | |
---|
[1279] | 544 | dim_full=$dim |
---|
| 545 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
| 546 | set $dim |
---|
| 547 | dimc=$# |
---|
[783] | 548 | echo calcul de la dimension |
---|
| 549 | echo dim $dim |
---|
| 550 | echo dimc $dimc |
---|
| 551 | |
---|
| 552 | |
---|
| 553 | ######################################################################## |
---|
| 554 | # Gestion des dimensions du modele. |
---|
[1114] | 555 | # on cree ou remplace le fichier des dimensions |
---|
[783] | 556 | ######################################################################## |
---|
| 557 | |
---|
[1695] | 558 | cd $LIBFGCM/grid |
---|
| 559 | if [[ -f dimensions.h ]] |
---|
| 560 | then |
---|
[4096] | 561 | if [[ $force_compile == true ]] |
---|
| 562 | then |
---|
| 563 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
| 564 | else |
---|
| 565 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
| 566 | echo "Wait until the first compilation is finished before launching this one." |
---|
| 567 | echo "If you are sure that you are not compiling elsewhere, " |
---|
| 568 | echo "run makelmdz_fcm with option -force_compile" |
---|
| 569 | exit 1 |
---|
| 570 | fi |
---|
[1695] | 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} |
---|
[4203] | 654 | SUFF_NAME=${SUFF_NAME}_phy${physique}_${rad} |
---|
[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 | |
---|
[4103] | 775 | set +e |
---|
| 776 | |
---|
[1002] | 777 | rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock |
---|
[1802] | 778 | ./build_gcm ${fcm_path} -j $job $full |
---|
[4103] | 779 | build_status=$? |
---|
[783] | 780 | |
---|
[1279] | 781 | rm -rf tmp_src |
---|
| 782 | rm -rf config |
---|
[783] | 783 | ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config |
---|
[2358] | 784 | ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/ppsrc tmp_src |
---|
[1695] | 785 | |
---|
[1869] | 786 | |
---|
[1696] | 787 | if [[ -r $LIBFGCM/grid/dimensions.h ]] |
---|
[1695] | 788 | then |
---|
| 789 | # Cleanup: remove dimension.h file |
---|
[1696] | 790 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
[1695] | 791 | fi |
---|
[4103] | 792 | |
---|
| 793 | exit $build_status |
---|