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