[1588] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | ########################################################################### |
---|
[3044] | 4 | # Author : Laurent Fairhead et Frédéric Hourdin |
---|
| 5 | # Usage : install_lmdz.sh -help |
---|
[1588] | 6 | # |
---|
[1708] | 7 | # bash installation script of the LMDZ model on a Linux PC. |
---|
| 8 | # the model is downloaded in the following direcory tree |
---|
[1588] | 9 | # $MODEL/modipsl/modeles/... |
---|
[1708] | 10 | # using the "modipsl" infrastructure created by the "IPSL" |
---|
| 11 | # for coupled (atmosphere/ocean/vegetation/chemistry) climate modeling |
---|
| 12 | # activities. |
---|
| 13 | # Here we only download atmospheric (LMDZ) and vegetation (ORCHIDEE) |
---|
| 14 | # components. |
---|
[1588] | 15 | # |
---|
[1708] | 16 | # The sources of the models can be found in the "modeles" directory. |
---|
| 17 | # In the present case, LMDZ5, ORCHIDEE and IOIPSL (handling of input-outputs |
---|
| 18 | # using the NetCDF library. |
---|
[1588] | 19 | # |
---|
[1708] | 20 | # The script downloads various source files (including a version of NetCDF) |
---|
| 21 | # and utilities, compiles the model, and runs a test simulation in a |
---|
| 22 | # munimal configuration. |
---|
[1588] | 23 | # |
---|
[3044] | 24 | # Prerequisites : pgf90/gfortran, ksh, wget , gunzip, tar, ... |
---|
[1588] | 25 | # |
---|
[1589] | 26 | # Modif 18/11/2011 |
---|
[1708] | 27 | # changes for option real 8. |
---|
| 28 | # We comopile with -r8 (or equivalent) and -DNC_DOUBLE for the GCM |
---|
| 29 | # but with -r4 for netcdf. Variable real must be set to |
---|
| 30 | # r4 or r8 at the beginning of the script below. |
---|
[1589] | 31 | # |
---|
[1588] | 32 | ########################################################################### |
---|
| 33 | |
---|
[2030] | 34 | echo install.sh DEBUT `date` |
---|
[2031] | 35 | |
---|
[1911] | 36 | set -e |
---|
| 37 | |
---|
[3044] | 38 | ################################################################ |
---|
| 39 | # Choice of installation options |
---|
| 40 | ################################################################ |
---|
[1588] | 41 | |
---|
[3044] | 42 | # A function to fetch files either locally or on the internet |
---|
| 43 | function myget { #1st and only argument should be file name |
---|
| 44 | # Path on local computer where to look for the datafile |
---|
[3076] | 45 | if [ -f /u/lmdz/WWW/LMDZ/pub/$1 ] ; then |
---|
| 46 | \cp -f -p /u/lmdz/WWW/LMDZ/pub/$1 . |
---|
| 47 | elif [ -f ~/LMDZ/pub/$1 ] ; then |
---|
| 48 | \cp -f -p ~/LMDZ/pub/$1 . |
---|
[3044] | 49 | else |
---|
[3076] | 50 | wget http://www.lmd.jussieu.fr/~lmdz/pub/$1 |
---|
| 51 | #dir=~/LMDZ/pub/`dirname $1` ; mkdir -p $dir ; cp -r `basename $1` $dir |
---|
[3044] | 52 | fi |
---|
| 53 | } |
---|
[1588] | 54 | |
---|
[3044] | 55 | |
---|
[1590] | 56 | #real=r4 |
---|
[1589] | 57 | real=r8 |
---|
| 58 | |
---|
[1708] | 59 | # WARNING !!!! For versions before october 2009, use |
---|
| 60 | # install.v2.sh instead of install.sh |
---|
[1588] | 61 | |
---|
[3044] | 62 | ######################################################################### |
---|
| 63 | # Valeur par défaut des parametres |
---|
| 64 | ######################################################################### |
---|
| 65 | svn="" |
---|
[3076] | 66 | version=trunk |
---|
[1588] | 67 | getlmdzor=1 |
---|
| 68 | netcdf=1 # 1 for automatic installation |
---|
| 69 | # 0 for no installation |
---|
| 70 | # /.../../netcdf-4.0.1 if wanting to link with an already |
---|
| 71 | # compiled netcdf library (implies to check option compatibility) |
---|
| 72 | check_linux=1 |
---|
| 73 | ioipsl=1 |
---|
[1693] | 74 | veget=1 |
---|
[1588] | 75 | bench=1 |
---|
| 76 | pclinux=1 |
---|
[3044] | 77 | SCM=0 |
---|
| 78 | # use the old orchidee interface without the calculation of z0h |
---|
| 79 | no_z0h_orc=1 |
---|
[2031] | 80 | # choose the resolution for the bench runs |
---|
[3044] | 81 | # grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE) |
---|
| 82 | # 96x71x19 standard configuration |
---|
| 83 | grid_resolution=144x142x79 |
---|
[2409] | 84 | grid_resolution=48x36x19 |
---|
[1693] | 85 | |
---|
[3044] | 86 | ## parallel can take the values none/mpi/omp/mpi_omp |
---|
| 87 | parallel=mpi_omp |
---|
| 88 | parallel=none |
---|
| 89 | OPT_GPROF="" |
---|
| 90 | OPT_MAKELMDZ="" |
---|
| 91 | MODEL="" |
---|
[2031] | 92 | |
---|
[3056] | 93 | ## also compile XIOS? (and more recent NetCDF/HDF5 libraries) Default=no |
---|
| 94 | with_xios="n" |
---|
| 95 | opt_makelmdz_xios="" |
---|
| 96 | |
---|
[3044] | 97 | ######################################################################### |
---|
| 98 | # Options interactives |
---|
| 99 | ######################################################################### |
---|
| 100 | while (($# > 0)) |
---|
| 101 | do |
---|
| 102 | case $1 in |
---|
| 103 | "-h") cat <<........fin |
---|
| 104 | $0 [ -v version ] [ -r svn_release ] |
---|
| 105 | [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ] |
---|
| 106 | [-name LOCAL_MODEL_NAME] [-gprof] [-opt_makelmdz] |
---|
[2031] | 107 | |
---|
[3044] | 108 | -v "version" like 20150828.trunk |
---|
| 109 | see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk |
---|
[2404] | 110 | |
---|
[3044] | 111 | -r "svn_release" : either the svn release number or "last" |
---|
[2404] | 112 | |
---|
[3044] | 113 | -parallel PARA : can be mpi_omp (mpi with openMP) or none (for sequential) |
---|
[2404] | 114 | |
---|
[3044] | 115 | -d GRID_RESOLUTION should be among the available benchs if -bench 1 |
---|
| 116 | among which : 48x36x19, 48x36x39 |
---|
| 117 | if wanting to run a bench simulation in addition to compilation |
---|
| 118 | default : 48x36x19 |
---|
| 119 | |
---|
| 120 | -bench activating the bench or not (0/1). Default 1 |
---|
| 121 | |
---|
| 122 | -name LOCAL_MODEL_NAME : default = LMDZversion.release |
---|
| 123 | |
---|
[3056] | 124 | -netcdf PATH : full path to an existing installed NetCDF library |
---|
| 125 | (without -netcdf: also download and install the NetCDF library) |
---|
| 126 | |
---|
| 127 | -xios also download and compile the XIOS library |
---|
| 128 | (requires the NetCDF4-HDF5 library, also installed by default) |
---|
| 129 | (requires to also have -parallel mpi_omp) |
---|
| 130 | |
---|
[3044] | 131 | -gprof to compile with -pg to enable profiling with gprof |
---|
[3056] | 132 | |
---|
[3044] | 133 | -SCM install 1D version automatically |
---|
[3056] | 134 | |
---|
[3044] | 135 | -opt_makelmdz to call makelmdz or makelmdz_fcm with additional options |
---|
| 136 | ........fin |
---|
| 137 | exit ;; |
---|
| 138 | "-v") version=$2 ; shift ; shift ;; |
---|
| 139 | "-r") svn=$2 ; shift ; shift ;; |
---|
| 140 | "-d") grid_resolution=$2 ; shift ; shift ;; |
---|
| 141 | "-gprof") OPT_GPROF="-pg" ; shift ;; |
---|
| 142 | "-SCM") SCM=1 ; shift ;; |
---|
| 143 | "-opt_makelmdz") OPT_MAKELMDZ="$2" ; shift ; shift ;; |
---|
| 144 | "-parallel") parallel=$2 |
---|
| 145 | case $parallel in |
---|
[3064] | 146 | "none"|"mpi"|"omp"|"mpi_omp") parallel=$2 ; shift ; shift ;; |
---|
| 147 | *) echo Only none mpi omp mpi_omp for the parallel option ; exit |
---|
[3044] | 148 | esac ;; |
---|
| 149 | "-bench") bench=$2 ; shift ; shift ;; |
---|
| 150 | "-name") MODEL=$2 ; shift ; shift ;; |
---|
[3056] | 151 | "-netcdf") netcdf=$2 ; shift ; shift ;; |
---|
| 152 | "-xios") with_xios="y" ; shift ;; |
---|
[3044] | 153 | *) ./install_lmdz.sh -h ; exit |
---|
| 154 | esac |
---|
| 155 | done |
---|
| 156 | |
---|
| 157 | if [ $parallel = none ] ; then sequential=1 ; else sequential=0 ; fi |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | compilo=gfortran # compilo=pgf90 or gfortran or ifort sur PC linux |
---|
| 161 | #Chemin pour placer le modele |
---|
| 162 | if [ "$MODEL" = "" ] ; then MODEL=./LMDZ$version$svn ; fi |
---|
| 163 | |
---|
| 164 | |
---|
| 165 | ## compile_with_fcm=1 : use makelmdz_fcm (1) or makelmdz (0) |
---|
| 166 | compile_with_fcm=1 |
---|
| 167 | arch=local |
---|
| 168 | |
---|
| 169 | |
---|
| 170 | if [ $compilo = g95 ] ; then echo g95 is not supported anymore ; exit ; fi |
---|
| 171 | |
---|
| 172 | ################################################################ |
---|
| 173 | # Specificite des machines |
---|
| 174 | ################################################################ |
---|
| 175 | |
---|
| 176 | hostname=`hostname` |
---|
| 177 | if [ "$pclinux" = 1 ] ; then o_ins_make="-t g95" ; else o_ins_make="" ; fi |
---|
| 178 | |
---|
| 179 | case ${hostname:0:5} in |
---|
| 180 | |
---|
| 181 | ada33) compilo="ifort" ; |
---|
| 182 | par_comp="ifort" ; |
---|
| 183 | o_ins_make="-t ada" ; |
---|
| 184 | make=gmake ; |
---|
| 185 | # module load intel/2013.0 ; |
---|
| 186 | arch=X64_ADA ;; |
---|
| 187 | |
---|
[3056] | 188 | cicla) compilo="gfortran" ; |
---|
| 189 | if [ $parallel != none ] ; then |
---|
| 190 | module load openmpi/1.4.5-gfortran ; |
---|
| 191 | root_mpi=$MPI_HOME ; |
---|
| 192 | path_mpi=$root_mpi/bin ; |
---|
| 193 | par_comp=${path_mpi}/mpif90 ; |
---|
| 194 | mpirun=${path_mpi}/mpirun ; |
---|
| 195 | fi ; |
---|
| 196 | arch=local ; |
---|
| 197 | make=make ; |
---|
| 198 | o_ins_make="-t g95" ;; |
---|
| 199 | |
---|
[3044] | 200 | *) compilo="gfortran" ; |
---|
| 201 | if [ $parallel = none -o -f /usr/bin/mpif90 ] ; then |
---|
[3076] | 202 | path_mpi=`which mpif90 | sed -e s:/mpif90::` ; |
---|
[3056] | 203 | if [ -d /usr/lib64/openmpi ] ; then |
---|
| 204 | root_mpi="/usr/lib64/openmpi" |
---|
| 205 | else |
---|
| 206 | root_mpi="/usr" |
---|
| 207 | fi |
---|
| 208 | # For Scientifique Linux at LMD : |
---|
[3044] | 209 | elif [ -f /usr/lib64/openmpi/1.4.5-gfortran/bin/mpif90 ] ; then |
---|
[3056] | 210 | path_mpi=/usr/lib64/openmpi/1.4.5-gfortran/bin ; |
---|
| 211 | root_mpi=/usr/lib64/openmpi/1.4.5-gfortran ; |
---|
| 212 | export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH |
---|
[3044] | 213 | else |
---|
[3056] | 214 | echo "Cannot find mpif90" ; |
---|
[3044] | 215 | exit ; |
---|
| 216 | fi ; |
---|
[3056] | 217 | par_comp=${path_mpi}/mpif90 ; |
---|
| 218 | mpirun=${path_mpi}/mpirun ; |
---|
[3044] | 219 | arch=local ; |
---|
| 220 | make=make ; |
---|
| 221 | o_ins_make="-t g95" |
---|
| 222 | esac |
---|
| 223 | |
---|
| 224 | |
---|
| 225 | # MPI_FLAGS are the flags needed for compilation with MPI |
---|
[3056] | 226 | #MPI_FLAGS="-I/usr/include/openmpi-x86_64 -fcray-pointer" |
---|
[3044] | 227 | MPI_FLAGS="-fcray-pointer" |
---|
| 228 | # MPI_LD are the flags needed for linking with MPI |
---|
| 229 | MPI_LD="-L/usr/lib64/openmpi/lib -lmpi" |
---|
| 230 | # OMP_FLAGS are the flags needed for compilation with OpenMP |
---|
| 231 | OMP_FLAGS="-fopenmp -fcray-pointer" |
---|
| 232 | # OMP_LD are the flags needed for linking with OpenMP |
---|
[3056] | 233 | #OMP_LD="-fopenmp -L/usr/lib64 -lnuma" |
---|
[3044] | 234 | OMP_LD="-fopenmp" |
---|
| 235 | |
---|
| 236 | |
---|
[1693] | 237 | ##################################################################### |
---|
| 238 | # Test for old gfortran compilers |
---|
[2030] | 239 | # If the compiler is too old (older than 4.3.x) we test if the |
---|
| 240 | # temporary gfortran44 patch is available on the computer in which |
---|
| 241 | # case the compiler is changed from gfortran to gfortran44 |
---|
| 242 | # Must be aware than parallelism can not be activated in this case |
---|
| 243 | ##################################################################### |
---|
| 244 | |
---|
[3044] | 245 | if [ "$compilo" = "gfortran" ] ; then |
---|
[2030] | 246 | gfortran=gfortran |
---|
[1693] | 247 | gfortranv=`gfortran --version | \ |
---|
| 248 | head -1 | awk ' { print $NF } ' | awk -F. ' { print $1 * 10 + $2 } '` |
---|
| 249 | if [ $gfortranv -le 43 ] ; then |
---|
[1708] | 250 | echo ERROR : Your gfortran compiler is too old |
---|
[3044] | 251 | echo 'Please choose a new one (ifort) and change the line' |
---|
[1693] | 252 | echo compilo=xxx |
---|
| 253 | echo in the install.sh script and rerun it |
---|
[2030] | 254 | if [ `which gfortran44 | wc -w` -ne 0 ] ; then |
---|
| 255 | gfortran=gfortran44 |
---|
| 256 | else |
---|
| 257 | echo gfotran trop vieux ; exit |
---|
| 258 | fi |
---|
[1693] | 259 | fi |
---|
[2030] | 260 | compilo=$gfortran |
---|
[1693] | 261 | fi |
---|
| 262 | ##################################################################### |
---|
| 263 | |
---|
[3056] | 264 | ## if also compiling XIOS, parallel must be mpi_omp |
---|
| 265 | if [ "$with_xios" = "y" -a "$parallel" != "mpi_omp" ] ; then |
---|
| 266 | echo "Error, you must set -parallel mpi_omp if you want XIOS" |
---|
| 267 | exit |
---|
| 268 | fi |
---|
| 269 | if [ "$with_xios" = "y" ] ; then |
---|
| 270 | opt_makelmdz_xios="-io xios" |
---|
| 271 | fi |
---|
[1693] | 272 | |
---|
[1588] | 273 | echo '################################################################' |
---|
| 274 | echo Choix des options de compilation |
---|
| 275 | echo '################################################################' |
---|
[1589] | 276 | |
---|
[2031] | 277 | export FC=$compilo |
---|
| 278 | export F90=$compilo |
---|
| 279 | export F77=$compilo |
---|
| 280 | export CPPFLAGS= |
---|
[3044] | 281 | OPTIMNC=$OPTIM |
---|
| 282 | BASE_LD="$OPT_GPROF" |
---|
| 283 | OPTPREC="$OPT_GPROF" |
---|
[3076] | 284 | ARFLAGS="rs" ; if [ -f /etc/issue ] ; then if [ "`grep -i ubuntu /etc/issue`" != "" ] ; then if [ "`grep -i ubuntu /etc/issue | awk ' { print $2 } ' | cut -d. -f1`" -ge 16 ] ; then ARFLAGS="rU" ; fi ; fi ; fi |
---|
[3044] | 285 | |
---|
[3076] | 286 | |
---|
| 287 | |
---|
[3044] | 288 | if [ "$compilo" = "$gfortran" ] ; then |
---|
[2031] | 289 | OPTIM='-O3' |
---|
[3044] | 290 | OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=nan" |
---|
[2031] | 291 | OPTDEV="-Wall -fbounds-check" |
---|
| 292 | fmod='I ' |
---|
[3044] | 293 | OPTPREC="$OPTPREC -cpp -ffree-line-length-0" |
---|
[2409] | 294 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE" ; fi |
---|
[2031] | 295 | export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
| 296 | export FFLAGS=" $OPTIMNC" |
---|
| 297 | export CC=gcc |
---|
| 298 | export CXX=g++ |
---|
[3044] | 299 | export fpp_flags="-P -C -traditional -ffreestanding" |
---|
| 300 | |
---|
[2031] | 301 | elif [ $compilo = mpif90 ] ; then |
---|
[1589] | 302 | OPTIM='-O3' |
---|
[3044] | 303 | OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all" |
---|
[2031] | 304 | OPTDEV="-Wall -fbounds-check" |
---|
[3044] | 305 | BASE_LD="$BASE_LD -lblas" |
---|
[2031] | 306 | fmod='I ' |
---|
[3044] | 307 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer" ; fi |
---|
[2031] | 308 | export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
| 309 | export FFLAGS=" $OPTIMNC" |
---|
| 310 | export CC=gcc |
---|
| 311 | export CXX=g++ |
---|
[3044] | 312 | |
---|
[1590] | 313 | elif [ $compilo = pgf90 ] ; then |
---|
[2203] | 314 | OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align' |
---|
| 315 | OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback' |
---|
| 316 | OPTDEV='-g -Mbounds -Ktrap=fp -traceback' |
---|
[2031] | 317 | fmod='module ' |
---|
[3044] | 318 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE" ; fi |
---|
[2203] | 319 | export CPPFLAGS="-DpgiFortran" |
---|
[2031] | 320 | export CC=pgcc |
---|
[2203] | 321 | export CFLAGS="-O2 -Msignextend" |
---|
[2031] | 322 | export CXX=pgCC |
---|
[2203] | 323 | export CXXFLAGS="-O2 -Msignextend" |
---|
| 324 | export FFLAGS="-O2 $OPTIMNC" |
---|
| 325 | export F90FLAGS="-O2 $OPTIMNC" |
---|
[1590] | 326 | compile_with_fcm=1 |
---|
[3044] | 327 | |
---|
[2031] | 328 | elif [ $compilo = ifort ] ; then |
---|
| 329 | OPTIM="-O2 -fp-model strict -ip -align all " |
---|
| 330 | OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check" |
---|
| 331 | OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check" |
---|
| 332 | fmod='module ' |
---|
[3044] | 333 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi |
---|
[2031] | 334 | export CPP="icc -E" |
---|
| 335 | export FFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 336 | export FCFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 337 | export CC=icc |
---|
| 338 | export CFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 339 | export CXX=icpc |
---|
| 340 | export CXXFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
[1590] | 341 | compile_with_fcm=1 |
---|
[3044] | 342 | |
---|
[2031] | 343 | else |
---|
| 344 | echo unexpected compiler $compilo ; exit |
---|
[1588] | 345 | fi |
---|
[2031] | 346 | |
---|
[1589] | 347 | OPTIMGCM="$OPTIM $OPTPREC" |
---|
[1588] | 348 | |
---|
| 349 | hostname=`hostname` |
---|
| 350 | |
---|
| 351 | ########################################################################## |
---|
[1731] | 352 | # If installing on know machines such as IBM x3750 (Ada) |
---|
[1708] | 353 | # at IDRIS, don't check for available software and don"t install netcdf |
---|
[1777] | 354 | if [ ${hostname:0:5} = ada33 ] ; then |
---|
[1731] | 355 | netcdf=0 # no need to recompile netcdf, alreday available |
---|
| 356 | check_linux=0 |
---|
| 357 | pclinux=0 |
---|
[3044] | 358 | ioipsl=1 # no need to recompile ioipsl, already available |
---|
[1731] | 359 | #netcdf="/smplocal/pub/NetCDF/4.1.3" |
---|
| 360 | compilo="ifort" |
---|
| 361 | fmod='module ' |
---|
[3044] | 362 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi |
---|
[1731] | 363 | OPTIM="-O2 -fp-model strict -ip -axAVX,SSE4.2 -align all " |
---|
| 364 | OPTIMGCM="$OPTIM $OPTPREC" |
---|
[1588] | 365 | fi |
---|
| 366 | ########################################################################## |
---|
| 367 | |
---|
| 368 | |
---|
[3044] | 369 | |
---|
[1588] | 370 | mkdir -p $MODEL |
---|
| 371 | echo $MODEL |
---|
[1708] | 372 | MODEL=`( cd $MODEL ; pwd )` # to get absolute path, if necessary |
---|
[1588] | 373 | |
---|
| 374 | |
---|
| 375 | |
---|
[1708] | 376 | # Option -fendian=big is only to be used with ARPEGE1D. |
---|
| 377 | # The -r8 should probably be avoided if running on 32 bit machines |
---|
| 378 | # Option r8 is not mandatory and generates larger executables. |
---|
| 379 | # It is however mandatory if using ARPEGE1D |
---|
| 380 | # Better optimization options might be a better choice (e.g. -O3) |
---|
[1588] | 381 | |
---|
| 382 | |
---|
| 383 | echo '################################################################' |
---|
| 384 | if [ "$check_linux" = 1 ] ; then |
---|
[1708] | 385 | echo Check if required software is available |
---|
[1588] | 386 | echo '################################################################' |
---|
| 387 | |
---|
| 388 | #### Ehouarn: test if ksh and/or bash are available |
---|
| 389 | use_shell="ksh" # default: use ksh |
---|
| 390 | if [ "`which ksh`" = "" ] ; then |
---|
[1708] | 391 | echo "no ksh ... we will use bash" |
---|
[1588] | 392 | use_shell="bash" |
---|
| 393 | if [ "`which bash`" = "" ] ; then |
---|
[1708] | 394 | echo "ksh (or bash) needed!! Install it!" |
---|
[1588] | 395 | fi |
---|
| 396 | fi |
---|
| 397 | |
---|
| 398 | |
---|
[3044] | 399 | for logiciel in csh wget tar gzip make $compilo gcc ; do |
---|
[1588] | 400 | if [ "`which $logiciel`" = "" ] ; then |
---|
[1708] | 401 | echo You must first install $logiciel on your system |
---|
[1588] | 402 | exit |
---|
| 403 | fi |
---|
| 404 | done |
---|
| 405 | |
---|
| 406 | if [ $pclinux = 1 ] ; then |
---|
| 407 | cd $MODEL |
---|
[2030] | 408 | cat <<eod > tt.f90 |
---|
[1588] | 409 | print*,'coucou' |
---|
| 410 | end |
---|
| 411 | eod |
---|
[1708] | 412 | $compilo tt.f90 -o a.out |
---|
[1588] | 413 | ./a.out >| tt |
---|
| 414 | if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then |
---|
[1708] | 415 | echo problem installing with compiler $compilo ; exit ; fi |
---|
[1588] | 416 | \rm tt a.out tt.f90 |
---|
| 417 | fi |
---|
| 418 | fi |
---|
| 419 | |
---|
| 420 | ########################################################################### |
---|
| 421 | if [ $getlmdzor = 1 ] ; then |
---|
| 422 | echo '##########################################################' |
---|
[1708] | 423 | echo Download a slightly modified version of LMDZ |
---|
[1588] | 424 | echo '##########################################################' |
---|
| 425 | cd $MODEL |
---|
[3076] | 426 | myget src/modipsl.$version.tar.gz |
---|
[3044] | 427 | echo install.sh wget_OK `date` |
---|
| 428 | gunzip modipsl.$version.tar.gz |
---|
| 429 | tar xvf modipsl.$version.tar |
---|
| 430 | \rm modipsl.$version.tar |
---|
[1588] | 431 | |
---|
| 432 | fi |
---|
| 433 | |
---|
| 434 | echo OK1 |
---|
| 435 | |
---|
| 436 | if [ $netcdf = 1 ] ; then |
---|
| 437 | echo '##########################################################' |
---|
[1708] | 438 | echo Compiling the Netcdf library |
---|
[1588] | 439 | echo '##########################################################' |
---|
| 440 | cd $MODEL |
---|
[3056] | 441 | if [ "$with_xios" = "n" ] ; then |
---|
| 442 | # keep it simple |
---|
| 443 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/netcdf-4.0.1.tar.gz |
---|
[3076] | 444 | myget import/netcdf-4.0.1.tar.gz |
---|
[3056] | 445 | gunzip netcdf-4.0.1.tar.gz |
---|
| 446 | tar xvf netcdf-4.0.1.tar |
---|
| 447 | \rm -f netcdf-4.0.1.tar |
---|
[1588] | 448 | |
---|
[3056] | 449 | cd netcdf-4.0.1 |
---|
[1588] | 450 | |
---|
[3056] | 451 | # seds to possibly use gfortran44 obsolete nowdays (Ehouarn: 10/2017) |
---|
| 452 | #sed -e 's/gfortran/'$gfortran'/g' configure >| tmp ; mv -f tmp configure ; chmod +x configure |
---|
| 453 | localdir=`pwd -P` |
---|
| 454 | ./configure --prefix=$localdir --enable-shared --disable-cxx |
---|
| 455 | #sed -e 's/gfortran/'$gfortran'/g' Makefile >| tmp ; mv -f tmp Makefile |
---|
| 456 | $make check |
---|
| 457 | $make install |
---|
| 458 | else |
---|
| 459 | # download and compile hdf5 and netcdf, etc. using the install_netcdf4_hdf5.bash script |
---|
| 460 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_netcdf4_hdf5.bash |
---|
[3076] | 461 | myget import/install_netcdf4_hdf5.bash |
---|
[3056] | 462 | chmod u=rwx install_netcdf4_hdf5.bash |
---|
| 463 | if [ "$compilo" = "gfortran" ] ; then |
---|
| 464 | ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC gcc -FC gfortran -CXX g++ -MPI $root_mpi |
---|
| 465 | elif [ "$compilo" = "ifort" ] ; then |
---|
| 466 | ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC icc -FC ifort -CXX icpc -MPI $root_mpi |
---|
| 467 | elif [ "$compilo" = "pgf90" ] ; then |
---|
| 468 | ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC pgcc -FC pgf90 -CXX pgCC -MPI $root_mpi |
---|
| 469 | else |
---|
| 470 | echo "unexpected compiler $compilo" ; exit |
---|
| 471 | fi |
---|
| 472 | fi # of if [ "$with_xios" = "n" ] |
---|
[2030] | 473 | echo install.sh netcdf_OK `date` |
---|
[1731] | 474 | fi # of if [ $netcdf = 1 ] |
---|
[1588] | 475 | |
---|
[2030] | 476 | |
---|
[1800] | 477 | #======================================================================================= |
---|
[1588] | 478 | echo OK2 ioipsl=$ioipsl |
---|
| 479 | echo '##########################################################' |
---|
[1731] | 480 | echo 'Installing MODIPSL, the installation package manager for the ' |
---|
| 481 | echo 'IPSL models and tools' |
---|
[1588] | 482 | echo '##########################################################' |
---|
| 483 | |
---|
| 484 | if [ $netcdf = 0 -o $netcdf = 1 ] ; then |
---|
[3056] | 485 | if [ "$with_xios" = "y" ] ; then |
---|
| 486 | ncdfdir=$MODEL/netcdf4_hdf5 |
---|
| 487 | else |
---|
| 488 | ncdfdir=$MODEL/netcdf-4.0.1 |
---|
| 489 | fi |
---|
[1588] | 490 | else |
---|
[3056] | 491 | ncdfdir=$netcdf |
---|
[1588] | 492 | fi |
---|
| 493 | |
---|
| 494 | if [ $ioipsl = 1 ] ; then |
---|
[1731] | 495 | cd $MODEL/modipsl |
---|
[2030] | 496 | \rm -rf lib/* |
---|
[2031] | 497 | |
---|
[1731] | 498 | cd util |
---|
[1588] | 499 | |
---|
[1731] | 500 | cp AA_make.gdef AA_make.orig |
---|
[2031] | 501 | F_C="$compilo -c " ; if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then F_C="$compilo -c -cpp " ; fi |
---|
[2203] | 502 | if [ "$compilo" = "pgf90" ] ; then F_C="$compilo -c -Mpreprocess" ; fi |
---|
[1731] | 503 | sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp |
---|
[2203] | 504 | sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \ |
---|
[1731] | 505 | -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ |
---|
| 506 | -e 's:g95.*.NCDF_INC.*.$:g95 NCDF_INC= '"$ncdfdir"'/include:' \ |
---|
[3044] | 507 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \ |
---|
[3063] | 508 | -e 's:g95 L_O =:g95 L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \ |
---|
[1731] | 509 | -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \ |
---|
| 510 | -e 's:#-Q- g95 M_K = gmake:#-Q- g95 M_K = make:' \ |
---|
| 511 | tmp >| AA_make.gdef |
---|
[1588] | 512 | |
---|
| 513 | |
---|
[3044] | 514 | # We use lines for g95 even for the other compilers to run ins_make |
---|
[1731] | 515 | if [ "$use_shell" = "ksh" ] ; then |
---|
[3044] | 516 | ./ins_make $o_ins_make |
---|
[1731] | 517 | else # bash |
---|
| 518 | sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash |
---|
[3044] | 519 | if [ "`grep ada AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar |
---|
| 520 | \cp -f ~rdzt401/bin/AA_make.gdef . |
---|
| 521 | fi |
---|
[1731] | 522 | chmod u=rwx ins_make.bash |
---|
[3044] | 523 | ./ins_make.bash $o_ins_make |
---|
[1731] | 524 | fi # of if [ "$use_shell" = "ksh" ] |
---|
| 525 | |
---|
[2031] | 526 | #======================================================================================= |
---|
[1731] | 527 | echo '##########################################################' |
---|
| 528 | echo 'Compiling IOIPSL, the interface library with Netcdf' |
---|
| 529 | echo '##########################################################' |
---|
| 530 | |
---|
| 531 | cd $MODEL/modipsl/modeles/IOIPSL/src |
---|
| 532 | if [ "$use_shell" = "bash" ] ; then |
---|
| 533 | cp Makefile Makefile.ksh |
---|
| 534 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
---|
[1588] | 535 | fi |
---|
[3044] | 536 | # if [ "$pclinux" = 1 ] ; then |
---|
[1731] | 537 | # Build IOIPSL modules and library |
---|
[3044] | 538 | echo EOEOFOOEOOOOOOOOOOOOOOOOOOOOOOOOOOOO |
---|
| 539 | $make clean |
---|
| 540 | $make |
---|
[2031] | 541 | if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then # copy module files to lib |
---|
[1731] | 542 | cp -f *.mod ../../../lib |
---|
| 543 | fi |
---|
| 544 | # Build IOIPSL tools (ie: "rebuild", if present) |
---|
| 545 | if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then |
---|
| 546 | cd $MODEL/modipsl/modeles/IOIPSL/tools |
---|
| 547 | # adapt Makefile & rebuild script if in bash |
---|
| 548 | if [ "$use_shell" = "bash" ] ; then |
---|
| 549 | cp Makefile Makefile.ksh |
---|
| 550 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
---|
| 551 | cp rebuild rebuild.ksh |
---|
| 552 | sed -e 's:/bin/ksh:/bin/bash:g' \ |
---|
| 553 | -e 's:print -u2:echo:g' \ |
---|
| 554 | -e 's:print:echo:g' rebuild.ksh > rebuild |
---|
| 555 | fi |
---|
[3044] | 556 | $make clean |
---|
| 557 | $make |
---|
[1731] | 558 | fi |
---|
[3044] | 559 | # fi # of if [ "$pclinux" = 1 ] |
---|
[1588] | 560 | |
---|
[1731] | 561 | else # of if [ $ioipsl = 1 ] |
---|
[1777] | 562 | if [ ${hostname:0:5} = ada33 ] ; then |
---|
[1731] | 563 | cd $MODEL/modipsl |
---|
| 564 | cd util |
---|
[1588] | 565 | |
---|
[1731] | 566 | cp AA_make.gdef AA_make.orig |
---|
| 567 | sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp |
---|
| 568 | sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c:F_C = $compilo -c": \ |
---|
| 569 | -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ |
---|
| 570 | -e 's:g95.*.NCDF_INC.*.$:g95 NCDF_INC= -I/smplocal/pub/HDF5/1.8.9/seq/include -I/smplocal/pub/NetCDF/4.1.3/include:' \ |
---|
| 571 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L/smplocal/pub/NetCDF/4.1.3/lib -lnetcdff -lnetcdf:' \ |
---|
| 572 | -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \ |
---|
| 573 | -e 's:#-Q- g95 M_K = gmake:#-Q- g95 M_K = make:' \ |
---|
| 574 | tmp >| AA_make.gdef |
---|
| 575 | |
---|
[3044] | 576 | ./ins_make $o_ins_make # We use lines for g95 even for the other compilers |
---|
[1731] | 577 | |
---|
| 578 | # on Ada, IOIPSL is already installed in ~rpsl035/IOIPSL_PLUS |
---|
| 579 | # so link it to current settings |
---|
| 580 | cd $MODEL/modipsl/modeles/ |
---|
| 581 | \rm -r -f IOIPSL |
---|
| 582 | ln -s ~rpsl035/IOIPSL_PLUS IOIPSL |
---|
| 583 | cd .. |
---|
[3044] | 584 | ln -s ~rpsl035/IOIPSL_PLUS/modipsl_Tagv2_2_3/bin/* bin/ |
---|
| 585 | ln -s ~rpsl035/IOIPSL_PLUS/modipsl_Tagv2_2_3/lib/* lib/ |
---|
[1731] | 586 | |
---|
[1777] | 587 | fi # of if [ ${hostname:0:5} = ada33 ] |
---|
[2030] | 588 | echo install.sh ioipsl_OK `date` |
---|
[1731] | 589 | fi # of if [ $ioipsl = 1 ] |
---|
[3044] | 590 | # Saving ioipsl lib for possible parallel compile |
---|
| 591 | cd $MODEL/modipsl |
---|
| 592 | tar cf ioipsl.tar lib/ bin/ |
---|
[1731] | 593 | |
---|
[3056] | 594 | #=========================================================================== |
---|
| 595 | if [ "$with_xios" = "y" ] ; then |
---|
| 596 | echo '##########################################################' |
---|
| 597 | echo 'Compiling XIOS' |
---|
| 598 | echo '##########################################################' |
---|
| 599 | cd $MODEL/modipsl/modeles |
---|
| 600 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_xios.bash |
---|
[3076] | 601 | myget import/install_xios.bash |
---|
[3056] | 602 | chmod u=rwx install_xios.bash |
---|
| 603 | ./install_xios.bash -prefix $MODEL/modipsl/modeles \ |
---|
| 604 | -netcdf ${ncdfdir} -hdf5 ${ncdfdir} \ |
---|
| 605 | -MPI $root_mpi -arch $arch |
---|
| 606 | fi |
---|
| 607 | |
---|
[1800] | 608 | #============================================================================ |
---|
[1837] | 609 | veget_version=false |
---|
[1731] | 610 | if [ "$veget" = 1 ] ; then |
---|
| 611 | echo '########################################################' |
---|
| 612 | echo 'Compiling ORCHIDEE, the continental surfaces model ' |
---|
| 613 | echo '########################################################' |
---|
| 614 | cd $MODEL/modipsl/modeles/ORCHIDEE |
---|
[2430] | 615 | export ORCHPATH=`pwd` |
---|
| 616 | if [ -d tools ] ; then |
---|
[3044] | 617 | orchidee_rev=2247 |
---|
[1837] | 618 | veget_version=orchidee2.0 |
---|
[3044] | 619 | cd arch |
---|
[2430] | 620 | sed -e s:"%COMPILER .*.$":"%COMPILER $compilo":1 \ |
---|
| 621 | -e s:"%LINK .*.$":"%LINK $compilo":1 \ |
---|
| 622 | -e s:"%FPP_FLAGS .*.$":"%FPP_FLAGS $fpp_flags":1 \ |
---|
| 623 | -e s:"%PROD_FFLAGS .*.$":"%PROD_FFLAGS $OPTIM":1 \ |
---|
| 624 | -e s:"%DEV_FFLAGS .*.$":"%DEV_FFLAGS $OPTDEV":1 \ |
---|
| 625 | -e s:"%DEBUG_FFLAGS .*.$":"%DEBUG_FFLAGS $OPTDEB":1 \ |
---|
[3044] | 626 | -e s:"%BASE_FFLAGS .*.$":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
| 627 | -e s:"%BASE_LD .*.$":"%BASE_LD $BASE_LD":1 \ |
---|
[3076] | 628 | -e s:"%ARFLAGS .*.$":"%ARFLAGS $ARFLAGS":1 \ |
---|
[2430] | 629 | arch-gfortran.fcm > arch-local.fcm |
---|
[3044] | 630 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path |
---|
[2430] | 631 | echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path |
---|
| 632 | echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path |
---|
| 633 | echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path |
---|
[3044] | 634 | cd ../ |
---|
[2430] | 635 | # compiling ORCHIDEE sequential mode |
---|
[3044] | 636 | ./makeorchidee_fcm -j 8 -noxios -prod -parallel none -arch $arch |
---|
| 637 | echo ./makeorchidee_fcm -j 8 -noxios -prod -parallel none -arch $arch |
---|
| 638 | echo Fin de la premiere compilation orchidee ; pwd |
---|
[1800] | 639 | else |
---|
[2430] | 640 | if [ -d src_parallel ] ; then |
---|
| 641 | liste_src="parallel parameters global stomate sechiba driver" |
---|
| 642 | veget_version=orchidee2.0 |
---|
| 643 | else |
---|
| 644 | # Obsolete, for ORCHIDEE_beton only |
---|
| 645 | liste_src="parameters stomate sechiba " |
---|
| 646 | # A trick to compile ORCHIDEE depending on if we are using real*4 or real*8 |
---|
| 647 | cd src_parameters ; \cp reqdprec.$real reqdprec.f90 ; cd .. |
---|
| 648 | veget_version=orchidee1.9 |
---|
| 649 | fi |
---|
| 650 | for d in $liste_src ; do src_d=src_$d |
---|
| 651 | echo src_d $src_d |
---|
| 652 | echo ls ; ls |
---|
| 653 | if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi |
---|
[3044] | 654 | cd $src_d ; \rm -f *.mod make ; $make clean |
---|
| 655 | $make ; if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi |
---|
[2430] | 656 | cd .. |
---|
| 657 | done |
---|
[1800] | 658 | fi |
---|
[2030] | 659 | echo install.sh orchidee_OK `date` |
---|
[1731] | 660 | fi # of if [ "$veget" = 1 ] |
---|
[1588] | 661 | |
---|
[2030] | 662 | |
---|
[1800] | 663 | #============================================================================ |
---|
[1588] | 664 | # Ehouarn: it may be directory LMDZ4 or LMDZ5 depending on tar file... |
---|
[3044] | 665 | if [ -d $MODEL/modipsl/modeles/LMD* ] ; then |
---|
[1588] | 666 | echo '##########################################################' |
---|
[1800] | 667 | echo 'Compiling LMDZ' |
---|
[1588] | 668 | echo '##########################################################' |
---|
[3044] | 669 | cd $MODEL/modipsl/modeles/LMD* |
---|
| 670 | LMDZPATH=`pwd` |
---|
[1588] | 671 | else |
---|
[3044] | 672 | echo "ERROR: No LMD* directory !!!" |
---|
[1800] | 673 | exit |
---|
[1588] | 674 | fi |
---|
| 675 | |
---|
| 676 | ########################################################### |
---|
[1708] | 677 | # For those who want to use fcm to compile via : |
---|
[1588] | 678 | # makelmdz_fcm -arch local ..... |
---|
| 679 | ############################################################ |
---|
| 680 | |
---|
[2031] | 681 | if [ "$pclinux" = "1" ] ; then |
---|
| 682 | |
---|
[1708] | 683 | # create local 'arch' files (if on Linux PC): |
---|
[1588] | 684 | cd arch |
---|
[1708] | 685 | # arch-local.path file |
---|
[3044] | 686 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path |
---|
[1590] | 687 | echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path |
---|
[1588] | 688 | echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
| 689 | echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
[3044] | 690 | echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path |
---|
| 691 | echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path |
---|
[1588] | 692 | echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
| 693 | echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
[3044] | 694 | |
---|
| 695 | BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib" |
---|
[1708] | 696 | # arch-local.fcm file (adapted from arch-linux-32bit.fcm) |
---|
[2031] | 697 | |
---|
| 698 | if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi |
---|
| 699 | sed -e s:"%COMPILER .*.$":"%COMPILER $compilo":1 \ |
---|
| 700 | -e s:"%LINK .*.$":"%LINK $compilo":1 \ |
---|
| 701 | -e s:"%PROD_FFLAGS .*.$":"%PROD_FFLAGS $OPTIM":1 \ |
---|
| 702 | -e s:"%DEV_FFLAGS .*.$":"%DEV_FFLAGS $OPTDEV":1 \ |
---|
| 703 | -e s:"%DEBUG_FFLAGS .*.$":"%DEBUG_FFLAGS $OPTDEB":1 \ |
---|
| 704 | -e s:"%BASE_FFLAGS .*.$":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
[2203] | 705 | -e s:"%FPP_DEF .*.$":"%FPP_DEF $FPP_DEF":1 \ |
---|
[3044] | 706 | -e s:"%BASE_LD .*.$":"%BASE_LD $BASE_LD":1 \ |
---|
[3076] | 707 | -e s:"%ARFLAGS .*.$":"%ARFLAGS $ARFLAGS":1 \ |
---|
[2031] | 708 | arch-linux-32bit.fcm > arch-local.fcm |
---|
| 709 | |
---|
[1588] | 710 | cd .. |
---|
[1708] | 711 | ### Adapt "bld.cfg" (add the shell): |
---|
[1588] | 712 | whereisthatshell=$(which ${use_shell}) |
---|
| 713 | echo "bld::tool::SHELL $whereisthatshell" >> bld.cfg |
---|
| 714 | |
---|
[1731] | 715 | fi # of if [ "$pclinux" = 1 ] |
---|
| 716 | |
---|
| 717 | |
---|
[3056] | 718 | cd $MODEL/modipsl/modeles/LMDZ* |
---|
[1731] | 719 | |
---|
[1588] | 720 | ################################################################## |
---|
[3056] | 721 | # Possibly update LMDZ if a specific svn release is requested |
---|
[3044] | 722 | ################################################################## |
---|
| 723 | |
---|
| 724 | if [ "$svn" = "last" ] ; then svnopt="" ; else svnopt="-r $svn" ; fi |
---|
| 725 | if [ "$svn" != "" ] ; then set +e ; svn upgrade ; set -e ; svn update $svnopt ; fi |
---|
| 726 | |
---|
| 727 | ################################################################## |
---|
[1708] | 728 | # Compile LMDZ |
---|
[1588] | 729 | ################################################################## |
---|
[3044] | 730 | |
---|
[2030] | 731 | echo install.sh avant_compilation `date` |
---|
[3044] | 732 | if [ $compile_with_fcm = 1 ] ; then makelmdz="makelmdz_fcm -arch $arch -j 8" ; else makelmdz="makelmdz -arch $arch" ; fi |
---|
[2031] | 733 | |
---|
[3044] | 734 | # use the orchidee interface that has no z0h |
---|
| 735 | if [ "$no_z0h_orc" = 1 ] ; then |
---|
| 736 | veget_version="$veget_version -cpp ORCHIDEE_NOZ0H" |
---|
| 737 | fi |
---|
| 738 | |
---|
| 739 | # sequential compilation and bench |
---|
| 740 | if [ "$sequential" = 1 ] ; then |
---|
| 741 | echo "./$makelmdz $OPT_MAKELMDZ -rrtm true -d ${grid_resolution} -v $veget_version gcm" >> compile.sh |
---|
| 742 | chmod +x ./compile.sh ; ./compile.sh |
---|
[2030] | 743 | echo install.sh apres_compilation `date` |
---|
[1588] | 744 | |
---|
[2030] | 745 | |
---|
[3044] | 746 | fi # fin sequential |
---|
| 747 | |
---|
| 748 | |
---|
| 749 | |
---|
| 750 | # compiling in parallel mode |
---|
| 751 | if [ $parallel != "none" ] ; then |
---|
[3056] | 752 | echo '##########################################################' |
---|
| 753 | echo ' Parallel compile ' |
---|
| 754 | echo '##########################################################' |
---|
| 755 | # saving the sequential libs and binaries |
---|
| 756 | cd $MODEL/modipsl |
---|
| 757 | tar cf sequential.tar bin/ lib/ |
---|
| 758 | \rm -rf bin/ lib/ |
---|
| 759 | tar xf ioipsl.tar |
---|
| 760 | # |
---|
| 761 | # Orchidee |
---|
| 762 | # |
---|
| 763 | cd $ORCHPATH |
---|
| 764 | if [ -d src_parallel ] ; then |
---|
[3044] | 765 | cd arch |
---|
| 766 | sed \ |
---|
| 767 | -e s:"%COMPILER.*.$":"%COMPILER $par_comp":1 \ |
---|
| 768 | -e s:"%LINK.*.$":"%LINK $par_comp":1 \ |
---|
| 769 | -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS $MPI_FLAGS":1 \ |
---|
| 770 | -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS $OMP_FLAGS":1 \ |
---|
| 771 | -e s:"%MPI_LD.*.$":"%MPI_LD $MPI_LD":1 \ |
---|
| 772 | -e s:"%OMP_LD.*.$":"%OMP_LD $OMP_LD":1 \ |
---|
| 773 | arch-local.fcm > tmp.fcm |
---|
| 774 | |
---|
| 775 | mv tmp.fcm arch-local.fcm |
---|
| 776 | cd ../ |
---|
[3056] | 777 | # compiling ORCHIDEE parallel mode |
---|
[3044] | 778 | ./makeorchidee_fcm -j 8 -clean -noxios -prod -parallel $parallel -arch $arch |
---|
| 779 | ./makeorchidee_fcm -j 8 -noxios -prod -parallel $parallel -arch $arch |
---|
| 780 | echo ./makeorchidee_fcm -j 8 -clean -noxios -prod -parallel $parallel -arch $arch |
---|
| 781 | echo ./makeorchidee_fcm -j 8 -noxios -prod -parallel $parallel -arch $arch |
---|
| 782 | echo deuxieme compilation orchidee ; pwd |
---|
[3056] | 783 | else |
---|
| 784 | echo '##########################################################' |
---|
| 785 | echo ' Orchidee version too old ' |
---|
| 786 | echo ' Please update to new version ' |
---|
| 787 | echo '##########################################################' |
---|
| 788 | exit |
---|
| 789 | fi # of if [ -d src_parallel ] |
---|
| 790 | # LMDZ |
---|
| 791 | cd $LMDZPATH |
---|
| 792 | if [ $arch = local ] ; then |
---|
| 793 | cd arch |
---|
| 794 | sed -e s:"%COMPILER.*.$":"%COMPILER $par_comp":1 \ |
---|
| 795 | -e s:"%LINK.*.$":"%LINK $par_comp":1 \ |
---|
| 796 | -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS $MPI_FLAGS":1 \ |
---|
| 797 | -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS $OMP_FLAGS":1 \ |
---|
[3076] | 798 | -e s:"%ARFLAGS.*.$":"%ARFLAGS $ARFLAGS":1 \ |
---|
[3056] | 799 | -e s@"%BASE_LD.*.$"@"%BASE_LD -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \ |
---|
| 800 | -e s:"%MPI_LD.*.$":"%MPI_LD $MPI_LD":1 \ |
---|
| 801 | -e s:"%OMP_LD.*.$":"%OMP_LD $OMP_LD":1 \ |
---|
| 802 | arch-local.fcm > tmp.fcm |
---|
| 803 | mv tmp.fcm arch-local.fcm |
---|
| 804 | cd ../ |
---|
| 805 | fi |
---|
| 806 | rm -f compile.sh |
---|
| 807 | if [ ${hostname:0:5} = ada33 ] ; then echo "module load intel/2013.0" > compile.sh ; fi |
---|
| 808 | echo resol=${grid_resolution} >> compile.sh |
---|
| 809 | echo ./$makelmdz $OPT_MAKELMDZ -rrtm true $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh |
---|
| 810 | chmod +x ./compile.sh ; ./compile.sh |
---|
[1588] | 811 | |
---|
[3056] | 812 | echo "Compilation finished" |
---|
| 813 | |
---|
| 814 | fi # of if [ $parallel != "none" ] |
---|
[3044] | 815 | |
---|
| 816 | echo LLLLLLLLLLLLLLLLLLLLLLLLLLL |
---|
| 817 | if [ "$gfortran" = "gfortran44" ] ; then |
---|
| 818 | echo Your gfortran compiler was too old so that the model was automatically |
---|
| 819 | echo compiled with gfortran44 instead. It can not be used in parallel mode. |
---|
| 820 | echo You can change the compiler at the begining of the install.sh |
---|
| 821 | echo script and reinstall. |
---|
| 822 | fi |
---|
| 823 | |
---|
[1588] | 824 | ################################################################## |
---|
[3044] | 825 | # Verification du succes de la compilation |
---|
[1588] | 826 | ################################################################## |
---|
[3044] | 827 | |
---|
| 828 | # Recherche de l'executable dont le nom a change au fil du temps ... |
---|
| 829 | gcm="" |
---|
| 830 | for exe in gcm.e bin/gcm_${grid_resolution}_phylmd_seq_orch.e bin/gcm_${grid_resolution}_phylmd_seq.e bin/gcm_${grid_resolution}_phylmd_para_mem_orch.e ; do |
---|
| 831 | if [ -f $exe ] ; then gcm=$exe ; fi |
---|
| 832 | done |
---|
| 833 | |
---|
| 834 | if [ "$gcm" = "" ] ; then |
---|
| 835 | echo 'Compilation failed !!' |
---|
[3056] | 836 | # Ehouarn : temporary, do not exit and let job finish (to set up bench case) |
---|
| 837 | #exit |
---|
| 838 | set +e |
---|
[3044] | 839 | else |
---|
| 840 | echo '##########################################################' |
---|
| 841 | echo 'Compilation successfull !! ' |
---|
| 842 | echo '##########################################################' |
---|
| 843 | echo The executable is $gcm |
---|
[1588] | 844 | fi |
---|
| 845 | |
---|
[3044] | 846 | ################################################################## |
---|
| 847 | # Below, we run a benchmark test (if bench=0) |
---|
| 848 | ################################################################## |
---|
| 849 | |
---|
| 850 | if [ $bench != 0 ] ; then |
---|
| 851 | |
---|
[1588] | 852 | echo '##########################################################' |
---|
[1731] | 853 | echo ' Running a test run ' |
---|
[1588] | 854 | echo '##########################################################' |
---|
| 855 | |
---|
[2030] | 856 | \rm -rf BENCH${grid_resolution} |
---|
[1588] | 857 | bench=bench_lmdz_${grid_resolution} |
---|
[2030] | 858 | echo install.sh avant_chargement_bench `date` |
---|
[3044] | 859 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz |
---|
[3076] | 860 | myget 3DBenchs/$bench.tar.gz |
---|
[3044] | 861 | echo install.sh after bench download `date` |
---|
| 862 | tar xvf $bench.tar.gz |
---|
[1588] | 863 | |
---|
[3056] | 864 | if [ "$with_xios" = "y" ] ; then |
---|
| 865 | cd BENCH${grid_resolution} |
---|
| 866 | cp ../DefLists/iodef.xml . |
---|
| 867 | cp ../DefLists/context_lmdz.xml . |
---|
| 868 | cp ../DefLists/field_def_lmdz.xml . |
---|
| 869 | cp ../DefLists/file_def_hist*xml . |
---|
| 870 | # adapt iodef.xml to use attached mode |
---|
| 871 | sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp |
---|
| 872 | \mv -f tmp iodef.xml |
---|
| 873 | # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE. |
---|
| 874 | # except for histday |
---|
| 875 | for histfile in file_def_hist*xml |
---|
| 876 | do |
---|
| 877 | if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then |
---|
| 878 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile |
---|
| 879 | else |
---|
| 880 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile |
---|
| 881 | fi |
---|
| 882 | done |
---|
| 883 | # and add option "ok_all_xml=y" in config.def |
---|
| 884 | echo "### XIOS outputs" >> config.def |
---|
| 885 | echo 'ok_all_xml=.true.' >> config.def |
---|
| 886 | cd .. |
---|
| 887 | fi |
---|
| 888 | |
---|
[3044] | 889 | cp $gcm BENCH${grid_resolution}/gcm.e |
---|
[1588] | 890 | |
---|
| 891 | cd BENCH${grid_resolution} |
---|
[3044] | 892 | # On cree le fichier bench.sh au besoin |
---|
| 893 | # Dans le cas 48x36x39 le bench.sh existe deja en parallele |
---|
[1588] | 894 | |
---|
[3044] | 895 | if [ "$grid_resolution" = "48x36x39" ] ; then |
---|
| 896 | echo On ne touche pas au bench.sh |
---|
| 897 | # But we have to adapt "run_local.sh" for $mpirun |
---|
| 898 | sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp |
---|
| 899 | mv -f tmp run_local.sh |
---|
| 900 | chmod u=rwx run_local.sh |
---|
| 901 | elif [ "${parallel:0:3}" = "mpi" ] ; then |
---|
| 902 | # Lancement avec deux procs mpi et 2 openMP |
---|
| 903 | echo "export OMP_STACKSIZE=800M" > bench.sh |
---|
| 904 | if [ "${parallel:4:3}" = "omp" ] ; then |
---|
| 905 | echo "export OMP_NUM_THREADS=2" >> bench.sh |
---|
| 906 | fi |
---|
| 907 | echo "ulimit -s unlimited" >> bench.sh |
---|
| 908 | echo "$mpirun -np 2 gcm.e > listing 2>&1" >> bench.sh |
---|
| 909 | else |
---|
| 910 | echo "./gcm.e > listing 2>&1" > bench.sh |
---|
| 911 | fi |
---|
| 912 | echo EXECUTION DU BENCH |
---|
[3076] | 913 | set +e |
---|
[3044] | 914 | date ; ./bench.sh > out.bench 2>&1 ; date |
---|
[3076] | 915 | set -e |
---|
[3044] | 916 | tail listing |
---|
[2030] | 917 | |
---|
[1588] | 918 | |
---|
| 919 | echo '##########################################################' |
---|
[1708] | 920 | echo 'Simulation finished in' `pwd` |
---|
[3044] | 921 | echo 'You have compiled with:' |
---|
| 922 | cat ../compile.sh |
---|
| 923 | if [ $parallel = "none" ] ; then |
---|
| 924 | echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e' |
---|
| 925 | echo 'or ./bench.sh' |
---|
| 926 | else |
---|
| 927 | echo 'You may re-run it with : ' |
---|
| 928 | echo 'cd ' `pwd` '; ./bench.sh' |
---|
| 929 | echo 'ulimit -s unlimited' |
---|
| 930 | echo 'export OMP_NUM_THREADS=2' |
---|
| 931 | echo 'export OMP_STACKSIZE=800M' |
---|
| 932 | echo "$mpirun -np 2 gcm.e " |
---|
| 933 | fi |
---|
[1588] | 934 | echo '##########################################################' |
---|
[2030] | 935 | |
---|
| 936 | fi |
---|
[3044] | 937 | |
---|
| 938 | |
---|
| 939 | ################################################################# |
---|
| 940 | # Installation eventuelle du 1D |
---|
| 941 | ################################################################# |
---|
| 942 | |
---|
| 943 | if [ $SCM = 1 ] ; then |
---|
| 944 | cd $MODEL |
---|
| 945 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/1D.tar.gz |
---|
[3076] | 946 | myget 1D/1D.tar.gz |
---|
[3044] | 947 | tar xvf 1D.tar.gz |
---|
| 948 | cd 1D |
---|
| 949 | ./run.sh |
---|
| 950 | fi |
---|