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