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