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