[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" |
---|
[2202] | 313 | if [[ $paramem == par ]] |
---|
| 314 | then |
---|
| 315 | echo "The version of the dynamics in dyn3dpar is no longer updated." |
---|
| 316 | echo "You should use option \"-mem\"." |
---|
| 317 | exit 1 |
---|
| 318 | fi |
---|
[1463] | 319 | fi |
---|
| 320 | |
---|
| 321 | if [[ "$parallel" == "mpi" ]] |
---|
| 322 | then |
---|
| 323 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
| 324 | # MPI additional compilation options |
---|
| 325 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
| 326 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
| 327 | # MPI additional links |
---|
| 328 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
| 329 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
| 330 | elif [[ "$parallel" == "omp" ]] |
---|
| 331 | then |
---|
| 332 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
| 333 | # OMP additional compilation options |
---|
| 334 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
| 335 | PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} ) |
---|
| 336 | # OMP additional links |
---|
| 337 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
| 338 | PARA_LD=$( echo ${archfileline##%OMP_LD} ) |
---|
| 339 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
| 340 | then |
---|
| 341 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
| 342 | # MPI additional compilation options |
---|
| 343 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
| 344 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
| 345 | # OMP additional compilation options |
---|
| 346 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
| 347 | PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} ) |
---|
| 348 | # MPI additional links |
---|
| 349 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
| 350 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
| 351 | # OMP additional links |
---|
| 352 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
| 353 | PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} ) |
---|
| 354 | fi |
---|
| 355 | |
---|
| 356 | if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \ |
---|
| 357 | && "$compil_mod" == "debug" ]] |
---|
| 358 | then |
---|
| 359 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
| 360 | echo "We suggest switching to \"-dev\"." |
---|
| 361 | fi |
---|
| 362 | |
---|
[1810] | 363 | |
---|
| 364 | #============================================================================== |
---|
| 365 | if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ] |
---|
[1463] | 366 | then |
---|
[1810] | 367 | |
---|
[1463] | 368 | INCLUDE="${INCLUDE} -I${ORCH_INCDIR}" |
---|
[1772] | 369 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
[1810] | 370 | # temporary, for Orchidee versions 1.9.* (before openmp activation) |
---|
| 371 | if [[ "$veget" == "orchidee1.9" ]] ; then |
---|
| 372 | CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP" |
---|
| 373 | fi |
---|
| 374 | if [[ "$veget" == "orchidee2.0" ]] ; then |
---|
[1838] | 375 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
[1810] | 376 | else |
---|
[1811] | 377 | orch_libs="sechiba parameters stomate parallel orglob" |
---|
[1810] | 378 | fi |
---|
| 379 | LIB="${LIB} -L${ORCH_LIBDIR}" |
---|
[1811] | 380 | for lib in ${orch_libs} ; do |
---|
[1810] | 381 | if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then |
---|
| 382 | LIB="${LIB} -l${LIBPREFIX}$lib " |
---|
| 383 | fi |
---|
| 384 | done |
---|
| 385 | elif [[ "$veget" != "false" ]] ; then |
---|
[1772] | 386 | echo "Option -v $veget does not exist" |
---|
| 387 | echo "Use ./makelmdz -h for more information" |
---|
| 388 | exit |
---|
[1463] | 389 | fi |
---|
| 390 | |
---|
[1810] | 391 | #=============================================================================== |
---|
[1463] | 392 | if [[ $io == ioipsl ]] |
---|
| 393 | then |
---|
| 394 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
| 395 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
---|
| 396 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
---|
[2097] | 397 | elif [[ $io == mix ]] |
---|
[1897] | 398 | then |
---|
| 399 | # For now, xios implies also using ioipsl |
---|
| 400 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS" |
---|
| 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" |
---|
[2097] | 403 | elif [[ $io == xios ]] |
---|
| 404 | then |
---|
| 405 | # For now, xios implies also using ioipsl |
---|
| 406 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT" |
---|
| 407 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
| 408 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios" |
---|
[1463] | 409 | fi |
---|
| 410 | |
---|
| 411 | if [[ "$cosp" == "true" ]] |
---|
| 412 | then |
---|
| 413 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
| 414 | COSP_PATH="$LIBFGCM/cosp" |
---|
| 415 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
| 416 | opt_dep="$opt_dep cosp" |
---|
| 417 | lcosp="-l${LIBPREFIX}cosp" |
---|
| 418 | INCLUDE="$INCLUDE"' -I$(LIBF)/cosp' |
---|
| 419 | fi |
---|
| 420 | |
---|
[1865] | 421 | if [[ "$sisvat" == "true" ]] |
---|
| 422 | then |
---|
| 423 | CPP_KEY="$CPP_KEY CPP_SISVAT" |
---|
| 424 | fi |
---|
| 425 | |
---|
[1990] | 426 | if [[ "$rrtm" == "true" ]] |
---|
| 427 | then |
---|
| 428 | CPP_KEY="$CPP_KEY CPP_RRTM" |
---|
| 429 | fi |
---|
[1865] | 430 | |
---|
[1990] | 431 | |
---|
[1551] | 432 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
| 433 | LIB="$LIB ${NETCDF_LIBDIR}" |
---|
[1463] | 434 | |
---|
| 435 | ######################################################################## |
---|
| 436 | # calcul du nombre de dimensions |
---|
| 437 | ######################################################################## |
---|
| 438 | |
---|
| 439 | |
---|
| 440 | dim_full=$dim |
---|
| 441 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
| 442 | set $dim |
---|
| 443 | dimc=$# |
---|
| 444 | echo calcul de la dimension |
---|
| 445 | echo dim $dim |
---|
| 446 | echo dimc $dimc |
---|
| 447 | |
---|
| 448 | ######################################################################## |
---|
| 449 | # Gestion des dimensions du modele. |
---|
| 450 | # on cree ou remplace le fichier des dimensions |
---|
| 451 | ######################################################################## |
---|
| 452 | |
---|
[1695] | 453 | cd $LIBFGCM/grid |
---|
| 454 | if [[ -f dimensions.h ]] |
---|
| 455 | then |
---|
| 456 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
| 457 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
| 458 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
| 459 | echo vous pouvez continuer en repondant oui. |
---|
| 460 | echo "Voulez-vous vraiment continuer?" |
---|
[1755] | 461 | echo "" |
---|
| 462 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
| 463 | echo "Wait until the first compilation is finished before launching this one." |
---|
| 464 | echo "If you are sure that you are not compiling elsewhere, just answer " |
---|
| 465 | echo "yes (or 'oui') to the question below to proceed." |
---|
| 466 | echo "Do you wish to continue?" |
---|
[1695] | 467 | read reponse |
---|
[1755] | 468 | if [[ $reponse == "oui" || $reponse == "yes" ]] |
---|
[1695] | 469 | then |
---|
[1696] | 470 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
[1695] | 471 | else |
---|
| 472 | exit |
---|
| 473 | fi |
---|
| 474 | fi |
---|
| 475 | |
---|
[1463] | 476 | cd $LIBFGCM/grid/dimension |
---|
| 477 | ./makdim $dim |
---|
[2202] | 478 | if (($? != 0)) |
---|
| 479 | then |
---|
| 480 | exit 1 |
---|
| 481 | fi |
---|
| 482 | |
---|
[1463] | 483 | cat $LIBFGCM/grid/dimensions.h |
---|
| 484 | cd $LMDGCM |
---|
| 485 | |
---|
| 486 | ######################################################################## |
---|
| 487 | # Differentes dynamiques (3d, 2d, 1d) |
---|
| 488 | ######################################################################## |
---|
| 489 | |
---|
[1810] | 490 | if (( $dimc == 3 )) ; then |
---|
| 491 | cd $LIBFGCM/grid |
---|
| 492 | \rm fxyprim.h |
---|
| 493 | cp -p fxy_${grille}.h fxyprim.h |
---|
[1463] | 494 | filtre="FILTRE=$filtre" |
---|
[2016] | 495 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common ' |
---|
[1810] | 496 | elif (( $dimc == 2 )) ; then |
---|
| 497 | filtre="FILTRE= L_FILTRE= " |
---|
| 498 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d' |
---|
| 499 | elif (( $dimc == 1 )) ; then |
---|
[2023] | 500 | CPP_KEY="$CPP_KEY CPP_1D" |
---|
[1810] | 501 | filtre="L_DYN= DYN= FILTRE= L_FILTRE= DIRMAIN=phy$physique " |
---|
[2016] | 502 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre |
---|
[1463] | 503 | else |
---|
[1810] | 504 | echo Dimension dimc=$dimc pas prevu ; exit |
---|
[1463] | 505 | fi |
---|
| 506 | |
---|
| 507 | cd $LMDGCM |
---|
| 508 | |
---|
[2112] | 509 | ######################################################################## |
---|
| 510 | # library directory name: |
---|
| 511 | ######################################################################## |
---|
[1463] | 512 | |
---|
[2112] | 513 | 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'` |
---|
| 514 | echo "Path to library: "$nomlib |
---|
| 515 | |
---|
[1463] | 516 | ######################################################################## |
---|
[2112] | 517 | # Cleanup for a full recompilation, if requested |
---|
| 518 | ######################################################################## |
---|
| 519 | |
---|
| 520 | if [[ $full == "full" ]] |
---|
| 521 | then |
---|
| 522 | # remove makefile and librairies |
---|
| 523 | echo "-full option: recompiling from scratch" |
---|
| 524 | \rm -f makefile |
---|
| 525 | \rm -rf "${LIBOGCM}/${nomlib}" |
---|
| 526 | fi |
---|
| 527 | |
---|
| 528 | ######################################################################## |
---|
[1463] | 529 | # Avant de lancer le make, on recree le makefile si necessaire |
---|
| 530 | ######################################################################## |
---|
| 531 | ######################################################################## |
---|
| 532 | # c'est a dire dans 3 cas: |
---|
| 533 | # 1. si la liste des fichiers .F et .h a ete modifiee depuis la |
---|
| 534 | # derniere creation du makefile |
---|
| 535 | # 2. si le fichier contenant cette liste "liste_des_sources" |
---|
| 536 | # n'existe pas. |
---|
| 537 | # 3. Si le makefile n'existe pas. |
---|
| 538 | ######################################################################## |
---|
| 539 | cd $LMDGCM |
---|
[1810] | 540 | |
---|
[1463] | 541 | find libf -name '*.[Fh]' -print > tmp77 |
---|
| 542 | find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print > tmp90 |
---|
[1964] | 543 | find libf -name '*.F90' -print >> tmp90 |
---|
[1463] | 544 | |
---|
| 545 | 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 ]] |
---|
| 546 | then |
---|
| 547 | echo "les fichiers suivants ont ete crees ou detruits" |
---|
| 548 | echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90" |
---|
| 549 | diff liste_des_sources_f77 tmp77 |
---|
| 550 | diff liste_des_sources_f90 tmp90 |
---|
| 551 | \cp -f tmp77 liste_des_sources_f77 |
---|
| 552 | \cp -f tmp90 liste_des_sources_f90 |
---|
| 553 | echo "on recree le makefile" |
---|
| 554 | ./create_make_gcm > tmp |
---|
| 555 | \mv -f tmp makefile |
---|
| 556 | echo "Nouveau makefile cree" |
---|
| 557 | fi |
---|
| 558 | |
---|
| 559 | ################################################################# |
---|
| 560 | # Preparation de l'execution de la comande make |
---|
| 561 | ################################################################# |
---|
| 562 | |
---|
| 563 | source_code=${code}.F |
---|
| 564 | if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]] |
---|
| 565 | then |
---|
| 566 | source_code=${code}.F90 |
---|
[2016] | 567 | elif [[ -r $LMDGCM/libf/phy$physique/${code}.F90 ]] ; then |
---|
| 568 | source_code=${code}.F90 |
---|
[1463] | 569 | fi |
---|
| 570 | |
---|
| 571 | if [[ ! -d "${LIBOGCM}/${nomlib}" ]] |
---|
| 572 | then |
---|
| 573 | mkdir ${LIBOGCM}/${nomlib} |
---|
| 574 | # check we indeed managed to create the directory |
---|
| 575 | if [[ ! $? ]] |
---|
| 576 | then |
---|
| 577 | echo "Error: could not create directory ${LIBOGCM}/${nomlib}" |
---|
| 578 | exit |
---|
| 579 | fi |
---|
| 580 | fi |
---|
| 581 | |
---|
| 582 | # where module files are created |
---|
| 583 | mod_loc_dir=$localdir |
---|
| 584 | |
---|
| 585 | if [[ "$physique" != "nophys" ]] |
---|
| 586 | then |
---|
| 587 | INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique" |
---|
| 588 | fi |
---|
[1810] | 589 | INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib} |
---|
[1463] | 590 | |
---|
| 591 | # ranlib utility (check it exists or else default to ls) |
---|
| 592 | if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]] |
---|
| 593 | then |
---|
| 594 | ranlib="ranlib" |
---|
| 595 | else |
---|
| 596 | ranlib="ls" |
---|
| 597 | fi |
---|
| 598 | |
---|
| 599 | # add CPP keys to COMPIL_FLAGS |
---|
| 600 | # (but first add -D before all CPP_KEY items) |
---|
| 601 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'` |
---|
| 602 | # (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas |
---|
| 603 | if [[ "${fcompiler:0:3}" == "xlf" ]] |
---|
| 604 | then |
---|
| 605 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'` |
---|
| 606 | fi |
---|
| 607 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}" |
---|
| 608 | |
---|
| 609 | ################################################################# |
---|
| 610 | # Execution du make |
---|
| 611 | ################################################################# |
---|
| 612 | echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
| 613 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
| 614 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
| 615 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
| 616 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
| 617 | INCLUDE="$INCLUDE" \ |
---|
| 618 | $filtre \ |
---|
| 619 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
| 620 | "PHYS=$physique" \ |
---|
| 621 | DIM=$dimc \ |
---|
| 622 | FLAG_PARA=$FLAG_PARA \ |
---|
| 623 | L_ADJNT=$adjnt \ |
---|
| 624 | L_COSP="$lcosp" \ |
---|
| 625 | L_CHIMIE="$libchimie" \ |
---|
| 626 | LOCAL_DIR="$localdir" \ |
---|
| 627 | F77="$fcompiler" \ |
---|
| 628 | F90="$fcompiler" \ |
---|
| 629 | OPLINK="$LIB" \ |
---|
| 630 | LINK="$linker" \ |
---|
| 631 | GCM="$LMDGCM" \ |
---|
| 632 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
| 633 | MOD_SUFFIX="mod" \ |
---|
| 634 | AR=$arcommand \ |
---|
| 635 | SOURCE=$source_code \ |
---|
| 636 | PROG=$code |
---|
| 637 | |
---|
| 638 | $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
| 639 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
| 640 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
| 641 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
| 642 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
| 643 | INCLUDE="$INCLUDE" \ |
---|
| 644 | $filtre \ |
---|
| 645 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
| 646 | "PHYS=$physique" \ |
---|
| 647 | DIM=$dimc \ |
---|
| 648 | FLAG_PARA=$FLAG_PARA \ |
---|
[1810] | 649 | L_ADJNT=$adjnt \ |
---|
[1463] | 650 | L_COSP="$lcosp" \ |
---|
| 651 | L_CHIMIE="$libchimie" \ |
---|
| 652 | LOCAL_DIR="$localdir" \ |
---|
| 653 | F77="$fcompiler" \ |
---|
| 654 | F90="$fcompiler" \ |
---|
| 655 | OPLINK="$LIB" \ |
---|
| 656 | LINK="$linker" \ |
---|
| 657 | GCM="$LMDGCM" \ |
---|
| 658 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
| 659 | MOD_SUFFIX="mod" \ |
---|
| 660 | AR=$arcommand \ |
---|
| 661 | SOURCE=$source_code \ |
---|
| 662 | PROG=$code |
---|
| 663 | |
---|
[1810] | 664 | |
---|
[1696] | 665 | if [[ -r $LIBFGCM/grid/dimensions.h ]] |
---|
[1463] | 666 | then |
---|
| 667 | # Cleanup: remove dimension.h file |
---|
[1696] | 668 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
[1463] | 669 | fi |
---|