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