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