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