[1463] | 1 | #!/bin/bash |
---|
| 2 | # |
---|
[1707] | 3 | # $Id$ |
---|
[1463] | 4 | # |
---|
| 5 | # |
---|
| 6 | ######################################################################## |
---|
| 7 | # for debug, uncomment line below |
---|
| 8 | #set -xv |
---|
| 9 | ######################################################################## |
---|
| 10 | # options par defaut pour la commande make |
---|
| 11 | ######################################################################## |
---|
| 12 | dim="96x72x19" |
---|
| 13 | physique=lmd |
---|
| 14 | code=gcm |
---|
| 15 | filtre=filtrez |
---|
| 16 | grille=reg |
---|
| 17 | couple=false |
---|
| 18 | veget=false |
---|
| 19 | chimie=false |
---|
| 20 | parallel=none |
---|
[1707] | 21 | paramem="par" |
---|
[1463] | 22 | compil_mod=prod |
---|
| 23 | io=ioipsl |
---|
| 24 | LIBPREFIX="" |
---|
| 25 | fcm_path=none |
---|
| 26 | cosp=false |
---|
[1910] | 27 | sisvat=false |
---|
[1999] | 28 | rrtm=false |
---|
[1463] | 29 | |
---|
| 30 | # guess a default 'arch' |
---|
[1707] | 31 | arch="local" # start with assuming we're on a local machine with local arch file |
---|
[1463] | 32 | ## try to recognise machine and infer arch from it |
---|
| 33 | machine=`hostname` |
---|
| 34 | if [[ "$machine" == "brodie" ]] |
---|
| 35 | then |
---|
| 36 | arch="SX8_BRODIE" |
---|
| 37 | fi |
---|
[1910] | 38 | if [[ "${machine:0:3}" == "ada" ]] |
---|
[1463] | 39 | then |
---|
[1910] | 40 | arch="X64_ADA" |
---|
[1463] | 41 | fi |
---|
| 42 | if [[ "${machine:0:6}" == "ciclad" ]] |
---|
| 43 | then |
---|
| 44 | arch="AMD64_CICLAD" |
---|
| 45 | fi |
---|
| 46 | if [[ "${machine:0:7}" == "platine" ]] |
---|
| 47 | then |
---|
| 48 | arch="IA64_PLATINE" |
---|
| 49 | fi |
---|
| 50 | if [[ "${machine:0:6}" == "titane" ]] |
---|
| 51 | then |
---|
| 52 | arch="X64_TITANE" |
---|
| 53 | fi |
---|
| 54 | if [[ "${machine:0:8}" == "mercure1" ]] |
---|
| 55 | then |
---|
| 56 | arch="SX8_MERCURE" |
---|
| 57 | fi |
---|
| 58 | if [[ "${machine:0:8}" == "mercure2" ]] |
---|
| 59 | then |
---|
| 60 | arch="SX9_MERCURE" |
---|
| 61 | fi |
---|
| 62 | |
---|
| 63 | LMDGCM=`pwd -P` |
---|
| 64 | LIBFGCM=$LMDGCM/libf |
---|
| 65 | LIBOGCM=$LMDGCM/libo |
---|
| 66 | if [[ ! -d $LIBOGCM ]] |
---|
| 67 | then |
---|
| 68 | # create the directory |
---|
| 69 | mkdir $LIBOGCM |
---|
| 70 | if [[ ! $? ]] |
---|
| 71 | then |
---|
| 72 | echo "Failed to create directory $LIBOGCM" |
---|
| 73 | exit |
---|
| 74 | fi |
---|
| 75 | fi |
---|
| 76 | COSP_PATH=$LMDGCM/.void_dir |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | localdir=`pwd -P` |
---|
| 81 | ######################################################################## |
---|
| 82 | # Quelques initialisations de variables du shell. |
---|
| 83 | ######################################################################## |
---|
| 84 | |
---|
| 85 | CPP_KEY="" |
---|
[1999] | 86 | INCLUDE='-I$(LIBF)/grid -I$(LIBF)/bibio -I$(LIBF)/dyn3d_common -I$(LIBF)/filtrez -I. ' |
---|
[1463] | 87 | LIB="" |
---|
| 88 | adjnt="" |
---|
| 89 | ##COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
| 90 | PARA_FFLAGS="" |
---|
| 91 | PARA_LD="" |
---|
| 92 | EXT_SRC="" |
---|
| 93 | |
---|
| 94 | ######################################################################## |
---|
| 95 | # lecture des options |
---|
| 96 | ######################################################################## |
---|
| 97 | |
---|
| 98 | while (($# > 0)) |
---|
| 99 | do |
---|
| 100 | case $1 in |
---|
| 101 | "-h") cat <<fin |
---|
| 102 | Usage : |
---|
[1795] | 103 | makelmdz [options] -arch nom_arch exec |
---|
| 104 | [-h] : brief help |
---|
| 105 | [-d [[IMx]JMx]LM] : IM, JM, LM are the dimensions in x, y, z (default: $dim) |
---|
| 106 | [-p PHYS] : set of physical parametrizations (in libf/phyPHYS), (default: lmd) |
---|
| 107 | [-prod / -dev / -debug] : compilation mode production (default) / developement / debug |
---|
| 108 | [-c false/MPI1/MPI2] : coupling with ocean model : MPI1/MPI2/false (default: false) |
---|
| 109 | [-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false) |
---|
| 110 | false : no vegetation model |
---|
| 111 | orchidee2.0 : compile using ORCHIDEE 2.0 (or more recent version) |
---|
| 112 | orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6 |
---|
| 113 | true : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6 |
---|
| 114 | [-chimie INCA/false] : with INCA chemistry model or without (default: false) |
---|
| 115 | [-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp |
---|
| 116 | [-g GRI] : grid configuration in dyn3d/GRI_xy.h (default: reg, inclues a zoom) |
---|
| 117 | [-io IO] : Input/Output library (default: ioipsl) |
---|
| 118 | [-include INCLUDES] : extra include path to add |
---|
| 119 | [-cpp CPP_KEY] : additional preprocessing definitions |
---|
| 120 | [-adjnt] : adjoint model, not operational ... |
---|
| 121 | [-mem] : reduced memory dynamics (if in parallel mode) |
---|
| 122 | [-filtre NOMFILTRE] : use filtre from libf/NOMFILTRE (default: filtrez) |
---|
| 123 | [-link LINKS] : additional links with other libraries |
---|
| 124 | [-fcm_path path] : path to the fcm tool (default: tools/fcm/bin) |
---|
| 125 | [-ext_src path] : path to an additional set of routines to compile with the model |
---|
| 126 | -arch nom_arch : target architecture |
---|
| 127 | exec : executable to build |
---|
[1463] | 128 | fin |
---|
| 129 | exit;; |
---|
| 130 | "-d") |
---|
| 131 | dim=$2 ; shift ; shift ;; |
---|
| 132 | |
---|
| 133 | "-p") |
---|
| 134 | physique="$2" ; shift ; shift ;; |
---|
| 135 | |
---|
| 136 | "-g") |
---|
| 137 | grille="$2" ; shift ; shift ;; |
---|
| 138 | |
---|
| 139 | "-c") |
---|
| 140 | couple="$2" ; shift ; shift ;; |
---|
| 141 | |
---|
| 142 | "-prod") |
---|
| 143 | compil_mod="prod" ; shift ;; |
---|
| 144 | |
---|
| 145 | "-dev") |
---|
| 146 | compil_mod="dev" ; shift ;; |
---|
| 147 | |
---|
| 148 | "-debug") |
---|
| 149 | compil_mod="debug" ; shift ;; |
---|
| 150 | |
---|
| 151 | "-io") |
---|
| 152 | io="$2" ; shift ; shift ;; |
---|
| 153 | |
---|
| 154 | "-v") |
---|
| 155 | veget="$2" ; shift ; shift ;; |
---|
| 156 | |
---|
| 157 | "-chimie") |
---|
| 158 | chimie="$2" ; shift ; shift ;; |
---|
| 159 | |
---|
| 160 | "-parallel") |
---|
| 161 | parallel="$2" ; shift ; shift ;; |
---|
| 162 | |
---|
| 163 | "-include") |
---|
| 164 | INCLUDE="$INCLUDE -I$2" ; shift ; shift ;; |
---|
| 165 | |
---|
| 166 | "-cpp") |
---|
| 167 | CPP_KEY="$CPP_KEY $2" ; shift ; shift ;; |
---|
| 168 | |
---|
| 169 | "-adjnt") |
---|
[1795] | 170 | echo "not operational ... work to be done here ";exit |
---|
[1463] | 171 | opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d " |
---|
| 172 | optim="$optim -Dadj" ; shift ;; |
---|
| 173 | |
---|
| 174 | "-cosp") |
---|
| 175 | cosp="$2" ; shift ; shift ;; |
---|
[1707] | 176 | |
---|
[1910] | 177 | "-sisvat") |
---|
| 178 | sisvat="$2" ; shift ; shift ;; |
---|
| 179 | |
---|
[1999] | 180 | "-rrtm") |
---|
| 181 | rrtm="$2" ; shift ; shift ;; |
---|
| 182 | |
---|
[1707] | 183 | "-mem") |
---|
| 184 | paramem="mem" ; shift ;; |
---|
[1463] | 185 | |
---|
| 186 | "-filtre") |
---|
| 187 | filtre=$2 ; shift ; shift ;; |
---|
| 188 | |
---|
| 189 | "-link") |
---|
| 190 | LIB="$LIB $2" ; shift ; shift ;; |
---|
| 191 | |
---|
| 192 | "-fcm_path") |
---|
| 193 | fcm_path=$2 ; shift ; shift ;; |
---|
| 194 | |
---|
| 195 | "-ext_src") |
---|
| 196 | EXT_SRC=$2 ; shift ; shift ;; |
---|
| 197 | |
---|
| 198 | "-arch") |
---|
| 199 | arch=$2 ; shift ; shift ;; |
---|
| 200 | |
---|
| 201 | *) |
---|
| 202 | code="$1" ; shift ;; |
---|
| 203 | esac |
---|
| 204 | done |
---|
| 205 | |
---|
| 206 | ############################################################### |
---|
| 207 | # lecture des chemins propres à l'architecture de la machine # |
---|
| 208 | ############################################################### |
---|
| 209 | rm -f .void_file |
---|
| 210 | echo > .void_file |
---|
| 211 | rm -rf .void_dir |
---|
| 212 | mkdir .void_dir |
---|
| 213 | rm -f arch.path |
---|
| 214 | if [[ -r arch/arch-${arch}.path ]] |
---|
| 215 | then |
---|
| 216 | ln -s arch/arch-${arch}.path ./arch.path |
---|
| 217 | source arch.path |
---|
| 218 | else |
---|
| 219 | echo "Error: missing arch/arch-${arch}.path file !" |
---|
| 220 | exit |
---|
| 221 | fi |
---|
| 222 | rm -f arch.fcm |
---|
| 223 | if [[ -r arch/arch-${arch}.fcm ]] |
---|
| 224 | then |
---|
| 225 | ln -s arch/arch-${arch}.fcm arch.fcm |
---|
| 226 | else |
---|
| 227 | echo "Error: missing arch/arch-${arch}.fcm file !" |
---|
| 228 | exit |
---|
| 229 | fi |
---|
| 230 | ######################################################################## |
---|
| 231 | # Definition des clefs CPP, des chemins des includes et modules |
---|
| 232 | # et des libraries |
---|
| 233 | ######################################################################## |
---|
| 234 | |
---|
| 235 | # basic compile flags from arch.fcm file |
---|
| 236 | archfileline=$( grep -i '^%BASE_FFLAGS' arch.fcm ) |
---|
| 237 | COMPIL_FFLAGS=$( echo ${archfileline##%BASE_FFLAGS} ) |
---|
| 238 | |
---|
| 239 | # other compile flags, depending on compilation mode |
---|
| 240 | if [[ "$compil_mod" == "prod" ]] |
---|
| 241 | then |
---|
| 242 | ## read COMPIL_FFLAGS from arch.fcm file |
---|
| 243 | archfileline=$( grep -i '^%PROD_FFLAGS' arch.fcm ) |
---|
| 244 | archfileopt=$( echo ${archfileline##%PROD_FFLAGS} ) |
---|
| 245 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}" |
---|
| 246 | elif [[ "$compil_mod" == "dev" ]] |
---|
| 247 | then |
---|
| 248 | ## read %DEV_FFLAGS from arch.fcm file |
---|
| 249 | archfileline=$( grep -i '^%DEV_FFLAGS' arch.fcm ) |
---|
| 250 | archfileopt=$( echo ${archfileline##%DEV_FFLAGS} ) |
---|
| 251 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}" |
---|
| 252 | elif [[ "$compil_mod" == "debug" ]] |
---|
| 253 | then |
---|
| 254 | ## read %DEBUG_FFLAGS from arch.fcm file |
---|
| 255 | archfileline=$( grep -i '^%DEBUG_FFLAGS' arch.fcm ) |
---|
| 256 | archfileopt=$( echo ${archfileline##%DEBUG_FFLAGS} ) |
---|
| 257 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}" |
---|
| 258 | fi |
---|
| 259 | |
---|
| 260 | # add CPP_KEY defined in arch.fcm file |
---|
| 261 | archfileline=$( grep -i '^%FPP_DEF' arch.fcm ) |
---|
| 262 | archfileopt=$( echo ${archfileline##%FPP_DEF} ) |
---|
| 263 | CPP_KEY="$CPP_KEY ${archfileopt}" |
---|
| 264 | |
---|
| 265 | # get compiler name from arch.fcm file |
---|
| 266 | archfileline=$( grep -i '^%COMPILER' arch.fcm ) |
---|
| 267 | fcompiler=$( echo ${archfileline##%COMPILER} ) |
---|
| 268 | |
---|
| 269 | # get linker name from arch.fcm file |
---|
| 270 | archfileline=$( grep -i '^%LINK' arch.fcm ) |
---|
| 271 | linker=$( echo ${archfileline##%LINK} ) |
---|
| 272 | |
---|
| 273 | # get ar command from arch.fcm file |
---|
| 274 | archfileline=$( grep -i '^%AR' arch.fcm ) |
---|
| 275 | arcommand=$( echo ${archfileline##%AR} ) |
---|
| 276 | |
---|
| 277 | # get make utility from arch.fcm file |
---|
| 278 | archfileline=$( grep -i '^%MAKE' arch.fcm ) |
---|
| 279 | makecommand=$( echo ${archfileline##%MAKE} ) |
---|
| 280 | |
---|
| 281 | # get basic libraries to link with arch.fcm file |
---|
| 282 | archfileline=$( grep -i '^%BASE_LD' arch.fcm ) |
---|
| 283 | archfileopt=$( echo ${archfileline##%BASE_LD} ) |
---|
| 284 | LIB="$LIB ${archfileopt}" |
---|
| 285 | |
---|
[1910] | 286 | # add Include files defined in arch.fcm file for pre-processing |
---|
| 287 | archfileline=$( grep -i '^%FPP_FLAGS' arch.fcm ) |
---|
| 288 | for inc in $archfileline ; do INCLUDE="$INCLUDE `echo $inc | grep '\-I'`" ; done |
---|
| 289 | |
---|
[1463] | 290 | if [[ "$physique" != "nophys" ]] |
---|
| 291 | then |
---|
[1707] | 292 | #We'll use some physics |
---|
| 293 | CPP_KEY="$CPP_KEY CPP_PHYS" |
---|
| 294 | if [[ "${physique:0:3}" == "lmd" ]] |
---|
| 295 | then |
---|
| 296 | #For lmd physics, default planet type is Earth |
---|
[1463] | 297 | CPP_KEY="$CPP_KEY CPP_EARTH" |
---|
[1707] | 298 | fi |
---|
[1463] | 299 | fi |
---|
| 300 | |
---|
| 301 | if [[ "$chimie" == "INCA" ]] |
---|
| 302 | then |
---|
| 303 | CPP_KEY="$CPP_KEY INCA" |
---|
| 304 | INCLUDE="$INCLUDE -I${INCA_INCDIR}" |
---|
| 305 | LIB="$LIB -L${INCA_LIBDIR} -lchimie" |
---|
| 306 | libchimie=" -L${INCA_LIBDIR} -lchimie" |
---|
| 307 | fi |
---|
| 308 | |
---|
| 309 | if [[ "$couple" != "false" ]] |
---|
| 310 | then |
---|
| 311 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
| 312 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
| 313 | LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io" |
---|
| 314 | fi |
---|
| 315 | |
---|
| 316 | if [[ "$parallel" == "none" ]] |
---|
| 317 | then |
---|
| 318 | FLAG_PARA='' |
---|
| 319 | else |
---|
[1864] | 320 | FLAG_PARA="$paramem" |
---|
[1463] | 321 | fi |
---|
| 322 | |
---|
| 323 | if [[ "$parallel" == "mpi" ]] |
---|
| 324 | then |
---|
| 325 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
| 326 | # MPI additional compilation options |
---|
| 327 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
| 328 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
| 329 | # MPI additional links |
---|
| 330 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
| 331 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
| 332 | elif [[ "$parallel" == "omp" ]] |
---|
| 333 | then |
---|
| 334 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
| 335 | # OMP additional compilation options |
---|
| 336 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
| 337 | PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} ) |
---|
| 338 | # OMP additional links |
---|
| 339 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
| 340 | PARA_LD=$( echo ${archfileline##%OMP_LD} ) |
---|
| 341 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
| 342 | then |
---|
| 343 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
| 344 | # MPI additional compilation options |
---|
| 345 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
| 346 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
| 347 | # OMP additional compilation options |
---|
| 348 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
| 349 | PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} ) |
---|
| 350 | # MPI additional links |
---|
| 351 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
| 352 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
| 353 | # OMP additional links |
---|
| 354 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
| 355 | PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} ) |
---|
| 356 | fi |
---|
| 357 | |
---|
| 358 | if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \ |
---|
| 359 | && "$compil_mod" == "debug" ]] |
---|
| 360 | then |
---|
| 361 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
| 362 | echo "We suggest switching to \"-dev\"." |
---|
| 363 | fi |
---|
| 364 | |
---|
[1864] | 365 | |
---|
| 366 | #============================================================================== |
---|
| 367 | if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ] |
---|
[1463] | 368 | then |
---|
[1864] | 369 | |
---|
[1463] | 370 | INCLUDE="${INCLUDE} -I${ORCH_INCDIR}" |
---|
[1795] | 371 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
[1864] | 372 | # temporary, for Orchidee versions 1.9.* (before openmp activation) |
---|
| 373 | if [[ "$veget" == "orchidee1.9" ]] ; then |
---|
| 374 | CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP" |
---|
| 375 | fi |
---|
| 376 | if [[ "$veget" == "orchidee2.0" ]] ; then |
---|
| 377 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
| 378 | else |
---|
| 379 | orch_libs="sechiba parameters stomate parallel orglob" |
---|
| 380 | fi |
---|
| 381 | LIB="${LIB} -L${ORCH_LIBDIR}" |
---|
| 382 | for lib in ${orch_libs} ; do |
---|
| 383 | if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then |
---|
| 384 | LIB="${LIB} -l${LIBPREFIX}$lib " |
---|
| 385 | fi |
---|
| 386 | done |
---|
| 387 | elif [[ "$veget" != "false" ]] ; then |
---|
[1795] | 388 | echo "Option -v $veget does not exist" |
---|
| 389 | echo "Use ./makelmdz -h for more information" |
---|
| 390 | exit |
---|
[1463] | 391 | fi |
---|
| 392 | |
---|
[1864] | 393 | #=============================================================================== |
---|
[1463] | 394 | if [[ $io == ioipsl ]] |
---|
| 395 | then |
---|
| 396 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
| 397 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
---|
| 398 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
---|
[1910] | 399 | elif [[ $io == xios ]] |
---|
| 400 | then |
---|
| 401 | # For now, xios implies also using ioipsl |
---|
| 402 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS" |
---|
| 403 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
| 404 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios" |
---|
[1463] | 405 | fi |
---|
| 406 | |
---|
| 407 | if [[ "$cosp" == "true" ]] |
---|
| 408 | then |
---|
| 409 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
| 410 | COSP_PATH="$LIBFGCM/cosp" |
---|
| 411 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
| 412 | opt_dep="$opt_dep cosp" |
---|
| 413 | lcosp="-l${LIBPREFIX}cosp" |
---|
| 414 | INCLUDE="$INCLUDE"' -I$(LIBF)/cosp' |
---|
| 415 | fi |
---|
| 416 | |
---|
[1910] | 417 | if [[ "$sisvat" == "true" ]] |
---|
| 418 | then |
---|
| 419 | CPP_KEY="$CPP_KEY CPP_SISVAT" |
---|
| 420 | fi |
---|
| 421 | |
---|
[1999] | 422 | if [[ "$rrtm" == "true" ]] |
---|
| 423 | then |
---|
| 424 | CPP_KEY="$CPP_KEY CPP_RRTM" |
---|
| 425 | fi |
---|
[1910] | 426 | |
---|
[1999] | 427 | |
---|
[1551] | 428 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
| 429 | LIB="$LIB ${NETCDF_LIBDIR}" |
---|
[1463] | 430 | |
---|
| 431 | ######################################################################## |
---|
| 432 | # calcul du nombre de dimensions |
---|
| 433 | ######################################################################## |
---|
| 434 | |
---|
| 435 | |
---|
| 436 | dim_full=$dim |
---|
| 437 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
| 438 | set $dim |
---|
| 439 | dimc=$# |
---|
| 440 | echo calcul de la dimension |
---|
| 441 | echo dim $dim |
---|
| 442 | echo dimc $dimc |
---|
| 443 | |
---|
| 444 | |
---|
| 445 | ######################################################################## |
---|
| 446 | # Gestion des dimensions du modele. |
---|
| 447 | # on cree ou remplace le fichier des dimensions |
---|
| 448 | ######################################################################## |
---|
| 449 | |
---|
[1707] | 450 | cd $LIBFGCM/grid |
---|
| 451 | if [[ -f dimensions.h ]] |
---|
| 452 | then |
---|
| 453 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
| 454 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
| 455 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
| 456 | echo vous pouvez continuer en repondant oui. |
---|
| 457 | echo "Voulez-vous vraiment continuer?" |
---|
[1752] | 458 | echo "" |
---|
| 459 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
| 460 | echo "Wait until the first compilation is finished before launching this one." |
---|
| 461 | echo "If you are sure that you are not compiling elsewhere, just answer " |
---|
| 462 | echo "yes (or 'oui') to the question below to proceed." |
---|
| 463 | echo "Do you wish to continue?" |
---|
[1707] | 464 | read reponse |
---|
[1752] | 465 | if [[ $reponse == "oui" || $reponse == "yes" ]] |
---|
[1707] | 466 | then |
---|
| 467 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
| 468 | else |
---|
| 469 | exit |
---|
| 470 | fi |
---|
| 471 | fi |
---|
| 472 | |
---|
| 473 | |
---|
[1463] | 474 | cd $LIBFGCM/grid/dimension |
---|
| 475 | ./makdim $dim |
---|
| 476 | cat $LIBFGCM/grid/dimensions.h |
---|
| 477 | cd $LMDGCM |
---|
| 478 | |
---|
| 479 | |
---|
| 480 | ######################################################################## |
---|
| 481 | # Differentes dynamiques (3d, 2d, 1d) |
---|
| 482 | ######################################################################## |
---|
| 483 | |
---|
[1864] | 484 | if (( $dimc == 3 )) ; then |
---|
| 485 | cd $LIBFGCM/grid |
---|
| 486 | \rm fxyprim.h |
---|
| 487 | cp -p fxy_${grille}.h fxyprim.h |
---|
[1463] | 488 | filtre="FILTRE=$filtre" |
---|
[1864] | 489 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} ' |
---|
| 490 | elif (( $dimc == 2 )) ; then |
---|
| 491 | filtre="FILTRE= L_FILTRE= " |
---|
| 492 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d' |
---|
| 493 | elif (( $dimc == 1 )) ; then |
---|
| 494 | filtre="L_DYN= DYN= FILTRE= L_FILTRE= DIRMAIN=phy$physique " |
---|
| 495 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d' # Pas tres propre |
---|
[1463] | 496 | else |
---|
[1864] | 497 | echo Dimension dimc=$dimc pas prevu ; exit |
---|
[1463] | 498 | fi |
---|
| 499 | |
---|
| 500 | ###################################################################### |
---|
| 501 | # Creation du suffixe de la configuration |
---|
| 502 | ###################################################################### |
---|
| 503 | |
---|
| 504 | SUFF_NAME=_${dim_full} |
---|
| 505 | SUFF_NAME=${SUFF_NAME}_phy${physique} |
---|
| 506 | |
---|
| 507 | if [[ "$parallel" != "none" ]] |
---|
| 508 | then |
---|
| 509 | SUFF_NAME=${SUFF_NAME}_para |
---|
[1707] | 510 | DYN=dyn${dimc}d${paramem} |
---|
| 511 | if [[ "$paramem" == "mem" ]] |
---|
| 512 | then |
---|
| 513 | SUFF_NAME=${SUFF_NAME}_${paramem} |
---|
| 514 | fi |
---|
[1463] | 515 | else |
---|
| 516 | SUFF_NAME=${SUFF_NAME}_seq |
---|
| 517 | DYN=dyn${dimc}d |
---|
| 518 | fi |
---|
| 519 | |
---|
[1795] | 520 | if [[ $veget != "false" ]] |
---|
[1463] | 521 | then |
---|
| 522 | SUFF_NAME=${SUFF_NAME}_orch |
---|
| 523 | fi |
---|
| 524 | |
---|
| 525 | if [[ $couple != "false" ]] |
---|
| 526 | then |
---|
| 527 | SUFF_NAME=${SUFF_NAME}_couple |
---|
| 528 | fi |
---|
| 529 | |
---|
| 530 | if [[ $chimie == "INCA" ]] |
---|
| 531 | then |
---|
| 532 | SUFF_NAME=${SUFF_NAME}_inca |
---|
| 533 | fi |
---|
| 534 | |
---|
| 535 | cd $LMDGCM |
---|
| 536 | |
---|
| 537 | |
---|
| 538 | ######################################################################## |
---|
| 539 | # Avant de lancer le make, on recree le makefile si necessaire |
---|
| 540 | ######################################################################## |
---|
| 541 | ######################################################################## |
---|
| 542 | # c'est a dire dans 3 cas: |
---|
| 543 | # 1. si la liste des fichiers .F et .h a ete modifiee depuis la |
---|
| 544 | # derniere creation du makefile |
---|
| 545 | # 2. si le fichier contenant cette liste "liste_des_sources" |
---|
| 546 | # n'existe pas. |
---|
| 547 | # 3. Si le makefile n'existe pas. |
---|
| 548 | ######################################################################## |
---|
| 549 | cd $LMDGCM |
---|
[1864] | 550 | |
---|
[1463] | 551 | find libf -name '*.[Fh]' -print > tmp77 |
---|
| 552 | find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print > tmp90 |
---|
[1999] | 553 | find libf -name '*.F90' -print >> tmp90 |
---|
[1463] | 554 | |
---|
| 555 | if [[ ! ( -r makefile ) || ! ( -r liste_des_sources_f90 ) || ! ( -r liste_des_sources_f77 ) || ` diff tmp77 liste_des_sources_f77 | wc -w ` -ne 0 || ` diff tmp90 liste_des_sources_f90 | wc -w ` -ne 0 ]] |
---|
| 556 | then |
---|
| 557 | echo "les fichiers suivants ont ete crees ou detruits" |
---|
| 558 | echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90" |
---|
| 559 | diff liste_des_sources_f77 tmp77 |
---|
| 560 | diff liste_des_sources_f90 tmp90 |
---|
| 561 | \cp -f tmp77 liste_des_sources_f77 |
---|
| 562 | \cp -f tmp90 liste_des_sources_f90 |
---|
| 563 | echo "on recree le makefile" |
---|
| 564 | ./create_make_gcm > tmp |
---|
| 565 | \mv -f tmp makefile |
---|
| 566 | echo "Nouveau makefile cree" |
---|
| 567 | fi |
---|
| 568 | |
---|
| 569 | ################################################################# |
---|
| 570 | # Preparation de l'execution de la comande make |
---|
| 571 | ################################################################# |
---|
| 572 | |
---|
| 573 | source_code=${code}.F |
---|
| 574 | if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]] |
---|
| 575 | then |
---|
| 576 | source_code=${code}.F90 |
---|
| 577 | fi |
---|
| 578 | |
---|
| 579 | # library directory name: |
---|
[1864] | 580 | nomlib=`echo ${arch}_${physique}_${dim_full}_${grille}_${compil_mod}_parall${parallel}_${CPP_KEY}_${FLAG_PARA} | sed -e 's/ //g' -e 's/-//g ' | sed -e 's/CPP_//g'` |
---|
| 581 | echo $nomlib |
---|
[1463] | 582 | |
---|
| 583 | if [[ ! -d "${LIBOGCM}/${nomlib}" ]] |
---|
| 584 | then |
---|
| 585 | mkdir ${LIBOGCM}/${nomlib} |
---|
| 586 | # check we indeed managed to create the directory |
---|
| 587 | if [[ ! $? ]] |
---|
| 588 | then |
---|
| 589 | echo "Error: could not create directory ${LIBOGCM}/${nomlib}" |
---|
| 590 | exit |
---|
| 591 | fi |
---|
| 592 | fi |
---|
| 593 | |
---|
| 594 | # where module files are created |
---|
| 595 | mod_loc_dir=$localdir |
---|
| 596 | |
---|
| 597 | if [[ "$physique" != "nophys" ]] |
---|
| 598 | then |
---|
| 599 | INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique" |
---|
| 600 | fi |
---|
[1864] | 601 | INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib} |
---|
[1463] | 602 | |
---|
| 603 | # ranlib utility (check it exists or else default to ls) |
---|
| 604 | if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]] |
---|
| 605 | then |
---|
| 606 | ranlib="ranlib" |
---|
| 607 | else |
---|
| 608 | ranlib="ls" |
---|
| 609 | fi |
---|
| 610 | |
---|
| 611 | # add CPP keys to COMPIL_FLAGS |
---|
| 612 | # (but first add -D before all CPP_KEY items) |
---|
| 613 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'` |
---|
| 614 | # (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas |
---|
| 615 | if [[ "${fcompiler:0:3}" == "xlf" ]] |
---|
| 616 | then |
---|
| 617 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'` |
---|
| 618 | fi |
---|
| 619 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}" |
---|
| 620 | |
---|
| 621 | ################################################################# |
---|
| 622 | # Execution du make |
---|
| 623 | ################################################################# |
---|
| 624 | echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
| 625 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
| 626 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
| 627 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
| 628 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
| 629 | INCLUDE="$INCLUDE" \ |
---|
| 630 | $filtre \ |
---|
| 631 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
| 632 | "PHYS=$physique" \ |
---|
| 633 | DIM=$dimc \ |
---|
| 634 | FLAG_PARA=$FLAG_PARA \ |
---|
| 635 | L_ADJNT=$adjnt \ |
---|
| 636 | L_COSP="$lcosp" \ |
---|
| 637 | L_CHIMIE="$libchimie" \ |
---|
| 638 | LOCAL_DIR="$localdir" \ |
---|
| 639 | F77="$fcompiler" \ |
---|
| 640 | F90="$fcompiler" \ |
---|
| 641 | OPLINK="$LIB" \ |
---|
| 642 | LINK="$linker" \ |
---|
| 643 | GCM="$LMDGCM" \ |
---|
| 644 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
| 645 | MOD_SUFFIX="mod" \ |
---|
| 646 | AR=$arcommand \ |
---|
| 647 | SOURCE=$source_code \ |
---|
| 648 | PROG=$code |
---|
| 649 | |
---|
| 650 | $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
| 651 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
| 652 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
| 653 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
| 654 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
| 655 | INCLUDE="$INCLUDE" \ |
---|
| 656 | $filtre \ |
---|
| 657 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
| 658 | "PHYS=$physique" \ |
---|
| 659 | DIM=$dimc \ |
---|
| 660 | FLAG_PARA=$FLAG_PARA \ |
---|
[1864] | 661 | L_ADJNT=$adjnt \ |
---|
[1463] | 662 | L_COSP="$lcosp" \ |
---|
| 663 | L_CHIMIE="$libchimie" \ |
---|
| 664 | LOCAL_DIR="$localdir" \ |
---|
| 665 | F77="$fcompiler" \ |
---|
| 666 | F90="$fcompiler" \ |
---|
| 667 | OPLINK="$LIB" \ |
---|
| 668 | LINK="$linker" \ |
---|
| 669 | GCM="$LMDGCM" \ |
---|
| 670 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
| 671 | MOD_SUFFIX="mod" \ |
---|
| 672 | AR=$arcommand \ |
---|
| 673 | SOURCE=$source_code \ |
---|
| 674 | PROG=$code |
---|
| 675 | |
---|
[1864] | 676 | |
---|
[1707] | 677 | if [[ -r $LIBFGCM/grid/dimensions.h ]] |
---|
[1463] | 678 | then |
---|
| 679 | # Cleanup: remove dimension.h file |
---|
[1707] | 680 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
[1463] | 681 | fi |
---|