| 1 | #!/bin/bash |
|---|
| 2 | |
|---|
| 3 | ########################################################################### |
|---|
| 4 | # Author : Frédéric Hourdin/LMD/hourdin@lmd.jussieu.fr |
|---|
| 5 | # Usage : install.sh |
|---|
| 6 | # |
|---|
| 7 | # bash installation script of the LMDZ model on a Linux PC. |
|---|
| 8 | # the model is downloaded in the following direcory tree |
|---|
| 9 | # $MODEL/modipsl/modeles/... |
|---|
| 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. |
|---|
| 15 | # |
|---|
| 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. |
|---|
| 19 | # |
|---|
| 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. |
|---|
| 23 | # |
|---|
| 24 | # Prerequisites : g95/pgf90/gfortran, ksh, wget , gunzip, tar, ... |
|---|
| 25 | # |
|---|
| 26 | # Modif 18/11/2011 |
|---|
| 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. |
|---|
| 31 | # |
|---|
| 32 | ########################################################################### |
|---|
| 33 | |
|---|
| 34 | echo install.sh DEBUT `date` |
|---|
| 35 | |
|---|
| 36 | set -e |
|---|
| 37 | |
|---|
| 38 | echo '################################################################' |
|---|
| 39 | echo Choice of installation options |
|---|
| 40 | echo '################################################################' |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | #real=r4 |
|---|
| 44 | real=r8 |
|---|
| 45 | |
|---|
| 46 | # WARNING !!!! For versions before october 2009, use |
|---|
| 47 | # install.v2.sh instead of install.sh |
|---|
| 48 | |
|---|
| 49 | version=20130716.trunk |
|---|
| 50 | version=testing |
|---|
| 51 | compilo=gfortran # compilo=pgf90 or g95 or gfortran or ifort sur PC linux |
|---|
| 52 | |
|---|
| 53 | #Chemin pour placer le modele |
|---|
| 54 | MODEL=./LMDZ$version |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | getlmdzor=1 |
|---|
| 58 | netcdf=1 # 1 for automatic installation |
|---|
| 59 | # 0 for no installation |
|---|
| 60 | # /.../../netcdf-4.0.1 if wanting to link with an already |
|---|
| 61 | # compiled netcdf library (implies to check option compatibility) |
|---|
| 62 | check_linux=1 |
|---|
| 63 | ioipsl=1 |
|---|
| 64 | veget=1 |
|---|
| 65 | bench=1 |
|---|
| 66 | pclinux=1 |
|---|
| 67 | |
|---|
| 68 | # choose the resolution for the bench runs |
|---|
| 69 | # grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE) |
|---|
| 70 | # 96x71x19 standard configuration |
|---|
| 71 | grid_resolution=48x36x19 |
|---|
| 72 | |
|---|
| 73 | ## compile_with_fcm=1 : use makelmdz_fcm, possible a of version 20111103.trunk (LMDZ5/trunk rev 1578) |
|---|
| 74 | ## compile_with_fcm=0 : use makelmdz |
|---|
| 75 | compile_with_fcm=0 |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | ##################################################################### |
|---|
| 79 | # Test for old gfortran compilers |
|---|
| 80 | # If the compiler is too old (older than 4.3.x) we test if the |
|---|
| 81 | # temporary gfortran44 patch is available on the computer in which |
|---|
| 82 | # case the compiler is changed from gfortran to gfortran44 |
|---|
| 83 | # Must be aware than parallelism can not be activated in this case |
|---|
| 84 | ##################################################################### |
|---|
| 85 | |
|---|
| 86 | if [ $compilo = gfortran ] ; then |
|---|
| 87 | gfortran=gfortran |
|---|
| 88 | gfortranv=`gfortran --version | \ |
|---|
| 89 | head -1 | awk ' { print $NF } ' | awk -F. ' { print $1 * 10 + $2 } '` |
|---|
| 90 | if [ $gfortranv -le 43 ] ; then |
|---|
| 91 | echo ERROR : Your gfortran compiler is too old |
|---|
| 92 | echo 'Please choose a new one (g95, ifort) and change the line' |
|---|
| 93 | echo compilo=xxx |
|---|
| 94 | echo in the install.sh script and rerun it |
|---|
| 95 | if [ `which gfortran44 | wc -w` -ne 0 ] ; then |
|---|
| 96 | gfortran=gfortran44 |
|---|
| 97 | else |
|---|
| 98 | echo gfotran trop vieux ; exit |
|---|
| 99 | fi |
|---|
| 100 | fi |
|---|
| 101 | compilo=$gfortran |
|---|
| 102 | fi |
|---|
| 103 | ##################################################################### |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | OPTPREC="" |
|---|
| 108 | echo '################################################################' |
|---|
| 109 | echo Choix des options de compilation |
|---|
| 110 | echo '################################################################' |
|---|
| 111 | |
|---|
| 112 | OPTIMNC=$OPTIM |
|---|
| 113 | export FC=$compilo |
|---|
| 114 | export F90=$compilo |
|---|
| 115 | export F77=$compilo |
|---|
| 116 | export CPPFLAGS= |
|---|
| 117 | BASE_LD= |
|---|
| 118 | if [ $compilo = g95 ] ; then |
|---|
| 119 | # Set the appropriate compilation options |
|---|
| 120 | OPTIM='-i4 -O3' |
|---|
| 121 | OPTDEB="-g -O0 -Wall -ftrace=full -fbounds-check -freal=nan" |
|---|
| 122 | OPTDEV="-g -O1 -Wall" |
|---|
| 123 | fmod='fmod=' |
|---|
| 124 | BASE_LD="" |
|---|
| 125 | if [ $real = r8 ] ; then OPTPREC="-r8 -DNC_DOUBLE" ; fi |
|---|
| 126 | export F90FLAGS=" -cpp -ffree-form $OPTIMNC" |
|---|
| 127 | export FFLAGS=" -cpp $OPTIMNC" |
|---|
| 128 | export CPPFLAGS=-Df2cFortran |
|---|
| 129 | export CC=gcc |
|---|
| 130 | export CXX=g++ |
|---|
| 131 | elif [ $compilo = $gfortran ] ; then |
|---|
| 132 | OPTIM='-O3' |
|---|
| 133 | OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all" |
|---|
| 134 | OPTDEV="-Wall -fbounds-check" |
|---|
| 135 | fmod='I ' |
|---|
| 136 | if [ $real = r8 ] ; then OPTPREC="-fdefault-real-8 -DNC_DOUBLE" ; fi |
|---|
| 137 | export F90FLAGS=" -ffree-form $OPTIMNC" |
|---|
| 138 | export FFLAGS=" $OPTIMNC" |
|---|
| 139 | export CC=gcc |
|---|
| 140 | export CXX=g++ |
|---|
| 141 | elif [ $compilo = mpif90 ] ; then |
|---|
| 142 | OPTIM='-O3' |
|---|
| 143 | OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all" |
|---|
| 144 | OPTDEV="-Wall -fbounds-check" |
|---|
| 145 | BASE_LD="-lblas" |
|---|
| 146 | fmod='I ' |
|---|
| 147 | if [ $real = r8 ] ; then OPTPREC="-fdefault-real-8 -DNC_DOUBLE -fcray-pointer" ; fi |
|---|
| 148 | export F90FLAGS=" -ffree-form $OPTIMNC" |
|---|
| 149 | export FFLAGS=" $OPTIMNC" |
|---|
| 150 | export CC=gcc |
|---|
| 151 | export CXX=g++ |
|---|
| 152 | elif [ $compilo = pgf90 ] ; then |
|---|
| 153 | OPTIM='-O2 -Munroll -Mnoframe -Mautoinline -Mcache_align' |
|---|
| 154 | fmod='module ' |
|---|
| 155 | if [ $real = r8 ] ; then OPTPREC="-r8 -DNC_DOUBLE" ; fi |
|---|
| 156 | export CPPFLAGS="-DNDEBUG -DpgiFortran" |
|---|
| 157 | export CC=pgcc |
|---|
| 158 | export CFLAGS="-Msignextend" |
|---|
| 159 | export CXX=pgCC |
|---|
| 160 | export CXXFLAGS="-Msignextend" |
|---|
| 161 | export FFLAGS="$OPTIMNC" |
|---|
| 162 | export F90FLAGS="$OPTIMNC" |
|---|
| 163 | compile_with_fcm=1 |
|---|
| 164 | elif [ $compilo = ifort ] ; then |
|---|
| 165 | OPTIM="-O2 -fp-model strict -ip -align all " |
|---|
| 166 | OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check" |
|---|
| 167 | OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check" |
|---|
| 168 | fmod='module ' |
|---|
| 169 | if [ $real = r8 ] ; then OPTPREC="-real-size 64 -DNC_DOUBLE" ; fi |
|---|
| 170 | export CPP="icc -E" |
|---|
| 171 | export FFLAGS="-O2 -ip -fpic -mcmodel=large" |
|---|
| 172 | export FCFLAGS="-O2 -ip -fpic -mcmodel=large" |
|---|
| 173 | export CC=icc |
|---|
| 174 | export CFLAGS="-O2 -ip -fpic -mcmodel=large" |
|---|
| 175 | export CXX=icpc |
|---|
| 176 | export CXXFLAGS="-O2 -ip -fpic -mcmodel=large" |
|---|
| 177 | compile_with_fcm=1 |
|---|
| 178 | else |
|---|
| 179 | echo unexpected compiler $compilo ; exit |
|---|
| 180 | fi |
|---|
| 181 | |
|---|
| 182 | OPTIMGCM="$OPTIM $OPTPREC" |
|---|
| 183 | |
|---|
| 184 | hostname=`hostname` |
|---|
| 185 | |
|---|
| 186 | ########################################################################## |
|---|
| 187 | # If installing on know machines such as IBM x3750 (Ada) |
|---|
| 188 | # at IDRIS, don't check for available software and don"t install netcdf |
|---|
| 189 | if [ ${hostname:0:5} = ada33 ] ; then |
|---|
| 190 | netcdf=0 # no need to recompile netcdf, alreday available |
|---|
| 191 | check_linux=0 |
|---|
| 192 | pclinux=0 |
|---|
| 193 | ioipsl=0 # no need to recompile ioipsl, already available |
|---|
| 194 | #netcdf="/smplocal/pub/NetCDF/4.1.3" |
|---|
| 195 | compilo="ifort" |
|---|
| 196 | fmod='module ' |
|---|
| 197 | if [ $real = r8 ] ; then OPTPREC="-real-size 64 -DNC_DOUBLE" ; fi |
|---|
| 198 | OPTIM="-O2 -fp-model strict -ip -axAVX,SSE4.2 -align all " |
|---|
| 199 | OPTIMGCM="$OPTIM $OPTPREC" |
|---|
| 200 | fi |
|---|
| 201 | ########################################################################## |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | mkdir -p $MODEL |
|---|
| 205 | echo $MODEL |
|---|
| 206 | MODEL=`( cd $MODEL ; pwd )` # to get absolute path, if necessary |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | # Option -fendian=big is only to be used with ARPEGE1D. |
|---|
| 211 | # The -r8 should probably be avoided if running on 32 bit machines |
|---|
| 212 | # Option r8 is not mandatory and generates larger executables. |
|---|
| 213 | # It is however mandatory if using ARPEGE1D |
|---|
| 214 | # Better optimization options might be a better choice (e.g. -O3) |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | echo '################################################################' |
|---|
| 218 | if [ "$check_linux" = 1 ] ; then |
|---|
| 219 | echo Check if required software is available |
|---|
| 220 | echo '################################################################' |
|---|
| 221 | |
|---|
| 222 | #### Ehouarn: test if ksh and/or bash are available |
|---|
| 223 | use_shell="ksh" # default: use ksh |
|---|
| 224 | if [ "`which ksh`" = "" ] ; then |
|---|
| 225 | echo "no ksh ... we will use bash" |
|---|
| 226 | use_shell="bash" |
|---|
| 227 | if [ "`which bash`" = "" ] ; then |
|---|
| 228 | echo "ksh (or bash) needed!! Install it!" |
|---|
| 229 | fi |
|---|
| 230 | fi |
|---|
| 231 | |
|---|
| 232 | |
|---|
| 233 | for logiciel in csh wget tar gzip make $compilo gcc ; do |
|---|
| 234 | if [ "`which $logiciel`" = "" ] ; then |
|---|
| 235 | echo You must first install $logiciel on your system |
|---|
| 236 | exit |
|---|
| 237 | fi |
|---|
| 238 | done |
|---|
| 239 | |
|---|
| 240 | if [ $pclinux = 1 ] ; then |
|---|
| 241 | cd $MODEL |
|---|
| 242 | cat <<eod > tt.f90 |
|---|
| 243 | print*,'coucou' |
|---|
| 244 | end |
|---|
| 245 | eod |
|---|
| 246 | $compilo tt.f90 -o a.out |
|---|
| 247 | ./a.out >| tt |
|---|
| 248 | if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then |
|---|
| 249 | echo problem installing with compiler $compilo ; exit ; fi |
|---|
| 250 | \rm tt a.out tt.f90 |
|---|
| 251 | fi |
|---|
| 252 | fi |
|---|
| 253 | |
|---|
| 254 | ########################################################################### |
|---|
| 255 | if [ $getlmdzor = 1 ] ; then |
|---|
| 256 | echo '##########################################################' |
|---|
| 257 | echo Download a slightly modified version of LMDZ |
|---|
| 258 | echo '##########################################################' |
|---|
| 259 | cd $MODEL |
|---|
| 260 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/modipsl.$version.tar.gz |
|---|
| 261 | echo install.sh wget_OK `date` |
|---|
| 262 | gunzip modipsl.$version.tar.gz |
|---|
| 263 | tar xvf modipsl.$version.tar |
|---|
| 264 | \rm modipsl.$version.tar |
|---|
| 265 | |
|---|
| 266 | # We download LMDZ and make some modifications to make it |
|---|
| 267 | #compatible with $compilo |
|---|
| 268 | # and we use an old stable but robust and well tested version of ORCHIDEE |
|---|
| 269 | # That version of ORCHIDEE can be obtained using |
|---|
| 270 | # wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/getlmdzor.x |
|---|
| 271 | fi |
|---|
| 272 | |
|---|
| 273 | echo OK1 |
|---|
| 274 | |
|---|
| 275 | if [ $netcdf = 1 ] ; then |
|---|
| 276 | echo '##########################################################' |
|---|
| 277 | echo Compiling the Netcdf library |
|---|
| 278 | echo '##########################################################' |
|---|
| 279 | cd $MODEL |
|---|
| 280 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/netcdf-4.0.1.tar.gz |
|---|
| 281 | gunzip netcdf-4.0.1.tar.gz |
|---|
| 282 | tar xvf netcdf-4.0.1.tar |
|---|
| 283 | \rm -f netcdf-4.0.1.tar |
|---|
| 284 | |
|---|
| 285 | cd netcdf-4.0.1 |
|---|
| 286 | |
|---|
| 287 | sed -e 's/gfortran/'$gfortran'/g' configure >| tmp ; mv -f tmp configure ; chmod +x configure |
|---|
| 288 | localdir=`pwd -P` |
|---|
| 289 | ./configure --prefix=$localdir |
|---|
| 290 | sed -e 's/gfortran/'$gfortran'/g' Makefile >| tmp ; mv -f tmp Makefile |
|---|
| 291 | make check |
|---|
| 292 | make install |
|---|
| 293 | echo install.sh netcdf_OK `date` |
|---|
| 294 | fi # of if [ $netcdf = 1 ] |
|---|
| 295 | |
|---|
| 296 | |
|---|
| 297 | #======================================================================================= |
|---|
| 298 | echo OK2 ioipsl=$ioipsl |
|---|
| 299 | echo '##########################################################' |
|---|
| 300 | echo 'Installing MODIPSL, the installation package manager for the ' |
|---|
| 301 | echo 'IPSL models and tools' |
|---|
| 302 | echo '##########################################################' |
|---|
| 303 | |
|---|
| 304 | if [ $netcdf = 0 -o $netcdf = 1 ] ; then |
|---|
| 305 | ncdfdir=$MODEL/netcdf-4.0.1 |
|---|
| 306 | else |
|---|
| 307 | ncdfdir=$netcdf |
|---|
| 308 | fi |
|---|
| 309 | |
|---|
| 310 | if [ $ioipsl = 1 ] ; then |
|---|
| 311 | cd $MODEL/modipsl |
|---|
| 312 | \rm -rf lib/* |
|---|
| 313 | |
|---|
| 314 | cd util |
|---|
| 315 | |
|---|
| 316 | cp AA_make.gdef AA_make.orig |
|---|
| 317 | F_C="$compilo -c " ; if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then F_C="$compilo -c -cpp " ; fi |
|---|
| 318 | sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp |
|---|
| 319 | sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c:F_C = $F_C": \ |
|---|
| 320 | -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ |
|---|
| 321 | -e 's:g95.*.NCDF_INC.*.$:g95 NCDF_INC= '"$ncdfdir"'/include:' \ |
|---|
| 322 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdf:' \ |
|---|
| 323 | -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \ |
|---|
| 324 | -e 's:#-Q- g95 M_K = gmake:#-Q- g95 M_K = make:' \ |
|---|
| 325 | tmp >| AA_make.gdef |
|---|
| 326 | |
|---|
| 327 | |
|---|
| 328 | if [ "$use_shell" = "ksh" ] ; then |
|---|
| 329 | if [ "$pclinux" = 1 ] ; then |
|---|
| 330 | ./ins_make -t g95 # We use lines for g95 even for the other compilers |
|---|
| 331 | fi |
|---|
| 332 | else # bash |
|---|
| 333 | sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash |
|---|
| 334 | chmod u=rwx ins_make.bash |
|---|
| 335 | if [ "$pclinux" = 1 ] ; then |
|---|
| 336 | ./ins_make.bash -t g95 # We use lines for g95 even for the other compilers |
|---|
| 337 | else |
|---|
| 338 | ./ins_make.bash |
|---|
| 339 | fi |
|---|
| 340 | fi # of if [ "$use_shell" = "ksh" ] |
|---|
| 341 | |
|---|
| 342 | #======================================================================================= |
|---|
| 343 | echo '##########################################################' |
|---|
| 344 | echo 'Compiling IOIPSL, the interface library with Netcdf' |
|---|
| 345 | echo '##########################################################' |
|---|
| 346 | |
|---|
| 347 | cd $MODEL/modipsl/modeles/IOIPSL/src |
|---|
| 348 | if [ "$use_shell" = "bash" ] ; then |
|---|
| 349 | cp Makefile Makefile.ksh |
|---|
| 350 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
|---|
| 351 | fi |
|---|
| 352 | if [ "$pclinux" = 1 ] ; then |
|---|
| 353 | # Build IOIPSL modules and library |
|---|
| 354 | if [ $compilo = g95 ] ; then |
|---|
| 355 | cp restcom.f90 restcom.f90.orig |
|---|
| 356 | sed -e 's:cmode=or(NF90_NOCLOBBER,NF90_64BIT_OFFSET):cmode=NF90_NOCLOBBER:' restcom.f90.orig > restcom.f90 |
|---|
| 357 | fi |
|---|
| 358 | make clean |
|---|
| 359 | make |
|---|
| 360 | if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then # copy module files to lib |
|---|
| 361 | cp -f *.mod ../../../lib |
|---|
| 362 | fi |
|---|
| 363 | # Build IOIPSL tools (ie: "rebuild", if present) |
|---|
| 364 | if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then |
|---|
| 365 | cd $MODEL/modipsl/modeles/IOIPSL/tools |
|---|
| 366 | # adapt Makefile & rebuild script if in bash |
|---|
| 367 | if [ "$use_shell" = "bash" ] ; then |
|---|
| 368 | cp Makefile Makefile.ksh |
|---|
| 369 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
|---|
| 370 | cp rebuild rebuild.ksh |
|---|
| 371 | sed -e 's:/bin/ksh:/bin/bash:g' \ |
|---|
| 372 | -e 's:print -u2:echo:g' \ |
|---|
| 373 | -e 's:print:echo:g' rebuild.ksh > rebuild |
|---|
| 374 | fi |
|---|
| 375 | make clean |
|---|
| 376 | make |
|---|
| 377 | fi |
|---|
| 378 | fi # of if [ "$pclinux" = 1 ] |
|---|
| 379 | |
|---|
| 380 | else # of if [ $ioipsl = 1 ] |
|---|
| 381 | if [ ${hostname:0:5} = ada33 ] ; then |
|---|
| 382 | cd $MODEL/modipsl |
|---|
| 383 | cd util |
|---|
| 384 | |
|---|
| 385 | cp AA_make.gdef AA_make.orig |
|---|
| 386 | sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp |
|---|
| 387 | sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c:F_C = $compilo -c": \ |
|---|
| 388 | -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ |
|---|
| 389 | -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:' \ |
|---|
| 390 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L/smplocal/pub/NetCDF/4.1.3/lib -lnetcdff -lnetcdf:' \ |
|---|
| 391 | -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \ |
|---|
| 392 | -e 's:#-Q- g95 M_K = gmake:#-Q- g95 M_K = make:' \ |
|---|
| 393 | tmp >| AA_make.gdef |
|---|
| 394 | |
|---|
| 395 | ./ins_make -t g95 # We use lines for g95 even for the other compilers |
|---|
| 396 | |
|---|
| 397 | # on Ada, IOIPSL is already installed in ~rpsl035/IOIPSL_PLUS |
|---|
| 398 | # so link it to current settings |
|---|
| 399 | cd $MODEL/modipsl/modeles/ |
|---|
| 400 | \rm -r -f IOIPSL |
|---|
| 401 | ln -s ~rpsl035/IOIPSL_PLUS IOIPSL |
|---|
| 402 | cd .. |
|---|
| 403 | ln -s ~rpsl035/IOIPSL_PLUS/modipsl/bin/* bin/ |
|---|
| 404 | ln -s ~rpsl035/IOIPSL_PLUS/modipsl/lib/* lib/ |
|---|
| 405 | |
|---|
| 406 | fi # of if [ ${hostname:0:5} = ada33 ] |
|---|
| 407 | echo install.sh ioipsl_OK `date` |
|---|
| 408 | fi # of if [ $ioipsl = 1 ] |
|---|
| 409 | |
|---|
| 410 | |
|---|
| 411 | #============================================================================ |
|---|
| 412 | veget_version=false |
|---|
| 413 | if [ "$veget" = 1 ] ; then |
|---|
| 414 | echo '########################################################' |
|---|
| 415 | echo 'Compiling ORCHIDEE, the continental surfaces model ' |
|---|
| 416 | echo '########################################################' |
|---|
| 417 | cd $MODEL/modipsl/modeles/ORCHIDEE |
|---|
| 418 | echo OKpwd ; pwd |
|---|
| 419 | if [ -d src_parallel ] ; then |
|---|
| 420 | liste_src="parallel parameters global stomate sechiba driver" |
|---|
| 421 | veget_version=orchidee2.0 |
|---|
| 422 | else |
|---|
| 423 | # Obsolete, for ORCHIDEE_beton only |
|---|
| 424 | liste_src="parameters stomate sechiba " |
|---|
| 425 | # A trick to compile ORCHIDEE depending on if we are using real*4 or real*8 |
|---|
| 426 | cd src_parameters ; \cp reqdprec.$real reqdprec.f90 ; cd .. |
|---|
| 427 | veget_version=orchidee1.9 |
|---|
| 428 | fi |
|---|
| 429 | echo liste_strc $liste_src |
|---|
| 430 | |
|---|
| 431 | for d in $liste_src ; do src_d=src_$d |
|---|
| 432 | echo src_d $src_d |
|---|
| 433 | echo ls ; ls |
|---|
| 434 | if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi |
|---|
| 435 | cd $src_d ; \rm -f *.mod make ; make clean |
|---|
| 436 | make ; if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi |
|---|
| 437 | cd .. |
|---|
| 438 | done |
|---|
| 439 | echo install.sh orchidee_OK `date` |
|---|
| 440 | fi # of if [ "$veget" = 1 ] |
|---|
| 441 | |
|---|
| 442 | |
|---|
| 443 | #============================================================================ |
|---|
| 444 | # Ehouarn: it may be directory LMDZ4 or LMDZ5 depending on tar file... |
|---|
| 445 | if [ -d $MODEL/modipsl/modeles/LMDZ[45] ] ; then |
|---|
| 446 | echo '##########################################################' |
|---|
| 447 | echo 'Compiling LMDZ' |
|---|
| 448 | echo '##########################################################' |
|---|
| 449 | cd $MODEL/modipsl/modeles/LMDZ[45] |
|---|
| 450 | else |
|---|
| 451 | echo "ERROR: No LMDZ4 (or LMDZ5) directory !!!" |
|---|
| 452 | exit |
|---|
| 453 | fi |
|---|
| 454 | |
|---|
| 455 | ########################################################### |
|---|
| 456 | # For those who want to use fcm to compile via : |
|---|
| 457 | # makelmdz_fcm -arch local ..... |
|---|
| 458 | ############################################################ |
|---|
| 459 | |
|---|
| 460 | if [ "$pclinux" = "1" ] ; then |
|---|
| 461 | |
|---|
| 462 | # create local 'arch' files (if on Linux PC): |
|---|
| 463 | cd arch |
|---|
| 464 | # arch-local.path file |
|---|
| 465 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdf\"" > arch-local.path |
|---|
| 466 | echo OK3 |
|---|
| 467 | echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path |
|---|
| 468 | echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
|---|
| 469 | echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
|---|
| 470 | echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
|---|
| 471 | echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
|---|
| 472 | # arch-local.fcm file (adapted from arch-linux-32bit.fcm) |
|---|
| 473 | |
|---|
| 474 | if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi |
|---|
| 475 | sed -e s:"%COMPILER .*.$":"%COMPILER $compilo":1 \ |
|---|
| 476 | -e s:"%LINK .*.$":"%LINK $compilo":1 \ |
|---|
| 477 | -e s:"%PROD_FFLAGS .*.$":"%PROD_FFLAGS $OPTIM":1 \ |
|---|
| 478 | -e s:"%DEV_FFLAGS .*.$":"%DEV_FFLAGS $OPTDEV":1 \ |
|---|
| 479 | -e s:"%DEBUG_FFLAGS .*.$":"%DEBUG_FFLAGS $OPTDEB":1 \ |
|---|
| 480 | -e s:"%BASE_FFLAGS .*.$":"%BASE_FFLAGS $OPTPREC":1 \ |
|---|
| 481 | arch-linux-32bit.fcm > arch-local.fcm |
|---|
| 482 | |
|---|
| 483 | cd .. |
|---|
| 484 | ### Adapt "bld.cfg" (add the shell): |
|---|
| 485 | whereisthatshell=$(which ${use_shell}) |
|---|
| 486 | echo "bld::tool::SHELL $whereisthatshell" >> bld.cfg |
|---|
| 487 | |
|---|
| 488 | fi # of if [ "$pclinux" = 1 ] |
|---|
| 489 | |
|---|
| 490 | |
|---|
| 491 | cd $MODEL/modipsl/modeles/LMDZ? |
|---|
| 492 | |
|---|
| 493 | ################################################################## |
|---|
| 494 | # Compile LMDZ |
|---|
| 495 | ################################################################## |
|---|
| 496 | echo install.sh avant_compilation `date` |
|---|
| 497 | if [ $compile_with_fcm = 1 ] ; then makelmdz=makelmdz_fcm ; else makelmdz=makelmdz ; fi |
|---|
| 498 | |
|---|
| 499 | ./$makelmdz -d ${grid_resolution} -v $veget_version gcm |
|---|
| 500 | echo install.sh apres_compilation `date` |
|---|
| 501 | |
|---|
| 502 | |
|---|
| 503 | if [ -f gcm.e ] || [ -f bin/gcm_${grid_resolution}_phylmd_seq_orch.e ] || [ -f bin/gcm_${grid_resolution}_phylmd_seq.e ] ; then |
|---|
| 504 | echo '##########################################################' |
|---|
| 505 | echo 'Compilation successfull !! ' |
|---|
| 506 | echo '##########################################################' |
|---|
| 507 | else |
|---|
| 508 | echo 'Compilation failed !!' |
|---|
| 509 | exit |
|---|
| 510 | fi |
|---|
| 511 | |
|---|
| 512 | ################################################################## |
|---|
| 513 | # Below, we run a benchmark test (if bench=0) |
|---|
| 514 | ################################################################## |
|---|
| 515 | if [ $bench = 0 ] ; then |
|---|
| 516 | exit |
|---|
| 517 | fi |
|---|
| 518 | |
|---|
| 519 | echo '##########################################################' |
|---|
| 520 | echo ' Running a test run ' |
|---|
| 521 | echo '##########################################################' |
|---|
| 522 | |
|---|
| 523 | \rm -rf BENCH${grid_resolution} |
|---|
| 524 | bench=bench_lmdz_${grid_resolution} |
|---|
| 525 | echo install.sh avant_chargement_bench `date` |
|---|
| 526 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/$bench.tar.gz |
|---|
| 527 | echo install.sh apres_chargement_bench `date` |
|---|
| 528 | gunzip $bench.tar.gz |
|---|
| 529 | tar xvf $bench.tar |
|---|
| 530 | |
|---|
| 531 | if [ -f gcm.e ] ; then |
|---|
| 532 | cp gcm.e BENCH${grid_resolution}/ |
|---|
| 533 | elif [ -f bin/gcm_${grid_resolution}_phylmd_seq_orch.e ] ; then |
|---|
| 534 | cp bin/gcm_${grid_resolution}_phylmd_seq_orch.e BENCH${grid_resolution}/gcm.e |
|---|
| 535 | elif [ -f bin/gcm_${grid_resolution}_phylmd_seq.e ] ; then |
|---|
| 536 | cp bin/gcm_${grid_resolution}_phylmd_seq.e BENCH${grid_resolution}/gcm.e |
|---|
| 537 | else |
|---|
| 538 | echo "No gcm.e found" |
|---|
| 539 | exit |
|---|
| 540 | fi |
|---|
| 541 | |
|---|
| 542 | |
|---|
| 543 | cd BENCH${grid_resolution} |
|---|
| 544 | ./bench.sh > bench.out 2>&1 |
|---|
| 545 | |
|---|
| 546 | |
|---|
| 547 | echo '##########################################################' |
|---|
| 548 | echo ' Bench results ' |
|---|
| 549 | echo '##########################################################' |
|---|
| 550 | |
|---|
| 551 | cat ./bench.out |
|---|
| 552 | echo install.sh FIN_du_BENCH `date` |
|---|
| 553 | |
|---|
| 554 | echo '##########################################################' |
|---|
| 555 | echo 'Simulation finished in' `pwd` |
|---|
| 556 | echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e' |
|---|
| 557 | echo 'or ./bench.sh' |
|---|
| 558 | echo '##########################################################' |
|---|
| 559 | |
|---|
| 560 | if [ "$gfortran" = "gfortran44" ] ; then |
|---|
| 561 | echo Your gfortran compiler was too old so that the model was automatically |
|---|
| 562 | echo compiled with gfortran44 instead. It can not be used in parallel mode. |
|---|
| 563 | echo You can change the compiler at the begining of the install.sh |
|---|
| 564 | echo script and reinstall. |
|---|
| 565 | fi |
|---|