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