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