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