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