[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 | |
---|
[3471] | 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 | |
---|
[3574] | 80 | # Get the compilation command |
---|
| 81 | compilation_command="$(basename $0) $@" |
---|
| 82 | |
---|
| 83 | # Parse arguments and capture options |
---|
[1] | 84 | while (($# > 0)) |
---|
| 85 | do |
---|
| 86 | case $1 in |
---|
| 87 | "-h") cat <<fin |
---|
| 88 | Usage : |
---|
[2339] | 89 | makelmdz_fcm [options] -arch arch_name exec |
---|
[957] | 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) |
---|
[2339] | 103 | [-cosp true/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) |
---|
[2339] | 119 | [-libphy] : only compile physics package (no dynamics or main program) |
---|
[957] | 120 | [-fcm_path path] : path to the fcm tool (default: tools/fcm/bin) |
---|
| 121 | [-ext_src path] : path to an additional set of routines to compile with the model |
---|
[1650] | 122 | [-arch_path path] : path to architecture files (default: $arch_default_path) |
---|
[3471] | 123 | -arch arch : target architecture |
---|
[957] | 124 | exec : executable to build |
---|
[1] | 125 | fin |
---|
[3574] | 126 | exit;; |
---|
[1] | 127 | |
---|
| 128 | "-d") |
---|
[3574] | 129 | dim=$2 ; shift ; shift ;; |
---|
[3471] | 130 | |
---|
[1] | 131 | "-p") |
---|
[3574] | 132 | physique="$2" ; shift ; shift ;; |
---|
[1] | 133 | |
---|
[957] | 134 | "-s") |
---|
[3574] | 135 | scatterers=$2 ; shift ; shift ;; |
---|
[957] | 136 | |
---|
| 137 | "-b") |
---|
[3574] | 138 | bands=$2 ; shift ; shift ;; |
---|
[957] | 139 | |
---|
[1] | 140 | "-g") |
---|
[3574] | 141 | grille="$2" ; shift ; shift ;; |
---|
[1] | 142 | |
---|
| 143 | "-c") |
---|
[3574] | 144 | couple="$2" ; shift ; shift ;; |
---|
[1] | 145 | |
---|
| 146 | "-prod") |
---|
[3574] | 147 | compil_mod="prod" ; shift ;; |
---|
[1] | 148 | |
---|
| 149 | "-dev") |
---|
[3574] | 150 | compil_mod="dev" ; shift ;; |
---|
[1] | 151 | |
---|
| 152 | "-debug") |
---|
[3574] | 153 | compil_mod="debug" ; shift ;; |
---|
[1] | 154 | |
---|
| 155 | "-io") |
---|
[3574] | 156 | io="$2" ; shift ; shift ;; |
---|
[1] | 157 | |
---|
| 158 | "-v") |
---|
[3574] | 159 | veget="$2" ; shift ; shift ;; |
---|
[1] | 160 | |
---|
[1300] | 161 | "-sisvat") |
---|
[3574] | 162 | sisvat="$2" ; shift ; shift ;; |
---|
[1300] | 163 | |
---|
[1302] | 164 | "-rrtm") |
---|
[3574] | 165 | rrtm="$2" ; shift ; shift ;; |
---|
[1302] | 166 | |
---|
[1650] | 167 | "-dust") |
---|
[3574] | 168 | dust="$2" ; shift ; shift ;; |
---|
[1650] | 169 | |
---|
| 170 | "-strataer") |
---|
[3574] | 171 | strataer="$2" ; shift ; shift ;; |
---|
[1650] | 172 | |
---|
[1] | 173 | "-chimie") |
---|
[3574] | 174 | chimie="$2" ; shift ; shift ;; |
---|
[1] | 175 | |
---|
| 176 | "-parallel") |
---|
[3574] | 177 | parallel="$2" ; shift ; shift ;; |
---|
[3471] | 178 | |
---|
[1] | 179 | "-include") |
---|
[3574] | 180 | INCLUDE_DIR="$INCLUDE_DIR -I$2" ; shift ; shift ;; |
---|
[1] | 181 | |
---|
| 182 | "-cpp") |
---|
[3574] | 183 | CPP_KEY="$CPP_KEY $2" ; shift ; shift ;; |
---|
[1] | 184 | |
---|
| 185 | "-adjnt") |
---|
[3574] | 186 | echo "not operational ... work to be done here ";exit 1 |
---|
| 187 | opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d " |
---|
| 188 | optim="$optim -Dadj" ; shift ;; |
---|
[1] | 189 | |
---|
| 190 | "-cosp") |
---|
| 191 | cosp="$2" ; shift ; shift ;; |
---|
| 192 | |
---|
[979] | 193 | "-mem") |
---|
| 194 | paramem="mem" ; shift ;; |
---|
[1] | 195 | |
---|
| 196 | "-filtre") |
---|
[3574] | 197 | filtre=$2 ; shift ; shift ;; |
---|
[1] | 198 | |
---|
| 199 | "-link") |
---|
[3574] | 200 | LIB="$LIB $2" ; shift ; shift ;; |
---|
[1] | 201 | |
---|
| 202 | "-fcm_path") |
---|
[3574] | 203 | fcm_path=$2 ; shift ; shift ;; |
---|
[1] | 204 | |
---|
| 205 | "-ext_src") |
---|
[3574] | 206 | EXT_SRC=$2 ; shift ; shift ;; |
---|
[1] | 207 | |
---|
[1019] | 208 | "-j") |
---|
[3574] | 209 | job=$2 ; shift ; shift ;; |
---|
[1019] | 210 | |
---|
| 211 | "-full") |
---|
[3574] | 212 | full="-full" ; shift ;; |
---|
[1019] | 213 | |
---|
[1540] | 214 | "-libphy") |
---|
[3574] | 215 | libphy="true" ; shift ;; |
---|
[1540] | 216 | |
---|
[1] | 217 | "-arch") |
---|
[3574] | 218 | arch=$2 ; arch_defined="TRUE" ; shift ; shift ;; |
---|
[1] | 219 | |
---|
[1650] | 220 | "-arch_path") |
---|
[3574] | 221 | arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; |
---|
[1650] | 222 | |
---|
[1] | 223 | *) |
---|
[3574] | 224 | code="$1" ; shift ;; |
---|
[1] | 225 | esac |
---|
| 226 | done |
---|
| 227 | |
---|
| 228 | ############################################################### |
---|
[3471] | 229 | # path to fcm |
---|
[1] | 230 | ############################################################### |
---|
[979] | 231 | # handle case when provided path to fcm was given as a relative |
---|
| 232 | # path (from makelmdz_fcm script directory) and not an absolute path |
---|
| 233 | if [[ ${fcm_path:0:1} != "/" ]] ; then |
---|
| 234 | # prepend with makelmdz_fcm location |
---|
| 235 | fcm_path=$(cd $(dirname $0) ; pwd)"/"${fcm_path} |
---|
| 236 | fi |
---|
| 237 | |
---|
| 238 | # add fcm_path to PATH |
---|
[847] | 239 | export PATH=${fcm_path}:${PATH} |
---|
[1] | 240 | |
---|
[979] | 241 | echo "Path to fcm:" |
---|
| 242 | echo ${fcm_path} |
---|
[1] | 243 | |
---|
[2339] | 244 | ################################# |
---|
| 245 | # setup arch.env and arch.path # |
---|
| 246 | ################################# |
---|
[1] | 247 | rm -f .void_file |
---|
| 248 | echo > .void_file |
---|
| 249 | rm -rf .void_dir |
---|
| 250 | mkdir .void_dir |
---|
| 251 | |
---|
[1650] | 252 | if [[ "$arch_defined" == "TRUE" ]] |
---|
| 253 | then |
---|
| 254 | rm -f arch.path |
---|
| 255 | rm -f arch.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 |
---|
[3471] | 264 | |
---|
[1650] | 265 | if test -f $arch_path/arch-${arch}.env |
---|
| 266 | then |
---|
| 267 | ln -s $arch_path/arch-${arch}.env arch.env |
---|
| 268 | elif test -f $arch_default_path/arch-${arch}.env |
---|
| 269 | then |
---|
| 270 | ln -s $arch_default_path/arch-${arch}.env arch.env |
---|
| 271 | else |
---|
| 272 | ln -s .void_file arch.env |
---|
| 273 | fi |
---|
| 274 | # source architecture PATH and ENV files |
---|
| 275 | source arch.env |
---|
| 276 | source arch.path |
---|
| 277 | else |
---|
| 278 | echo "You must define a target architecture" |
---|
| 279 | exit 1 |
---|
| 280 | fi |
---|
| 281 | |
---|
[1] | 282 | ######################################################################## |
---|
| 283 | # Definition des clefs CPP, des chemins des includes et modules |
---|
| 284 | # et des libraries |
---|
| 285 | ######################################################################## |
---|
| 286 | |
---|
| 287 | if [[ "$compil_mod" == "prod" ]] |
---|
| 288 | then |
---|
| 289 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
| 290 | elif [[ "$compil_mod" == "dev" ]] |
---|
| 291 | then |
---|
| 292 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
| 293 | elif [[ "$compil_mod" == "debug" ]] |
---|
| 294 | then |
---|
| 295 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
| 296 | fi |
---|
| 297 | |
---|
[1403] | 298 | phys_root=$physique |
---|
| 299 | if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi |
---|
| 300 | if [[ "${physique:0:3}" == "mar" ]] ; then phys_root=mar ; fi |
---|
| 301 | if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi |
---|
| 302 | if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi |
---|
| 303 | if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi |
---|
| 304 | if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi |
---|
| 305 | if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi |
---|
| 306 | |
---|
[1] | 307 | if [[ "$physique" != "nophys" ]] |
---|
| 308 | then |
---|
[847] | 309 | #We'll use some physics |
---|
[37] | 310 | CPP_KEY="$CPP_KEY CPP_PHYS" |
---|
[1403] | 311 | if [[ "${phys_root}" == "lmd" ]] |
---|
[847] | 312 | then |
---|
| 313 | #For lmd physics, default planet type is Earth |
---|
[1] | 314 | CPP_KEY="$CPP_KEY CPP_EARTH" |
---|
[847] | 315 | fi |
---|
[1521] | 316 | # set physics common utilities path |
---|
| 317 | PHY_COMMON_PATH="${LIBFGCM}/phy_common" |
---|
[1403] | 318 | # set the dyn/phys interface path |
---|
[1540] | 319 | DYN_PHYS_PATH="${LIBFGCM}/dynphy_lonlat" |
---|
| 320 | DYN_PHYS_SUB_PATH="${LIBFGCM}/dynphy_lonlat/phy${phys_root}" |
---|
[1] | 321 | fi |
---|
| 322 | |
---|
[1403] | 323 | if [[ "$filtre" == "filtrez" ]] |
---|
| 324 | then |
---|
| 325 | FILTRE_PATH=${LIBFGCM}/$filtre |
---|
| 326 | fi |
---|
| 327 | |
---|
[1] | 328 | if [[ "$chimie" == "INCA" ]] |
---|
| 329 | then |
---|
| 330 | CPP_KEY="$CPP_KEY INCA" |
---|
[2645] | 331 | INCLUDE_DIR="$INCLUDE_DIR -I${INCA_INCDIR}" |
---|
[1695] | 332 | LIB="$LIB -L${INCA_LIBDIR} ${INCA_LIB}" |
---|
[1] | 333 | fi |
---|
| 334 | |
---|
| 335 | if [[ "$couple" != "false" ]] |
---|
| 336 | then |
---|
[1302] | 337 | if [[ "$couple" == "MPI1" ]] |
---|
| 338 | then |
---|
[3574] | 339 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
| 340 | export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1 |
---|
| 341 | export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib |
---|
| 342 | INCLUDE_DIR="$INCLUDE_DIR -I${OASIS_INCDIR}" |
---|
| 343 | LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}" |
---|
[1302] | 344 | else |
---|
[3574] | 345 | CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT" |
---|
| 346 | INCLUDE_DIR="$INCLUDE_DIR -I${OASIS_INCDIR}" |
---|
| 347 | LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}" |
---|
[1302] | 348 | fi |
---|
[1] | 349 | fi |
---|
| 350 | |
---|
[1530] | 351 | if [[ "$parallel" != "none" && \ |
---|
| 352 | ( "$code" == "newstart" || "$code" == "start2archive" ) ]] |
---|
| 353 | then |
---|
| 354 | echo "newstart or start2archive utilities should be run in serial!" |
---|
| 355 | echo " Compile without -parallel [mpi|omp|mpi_omp] option!" |
---|
[3484] | 356 | exit 1 |
---|
[1530] | 357 | fi |
---|
| 358 | |
---|
[1] | 359 | if [[ "$parallel" == "mpi" ]] |
---|
| 360 | then |
---|
| 361 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
| 362 | PARA_FFLAGS="%MPI_FFLAGS" |
---|
| 363 | PARA_LD="%MPI_LD" |
---|
| 364 | elif [[ "$parallel" == "omp" ]] |
---|
| 365 | then |
---|
| 366 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
| 367 | PARA_FFLAGS="%OMP_FFLAGS" |
---|
| 368 | PARA_LD="%OMP_LD" |
---|
| 369 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
| 370 | then |
---|
| 371 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
| 372 | PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS" |
---|
| 373 | PARA_LD="%MPI_LD %OMP_LD" |
---|
| 374 | fi |
---|
| 375 | |
---|
| 376 | if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \ |
---|
| 377 | && "$compil_mod" == "debug" ]] |
---|
| 378 | then |
---|
| 379 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
| 380 | echo "We suggest switching to \"-dev\"." |
---|
| 381 | fi |
---|
| 382 | |
---|
[1019] | 383 | if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ] |
---|
[1] | 384 | then |
---|
[1019] | 385 | #NB: option 'true': for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6 |
---|
| 386 | # For this case, cpp flag ORCHIDEE_NOOPENMP must be added to the makelmdz_fcm arguments |
---|
| 387 | # 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] | 388 | INCLUDE_DIR="${INCLUDE_DIR} ${ORCHIDEE_INCDIR}" |
---|
[1] | 389 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
[1019] | 390 | # temporary, for Orchidee versions 1.9.* (before openmp activation) |
---|
| 391 | if [[ "$veget" == "orchidee1.9" ]] ; then |
---|
| 392 | CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP" |
---|
| 393 | fi |
---|
| 394 | if [[ "$veget" == "orchidee2.0" ]] ; then |
---|
[1300] | 395 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
[1019] | 396 | else |
---|
| 397 | orch_libs="sechiba parameters stomate parallel orglob" |
---|
| 398 | fi |
---|
[1695] | 399 | LIB="${LIB} -L${ORCHIDEE_LIBDIR} ${ORCHIDEE_LIB}" |
---|
[1019] | 400 | elif [[ "$veget" != "false" ]] ; then |
---|
| 401 | echo "Option -v $veget does not exist" |
---|
| 402 | echo "Use ./makelmdz_fcm -h for more information" |
---|
[3484] | 403 | exit 1 |
---|
[1] | 404 | fi |
---|
| 405 | |
---|
[1300] | 406 | if [[ "$sisvat" == "true" ]] |
---|
| 407 | then |
---|
| 408 | CPP_KEY="$CPP_KEY CPP_SISVAT" |
---|
[1302] | 409 | SISVAT_PATH="$LIBFGCM/%PHYS/sisvat" |
---|
[1300] | 410 | fi |
---|
| 411 | |
---|
[1302] | 412 | if [[ "$rrtm" == "true" ]] |
---|
| 413 | then |
---|
| 414 | CPP_KEY="$CPP_KEY CPP_RRTM" |
---|
| 415 | RRTM_PATH="$LIBFGCM/%PHYS/rrtm" |
---|
| 416 | fi |
---|
| 417 | |
---|
[1650] | 418 | if [[ "$dust" == "true" ]] |
---|
| 419 | then |
---|
| 420 | CPP_KEY="$CPP_KEY CPP_Dust" |
---|
| 421 | DUST_PATH="$LIBFGCM/%PHYS/Dust" |
---|
| 422 | fi |
---|
| 423 | |
---|
| 424 | if [[ "$strataer" == "true" ]] |
---|
| 425 | then |
---|
| 426 | CPP_KEY="$CPP_KEY CPP_StratAer" |
---|
| 427 | STRATAER_PATH="$LIBFGCM/%PHYS/StratAer" |
---|
| 428 | fi |
---|
| 429 | |
---|
[1] | 430 | if [[ $io == ioipsl ]] |
---|
| 431 | then |
---|
| 432 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
[2645] | 433 | INCLUDE_DIR="$INCLUDE_DIR ${IOIPSL_INCDIR}" |
---|
[1695] | 434 | LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB}" |
---|
[1391] | 435 | elif [[ $io == mix ]] |
---|
[1300] | 436 | then |
---|
| 437 | # For now, xios implies also using ioipsl |
---|
| 438 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS" |
---|
[2645] | 439 | INCLUDE_DIR="$INCLUDE_DIR ${IOIPSL_INCDIR} ${XIOS_INCDIR}" |
---|
[1695] | 440 | LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}" |
---|
[1391] | 441 | elif [[ $io == xios ]] |
---|
| 442 | then |
---|
| 443 | # For now, xios implies also using ioipsl |
---|
| 444 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT" |
---|
[2645] | 445 | INCLUDE_DIR="$INCLUDE_DIR ${IOIPSL_INCDIR} ${XIOS_INCDIR}" |
---|
[1695] | 446 | LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}" |
---|
[1] | 447 | fi |
---|
[895] | 448 | |
---|
[1] | 449 | if [[ "$cosp" == "true" ]] |
---|
| 450 | then |
---|
| 451 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
| 452 | COSP_PATH="$LIBFGCM/cosp" |
---|
| 453 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
| 454 | fi |
---|
| 455 | |
---|
[1403] | 456 | # for Titan (but could be used by others as well), there is also "chimtitan" |
---|
| 457 | if [[ -d ${LIBFGCM}/chim${physique} ]] |
---|
[895] | 458 | then |
---|
| 459 | CHEM_PATH="${LIBFGCM}/chim${physique}" |
---|
[2645] | 460 | INCLUDE_DIR="$INCLUDE_DIR -I${LIBFGCM}/chim${physique}" |
---|
[895] | 461 | fi |
---|
| 462 | |
---|
[1793] | 463 | # for Titan add microphysics dependencies |
---|
| 464 | if [[ -d ${LIBFGCM}/muphy${physique} ]] ; then |
---|
[2369] | 465 | if ! [ `echo $CPP_KEY | grep -c "OLD_COMPILO"` -gt 0 ] ; then |
---|
| 466 | # add muphy{physique} to the list of files to compile. |
---|
| 467 | MUPHY_PATH="${LIBFGCM}/muphy${physique}" |
---|
| 468 | # For Titan as we embbed some libraries with CPP keys, we define them: |
---|
| 469 | # -DPREC={32|64|80} real kind precision (32: simple, 64: double, 80: extended double) |
---|
| 470 | # -DHAVE_NC_FTN=1 (mandatory: for support of NetCDF in lintnd). |
---|
| 471 | CPP_KEY="$CPP_KEY PREC=64 HAVE_NC_FTN=1" |
---|
| 472 | if [[ "${physique}" == "titan" ]] ; then |
---|
| 473 | echo "Yaahh you're about to use YAMMS in a GCM..." |
---|
| 474 | fi |
---|
[1793] | 475 | fi |
---|
| 476 | fi |
---|
| 477 | |
---|
[1661] | 478 | # for Venus (but could be used by others as well), there is also "phyvenus/cloudvenus" |
---|
| 479 | if [[ -d ${LIBFGCM}/phy${physique}/cloud${physique} ]] |
---|
| 480 | then |
---|
| 481 | CLOUD_PATH="${LIBFGCM}/phy${physique}/cloud${physique}" |
---|
[2645] | 482 | INCLUDE_DIR="$INCLUDE_DIR -I${LIBFGCM}/phy${physique}/cloud${physique}" |
---|
[1661] | 483 | fi |
---|
| 484 | |
---|
[1107] | 485 | # for Mars (but could be used by others as well), there is also "aeronomars" |
---|
| 486 | if [[ -d ${LIBFGCM}/aerono${physique} ]] |
---|
| 487 | then |
---|
| 488 | AERONO_PATH="${LIBFGCM}/aerono${physique}" |
---|
[2645] | 489 | INCLUDE_DIR="$INCLUDE_DIR -I${LIBFGCM}/aerono${physique}" |
---|
[1107] | 490 | fi |
---|
| 491 | |
---|
[2781] | 492 | if [[ -d ${LIBFGCM}/evolution && "$code" == "pem" ]] |
---|
[2778] | 493 | then |
---|
[2985] | 494 | if [[ "$physique" == "std" ]] |
---|
| 495 | then |
---|
| 496 | CPP_KEY="$CPP_KEY CPP_STD" |
---|
| 497 | fi |
---|
[2778] | 498 | EVOLUTION_PATH="${LIBFGCM}/evolution" |
---|
| 499 | INCLUDE="$INCLUDE -I${LIBFGCM}/evolution" |
---|
| 500 | fi |
---|
| 501 | |
---|
[2985] | 502 | if [[ -d ${LIBFGCM}/evolution && "$code" == "reshape_XIOS_output" ]] |
---|
| 503 | then |
---|
| 504 | if [[ "$physique" == "std" ]] |
---|
| 505 | then |
---|
| 506 | CPP_KEY="$CPP_KEY CPP_STD" |
---|
| 507 | fi |
---|
| 508 | EVOLUTION_PATH="${LIBFGCM}/evolution" |
---|
| 509 | INCLUDE="$INCLUDE -I${LIBFGCM}/evolution" |
---|
| 510 | fi |
---|
| 511 | |
---|
| 512 | |
---|
[1695] | 513 | # NETCDF library include/library paths |
---|
[2645] | 514 | INCLUDE_DIR="$INCLUDE_DIR ${NETCDF_INCDIR}" |
---|
[1695] | 515 | LIB="$LIB ${NETCDF_LIBDIR} ${NETCDF_LIB}" |
---|
[270] | 516 | |
---|
[1] | 517 | ######################################################################## |
---|
| 518 | # calcul du nombre de dimensions |
---|
| 519 | ######################################################################## |
---|
| 520 | |
---|
| 521 | |
---|
| 522 | dim_full=$dim |
---|
[3471] | 523 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
[1] | 524 | set $dim |
---|
| 525 | dimc=$# |
---|
| 526 | echo calcul de la dimension |
---|
| 527 | echo dim $dim |
---|
| 528 | echo dimc $dimc |
---|
| 529 | |
---|
| 530 | |
---|
| 531 | ######################################################################## |
---|
| 532 | # Gestion des dimensions du modele. |
---|
| 533 | # on cree ou remplace le fichier des dimensions |
---|
| 534 | ######################################################################## |
---|
| 535 | |
---|
[979] | 536 | cd $LIBFGCM/grid |
---|
| 537 | if [[ -f dimensions.h ]] |
---|
| 538 | then |
---|
| 539 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
| 540 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
| 541 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
| 542 | echo vous pouvez continuer en repondant oui. |
---|
| 543 | echo "Voulez-vous vraiment continuer?" |
---|
| 544 | echo "" |
---|
| 545 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
| 546 | echo "Wait until the first compilation is finished before launching this one." |
---|
| 547 | echo "If you are sure that you are not compiling elsewhere, just answer " |
---|
| 548 | echo "yes (or 'oui') to the question below to proceed." |
---|
| 549 | echo "Do you wish to continue?" |
---|
| 550 | read reponse |
---|
| 551 | if [[ $reponse == "oui" || $reponse == "yes" ]] |
---|
| 552 | then |
---|
| 553 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
| 554 | else |
---|
[3484] | 555 | exit 1 |
---|
[979] | 556 | fi |
---|
| 557 | fi |
---|
| 558 | |
---|
| 559 | |
---|
[1] | 560 | cd $LIBFGCM/grid/dimension |
---|
| 561 | ./makdim $dim |
---|
[1441] | 562 | if (($? != 0)) |
---|
| 563 | then |
---|
| 564 | exit 1 |
---|
| 565 | fi |
---|
| 566 | |
---|
[1] | 567 | cat $LIBFGCM/grid/dimensions.h |
---|
| 568 | cd $LMDGCM |
---|
| 569 | |
---|
[957] | 570 | if [[ "$bands" != "" ]] |
---|
[847] | 571 | then |
---|
[957] | 572 | # Generic model, recreate bands.h (IR & VIS bands for radiative transfer) |
---|
[2967] | 573 | makbandsarg=$(echo $bands | sed -e 's/[^0-9]/ /g') |
---|
[957] | 574 | cd $LIBFGCM/phy$physique/bands |
---|
[2967] | 575 | ./makbands $makbandsarg |
---|
[957] | 576 | cat $LIBFGCM/phy$physique/bands.h |
---|
| 577 | cd $LMDGCM |
---|
[847] | 578 | fi |
---|
[1] | 579 | |
---|
[957] | 580 | if [[ "$scatterers" != "" ]] |
---|
| 581 | then |
---|
[2441] | 582 | if [[ -f $LIBFGCM/phy$physique/scatterers/make_scatterers ]] |
---|
| 583 | then |
---|
| 584 | # Generic model, recreate scatterers.h |
---|
| 585 | cd $LIBFGCM/phy$physique/scatterers |
---|
| 586 | ./make_scatterers $scatterers |
---|
| 587 | cat $LIBFGCM/phy$physique/scatterers.h |
---|
| 588 | cd $LMDGCM |
---|
| 589 | else |
---|
| 590 | echo "Error: you should not use the -s # option with -p $physique" |
---|
[3484] | 591 | exit 1 |
---|
[2441] | 592 | fi |
---|
[957] | 593 | fi |
---|
| 594 | |
---|
| 595 | |
---|
[1] | 596 | ######################################################################## |
---|
[3574] | 597 | # Generation of a Fortran subroutine to track compilation and version |
---|
| 598 | # details through the executable file |
---|
| 599 | ######################################################################## |
---|
| 600 | |
---|
| 601 | # Path and name of the generated file |
---|
| 602 | info_file="$LIBFGCM/misc/version_info.F90" |
---|
| 603 | |
---|
| 604 | # Path and name of the file containing the difference result |
---|
| 605 | diff_file="version_diff.txt" |
---|
| 606 | |
---|
| 607 | # Get the current date |
---|
| 608 | current_date=$(date) |
---|
| 609 | |
---|
| 610 | # Determine version control system (SVN, Git or none) |
---|
| 611 | if command -v svn > /dev/null && svn info > /dev/null 2>&1; then |
---|
| 612 | vcs="svn" |
---|
| 613 | vcs_info=$(svn info $LMDGCM/..) |
---|
| 614 | vcs_diff=$(svn diff $LMDGCM/..) |
---|
| 615 | elif command -v git > /dev/null && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then |
---|
| 616 | vcs="git" |
---|
| 617 | vcs_info=$(git log -1 --pretty=format:"%H%n%an%n%ad%n%s" $LMDGCM/..) |
---|
| 618 | vcs_diff=$(git diff $LMDGCM/..) |
---|
| 619 | else |
---|
| 620 | vcs="none" |
---|
| 621 | fi |
---|
| 622 | |
---|
| 623 | # Function to escape the simple quotation sign |
---|
| 624 | escape_signs() { |
---|
| 625 | echo "$1" | sed "s/'/''/g" |
---|
| 626 | } |
---|
| 627 | |
---|
| 628 | # Generate the Fortran subroutine |
---|
| 629 | cat << EOF > "$info_file" |
---|
| 630 | !*********************************************************************** |
---|
| 631 | ! File generated automatically at compilation |
---|
| 632 | ! |
---|
| 633 | ! DESCRIPTION: |
---|
| 634 | ! The subroutine 'print_version_info' prints compilation details, the |
---|
| 635 | ! version control information (SVN or Git) and the diff result if |
---|
| 636 | ! applicable. |
---|
| 637 | ! |
---|
| 638 | ! PARAMETERS: |
---|
| 639 | ! None. |
---|
| 640 | ! |
---|
| 641 | ! USAGE: |
---|
| 642 | ! Put the argument 'version' as an option when executing the code to |
---|
| 643 | ! display compilation and version details. It is useful for tracking |
---|
| 644 | ! code builds through the executable file. |
---|
| 645 | !*********************************************************************** |
---|
| 646 | |
---|
| 647 | MODULE version_info_mod |
---|
| 648 | |
---|
| 649 | !======================================================================= |
---|
| 650 | contains |
---|
| 651 | !======================================================================= |
---|
| 652 | |
---|
| 653 | SUBROUTINE print_version_info() |
---|
| 654 | |
---|
| 655 | write(*,*) '=== Compilation details ===' |
---|
| 656 | write(*,*) 'Date: ${current_date}' |
---|
| 657 | write(*,*) 'Command: ${compilation_command}' |
---|
| 658 | write(*,*) |
---|
| 659 | EOF |
---|
| 660 | |
---|
| 661 | if [ "$vcs" == "svn" ]; then # SVN info |
---|
| 662 | echo " write(*,*) '===== SVN Information ====='" >> "$info_file" |
---|
| 663 | while IFS= read -r line; do |
---|
| 664 | echo " write(*,*) '${line//\"/\\\"}'" >> "$info_file" |
---|
| 665 | done <<< "$vcs_info" |
---|
| 666 | echo " write(*,*)" >> "$info_file" |
---|
| 667 | echo " write(*,*) '======== SVN Diff ========='" >> "$info_file" |
---|
| 668 | echo " write(*,*) 'Writing SVN diff to file: ${diff_file}'" >> "$info_file" |
---|
| 669 | echo " open(unit = 1,file = \"${diff_file}\",status = 'replace')" >> "$info_file" |
---|
| 670 | while IFS= read -r line; do |
---|
| 671 | escaped_line=$(escape_signs "$line") |
---|
| 672 | echo " write(1,*) '${escaped_line//\"/\\\"}'" >> "$info_file" |
---|
| 673 | done <<< "$vcs_diff" |
---|
| 674 | echo " close(1)" >> "$info_file" |
---|
| 675 | |
---|
| 676 | |
---|
| 677 | elif [ "$vcs" == "git" ]; then # Git info |
---|
| 678 | echo " write(*,*) '===== Git Information ====='" >> "$info_file" |
---|
| 679 | while IFS= read -r line; do |
---|
| 680 | echo " write(*,*) \"${line//\"/\\\"}\"" >> "$info_file" |
---|
| 681 | done <<< "$vcs_info" |
---|
| 682 | echo " write(*,*)" >> "$info_file" |
---|
| 683 | echo " write(*,*) '======== Git Diff ========='" >> "$info_file" |
---|
| 684 | echo " write(*,*) 'Writing Git diff to file: ${diff_file}'" >> "$info_file" |
---|
| 685 | while IFS= read -r line; do |
---|
| 686 | escaped_line=$(escape_signs "$line") |
---|
| 687 | echo " write(1,*) '${escaped_line//\"/\\\"}'" >> "$info_file" |
---|
| 688 | done <<< "$vcs_diff" |
---|
| 689 | echo " close(1)" >> "$info_file" |
---|
| 690 | else # Non-versioned code |
---|
| 691 | echo " write(*,*) 'No version control information available.'" >> "$info_file" |
---|
| 692 | fi |
---|
| 693 | echo " write(*,*) '==========================='" >> "$info_file" |
---|
| 694 | |
---|
| 695 | cat << EOF >> "$info_file" |
---|
| 696 | |
---|
| 697 | END SUBROUTINE print_version_info |
---|
| 698 | |
---|
| 699 | END MODULE version_info_mod |
---|
| 700 | EOF |
---|
| 701 | |
---|
| 702 | # Termination message |
---|
| 703 | echo "'$info_file' has been successfully generated." |
---|
| 704 | |
---|
| 705 | |
---|
| 706 | ######################################################################## |
---|
[1] | 707 | # Differentes dynamiques (3d, 2d, 1d) |
---|
| 708 | ######################################################################## |
---|
| 709 | |
---|
| 710 | dimension=`echo $dim | wc -w` |
---|
| 711 | echo dimension $dimension |
---|
| 712 | |
---|
| 713 | if (( $dimension == 3 )) |
---|
| 714 | then |
---|
| 715 | cd $LIBFGCM/grid |
---|
| 716 | \rm fxyprim.h |
---|
| 717 | cp -p fxy_${grille}.h fxyprim.h |
---|
[895] | 718 | #else |
---|
| 719 | # echo "Probleme dans les dimensions de la dynamique !!" |
---|
| 720 | # echo "Non reactive pour l'instant !!!" |
---|
[1] | 721 | fi |
---|
| 722 | |
---|
[895] | 723 | if (( $dimension == 1 )) |
---|
| 724 | then |
---|
[1530] | 725 | ## Sanity check: 1D models should be used in serial |
---|
[2996] | 726 | ## unless compiled with xios and then it should be in mpi only |
---|
| 727 | if [[ $io == xios ]] |
---|
[1530] | 728 | then |
---|
[2996] | 729 | echo "OK io xios" |
---|
| 730 | if [[ $parallel != "mpi" ]] |
---|
| 731 | then |
---|
| 732 | echo "Error: a 1D model compiled with xios should also be compiled with " |
---|
| 733 | echo " -parallel mpi option!" |
---|
[3484] | 734 | exit 1 |
---|
[2996] | 735 | fi |
---|
| 736 | else |
---|
| 737 | # no xios, check that it is in serial only |
---|
| 738 | if [[ $parallel != "none" ]] |
---|
| 739 | then |
---|
[1530] | 740 | echo "Error: a 1D model should not be compiled with " |
---|
| 741 | echo " -parallel [mpi|omp|mpi_omp] option!" |
---|
[3484] | 742 | exit 1 |
---|
[2996] | 743 | fi |
---|
| 744 | fi # of if [[ $io == "xios" ]] |
---|
[1403] | 745 | CPP_KEY="$CPP_KEY CPP_1D" |
---|
[895] | 746 | ##in 1D, add dyn3d to include path (because main prog is in physics) |
---|
[2645] | 747 | INCLUDE_DIR="$INCLUDE_DIR -Ilibf/dyn3d -Ilibf/dyn3d_common" |
---|
[1403] | 748 | ## no filtre in 1d: |
---|
| 749 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
| 750 | ## no need to compile all routines in dyn3d_common either: |
---|
| 751 | DYN_COMMON_PATH=$LMDGCM/.void_dir |
---|
| 752 | ## no need to compile all routines in dynlmdz_phy... ; |
---|
| 753 | ## (because key ones are included in 1D main program) |
---|
| 754 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
| 755 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
[895] | 756 | fi |
---|
| 757 | |
---|
[1] | 758 | ###################################################################### |
---|
| 759 | # Traitement special pour le nouveau rayonnement de Laurent Li. |
---|
| 760 | # ---> YM desactive pour le traitemement en parallele |
---|
| 761 | ###################################################################### |
---|
| 762 | |
---|
| 763 | #if [[ -f $libf/phy$physique/raddim.h ]] |
---|
| 764 | #then |
---|
| 765 | # if [[ -f $libf/phy$physique/raddim.$dimh.h ]] |
---|
| 766 | #then |
---|
| 767 | # \rm -f $libf/phy$physique/raddim.h |
---|
| 768 | # cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h |
---|
[3471] | 769 | # echo $libf/phy$physique/raddim.$dimh.h |
---|
[1] | 770 | # cat $libf/phy$physique/raddim.h |
---|
| 771 | # else |
---|
| 772 | # echo On peut diminuer la taille de l executable en creant |
---|
| 773 | # echo le fichier $libf/phy$physique/raddim.$dimh.h |
---|
| 774 | # \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h |
---|
| 775 | # fi |
---|
| 776 | #fi |
---|
| 777 | |
---|
| 778 | ###################################################################### |
---|
| 779 | # Gestion du filtre qui n'existe qu'en 3d. |
---|
| 780 | ###################################################################### |
---|
| 781 | |
---|
| 782 | if (( `expr $dimc \> 2` == 1 )) |
---|
| 783 | then |
---|
| 784 | filtre="FILTRE=$filtre" |
---|
| 785 | else |
---|
| 786 | filtre="FILTRE= L_FILTRE= " |
---|
| 787 | fi |
---|
| 788 | echo MACRO FILTRE $filtre |
---|
| 789 | |
---|
| 790 | echo $dimc |
---|
| 791 | |
---|
| 792 | |
---|
| 793 | |
---|
| 794 | ###################################################################### |
---|
| 795 | # Creation du suffixe de la configuration |
---|
| 796 | ###################################################################### |
---|
| 797 | |
---|
[3499] | 798 | if [[ $libphy != "true" ]];then |
---|
| 799 | SUFF_NAME=_${dim_full} |
---|
| 800 | fi |
---|
[1] | 801 | SUFF_NAME=${SUFF_NAME}_phy${physique} |
---|
| 802 | |
---|
[2967] | 803 | if [[ "$bands" != "" ]] |
---|
| 804 | then |
---|
| 805 | #if bands option -b VISxIR is used, add "_bVISxIR" to executable name |
---|
| 806 | SUFF_NAME=${SUFF_NAME}_b$bands |
---|
| 807 | fi |
---|
| 808 | |
---|
[1] | 809 | if [[ "$parallel" != "none" ]] |
---|
| 810 | then |
---|
| 811 | SUFF_NAME=${SUFF_NAME}_para |
---|
[2996] | 812 | if (( $dimension == 1 )) |
---|
| 813 | then |
---|
[3471] | 814 | # dynamics-related routines in"dyn1d" subdirectory of phy${physique} |
---|
[2996] | 815 | DYN=phy${physique}/dyn1d |
---|
| 816 | else |
---|
| 817 | DYN=dyn${dimc}d${paramem} |
---|
| 818 | fi |
---|
[979] | 819 | if [[ "$paramem" == "mem" ]] |
---|
| 820 | then |
---|
| 821 | SUFF_NAME=${SUFF_NAME}_${paramem} |
---|
| 822 | fi |
---|
[1] | 823 | else |
---|
| 824 | SUFF_NAME=${SUFF_NAME}_seq |
---|
[1403] | 825 | if (( $dimension == 1 )) |
---|
| 826 | then |
---|
[3471] | 827 | # dynamics-related routines in"dyn1d" subdirectory of phy${physique} |
---|
[1403] | 828 | DYN=phy${physique}/dyn1d |
---|
| 829 | else |
---|
| 830 | DYN=dyn${dimc}d |
---|
[895] | 831 | fi |
---|
[1] | 832 | fi |
---|
| 833 | |
---|
[1019] | 834 | if [[ $veget != "false" ]] |
---|
[1] | 835 | then |
---|
| 836 | SUFF_NAME=${SUFF_NAME}_orch |
---|
| 837 | fi |
---|
| 838 | |
---|
| 839 | if [[ $couple != "false" ]] |
---|
| 840 | then |
---|
| 841 | SUFF_NAME=${SUFF_NAME}_couple |
---|
| 842 | fi |
---|
| 843 | |
---|
| 844 | if [[ $chimie == "INCA" ]] |
---|
| 845 | then |
---|
| 846 | SUFF_NAME=${SUFF_NAME}_inca |
---|
| 847 | fi |
---|
[3499] | 848 | SUFF_DEBUG= |
---|
[3471] | 849 | if [[ "$compil_mod" == "debug" ]] |
---|
| 850 | then |
---|
[3499] | 851 | SUFF_DEBUG=_debug |
---|
[3471] | 852 | fi |
---|
[3499] | 853 | SUFF_DIR=${SUFF_NAME}${SUFF_DEBUG} |
---|
[1] | 854 | |
---|
[1540] | 855 | if [[ $libphy == "true" ]] |
---|
| 856 | then |
---|
| 857 | # special case where we compile only the physics |
---|
| 858 | DYN=$LMDGCM/.void_dir |
---|
| 859 | DYN_COMMON_PATH=$LMDGCM/.void_dir |
---|
| 860 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
| 861 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
| 862 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
| 863 | #and there is no main program to generate |
---|
| 864 | code="" |
---|
| 865 | SUFF_NAME="" |
---|
[3499] | 866 | # SUFF_DIR= |
---|
[1540] | 867 | else |
---|
| 868 | SUFF_NAME=${SUFF_NAME}.e |
---|
| 869 | fi |
---|
| 870 | |
---|
[1] | 871 | cd $LMDGCM |
---|
| 872 | config_fcm="config.fcm" |
---|
| 873 | rm -f $config_fcm |
---|
| 874 | touch $config_fcm |
---|
| 875 | |
---|
| 876 | echo "%ARCH $arch" >> $config_fcm |
---|
[3471] | 877 | echo "%INCDIR $INCLUDE_DIR" >> $config_fcm |
---|
[1] | 878 | echo "%LIB $LIB" >> $config_fcm |
---|
| 879 | echo "%ROOT_PATH $PWD" >> $config_fcm |
---|
| 880 | echo "%LIBF $LIBFGCM" >> $config_fcm |
---|
| 881 | echo "%LIBO $LIBOGCM" >> $config_fcm |
---|
| 882 | echo "%DYN $DYN" >> $config_fcm |
---|
[1403] | 883 | echo "%DYN_COMMON $DYN_COMMON_PATH" >> $config_fcm |
---|
[1521] | 884 | echo "%PHY_COMMON $PHY_COMMON_PATH" >> $config_fcm |
---|
[1403] | 885 | echo "%FILTRE $FILTRE_PATH" >> $config_fcm |
---|
[1] | 886 | echo "%PHYS phy${physique}" >> $config_fcm |
---|
[1403] | 887 | echo "%DYN_PHYS $DYN_PHYS_PATH" >> $config_fcm |
---|
| 888 | echo "%DYN_PHYS_SUB $DYN_PHYS_SUB_PATH" >> $config_fcm |
---|
[1302] | 889 | echo "%RRTM $RRTM_PATH" >> $config_fcm |
---|
[1650] | 890 | echo "%DUST $DUST_PATH" >> $config_fcm |
---|
| 891 | echo "%STRATAER $STRATAER_PATH" >> $config_fcm |
---|
[1302] | 892 | echo "%SISVAT $SISVAT_PATH" >> $config_fcm |
---|
[1] | 893 | echo "%COSP $COSP_PATH" >> $config_fcm |
---|
[895] | 894 | echo "%CHEM $CHEM_PATH" >> $config_fcm |
---|
[1661] | 895 | echo "%CLOUD $CLOUD_PATH" >> $config_fcm |
---|
[1793] | 896 | echo "%MUPHY $MUPHY_PATH" >> $config_fcm |
---|
[1107] | 897 | echo "%AERONO $AERONO_PATH" >> $config_fcm |
---|
[2778] | 898 | echo "%EVOLUTION $EVOLUTION_PATH" >> $config_fcm |
---|
[1] | 899 | echo "%CPP_KEY $CPP_KEY" >> $config_fcm |
---|
| 900 | echo "%EXEC $code" >> $config_fcm |
---|
| 901 | echo "%SUFF_NAME $SUFF_NAME" >> $config_fcm |
---|
[3475] | 902 | echo "%SUFF_DIR $SUFF_DIR" >> $config_fcm |
---|
[1] | 903 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm |
---|
| 904 | echo "%PARA_FFLAGS $PARA_FFLAGS" >> $config_fcm |
---|
| 905 | echo "%PARA_LD $PARA_LD" >> $config_fcm |
---|
| 906 | echo "%EXT_SRC $EXT_SRC" >> $config_fcm |
---|
| 907 | |
---|
[2339] | 908 | # setup arch.fcm and arch.opt |
---|
| 909 | rm -f arch.fcm |
---|
| 910 | rm -f arch.opt |
---|
[1] | 911 | ln -s arch/arch-${arch}.fcm arch.fcm |
---|
| 912 | if test -f arch/arch-${arch}.opt && [ $compil_mod = "prod" ] |
---|
| 913 | then |
---|
| 914 | ln -s arch/arch-${arch}.opt arch.opt |
---|
| 915 | else |
---|
| 916 | ln -s .void_file arch.opt |
---|
| 917 | fi |
---|
| 918 | |
---|
[2339] | 919 | # cleanup before compiling |
---|
[3481] | 920 | if [[ $libphy != "true" ]]; then |
---|
[3499] | 921 | rm -f bin/${code}${SUFF_NAME} |
---|
[3481] | 922 | fi |
---|
[3499] | 923 | rm -f $LIBOGCM/${arch}${SUFF_DIR}/.config/fcm.bld.lock |
---|
[1] | 924 | |
---|
[3499] | 925 | function delete_dim_h { |
---|
| 926 | if [[ -r $LIBFGCM/grid/dimensions.h ]];then |
---|
| 927 | echo "Removing dimensions.h" |
---|
| 928 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
| 929 | fi |
---|
| 930 | } |
---|
| 931 | |
---|
| 932 | ./build_gcm ${fcm_path} -j $job $full || (echo "Build gcm failed."; delete_dim_h; exit 1) |
---|
| 933 | |
---|
[1] | 934 | rm -rf tmp_src |
---|
| 935 | rm -rf config |
---|
[3499] | 936 | ln -s $LIBOGCM/${arch}${SUFF_DIR}/.config config |
---|
| 937 | ln -s $LIBOGCM/${arch}${SUFF_DIR}/.config/ppsrc tmp_src |
---|
[979] | 938 | |
---|
[3499] | 939 | delete_dim_h |
---|