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