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