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