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