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