[1279] | 1 | #!/bin/bash |
---|
| 2 | # $Id: makelmdz_fcm 3406 2018-10-23 09:16:41Z idelkadi $ |
---|
| 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 |
---|
[1802] | 36 | job=1 |
---|
| 37 | full='' |
---|
[2358] | 38 | libphy=false |
---|
[783] | 39 | |
---|
[2743] | 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 |
---|
[2239] | 47 | DYN_COMMON_PATH=$LIBFGCM/dyn3d_common |
---|
[2084] | 48 | # path for optional packages, but default set to ".void_dir" |
---|
[2239] | 49 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
| 50 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
[2242] | 51 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
[2326] | 52 | PHY_COMMON_PATH=$LMDGCM/.void_dir |
---|
[2084] | 53 | RRTM_PATH=$LMDGCM/.void_dir |
---|
[2631] | 54 | DUST_PATH=$LMDGCM/.void_dir |
---|
[2690] | 55 | STRATAER_PATH=$LMDGCM/.void_dir |
---|
[2084] | 56 | SISVAT_PATH=$LMDGCM/.void_dir |
---|
[1327] | 57 | COSP_PATH=$LMDGCM/.void_dir |
---|
[1578] | 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 : |
---|
[1772] | 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 |
---|
[1965] | 87 | [-c false/MPI1/OMCT] : coupling with ocean model : MPI1/OMCT/false (default: false) |
---|
[1772] | 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) |
---|
[2238] | 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) |
---|
[2631] | 97 | [-dust true/false] : compile with/without the dust package by Boucher and co (default: false) |
---|
[2690] | 98 | [-strataer true/false] : compile with/without the strat aer package by Boucher and co (default: false) |
---|
[1772] | 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) |
---|
[2097] | 101 | [-io ioipsl/mix/xios] : Input/Output library (default: ioipsl) |
---|
[1772] | 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 |
---|
[1802] | 108 | [-j n] : active parallel compiling on ntask |
---|
| 109 | [-full] : full recompiling |
---|
[2358] | 110 | [-libphy] : only compile physics package (no dynamics or main program) |
---|
[1772] | 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 |
---|
[2743] | 113 | [-arch_path path] : path to architecture files (default: $arch_default_path) |
---|
[1772] | 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 | |
---|
[1865] | 146 | "-sisvat") |
---|
| 147 | sisvat="$2" ; shift ; shift ;; |
---|
| 148 | |
---|
[1990] | 149 | "-rrtm") |
---|
| 150 | rrtm="$2" ; shift ; shift ;; |
---|
| 151 | |
---|
[2631] | 152 | "-dust") |
---|
| 153 | dust="$2" ; shift ; shift ;; |
---|
| 154 | |
---|
[2690] | 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") |
---|
[1772] | 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 ;; |
---|
[1680] | 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 ;; |
---|
[2358] | 192 | |
---|
[1802] | 193 | "-j") |
---|
| 194 | job=$2 ; shift ; shift ;; |
---|
[2358] | 195 | |
---|
[1802] | 196 | "-full") |
---|
| 197 | full="-full" ; shift ;; |
---|
[783] | 198 | |
---|
[2358] | 199 | "-libphy") |
---|
| 200 | libphy="true" ; shift ;; |
---|
| 201 | |
---|
[1279] | 202 | "-arch") |
---|
[2743] | 203 | arch=$2 ; arch_defined="TRUE" ; shift ; shift ;; |
---|
[783] | 204 | |
---|
[2743] | 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 | ############################################################### |
---|
[1755] | 214 | # path to fcm |
---|
[1136] | 215 | ############################################################### |
---|
[1755] | 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 | |
---|
[1757] | 223 | # add fcm_path to PATH |
---|
| 224 | export PATH=${fcm_path}:${PATH} |
---|
| 225 | |
---|
[1755] | 226 | echo "Path to fcm:" |
---|
| 227 | echo ${fcm_path} |
---|
[1136] | 228 | |
---|
[783] | 229 | ############################################################### |
---|
[2098] | 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 | |
---|
[2743] | 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 |
---|
[3406] | 269 | set +e |
---|
[2743] | 270 | source arch.env |
---|
| 271 | source arch.path |
---|
[3406] | 272 | set -e |
---|
[2743] | 273 | else |
---|
| 274 | echo "You must define a target architecture" |
---|
| 275 | exit 1 |
---|
| 276 | fi |
---|
| 277 | |
---|
[783] | 278 | ######################################################################## |
---|
| 279 | # Definition des clefs CPP, des chemins des includes et modules |
---|
| 280 | # et des libraries |
---|
| 281 | ######################################################################## |
---|
| 282 | |
---|
[1279] | 283 | if [[ "$compil_mod" == "prod" ]] |
---|
| 284 | then |
---|
| 285 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
| 286 | elif [[ "$compil_mod" == "dev" ]] |
---|
| 287 | then |
---|
| 288 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
| 289 | elif [[ "$compil_mod" == "debug" ]] |
---|
| 290 | then |
---|
| 291 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
| 292 | fi |
---|
[783] | 293 | |
---|
[2250] | 294 | phys_root=$physique |
---|
| 295 | if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi |
---|
| 296 | if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi |
---|
| 297 | if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi |
---|
| 298 | if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi |
---|
| 299 | if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi |
---|
| 300 | if [[ "${physique:0:3}" == "mar" ]] ; then phys_root=mar ; fi |
---|
| 301 | if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi |
---|
| 302 | |
---|
[1279] | 303 | if [[ "$physique" != "nophys" ]] |
---|
| 304 | then |
---|
[1615] | 305 | #We'll use some physics |
---|
| 306 | CPP_KEY="$CPP_KEY CPP_PHYS" |
---|
[2250] | 307 | if [[ "${phys_root}" == "lmd" ]] |
---|
[1615] | 308 | then |
---|
| 309 | #For lmd physics, default planet type is Earth |
---|
[1279] | 310 | CPP_KEY="$CPP_KEY CPP_EARTH" |
---|
[1615] | 311 | fi |
---|
[2326] | 312 | # set physics common utilities path |
---|
| 313 | PHY_COMMON_PATH="${LIBFGCM}/phy_common" |
---|
[2239] | 314 | # set the dyn/phys interface path |
---|
[2417] | 315 | DYN_PHYS_PATH="${LIBFGCM}/dynphy_lonlat" |
---|
| 316 | DYN_PHYS_SUB_PATH="${LIBFGCM}/dynphy_lonlat/phy${phys_root}" |
---|
[1279] | 317 | fi |
---|
[783] | 318 | |
---|
[2239] | 319 | if [[ "$filtre" == "filtrez" ]] |
---|
| 320 | then |
---|
| 321 | FILTRE_PATH=${LIBFGCM}/$filtre |
---|
| 322 | fi |
---|
| 323 | |
---|
[1279] | 324 | if [[ "$chimie" == "INCA" ]] |
---|
| 325 | then |
---|
| 326 | CPP_KEY="$CPP_KEY INCA" |
---|
| 327 | INCLUDE="$INCLUDE -I${INCA_INCDIR}" |
---|
[3406] | 328 | LIB="$LIB -L${INCA_LIBDIR} ${INCA_LIB}" |
---|
[1279] | 329 | fi |
---|
[783] | 330 | |
---|
[1279] | 331 | if [[ "$couple" != "false" ]] |
---|
| 332 | then |
---|
[1965] | 333 | if [[ "$couple" == "MPI1" ]] |
---|
| 334 | then |
---|
| 335 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
| 336 | export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1 |
---|
| 337 | export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib |
---|
| 338 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
[3406] | 339 | LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}" |
---|
[1965] | 340 | else |
---|
| 341 | CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT" |
---|
| 342 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
[3406] | 343 | LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}" |
---|
[1965] | 344 | fi |
---|
[1279] | 345 | fi |
---|
[783] | 346 | |
---|
[1279] | 347 | if [[ "$parallel" == "mpi" ]] |
---|
| 348 | then |
---|
| 349 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
| 350 | PARA_FFLAGS="%MPI_FFLAGS" |
---|
| 351 | PARA_LD="%MPI_LD" |
---|
| 352 | elif [[ "$parallel" == "omp" ]] |
---|
| 353 | then |
---|
| 354 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
| 355 | PARA_FFLAGS="%OMP_FFLAGS" |
---|
| 356 | PARA_LD="%OMP_LD" |
---|
| 357 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
| 358 | then |
---|
| 359 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
| 360 | PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS" |
---|
| 361 | PARA_LD="%MPI_LD %OMP_LD" |
---|
| 362 | fi |
---|
[783] | 363 | |
---|
[1279] | 364 | if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \ |
---|
| 365 | && "$compil_mod" == "debug" ]] |
---|
| 366 | then |
---|
| 367 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
| 368 | echo "We suggest switching to \"-dev\"." |
---|
| 369 | fi |
---|
[783] | 370 | |
---|
[1811] | 371 | if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ] |
---|
[1279] | 372 | then |
---|
[1811] | 373 | #NB: option 'true': for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6 |
---|
| 374 | # For this case, cpp flag ORCHIDEE_NOOPENMP must be added to the makelmdz_fcm arguments |
---|
| 375 | # 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 |
---|
[3406] | 376 | INCLUDE="${INCLUDE} ${ORCHIDEE_INCDIR}" |
---|
[1772] | 377 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
[1811] | 378 | # temporary, for Orchidee versions 1.9.* (before openmp activation) |
---|
| 379 | if [[ "$veget" == "orchidee1.9" ]] ; then |
---|
| 380 | CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP" |
---|
| 381 | fi |
---|
| 382 | if [[ "$veget" == "orchidee2.0" ]] ; then |
---|
[1854] | 383 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
[1811] | 384 | else |
---|
| 385 | orch_libs="sechiba parameters stomate parallel orglob" |
---|
| 386 | fi |
---|
[3406] | 387 | LIB="${LIB} -L${ORCHIDEE_LIBDIR} ${ORCHIDEE_LIB}" |
---|
[1811] | 388 | elif [[ "$veget" != "false" ]] ; then |
---|
[1772] | 389 | echo "Option -v $veget does not exist" |
---|
| 390 | echo "Use ./makelmdz_fcm -h for more information" |
---|
| 391 | exit |
---|
[1279] | 392 | fi |
---|
[783] | 393 | |
---|
[1865] | 394 | if [[ "$sisvat" == "true" ]] |
---|
| 395 | then |
---|
| 396 | CPP_KEY="$CPP_KEY CPP_SISVAT" |
---|
[2084] | 397 | SISVAT_PATH="$LIBFGCM/%PHYS/sisvat" |
---|
[1865] | 398 | fi |
---|
| 399 | |
---|
[1990] | 400 | if [[ "$rrtm" == "true" ]] |
---|
| 401 | then |
---|
| 402 | CPP_KEY="$CPP_KEY CPP_RRTM" |
---|
[2084] | 403 | RRTM_PATH="$LIBFGCM/%PHYS/rrtm" |
---|
[1990] | 404 | fi |
---|
| 405 | |
---|
[2631] | 406 | if [[ "$dust" == "true" ]] |
---|
| 407 | then |
---|
| 408 | CPP_KEY="$CPP_KEY CPP_Dust" |
---|
| 409 | DUST_PATH="$LIBFGCM/%PHYS/Dust" |
---|
| 410 | fi |
---|
| 411 | |
---|
[2690] | 412 | if [[ "$strataer" == "true" ]] |
---|
| 413 | then |
---|
| 414 | CPP_KEY="$CPP_KEY CPP_StratAer" |
---|
| 415 | STRATAER_PATH="$LIBFGCM/%PHYS/StratAer" |
---|
| 416 | fi |
---|
| 417 | |
---|
[1279] | 418 | if [[ $io == ioipsl ]] |
---|
| 419 | then |
---|
| 420 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
[3406] | 421 | INCLUDE="$INCLUDE ${IOIPSL_INCDIR}" |
---|
| 422 | LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB}" |
---|
[2097] | 423 | elif [[ $io == mix ]] |
---|
[1897] | 424 | then |
---|
| 425 | # For now, xios implies also using ioipsl |
---|
| 426 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS" |
---|
[3406] | 427 | INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}" |
---|
| 428 | LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}" |
---|
[2097] | 429 | elif [[ $io == xios ]] |
---|
| 430 | then |
---|
| 431 | # For now, xios implies also using ioipsl |
---|
| 432 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT" |
---|
[3406] | 433 | INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}" |
---|
| 434 | LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}" |
---|
[1279] | 435 | fi |
---|
[1897] | 436 | |
---|
[1279] | 437 | if [[ "$cosp" == "true" ]] |
---|
| 438 | then |
---|
| 439 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
[2239] | 440 | COSP_PATH="$LIBFGCM/phylmd/cosp" |
---|
[1279] | 441 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
| 442 | fi |
---|
[783] | 443 | |
---|
[3406] | 444 | # NETCDF library include/library paths |
---|
[1551] | 445 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
[3406] | 446 | LIB="$LIB ${NETCDF_LIBDIR} ${NETCDF_LIB}" |
---|
[1551] | 447 | |
---|
[783] | 448 | ######################################################################## |
---|
| 449 | # calcul du nombre de dimensions |
---|
| 450 | ######################################################################## |
---|
| 451 | |
---|
| 452 | |
---|
[1279] | 453 | dim_full=$dim |
---|
| 454 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
| 455 | set $dim |
---|
| 456 | dimc=$# |
---|
[783] | 457 | echo calcul de la dimension |
---|
| 458 | echo dim $dim |
---|
| 459 | echo dimc $dimc |
---|
| 460 | |
---|
| 461 | |
---|
| 462 | ######################################################################## |
---|
| 463 | # Gestion des dimensions du modele. |
---|
[1114] | 464 | # on cree ou remplace le fichier des dimensions |
---|
[783] | 465 | ######################################################################## |
---|
| 466 | |
---|
[1695] | 467 | cd $LIBFGCM/grid |
---|
| 468 | if [[ -f dimensions.h ]] |
---|
| 469 | then |
---|
| 470 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
| 471 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
| 472 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
| 473 | echo vous pouvez continuer en repondant oui. |
---|
| 474 | echo "Voulez-vous vraiment continuer?" |
---|
[1755] | 475 | echo "" |
---|
| 476 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
| 477 | echo "Wait until the first compilation is finished before launching this one." |
---|
| 478 | echo "If you are sure that you are not compiling elsewhere, just answer " |
---|
| 479 | echo "yes (or 'oui') to the question below to proceed." |
---|
| 480 | echo "Do you wish to continue?" |
---|
[1695] | 481 | read reponse |
---|
[1755] | 482 | if [[ $reponse == "oui" || $reponse == "yes" ]] |
---|
[1695] | 483 | then |
---|
[1696] | 484 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
[1695] | 485 | else |
---|
| 486 | exit |
---|
| 487 | fi |
---|
| 488 | fi |
---|
| 489 | |
---|
| 490 | |
---|
[783] | 491 | cd $LIBFGCM/grid/dimension |
---|
[1114] | 492 | ./makdim $dim |
---|
[783] | 493 | cat $LIBFGCM/grid/dimensions.h |
---|
| 494 | cd $LMDGCM |
---|
| 495 | |
---|
| 496 | |
---|
| 497 | ######################################################################## |
---|
| 498 | # Differentes dynamiques (3d, 2d, 1d) |
---|
| 499 | ######################################################################## |
---|
| 500 | |
---|
[1279] | 501 | dimension=`echo $dim | wc -w` |
---|
[783] | 502 | echo dimension $dimension |
---|
| 503 | |
---|
[1279] | 504 | if (( $dimension == 3 )) |
---|
| 505 | then |
---|
[783] | 506 | cd $LIBFGCM/grid |
---|
| 507 | \rm fxyprim.h |
---|
| 508 | cp -p fxy_${grille}.h fxyprim.h |
---|
[2239] | 509 | #else |
---|
| 510 | # echo "Probleme dans les dimensions de la dynamique !!" |
---|
| 511 | # echo "Non reactive pour l'instant !!!" |
---|
[1279] | 512 | fi |
---|
[783] | 513 | |
---|
[2239] | 514 | if (( $dimension == 1 )) |
---|
| 515 | then |
---|
| 516 | CPP_KEY="$CPP_KEY CPP_1D" |
---|
| 517 | ##in 1D, add dyn3d to include path (because main prog is in physics) |
---|
| 518 | INCLUDE="$INCLUDE -Ilibf/dyn3d -Ilibf/dyn3d_common" |
---|
| 519 | ## no filtre in 1d: |
---|
| 520 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
| 521 | ## no need to compile all routines in dyn3d_common either: |
---|
| 522 | DYN_COMMON_PATH=$LMDGCM/.void_dir |
---|
| 523 | ## no need to compile all routines in dynlmdz_phy... ; |
---|
| 524 | ## (because key ones are included in 1D main program) |
---|
| 525 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
[2242] | 526 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
[2239] | 527 | fi |
---|
| 528 | |
---|
[783] | 529 | ###################################################################### |
---|
| 530 | # Traitement special pour le nouveau rayonnement de Laurent Li. |
---|
| 531 | # ---> YM desactive pour le traitemement en parallele |
---|
| 532 | ###################################################################### |
---|
| 533 | |
---|
[1279] | 534 | #if [[ -f $libf/phy$physique/raddim.h ]] |
---|
| 535 | #then |
---|
| 536 | # if [[ -f $libf/phy$physique/raddim.$dimh.h ]] |
---|
| 537 | #then |
---|
[783] | 538 | # \rm -f $libf/phy$physique/raddim.h |
---|
| 539 | # cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h |
---|
| 540 | # echo $libf/phy$physique/raddim.$dimh.h |
---|
| 541 | # cat $libf/phy$physique/raddim.h |
---|
| 542 | # else |
---|
| 543 | # echo On peut diminuer la taille de l executable en creant |
---|
| 544 | # echo le fichier $libf/phy$physique/raddim.$dimh.h |
---|
| 545 | # \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h |
---|
[1279] | 546 | # fi |
---|
| 547 | #fi |
---|
[783] | 548 | |
---|
| 549 | ###################################################################### |
---|
| 550 | # Gestion du filtre qui n'existe qu'en 3d. |
---|
| 551 | ###################################################################### |
---|
| 552 | |
---|
[1279] | 553 | if (( `expr $dimc \> 2` == 1 )) |
---|
| 554 | then |
---|
| 555 | filtre="FILTRE=$filtre" |
---|
[783] | 556 | else |
---|
[1279] | 557 | filtre="FILTRE= L_FILTRE= " |
---|
| 558 | fi |
---|
[783] | 559 | echo MACRO FILTRE $filtre |
---|
| 560 | |
---|
| 561 | echo $dimc |
---|
| 562 | |
---|
| 563 | |
---|
| 564 | |
---|
| 565 | ###################################################################### |
---|
| 566 | # Creation du suffixe de la configuration |
---|
| 567 | ###################################################################### |
---|
| 568 | |
---|
| 569 | |
---|
[1279] | 570 | SUFF_NAME=_${dim_full} |
---|
| 571 | SUFF_NAME=${SUFF_NAME}_phy${physique} |
---|
[783] | 572 | |
---|
[1279] | 573 | if [[ "$parallel" != "none" ]] |
---|
| 574 | then |
---|
| 575 | SUFF_NAME=${SUFF_NAME}_para |
---|
[1680] | 576 | DYN=dyn${dimc}d${paramem} |
---|
| 577 | if [[ "$paramem" == "mem" ]] |
---|
| 578 | then |
---|
[2202] | 579 | SUFF_NAME=${SUFF_NAME}_${paramem} |
---|
| 580 | else |
---|
| 581 | echo "The version of the dynamics in dyn3dpar is no longer updated." |
---|
| 582 | echo "You should use option \"-mem\"." |
---|
| 583 | exit 1 |
---|
[1680] | 584 | fi |
---|
[783] | 585 | else |
---|
[1279] | 586 | SUFF_NAME=${SUFF_NAME}_seq |
---|
[2239] | 587 | if (( $dimension == 1 )) |
---|
| 588 | then |
---|
| 589 | # dynamics-related routines in"dyn1d" subdirectory of phy${physique} |
---|
| 590 | DYN=phy${physique}/dyn1d |
---|
| 591 | else |
---|
| 592 | DYN=dyn${dimc}d |
---|
| 593 | fi |
---|
[1279] | 594 | fi |
---|
[783] | 595 | |
---|
[1772] | 596 | if [[ $veget != "false" ]] |
---|
[1279] | 597 | then |
---|
| 598 | SUFF_NAME=${SUFF_NAME}_orch |
---|
| 599 | fi |
---|
[783] | 600 | |
---|
[1279] | 601 | if [[ $couple != "false" ]] |
---|
| 602 | then |
---|
| 603 | SUFF_NAME=${SUFF_NAME}_couple |
---|
| 604 | fi |
---|
[783] | 605 | |
---|
[1279] | 606 | if [[ $chimie == "INCA" ]] |
---|
| 607 | then |
---|
| 608 | SUFF_NAME=${SUFF_NAME}_inca |
---|
| 609 | fi |
---|
[783] | 610 | |
---|
[2358] | 611 | if [[ $libphy == "true" ]] |
---|
| 612 | then |
---|
| 613 | # special case where we compile only the physics |
---|
| 614 | DYN=$LMDGCM/.void_dir |
---|
| 615 | DYN_COMMON_PATH=$LMDGCM/.void_dir |
---|
| 616 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
| 617 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
| 618 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
| 619 | #and there is no main program to generate |
---|
| 620 | code="" |
---|
| 621 | SUFF_NAME="" |
---|
| 622 | else |
---|
| 623 | SUFF_NAME=${SUFF_NAME}.e |
---|
| 624 | fi |
---|
| 625 | |
---|
[783] | 626 | cd $LMDGCM |
---|
[1279] | 627 | config_fcm="config.fcm" |
---|
[783] | 628 | rm -f $config_fcm |
---|
| 629 | touch $config_fcm |
---|
| 630 | rm -f bin/${code}${SUFF_NAME}.e |
---|
| 631 | rm -f arch.fcm |
---|
[1279] | 632 | rm -f arch.opt |
---|
[783] | 633 | |
---|
| 634 | echo "%ARCH $arch" >> $config_fcm |
---|
| 635 | echo "%INCDIR $INCLUDE" >> $config_fcm |
---|
| 636 | echo "%LIB $LIB" >> $config_fcm |
---|
| 637 | echo "%ROOT_PATH $PWD" >> $config_fcm |
---|
| 638 | echo "%LIBF $LIBFGCM" >> $config_fcm |
---|
| 639 | echo "%LIBO $LIBOGCM" >> $config_fcm |
---|
| 640 | echo "%DYN $DYN" >> $config_fcm |
---|
[2239] | 641 | echo "%DYN_COMMON $DYN_COMMON_PATH" >> $config_fcm |
---|
[2326] | 642 | echo "%PHY_COMMON $PHY_COMMON_PATH" >> $config_fcm |
---|
[2239] | 643 | echo "%FILTRE $FILTRE_PATH" >> $config_fcm |
---|
[783] | 644 | echo "%PHYS phy${physique}" >> $config_fcm |
---|
[2239] | 645 | echo "%DYN_PHYS $DYN_PHYS_PATH" >> $config_fcm |
---|
[2242] | 646 | echo "%DYN_PHYS_SUB $DYN_PHYS_SUB_PATH" >> $config_fcm |
---|
[2084] | 647 | echo "%RRTM $RRTM_PATH" >> $config_fcm |
---|
[2631] | 648 | echo "%DUST $DUST_PATH" >> $config_fcm |
---|
[2690] | 649 | echo "%STRATAER $STRATAER_PATH" >> $config_fcm |
---|
[2084] | 650 | echo "%SISVAT $SISVAT_PATH" >> $config_fcm |
---|
[1327] | 651 | echo "%COSP $COSP_PATH" >> $config_fcm |
---|
[783] | 652 | echo "%CPP_KEY $CPP_KEY" >> $config_fcm |
---|
| 653 | echo "%EXEC $code" >> $config_fcm |
---|
| 654 | echo "%SUFF_NAME $SUFF_NAME" >> $config_fcm |
---|
[1002] | 655 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm |
---|
| 656 | echo "%PARA_FFLAGS $PARA_FFLAGS" >> $config_fcm |
---|
| 657 | echo "%PARA_LD $PARA_LD" >> $config_fcm |
---|
[1279] | 658 | echo "%EXT_SRC $EXT_SRC" >> $config_fcm |
---|
[783] | 659 | |
---|
[1002] | 660 | |
---|
| 661 | |
---|
[1137] | 662 | ln -s arch/arch-${arch}.fcm arch.fcm |
---|
[1279] | 663 | if test -f arch/arch-${arch}.opt && [ $compil_mod = "prod" ] |
---|
| 664 | then |
---|
| 665 | ln -s arch/arch-${arch}.opt arch.opt |
---|
| 666 | else |
---|
| 667 | ln -s .void_file arch.opt |
---|
| 668 | fi |
---|
| 669 | |
---|
[1002] | 670 | rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock |
---|
[3406] | 671 | set +e |
---|
[1802] | 672 | ./build_gcm ${fcm_path} -j $job $full |
---|
[3406] | 673 | status=$? |
---|
[783] | 674 | |
---|
[1279] | 675 | rm -rf tmp_src |
---|
| 676 | rm -rf config |
---|
[783] | 677 | ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config |
---|
[2358] | 678 | ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/ppsrc tmp_src |
---|
[1695] | 679 | |
---|
[1869] | 680 | |
---|
[1696] | 681 | if [[ -r $LIBFGCM/grid/dimensions.h ]] |
---|
[1695] | 682 | then |
---|
| 683 | # Cleanup: remove dimension.h file |
---|
[1696] | 684 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
[1695] | 685 | fi |
---|
[3406] | 686 | |
---|
| 687 | if [ $status -ne 0 ]; then |
---|
| 688 | exit $status |
---|
| 689 | fi |
---|