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