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