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