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