[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 | |
---|
[1708] | 45 | #version=20110921.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) |
---|
| 82 | ## compile_with_fcm=0 : use makegcm |
---|
[1693] | 83 | compile_with_fcm=1 |
---|
[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 |
---|
| 104 | OPTIM="-O2 -ip -mkl=sequential -align all -static " |
---|
| 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 | ########################################################################## |
---|
[1708] | 118 | # If installing on know machines such as NEC Brodie |
---|
| 119 | # at IDRIS, don't check for available software and don"t install netcdf |
---|
[1588] | 120 | if [ $hostname = brodie ] ; then |
---|
| 121 | netcdf=0 |
---|
| 122 | check_linux=0 |
---|
| 123 | pclinux=0 |
---|
| 124 | fi |
---|
| 125 | ########################################################################## |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | mkdir -p $MODEL |
---|
| 129 | echo $MODEL |
---|
[1708] | 130 | MODEL=`( cd $MODEL ; pwd )` # to get absolute path, if necessary |
---|
[1588] | 131 | |
---|
| 132 | |
---|
| 133 | |
---|
[1708] | 134 | # Option -fendian=big is only to be used with ARPEGE1D. |
---|
| 135 | # The -r8 should probably be avoided if running on 32 bit machines |
---|
| 136 | # Option r8 is not mandatory and generates larger executables. |
---|
| 137 | # It is however mandatory if using ARPEGE1D |
---|
| 138 | # Better optimization options might be a better choice (e.g. -O3) |
---|
[1588] | 139 | |
---|
| 140 | |
---|
| 141 | echo '################################################################' |
---|
| 142 | if [ "$check_linux" = 1 ] ; then |
---|
[1708] | 143 | echo Check if required software is available |
---|
[1588] | 144 | echo '################################################################' |
---|
| 145 | |
---|
| 146 | #### Ehouarn: test if ksh and/or bash are available |
---|
| 147 | use_shell="ksh" # default: use ksh |
---|
| 148 | if [ "`which ksh`" = "" ] ; then |
---|
[1708] | 149 | echo "no ksh ... we will use bash" |
---|
[1588] | 150 | use_shell="bash" |
---|
| 151 | if [ "`which bash`" = "" ] ; then |
---|
[1708] | 152 | echo "ksh (or bash) needed!! Install it!" |
---|
[1588] | 153 | fi |
---|
| 154 | fi |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | for logiciel in csh wget tar gzip make $compilo gcc ; do |
---|
| 158 | if [ "`which $logiciel`" = "" ] ; then |
---|
[1708] | 159 | echo You must first install $logiciel on your system |
---|
[1588] | 160 | exit |
---|
| 161 | fi |
---|
| 162 | done |
---|
| 163 | |
---|
| 164 | if [ $pclinux = 1 ] ; then |
---|
| 165 | cd $MODEL |
---|
| 166 | cat <<eod> tt.f90 |
---|
| 167 | print*,'coucou' |
---|
| 168 | end |
---|
| 169 | eod |
---|
[1708] | 170 | $compilo tt.f90 -o a.out |
---|
[1588] | 171 | ./a.out >| tt |
---|
| 172 | if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then |
---|
[1708] | 173 | echo problem installing with compiler $compilo ; exit ; fi |
---|
[1588] | 174 | \rm tt a.out tt.f90 |
---|
| 175 | fi |
---|
| 176 | fi |
---|
| 177 | |
---|
| 178 | ########################################################################### |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | if [ $getlmdzor = 1 ] ; then |
---|
| 183 | echo '##########################################################' |
---|
[1708] | 184 | echo Download a slightly modified version of LMDZ |
---|
[1588] | 185 | echo '##########################################################' |
---|
| 186 | cd $MODEL |
---|
| 187 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/modipsl.$version.tar.gz |
---|
| 188 | gunzip modipsl.$version.tar.gz |
---|
| 189 | tar xvf modipsl.$version.tar |
---|
| 190 | \rm modipsl.$version.tar |
---|
| 191 | |
---|
[1708] | 192 | # We download LMDZ and make some modifications to make it |
---|
| 193 | #compatible with $compilo |
---|
| 194 | # and we use an old stable but robust and well tested version of ORCHIDEE |
---|
| 195 | # That version of ORCHIDEE can be obtained using |
---|
[1588] | 196 | # wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/getlmdzor.x |
---|
| 197 | fi |
---|
| 198 | |
---|
| 199 | echo OK1 |
---|
| 200 | |
---|
| 201 | if [ $netcdf = 1 ] ; then |
---|
| 202 | echo '##########################################################' |
---|
[1708] | 203 | echo Compiling the Netcdf library |
---|
[1588] | 204 | echo '##########################################################' |
---|
| 205 | cd $MODEL |
---|
| 206 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/netcdf-4.0.1.tar.gz |
---|
| 207 | gunzip netcdf-4.0.1.tar.gz |
---|
| 208 | tar xvf netcdf-4.0.1.tar |
---|
| 209 | \rm -f netcdf-4.0.1.tar |
---|
| 210 | |
---|
| 211 | cd netcdf-4.0.1 |
---|
| 212 | |
---|
[1589] | 213 | OPTIMNC=$OPTIM |
---|
[1588] | 214 | if [ $compilo = g95 ] ; then |
---|
[1708] | 215 | # Set the appropriate compilation options |
---|
[1588] | 216 | export FC=g95 |
---|
| 217 | export F90=g95 |
---|
[1589] | 218 | export F90FLAGS=" -cpp -ffree-form $OPTIMNC" |
---|
| 219 | export FFLAGS=" -cpp $OPTIMNC" |
---|
[1588] | 220 | export CPPFLAGS=-Df2cFortran |
---|
| 221 | export CC=gcc |
---|
| 222 | export CXX=g++ |
---|
| 223 | elif [ $compilo = gfortran ] ; then |
---|
| 224 | export FC=gfortran |
---|
| 225 | export F90=gfortran |
---|
[1589] | 226 | export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
| 227 | export FFLAGS=" $OPTIMNC" |
---|
[1588] | 228 | export CPPFLAGS= |
---|
| 229 | export CC=gcc |
---|
| 230 | export CXX=g++ |
---|
| 231 | elif [ $compilo = pgf90 ] ; then |
---|
| 232 | export CPPFLAGS="-DNDEBUG -DpgiFortran" |
---|
| 233 | export CC=pgcc |
---|
| 234 | export CFLAGS="-Msignextend" |
---|
| 235 | export CXX=pgCC |
---|
| 236 | export CXXFLAGS="-Msignextend" |
---|
| 237 | export FC=pgf90 |
---|
[1589] | 238 | export FFLAGS="$OPTIMNC" |
---|
[1588] | 239 | export F90=pgf90 |
---|
[1589] | 240 | export F90FLAGS="$OPTIMNC" |
---|
[1590] | 241 | elif [ $compilo = ifort ] ; then |
---|
| 242 | export CPP="icc -E" |
---|
| 243 | export F77=ifort |
---|
| 244 | export FFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 245 | export F90=ifort |
---|
| 246 | export FCFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 247 | export CC=icc |
---|
| 248 | export CFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 249 | export CXX=icpc |
---|
| 250 | export CXXFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
[1588] | 251 | else |
---|
[1708] | 252 | echo unexpected compiler $compilo ; exit |
---|
[1588] | 253 | fi |
---|
| 254 | ## end of if [ $netcdf = 1 ] |
---|
[1708] | 255 | #cd src |
---|
[1588] | 256 | |
---|
| 257 | ### Correction d'un petit probleme de netcdf |
---|
| 258 | ##sed -e '83s/^$/\#define f2cFortran/' cfortran.h >| tmp ; \mv tmp cfortran.h |
---|
| 259 | |
---|
| 260 | # Compilation |
---|
| 261 | # Modif du 6 juillet 2009. Plantage quand on essaie de compiler netcdf avec |
---|
| 262 | # gcc plutôt que c++ |
---|
| 263 | ##sed -e 's/ c++/ gcc/g' configure >| tmp ; mv -f tmp configure ; chmod +x configure |
---|
| 264 | localdir=`pwd -P` |
---|
| 265 | ./configure --prefix=$localdir |
---|
| 266 | make check |
---|
| 267 | make install |
---|
| 268 | fi |
---|
| 269 | |
---|
| 270 | echo OK2 ioipsl=$ioipsl |
---|
| 271 | echo '##########################################################' |
---|
[1708] | 272 | echo Installing MODIPSL, the installation package manager for the |
---|
| 273 | echo IPSL models and tools |
---|
[1588] | 274 | echo '##########################################################' |
---|
| 275 | |
---|
| 276 | if [ $netcdf = 0 -o $netcdf = 1 ] ; then |
---|
| 277 | ncdfdir=$MODEL/netcdf-4.0.1 |
---|
| 278 | else |
---|
| 279 | ncdfdir=$netcdf |
---|
| 280 | fi |
---|
| 281 | |
---|
| 282 | if [ $ioipsl = 1 ] ; then |
---|
| 283 | cd $MODEL/modipsl |
---|
| 284 | \rm -r lib/* |
---|
| 285 | |
---|
| 286 | cd util |
---|
| 287 | |
---|
| 288 | if [ $compilo = pgf90 ] ; then |
---|
| 289 | fmod='module ' |
---|
| 290 | elif [ $compilo = g95 ] ; then |
---|
| 291 | fmod='fmod=' |
---|
[1590] | 292 | elif [ $compilo = ifort ] ; then |
---|
| 293 | fmod='module ' |
---|
[1588] | 294 | else # gfortran |
---|
| 295 | fmod='I ' |
---|
| 296 | fi |
---|
| 297 | cp AA_make.gdef AA_make.orig |
---|
| 298 | sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp |
---|
| 299 | sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c:F_C = $compilo -c": \ |
---|
[1589] | 300 | -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ |
---|
[1621] | 301 | -e 's:g95.*.NCDF_INC.*.$:g95 NCDF_INC= '"$ncdfdir"'/include:' \ |
---|
| 302 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdf:' \ |
---|
[1588] | 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 |
---|
| 306 | |
---|
| 307 | |
---|
| 308 | if [ "$use_shell" = "ksh" ] ; then |
---|
| 309 | if [ "$pclinux" = 1 ] ; then |
---|
[1708] | 310 | ./ins_make -t g95 # We use lines for g95 even for the other compilers |
---|
[1588] | 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 |
---|
[1708] | 316 | ./ins_make.bash -t g95 # We use lines for g95 even for the other compilers |
---|
[1588] | 317 | else |
---|
| 318 | ./ins_make.bash |
---|
| 319 | fi |
---|
| 320 | fi |
---|
| 321 | |
---|
| 322 | echo '##########################################################' |
---|
[1708] | 323 | echo Compiling IOIPSL, the interface library with Netcdf |
---|
[1588] | 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 |
---|
| 330 | fi |
---|
| 331 | if [ "$pclinux" = 1 ] ; then |
---|
[1621] | 332 | # Build IOIPSL modules and library |
---|
[1588] | 333 | make clean |
---|
| 334 | make |
---|
| 335 | if [ $compilo = gfortran ] ; then # copy module files to lib |
---|
| 336 | cp -f *.mod ../../../lib |
---|
| 337 | fi |
---|
[1621] | 338 | # Build IOIPSL tools (ie: "rebuild", if present) |
---|
| 339 | if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then |
---|
| 340 | cd $MODEL/modipsl/modeles/IOIPSL/tools |
---|
| 341 | # adapt Makefile & rebuild script if in bash |
---|
| 342 | if [ "$use_shell" = "bash" ] ; then |
---|
| 343 | cp Makefile Makefile.ksh |
---|
| 344 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
---|
| 345 | cp rebuild rebuild.ksh |
---|
| 346 | sed -e 's:/bin/ksh:/bin/bash:g' \ |
---|
| 347 | -e 's:print -u2:echo:g' \ |
---|
| 348 | -e 's:print:echo:g' rebuild.ksh > rebuild |
---|
| 349 | fi |
---|
| 350 | make clean |
---|
| 351 | make |
---|
| 352 | fi |
---|
[1588] | 353 | else |
---|
| 354 | # we're on brodie |
---|
| 355 | sxgmake clean |
---|
| 356 | sxgmake |
---|
| 357 | fi |
---|
| 358 | |
---|
| 359 | if [ "$veget" = 1 ] ; then |
---|
| 360 | echo '########################################################' |
---|
[1708] | 361 | echo Compiling ORCHIDEE, the continental surfaces model |
---|
[1588] | 362 | echo '########################################################' |
---|
| 363 | cd $MODEL/modipsl/modeles/ORCHIDEE |
---|
| 364 | cd src_parameters |
---|
[1708] | 365 | # A trick to compile ORCHIDEE depending on if we are using real*4 or real*8 |
---|
[1589] | 366 | |
---|
| 367 | |
---|
[1588] | 368 | \cp reqdprec.$real reqdprec.f90 |
---|
| 369 | make |
---|
| 370 | if [ $compilo = gfortran ] ; then # copy module files to lib |
---|
| 371 | cp -f *.mod ../../../lib |
---|
| 372 | fi |
---|
| 373 | cd ../src_stomate |
---|
| 374 | make |
---|
| 375 | if [ $compilo = gfortran ] ; then # copy module files to lib |
---|
| 376 | cp -f *.mod ../../../lib |
---|
| 377 | fi |
---|
| 378 | cd ../src_sechiba |
---|
| 379 | make |
---|
| 380 | if [ $compilo = gfortran ] ; then # copy module files to lib |
---|
| 381 | cp -f *.mod ../../../lib |
---|
| 382 | fi |
---|
| 383 | fi |
---|
| 384 | fi |
---|
| 385 | |
---|
| 386 | |
---|
| 387 | # Ehouarn: it may be directory LMDZ4 or LMDZ5 depending on tar file... |
---|
| 388 | if [[ -d $MODEL/modipsl/modeles/LMDZ4 ]] ; then |
---|
| 389 | echo '##########################################################' |
---|
| 390 | echo 'Compilation de LMDZ4' |
---|
| 391 | echo '##########################################################' |
---|
| 392 | cd $MODEL/modipsl/modeles/LMDZ4 |
---|
| 393 | else |
---|
| 394 | if [[ -d $MODEL/modipsl/modeles/LMDZ5 ]] ; then |
---|
| 395 | echo '##########################################################' |
---|
[1708] | 396 | echo 'Compiling LMDZ5' |
---|
[1588] | 397 | echo '##########################################################' |
---|
| 398 | cd $MODEL/modipsl/modeles/LMDZ5 |
---|
| 399 | else |
---|
| 400 | echo "ERROR: No LMDZ4 (or LMDZ5) directory !!!" |
---|
| 401 | exit |
---|
| 402 | fi |
---|
| 403 | fi |
---|
| 404 | |
---|
[1708] | 405 | ########################################################## |
---|
| 406 | # Traitement momentanne a cause d'un bug dans makegcm |
---|
| 407 | cp create_make_gcm create_make_gcm.orig |
---|
| 408 | nl=`sed -n -e /PROGRAM/= create_make_gcm.orig | tail -1` |
---|
| 409 | sed -e "$nl s/ PROGRA/PROGRA/" create_make_gcm.orig >| create_make_gcm |
---|
| 410 | |
---|
| 411 | #mv -f tmp crea |
---|
[1588] | 412 | if [ "$pclinux" = 1 ] ; then |
---|
| 413 | if [ $compilo = gfortran ] ; then |
---|
| 414 | sed \ |
---|
| 415 | -e 's:\#setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
---|
| 416 | -e 's:\#setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
---|
| 417 | -e 's:setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
---|
| 418 | -e 's:setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
---|
| 419 | -e 's/set FC_LINUX.*.$/set FC_LINUX='$compilo'/' \ |
---|
| 420 | -e 's/g95/gfortran/g' \ |
---|
| 421 | -e 's/-fmod=/-I/g' \ |
---|
| 422 | -e 's/-fno-second-underscore//' -e 's/-fstatic//' \ |
---|
| 423 | -e 's/-lparallel//' \ |
---|
[1708] | 424 | -e 's/-lnetcdff//g' \ |
---|
[1588] | 425 | -e 's/-lorglob//' \ |
---|
| 426 | -e 's/-ffixed-form//' -e 's/-ffree-form//' \ |
---|
[1589] | 427 | -e 's/set OPT_LINUX.*.$/set OPT_LINUX=\"'"$OPTIMGCM"\"'/' makegcm.orig >| makegcm |
---|
[1590] | 428 | elif [ $compilo = ifort ] ; then |
---|
| 429 | sed \ |
---|
| 430 | -e 's:\#setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
---|
| 431 | -e 's:\#setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
---|
| 432 | -e 's:setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
---|
| 433 | -e 's:setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
---|
| 434 | -e 's/set FC_LINUX.*.$/set FC_LINUX='$compilo'/' \ |
---|
| 435 | -e 's/g95/ifort/g' \ |
---|
| 436 | -e 's/-fmod=/-module /g' \ |
---|
| 437 | -e 's/-fno-second-underscore//' -e 's/-fstatic//' \ |
---|
| 438 | -e 's/-lparallel//' \ |
---|
[1708] | 439 | -e 's/-lnetcdff//g' \ |
---|
[1590] | 440 | -e 's/-lorglob//' \ |
---|
| 441 | -e 's/-ffixed-form//' -e 's/-ffree-form//' \ |
---|
| 442 | -e 's/set OPT_LINUX.*.$/set OPT_LINUX=\"'"$OPTIMGCM"\"'/' makegcm.orig >| makegcm |
---|
[1588] | 443 | else # g95 or pgf90 |
---|
| 444 | sed \ |
---|
| 445 | -e 's:\#setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
---|
| 446 | -e 's:\#setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
---|
| 447 | -e 's:setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
---|
| 448 | -e 's:setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
---|
| 449 | -e 's/set FC_LINUX.*.$/set FC_LINUX='$compilo'/' \ |
---|
| 450 | -e 's/-fno-second-underscore//' -e 's/-fstatic//' \ |
---|
| 451 | -e 's/-lparallel//' \ |
---|
[1708] | 452 | -e 's/-lnetcdff//g' \ |
---|
[1588] | 453 | -e 's/-lorglob//' \ |
---|
| 454 | -e 's/-ffixed-form//' -e 's/-ffree-form//' \ |
---|
[1589] | 455 | -e 's/set OPT_LINUX.*.$/set OPT_LINUX=\"'"$OPTIMGCM"\"'/' makegcm.orig >| makegcm |
---|
[1588] | 456 | fi |
---|
| 457 | else |
---|
| 458 | sed \ |
---|
| 459 | -e 's/-lparallel//' \ |
---|
| 460 | -e 's/-lorglob//' \ |
---|
| 461 | -e 's/-lsxorglob//' \ |
---|
| 462 | -e 's/-lsxparallel//' \ |
---|
| 463 | -e 's/-lsxioipsl/-lioipsl/g' \ |
---|
| 464 | makegcm.orig >| makegcm |
---|
| 465 | fi |
---|
| 466 | |
---|
| 467 | chmod +x makegcm |
---|
| 468 | |
---|
| 469 | ########################################################### |
---|
[1708] | 470 | # For those who want to use fcm to compile via : |
---|
[1588] | 471 | # makelmdz_fcm -arch local ..... |
---|
| 472 | ############################################################ |
---|
| 473 | |
---|
| 474 | if [ "$pclinux" = 1 ] ; then |
---|
[1708] | 475 | # create local 'arch' files (if on Linux PC): |
---|
[1588] | 476 | cd arch |
---|
[1708] | 477 | # arch-local.path file |
---|
[1590] | 478 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdf\"" > arch-local.path |
---|
| 479 | echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path |
---|
[1588] | 480 | echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
| 481 | echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
| 482 | echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
| 483 | echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
[1708] | 484 | # arch-local.fcm file (adapted from arch-linux-32bit.fcm) |
---|
[1588] | 485 | if [ $compilo = g95 ] ; then |
---|
| 486 | sed -e s:"%COMPILER pgf95":"%COMPILER g95":1 \ |
---|
| 487 | -e s:"%LINK pgf95":"%LINK g95":1 \ |
---|
[1590] | 488 | -e s:"%PROD_FFLAGS -fast":"%PROD_FFLAGS $OPTIM":1 \ |
---|
[1709] | 489 | -e s:"%DEV_FFLAGS -g -O1":"%DEV_FFLAGS -g -O1 -Wall":1 \ |
---|
| 490 | -e s:"%DEBUG_FFLAGS -g -O0 -Kieee -Ktrap=fp -Mbounds":"%DEBUG_FFLAGS -g -O0 -Wall -ftrace=full -fbounds-check -freal=nan":1 \ |
---|
[1590] | 491 | -e s:"%BASE_FFLAGS ":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
[1588] | 492 | arch-linux-32bit.fcm > arch-local.fcm |
---|
[1589] | 493 | if [ $real = r8 ] ; then |
---|
[1588] | 494 | sed -e s:"%FPP_DEF ":"%FPP_DEF NC_DOUBLE":1 \ |
---|
| 495 | arch-local.fcm > arch-local.fcm.new |
---|
| 496 | mv -f arch-local.fcm.new arch-local.fcm |
---|
| 497 | fi |
---|
| 498 | elif [ $compilo = gfortran ] ; then |
---|
| 499 | sed -e s:"%COMPILER pgf95":"%COMPILER gfortran":1 \ |
---|
| 500 | -e s:"%LINK pgf95":"%LINK gfortran":1 \ |
---|
[1590] | 501 | -e s:"%PROD_FFLAGS -fast":"%PROD_FFLAGS $OPTIM":1 \ |
---|
[1709] | 502 | -e s:"%DEV_FFLAGS -g -O1":"%DEV_FFLAGS -Wall -fbounds-check":1 \ |
---|
| 503 | -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] | 504 | -e s:"%BASE_FFLAGS ":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
[1588] | 505 | arch-linux-32bit.fcm > arch-local.fcm |
---|
[1589] | 506 | if [ $real = r8 ] ; then |
---|
[1588] | 507 | sed -e s:"%FPP_DEF ":"%FPP_DEF NC_DOUBLE":1 \ |
---|
| 508 | arch-local.fcm > arch-local.fcm.new |
---|
| 509 | mv -f arch-local.fcm.new arch-local.fcm |
---|
| 510 | fi |
---|
| 511 | elif [ $compilo = pgf90 ] ; then |
---|
| 512 | sed -e s:"-Wl,-Bstatic -L/usr/lib/gcc-lib/i386-linux/2.95.2":" ":1 \ |
---|
[1590] | 513 | -e s:"%PROD_FFLAGS -fast":"%PROD_FFLAGS $OPTIM":1 \ |
---|
| 514 | -e s:"%BASE_FFLAGS ":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
[1588] | 515 | arch-linux-32bit.fcm > arch-local.fcm |
---|
[1590] | 516 | if [ $real = r8 ] ; then |
---|
[1588] | 517 | sed -e s:"%FPP_DEF ":"%FPP_DEF NC_DOUBLE":1 \ |
---|
| 518 | arch-local.fcm > arch-local.fcm.new |
---|
| 519 | mv -f arch-local.fcm.new arch-local.fcm |
---|
| 520 | fi |
---|
[1590] | 521 | elif [ $compilo = ifort ] ; then |
---|
| 522 | sed -e s:"%COMPILER pgf95":"%COMPILER ifort":1 \ |
---|
| 523 | -e s:"%LINK pgf95":"%LINK ifort":1 \ |
---|
| 524 | -e s:"-Wl,-Bstatic -L/usr/lib/gcc-lib/i386-linux/2.95.2":" ":1 \ |
---|
| 525 | -e s:"%PROD_FFLAGS -fast":"%PROD_FFLAGS $OPTIM":1 \ |
---|
| 526 | -e s:"%BASE_FFLAGS ":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
[1709] | 527 | -e s:"%DEV_FFLAGS -g -O1":"%DEV_FFLAGS -p -g -O2 -traceback -fp-stack-check -ftrapuv -check":1 \ |
---|
[1590] | 528 | -e s:"%DEBUG_FFLAGS -g -O0 -Kieee -Ktrap=fp -Mbounds":"%DEBUG_FFLAGS -g -no-ftz -traceback -ftrapuv -fp-stack-check -check":1 \ |
---|
| 529 | arch-linux-32bit.fcm > arch-local.fcm |
---|
| 530 | if [ $real = r8 ] ; then |
---|
| 531 | sed -e s:"%FPP_DEF ":"%FPP_DEF NC_DOUBLE":1 \ |
---|
| 532 | arch-local.fcm > arch-local.fcm.new |
---|
| 533 | mv -f arch-local.fcm.new arch-local.fcm |
---|
| 534 | fi |
---|
[1588] | 535 | else |
---|
[1708] | 536 | echo Unexpected compiler $compilo ; exit |
---|
[1588] | 537 | fi # of if [ $compilo = g95 ] elif [ $compilo = pgf90 ] |
---|
| 538 | cd .. |
---|
[1708] | 539 | ### Adapt "bld.cfg" (add the shell): |
---|
[1588] | 540 | whereisthatshell=$(which ${use_shell}) |
---|
| 541 | echo "bld::tool::SHELL $whereisthatshell" >> bld.cfg |
---|
| 542 | |
---|
[1710] | 543 | ### Modify makelmdz_fcm and makelmdz to use ORCHIDEE in the bench: |
---|
[1708] | 544 | ### remove liborglob.a and libparallel.a |
---|
[1588] | 545 | cp makelmdz_fcm makelmdz_fcm.orig |
---|
| 546 | sed -e "s/-l\${LIBPREFIX}parallel//" \ |
---|
| 547 | sed -e "s/-l\${LIBPREFIX}orglob//" \ |
---|
| 548 | makelmdz_fcm.orig > makelmdz_fcm |
---|
[1710] | 549 | cp makelmdz makelmdz.orig |
---|
| 550 | sed -e "s/-l\${LIBPREFIX}parallel//" \ |
---|
| 551 | sed -e "s/-l\${LIBPREFIX}orglob//" \ |
---|
| 552 | makelmdz.orig > makelmdz |
---|
[1588] | 553 | |
---|
| 554 | fi # of if [ "$pclinux" = 1 ] |
---|
| 555 | |
---|
| 556 | ################################################################## |
---|
[1708] | 557 | # Compile LMDZ |
---|
[1588] | 558 | ################################################################## |
---|
| 559 | ok_veget=false |
---|
[1708] | 560 | if [ "$veget" = 1 ] ; then $ok_veget = true; fi |
---|
[1588] | 561 | if [ $compile_with_fcm = 1 ] ; then |
---|
[1708] | 562 | # Compile with makelmdz_fcm |
---|
[1588] | 563 | ./makelmdz_fcm -d ${grid_resolution} -arch local -v $ok_veget gcm |
---|
| 564 | else |
---|
[1708] | 565 | # Comple with makegcm: |
---|
[1590] | 566 | # 3 times! because some dependecies are not well resolved with makegcm |
---|
[1588] | 567 | ./makegcm -d ${grid_resolution} -v $ok_veget gcm |
---|
| 568 | ./makegcm -d ${grid_resolution} -v $ok_veget gcm |
---|
| 569 | ./makegcm -d ${grid_resolution} -v $ok_veget gcm |
---|
| 570 | fi |
---|
| 571 | |
---|
| 572 | if [ -f gcm.e ] || [ -f bin/gcm_${grid_resolution}_phylmd_seq_orch.e ] || [ -f bin/gcm_${grid_resolution}_phylmd_seq.e ] ; then |
---|
| 573 | echo '##########################################################' |
---|
[1708] | 574 | echo Compilation successfull !! |
---|
[1588] | 575 | echo '##########################################################' |
---|
| 576 | else |
---|
[1708] | 577 | echo Compilation failed !! |
---|
[1588] | 578 | exit |
---|
| 579 | fi |
---|
| 580 | |
---|
| 581 | ################################################################## |
---|
[1708] | 582 | # Below, we run a benchmark test (if bench=0) |
---|
[1588] | 583 | ################################################################## |
---|
| 584 | if [ $bench = 0 ] ; then |
---|
| 585 | exit |
---|
| 586 | fi |
---|
| 587 | |
---|
| 588 | echo '##########################################################' |
---|
[1708] | 589 | echo Running a test run |
---|
[1588] | 590 | echo '##########################################################' |
---|
| 591 | |
---|
| 592 | \rm -r BENCH${grid_resolution} |
---|
| 593 | bench=bench_lmdz_${grid_resolution} |
---|
| 594 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/$bench.tar.gz |
---|
| 595 | gunzip $bench.tar.gz |
---|
| 596 | tar xvf $bench.tar |
---|
| 597 | |
---|
| 598 | if [ -f gcm.e ] ; then |
---|
| 599 | cp gcm.e BENCH${grid_resolution}/ |
---|
| 600 | elif [ -f bin/gcm_${grid_resolution}_phylmd_seq_orch.e ] ; then |
---|
| 601 | cp bin/gcm_${grid_resolution}_phylmd_seq_orch.e BENCH${grid_resolution}/gcm.e |
---|
| 602 | elif [ -f bin/gcm_${grid_resolution}_phylmd_seq.e ] ; then |
---|
| 603 | cp bin/gcm_${grid_resolution}_phylmd_seq.e BENCH${grid_resolution}/gcm.e |
---|
| 604 | else |
---|
| 605 | echo "No gcm.e found" |
---|
| 606 | exit |
---|
| 607 | fi |
---|
| 608 | |
---|
| 609 | if [ $hostname = brodie ] ; then |
---|
[1708] | 610 | echo to run the bench, you must log on to Brodie01 |
---|
| 611 | echo and then change directory to `pwd`/BENCH${grid_resolution} |
---|
| 612 | echo and run the gcm |
---|
[1588] | 613 | exit |
---|
| 614 | fi |
---|
| 615 | |
---|
| 616 | cd BENCH${grid_resolution} |
---|
| 617 | ./bench.sh > bench.out 2>&1 |
---|
| 618 | |
---|
| 619 | echo '##########################################################' |
---|
[1708] | 620 | echo ' Bench results ' |
---|
[1588] | 621 | echo '##########################################################' |
---|
| 622 | |
---|
| 623 | cat ./bench.out |
---|
| 624 | |
---|
| 625 | echo '##########################################################' |
---|
[1708] | 626 | echo 'Simulation finished in' `pwd` |
---|
| 627 | echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e' |
---|
| 628 | echo 'or ./bench.sh' |
---|
[1588] | 629 | echo '##########################################################' |
---|
| 630 | |
---|