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