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