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