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