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