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