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