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