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