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