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