[1588] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | ########################################################################### |
---|
| 4 | # Auteur : Frédéric Hourdin/LMD/hourdin@lmd.jussieu.fr |
---|
| 5 | # Usage : install.sh |
---|
| 6 | # |
---|
| 7 | # Script bash d'installation du modele LMDZ sur un ordinateur PC/Linux |
---|
| 8 | # en utilisant le compilateur g95. |
---|
| 9 | # Le modele est récupéré dans une arborescence |
---|
| 10 | # $MODEL/modipsl/modeles/... |
---|
| 11 | # en utilisant l'infrastructure "modipsl" mise au point à l'"IPSL" pour |
---|
| 12 | #les besoins de la modélisation couplée du climat |
---|
| 13 | #(atmosphere/ocean/vegetation/chimie) |
---|
| 14 | # On ne récupère ici que les composantes atmosphériques (LMDZ4) |
---|
| 15 | # et végétation (ORCHIDEE). |
---|
| 16 | # |
---|
| 17 | # Sous le répertoire "modeles", on trouve en fait les sources de différents |
---|
| 18 | # modèles. Ici, LMDZ4, ORCHIDEEet IOIPSL, ensemble de programmes |
---|
| 19 | # d'entrée/sortie faisant appel à la librairie netcdf. |
---|
| 20 | # |
---|
| 21 | # Le script récupères les différents jeux de sources (y compris une |
---|
| 22 | # version de netcdf) et utilitaires, compile le modèle, et lance une |
---|
| 23 | # simulation de test dans une configuration très légère sur |
---|
| 24 | # $MODEL/modipsl/modeles/LMDZ4/INI |
---|
| 25 | # |
---|
| 26 | # Pré-requis : g95/pgf90/gfortran, ksh, wget , gunzip, tar, ... (à compléter) |
---|
| 27 | # |
---|
[1589] | 28 | # Modif 18/11/2011 |
---|
| 29 | # changement pour l'option real 8. |
---|
| 30 | # On compile avec -r8 (ou équivalent) et -DNC_DOUBLE pour le GCM |
---|
| 31 | # mais avec -r4 netcdf. La variable real est initialisée à |
---|
| 32 | # r4 ou r8 en début de script. |
---|
| 33 | # |
---|
[1588] | 34 | ########################################################################### |
---|
| 35 | |
---|
| 36 | echo '################################################################' |
---|
| 37 | echo Choix des options d installation |
---|
| 38 | echo '################################################################' |
---|
| 39 | |
---|
| 40 | |
---|
[1590] | 41 | #real=r4 |
---|
[1589] | 42 | real=r8 |
---|
| 43 | |
---|
[1588] | 44 | # ATTENTION !!!! Pour des versions anterieures a octobre 2009, utiliser |
---|
| 45 | # install.v2.sh au lieu de install.sh |
---|
| 46 | |
---|
| 47 | version=20110921.trunk |
---|
| 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 |
---|
| 58 | veget=0 |
---|
| 59 | bench=1 |
---|
[1590] | 60 | ## compilo=pgf90 ou g95 ou gfortran ou ifort sur PC linux |
---|
[1588] | 61 | compilo=gfortran |
---|
| 62 | pclinux=1 |
---|
| 63 | |
---|
| 64 | ## compile_with_fcm=1 : utilise makelmdz_fcm, possible a partir de la version 20111103.trunk (LMDZ5/trunk rev 1578) |
---|
| 65 | ## compile_with_fcm=0 : utilise makegcm (default) |
---|
| 66 | compile_with_fcm=0 |
---|
| 67 | |
---|
[1589] | 68 | OPTPREC="" |
---|
[1588] | 69 | echo '################################################################' |
---|
| 70 | echo Choix des options de compilation |
---|
| 71 | echo '################################################################' |
---|
[1589] | 72 | |
---|
[1588] | 73 | if [ $compilo = g95 ] ; then |
---|
[1589] | 74 | if [ $real = r8 ] ; then OPTPREC="-r8 -DNC_DOUBLE" ; fi |
---|
| 75 | OPTIM='-i4 -O3' |
---|
[1588] | 76 | elif [ $compilo = gfortran ] ; then |
---|
[1589] | 77 | if [ $real = r8 ] ; then OPTPREC="-fdefault-real-8 -DNC_DOUBLE" ; fi |
---|
| 78 | OPTIM='-O3' |
---|
[1590] | 79 | elif [ $compilo = pgf90 ] ; then |
---|
| 80 | if [ $real = r8 ] ; then OPTPREC="-r8 -DNC_DOUBLE" ; fi |
---|
[1588] | 81 | OPTIM='-O2 -Munroll -Mnoframe -Mautoinline -Mcache_align' |
---|
[1590] | 82 | # with pgf90, compile with fcm |
---|
| 83 | compile_with_fcm=1 |
---|
| 84 | else |
---|
| 85 | # ifort |
---|
| 86 | if [ $real = r8 ] ; then OPTPREC="-real-size 64 -DNC_DOUBLE" ; fi |
---|
| 87 | OPTIM="-O2 -ip -mkl=sequential -align all -static " |
---|
| 88 | # with ifort, compile with fcm |
---|
| 89 | compile_with_fcm=1 |
---|
[1588] | 90 | fi |
---|
[1589] | 91 | OPTIMGCM="$OPTIM $OPTPREC" |
---|
[1588] | 92 | |
---|
| 93 | # choix de la resolution pour le bench |
---|
| 94 | # grid_resolution= 32x24x11 for test (test without ORCHIDEE) |
---|
| 95 | # 96x71x19 standard configuration |
---|
| 96 | grid_resolution=48x36x19 |
---|
| 97 | |
---|
| 98 | hostname=`hostname` |
---|
| 99 | |
---|
| 100 | ########################################################################## |
---|
| 101 | # Dans le cas où on installe sur des machines connues comme la NEC |
---|
| 102 | # brodie |
---|
| 103 | # de l'IDRIS, on ne verifie pas les logiciels existants et on n'installe |
---|
| 104 | # pas netcdf. |
---|
| 105 | if [ $hostname = brodie ] ; then |
---|
| 106 | netcdf=0 |
---|
| 107 | check_linux=0 |
---|
| 108 | pclinux=0 |
---|
| 109 | fi |
---|
| 110 | ########################################################################## |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | mkdir -p $MODEL |
---|
| 114 | echo $MODEL |
---|
| 115 | MODEL=`( cd $MODEL ; pwd )` # transformation en chemin absolu si necessaire |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | # Le -fendian=big n'est à utiliser vraiment utile que pour ARPEGE1D. |
---|
| 120 | # Le -r8 doit sans doute être éviter si on veut tourner rapidement sur |
---|
| 121 | # des machines 32 bits. |
---|
| 122 | # L'option r8 n'est pas forcement indispensable et elle produit |
---|
| 123 | # des executables plus gros. |
---|
| 124 | # Elles est indispensable cependant pour ARPEGE1D |
---|
| 125 | # On doit pouvoir aussi utiliser des optimisations plus fortes (-O3 par |
---|
| 126 | # exemple). |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | echo '################################################################' |
---|
| 130 | if [ "$check_linux" = 1 ] ; then |
---|
| 131 | echo Test sur les logiciels requis |
---|
| 132 | echo '################################################################' |
---|
| 133 | |
---|
| 134 | #### Ehouarn: test if ksh and/or bash are available |
---|
| 135 | use_shell="ksh" # default: use ksh |
---|
| 136 | if [ "`which ksh`" = "" ] ; then |
---|
| 137 | echo "pas de ksh ... on va utiliser bash" |
---|
| 138 | use_shell="bash" |
---|
| 139 | if [ "`which bash`" = "" ] ; then |
---|
| 140 | echo "Il faut d\'abord installer ksh (ou bash)" |
---|
| 141 | fi |
---|
| 142 | fi |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | for logiciel in csh wget tar gzip make $compilo gcc ; do |
---|
| 146 | if [ "`which $logiciel`" = "" ] ; then |
---|
| 147 | echo Il faut installer d\'abord $logiciel |
---|
| 148 | exit |
---|
| 149 | fi |
---|
| 150 | done |
---|
| 151 | |
---|
| 152 | if [ $pclinux = 1 ] ; then |
---|
| 153 | cd $MODEL |
---|
| 154 | cat <<eod> tt.f90 |
---|
| 155 | print*,'coucou' |
---|
| 156 | end |
---|
| 157 | eod |
---|
| 158 | $compilo tt.f90 |
---|
| 159 | ./a.out >| tt |
---|
| 160 | if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then |
---|
| 161 | echo probleme avec installation de $compilo ; exit ; fi |
---|
| 162 | \rm tt a.out tt.f90 |
---|
| 163 | fi |
---|
| 164 | fi |
---|
| 165 | |
---|
| 166 | ########################################################################### |
---|
| 167 | |
---|
| 168 | |
---|
| 169 | |
---|
| 170 | if [ $getlmdzor = 1 ] ; then |
---|
| 171 | echo '##########################################################' |
---|
| 172 | echo On recupere une version un peu modifiee de LMDZ |
---|
| 173 | echo '##########################################################' |
---|
| 174 | cd $MODEL |
---|
| 175 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/modipsl.$version.tar.gz |
---|
| 176 | gunzip modipsl.$version.tar.gz |
---|
| 177 | tar xvf modipsl.$version.tar |
---|
| 178 | \rm modipsl.$version.tar |
---|
| 179 | |
---|
| 180 | # On recupere en fait une version du 01 10 2006 obtenue |
---|
| 181 | # Par un cvs get |
---|
| 182 | # Puis modifiees pour etre compatible avec la compilation $compilo. |
---|
| 183 | # et pour betoner ORCHIDEE |
---|
| 184 | # Cette version est recuperable avec le script |
---|
| 185 | # wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/getlmdzor.x |
---|
| 186 | fi |
---|
| 187 | |
---|
| 188 | echo OK1 |
---|
| 189 | |
---|
| 190 | if [ $netcdf = 1 ] ; then |
---|
| 191 | echo '##########################################################' |
---|
| 192 | echo Compilation de netcdf |
---|
| 193 | echo '##########################################################' |
---|
| 194 | cd $MODEL |
---|
| 195 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/netcdf-4.0.1.tar.gz |
---|
| 196 | gunzip netcdf-4.0.1.tar.gz |
---|
| 197 | tar xvf netcdf-4.0.1.tar |
---|
| 198 | \rm -f netcdf-4.0.1.tar |
---|
| 199 | |
---|
| 200 | cd netcdf-4.0.1 |
---|
| 201 | |
---|
[1589] | 202 | OPTIMNC=$OPTIM |
---|
[1588] | 203 | if [ $compilo = g95 ] ; then |
---|
| 204 | # On modifie les options de compilation |
---|
| 205 | export FC=g95 |
---|
| 206 | export F90=g95 |
---|
[1589] | 207 | export F90FLAGS=" -cpp -ffree-form $OPTIMNC" |
---|
| 208 | export FFLAGS=" -cpp $OPTIMNC" |
---|
[1588] | 209 | export CPPFLAGS=-Df2cFortran |
---|
| 210 | export CC=gcc |
---|
| 211 | export CXX=g++ |
---|
| 212 | elif [ $compilo = gfortran ] ; then |
---|
| 213 | export FC=gfortran |
---|
| 214 | export F90=gfortran |
---|
[1589] | 215 | export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
| 216 | export FFLAGS=" $OPTIMNC" |
---|
[1588] | 217 | export CPPFLAGS= |
---|
| 218 | export CC=gcc |
---|
| 219 | export CXX=g++ |
---|
| 220 | elif [ $compilo = pgf90 ] ; then |
---|
| 221 | export CPPFLAGS="-DNDEBUG -DpgiFortran" |
---|
| 222 | export CC=pgcc |
---|
| 223 | export CFLAGS="-Msignextend" |
---|
| 224 | export CXX=pgCC |
---|
| 225 | export CXXFLAGS="-Msignextend" |
---|
| 226 | export FC=pgf90 |
---|
[1589] | 227 | export FFLAGS="$OPTIMNC" |
---|
[1588] | 228 | export F90=pgf90 |
---|
[1589] | 229 | export F90FLAGS="$OPTIMNC" |
---|
[1590] | 230 | elif [ $compilo = ifort ] ; then |
---|
| 231 | export CPP="icc -E" |
---|
| 232 | export F77=ifort |
---|
| 233 | export FFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 234 | export F90=ifort |
---|
| 235 | export FCFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 236 | export CC=icc |
---|
| 237 | export CFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
| 238 | export CXX=icpc |
---|
| 239 | export CXXFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
[1588] | 240 | else |
---|
| 241 | echo Le compilateur $compilo pas prevu ; exit |
---|
| 242 | fi |
---|
| 243 | ## end of if [ $netcdf = 1 ] |
---|
| 244 | cd src |
---|
| 245 | |
---|
| 246 | ### Correction d'un petit probleme de netcdf |
---|
| 247 | ##sed -e '83s/^$/\#define f2cFortran/' cfortran.h >| tmp ; \mv tmp cfortran.h |
---|
| 248 | |
---|
| 249 | # Compilation |
---|
| 250 | # Modif du 6 juillet 2009. Plantage quand on essaie de compiler netcdf avec |
---|
| 251 | # gcc plutôt que c++ |
---|
| 252 | ##sed -e 's/ c++/ gcc/g' configure >| tmp ; mv -f tmp configure ; chmod +x configure |
---|
| 253 | localdir=`pwd -P` |
---|
| 254 | ./configure --prefix=$localdir |
---|
| 255 | make check |
---|
| 256 | make install |
---|
| 257 | fi |
---|
| 258 | |
---|
| 259 | echo OK2 ioipsl=$ioipsl |
---|
| 260 | echo '##########################################################' |
---|
| 261 | echo Installation de MODIPSL, la procedure d\'installation des |
---|
| 262 | echo modeles de l\'IPSL |
---|
| 263 | echo '##########################################################' |
---|
| 264 | |
---|
| 265 | if [ $netcdf = 0 -o $netcdf = 1 ] ; then |
---|
| 266 | ncdfdir=$MODEL/netcdf-4.0.1 |
---|
| 267 | else |
---|
| 268 | ncdfdir=$netcdf |
---|
| 269 | fi |
---|
| 270 | |
---|
| 271 | if [ $ioipsl = 1 ] ; then |
---|
| 272 | cd $MODEL/modipsl |
---|
| 273 | \rm -r lib/* |
---|
| 274 | |
---|
| 275 | cd util |
---|
| 276 | |
---|
| 277 | if [ $compilo = pgf90 ] ; then |
---|
| 278 | fmod='module ' |
---|
| 279 | elif [ $compilo = g95 ] ; then |
---|
| 280 | fmod='fmod=' |
---|
[1590] | 281 | elif [ $compilo = ifort ] ; then |
---|
| 282 | fmod='module ' |
---|
[1588] | 283 | else # gfortran |
---|
| 284 | fmod='I ' |
---|
| 285 | fi |
---|
| 286 | cp AA_make.gdef AA_make.orig |
---|
| 287 | sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp |
---|
| 288 | sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c:F_C = $compilo -c": \ |
---|
[1589] | 289 | -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ |
---|
[1588] | 290 | -e 's:g95.*.NCDF_INC.*.$:g95 NCDF_INC='"$ncdfdir"'/include:' \ |
---|
| 291 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB='"$ncdfdir"'/lib:' \ |
---|
| 292 | -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \ |
---|
| 293 | -e 's:#-Q- g95 M_K = gmake:#-Q- g95 M_K = make:' \ |
---|
| 294 | tmp >| AA_make.gdef |
---|
| 295 | |
---|
| 296 | |
---|
| 297 | if [ "$use_shell" = "ksh" ] ; then |
---|
| 298 | if [ "$pclinux" = 1 ] ; then |
---|
| 299 | ./ins_make -t g95 # On utilise les lignes g95 meme pour les autres compilo |
---|
| 300 | fi |
---|
| 301 | else # bash |
---|
| 302 | sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash |
---|
| 303 | chmod u=rwx ins_make.bash |
---|
| 304 | if [ "$pclinux" = 1 ] ; then |
---|
| 305 | ./ins_make.bash -t g95 # On utilise les lignes g95 meme pour les autres compilo |
---|
| 306 | else |
---|
| 307 | ./ins_make.bash |
---|
| 308 | fi |
---|
| 309 | fi |
---|
| 310 | |
---|
| 311 | echo '##########################################################' |
---|
| 312 | echo Compilation de IOIPSL, bibliotheque d\'interface avec Netcd |
---|
| 313 | echo '##########################################################' |
---|
| 314 | |
---|
| 315 | cd $MODEL/modipsl/modeles/IOIPSL/src |
---|
| 316 | if [ "$use_shell" = "bash" ] ; then |
---|
| 317 | cp Makefile Makefile.ksh |
---|
| 318 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
---|
| 319 | fi |
---|
| 320 | if [ "$pclinux" = 1 ] ; then |
---|
| 321 | make clean |
---|
| 322 | make |
---|
| 323 | if [ $compilo = gfortran ] ; then # copy module files to lib |
---|
| 324 | cp -f *.mod ../../../lib |
---|
| 325 | fi |
---|
| 326 | else |
---|
| 327 | # we're on brodie |
---|
| 328 | sxgmake clean |
---|
| 329 | sxgmake |
---|
| 330 | fi |
---|
| 331 | |
---|
| 332 | if [ "$veget" = 1 ] ; then |
---|
| 333 | echo '########################################################' |
---|
| 334 | echo Compilation de ORCHIDEE, modele des surface continentales |
---|
| 335 | echo '########################################################' |
---|
| 336 | cd $MODEL/modipsl/modeles/ORCHIDEE |
---|
| 337 | cd src_parameters |
---|
| 338 | # Une petite astuce pour ORCHIDEE suivant qu'on est en real*4 ou real*8 |
---|
[1589] | 339 | |
---|
| 340 | |
---|
[1588] | 341 | \cp reqdprec.$real reqdprec.f90 |
---|
| 342 | make |
---|
| 343 | if [ $compilo = gfortran ] ; then # copy module files to lib |
---|
| 344 | cp -f *.mod ../../../lib |
---|
| 345 | fi |
---|
| 346 | cd ../src_stomate |
---|
| 347 | make |
---|
| 348 | if [ $compilo = gfortran ] ; then # copy module files to lib |
---|
| 349 | cp -f *.mod ../../../lib |
---|
| 350 | fi |
---|
| 351 | cd ../src_sechiba |
---|
| 352 | make |
---|
| 353 | if [ $compilo = gfortran ] ; then # copy module files to lib |
---|
| 354 | cp -f *.mod ../../../lib |
---|
| 355 | fi |
---|
| 356 | fi |
---|
| 357 | fi |
---|
| 358 | |
---|
| 359 | |
---|
| 360 | # Ehouarn: it may be directory LMDZ4 or LMDZ5 depending on tar file... |
---|
| 361 | if [[ -d $MODEL/modipsl/modeles/LMDZ4 ]] ; then |
---|
| 362 | echo '##########################################################' |
---|
| 363 | echo 'Compilation de LMDZ4' |
---|
| 364 | echo '##########################################################' |
---|
| 365 | cd $MODEL/modipsl/modeles/LMDZ4 |
---|
| 366 | else |
---|
| 367 | if [[ -d $MODEL/modipsl/modeles/LMDZ5 ]] ; then |
---|
| 368 | echo '##########################################################' |
---|
| 369 | echo 'Compilation de LMDZ5' |
---|
| 370 | echo '##########################################################' |
---|
| 371 | cd $MODEL/modipsl/modeles/LMDZ5 |
---|
| 372 | else |
---|
| 373 | echo "ERROR: No LMDZ4 (or LMDZ5) directory !!!" |
---|
| 374 | exit |
---|
| 375 | fi |
---|
| 376 | fi |
---|
| 377 | |
---|
| 378 | if [ "$pclinux" = 1 ] ; then |
---|
| 379 | if [ $compilo = gfortran ] ; then |
---|
| 380 | sed \ |
---|
| 381 | -e 's:\#setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
---|
| 382 | -e 's:\#setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
---|
| 383 | -e 's:setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
---|
| 384 | -e 's:setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
---|
| 385 | -e 's/set FC_LINUX.*.$/set FC_LINUX='$compilo'/' \ |
---|
| 386 | -e 's/g95/gfortran/g' \ |
---|
| 387 | -e 's/-fmod=/-I/g' \ |
---|
| 388 | -e 's/-fno-second-underscore//' -e 's/-fstatic//' \ |
---|
| 389 | -e 's/-lparallel//' \ |
---|
| 390 | -e 's/-lorglob//' \ |
---|
| 391 | -e 's/-ffixed-form//' -e 's/-ffree-form//' \ |
---|
[1589] | 392 | -e 's/set OPT_LINUX.*.$/set OPT_LINUX=\"'"$OPTIMGCM"\"'/' makegcm.orig >| makegcm |
---|
[1590] | 393 | elif [ $compilo = ifort ] ; then |
---|
| 394 | sed \ |
---|
| 395 | -e 's:\#setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
---|
| 396 | -e 's:\#setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
---|
| 397 | -e 's:setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
---|
| 398 | -e 's:setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
---|
| 399 | -e 's/set FC_LINUX.*.$/set FC_LINUX='$compilo'/' \ |
---|
| 400 | -e 's/g95/ifort/g' \ |
---|
| 401 | -e 's/-fmod=/-module /g' \ |
---|
| 402 | -e 's/-fno-second-underscore//' -e 's/-fstatic//' \ |
---|
| 403 | -e 's/-lparallel//' \ |
---|
| 404 | -e 's/-lorglob//' \ |
---|
| 405 | -e 's/-ffixed-form//' -e 's/-ffree-form//' \ |
---|
| 406 | -e 's/set OPT_LINUX.*.$/set OPT_LINUX=\"'"$OPTIMGCM"\"'/' makegcm.orig >| makegcm |
---|
[1588] | 407 | else # g95 or pgf90 |
---|
| 408 | sed \ |
---|
| 409 | -e 's:\#setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
---|
| 410 | -e 's:\#setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
---|
| 411 | -e 's:setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
---|
| 412 | -e 's:setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
---|
| 413 | -e 's/set FC_LINUX.*.$/set FC_LINUX='$compilo'/' \ |
---|
| 414 | -e 's/-fno-second-underscore//' -e 's/-fstatic//' \ |
---|
| 415 | -e 's/-lparallel//' \ |
---|
| 416 | -e 's/-lorglob//' \ |
---|
| 417 | -e 's/-ffixed-form//' -e 's/-ffree-form//' \ |
---|
[1589] | 418 | -e 's/set OPT_LINUX.*.$/set OPT_LINUX=\"'"$OPTIMGCM"\"'/' makegcm.orig >| makegcm |
---|
[1588] | 419 | fi |
---|
| 420 | else |
---|
| 421 | sed \ |
---|
| 422 | -e 's/-lparallel//' \ |
---|
| 423 | -e 's/-lorglob//' \ |
---|
| 424 | -e 's/-lsxorglob//' \ |
---|
| 425 | -e 's/-lsxparallel//' \ |
---|
| 426 | -e 's/-lsxioipsl/-lioipsl/g' \ |
---|
| 427 | makegcm.orig >| makegcm |
---|
| 428 | fi |
---|
| 429 | |
---|
| 430 | chmod +x makegcm |
---|
| 431 | |
---|
| 432 | ########################################################### |
---|
| 433 | # Pour ceux qui voudraient utiliser fcm et pouvoir faire : |
---|
| 434 | # makelmdz_fcm -arch local ..... |
---|
| 435 | ############################################################ |
---|
| 436 | |
---|
| 437 | if [ "$pclinux" = 1 ] ; then |
---|
| 438 | # creation de fichiers 'arch' locaux (si sur PC Linx): |
---|
| 439 | cd arch |
---|
| 440 | # fichier arch-local.path |
---|
[1590] | 441 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdf\"" > arch-local.path |
---|
| 442 | echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path |
---|
[1588] | 443 | echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
| 444 | echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
| 445 | echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
| 446 | echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
| 447 | # fichier arch-local.fcm (adaptation de arch-linux-32bit.fcm) |
---|
| 448 | if [ $compilo = g95 ] ; then |
---|
| 449 | sed -e s:"%COMPILER pgf95":"%COMPILER g95":1 \ |
---|
| 450 | -e s:"%LINK pgf95":"%LINK g95":1 \ |
---|
[1590] | 451 | -e s:"%PROD_FFLAGS -fast":"%PROD_FFLAGS $OPTIM":1 \ |
---|
| 452 | -e s:"%BASE_FFLAGS ":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
[1588] | 453 | arch-linux-32bit.fcm > arch-local.fcm |
---|
[1589] | 454 | if [ $real = r8 ] ; then |
---|
[1588] | 455 | sed -e s:"%FPP_DEF ":"%FPP_DEF NC_DOUBLE":1 \ |
---|
| 456 | arch-local.fcm > arch-local.fcm.new |
---|
| 457 | mv -f arch-local.fcm.new arch-local.fcm |
---|
| 458 | fi |
---|
| 459 | elif [ $compilo = gfortran ] ; then |
---|
| 460 | sed -e s:"%COMPILER pgf95":"%COMPILER gfortran":1 \ |
---|
| 461 | -e s:"%LINK pgf95":"%LINK gfortran":1 \ |
---|
[1590] | 462 | -e s:"%PROD_FFLAGS -fast":"%PROD_FFLAGS $OPTIM":1 \ |
---|
| 463 | -e s:"%BASE_FFLAGS ":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
[1588] | 464 | arch-linux-32bit.fcm > arch-local.fcm |
---|
[1589] | 465 | if [ $real = r8 ] ; then |
---|
[1588] | 466 | sed -e s:"%FPP_DEF ":"%FPP_DEF NC_DOUBLE":1 \ |
---|
| 467 | arch-local.fcm > arch-local.fcm.new |
---|
| 468 | mv -f arch-local.fcm.new arch-local.fcm |
---|
| 469 | fi |
---|
| 470 | elif [ $compilo = pgf90 ] ; then |
---|
| 471 | sed -e s:"-Wl,-Bstatic -L/usr/lib/gcc-lib/i386-linux/2.95.2":" ":1 \ |
---|
[1590] | 472 | -e s:"%PROD_FFLAGS -fast":"%PROD_FFLAGS $OPTIM":1 \ |
---|
| 473 | -e s:"%BASE_FFLAGS ":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
[1588] | 474 | arch-linux-32bit.fcm > arch-local.fcm |
---|
[1590] | 475 | if [ $real = r8 ] ; then |
---|
[1588] | 476 | sed -e s:"%FPP_DEF ":"%FPP_DEF NC_DOUBLE":1 \ |
---|
| 477 | arch-local.fcm > arch-local.fcm.new |
---|
| 478 | mv -f arch-local.fcm.new arch-local.fcm |
---|
| 479 | fi |
---|
[1590] | 480 | elif [ $compilo = ifort ] ; then |
---|
| 481 | sed -e s:"%COMPILER pgf95":"%COMPILER ifort":1 \ |
---|
| 482 | -e s:"%LINK pgf95":"%LINK ifort":1 \ |
---|
| 483 | -e s:"-Wl,-Bstatic -L/usr/lib/gcc-lib/i386-linux/2.95.2":" ":1 \ |
---|
| 484 | -e s:"%PROD_FFLAGS -fast":"%PROD_FFLAGS $OPTIM":1 \ |
---|
| 485 | -e s:"%BASE_FFLAGS ":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
| 486 | -e s:"%DEBUG_FFLAGS -g -O0 -Kieee -Ktrap=fp -Mbounds":"%DEBUG_FFLAGS -g -no-ftz -traceback -ftrapuv -fp-stack-check -check":1 \ |
---|
| 487 | arch-linux-32bit.fcm > arch-local.fcm |
---|
| 488 | if [ $real = r8 ] ; then |
---|
| 489 | sed -e s:"%FPP_DEF ":"%FPP_DEF NC_DOUBLE":1 \ |
---|
| 490 | arch-local.fcm > arch-local.fcm.new |
---|
| 491 | mv -f arch-local.fcm.new arch-local.fcm |
---|
| 492 | fi |
---|
[1588] | 493 | else |
---|
| 494 | echo Le compilateur $compilo pas prevu ; exit |
---|
| 495 | fi # of if [ $compilo = g95 ] elif [ $compilo = pgf90 ] |
---|
| 496 | cd .. |
---|
| 497 | ### Adaptation de "bld.cfg" (ajout du shell): |
---|
| 498 | whereisthatshell=$(which ${use_shell}) |
---|
| 499 | echo "bld::tool::SHELL $whereisthatshell" >> bld.cfg |
---|
| 500 | |
---|
| 501 | ### Modification de makelmdz_fcm pour utilisation de ORCHIDEE dans cette bench: |
---|
| 502 | ### on enleve liborglob.a et libparallel.a |
---|
| 503 | cp makelmdz_fcm makelmdz_fcm.orig |
---|
| 504 | sed -e "s/-l\${LIBPREFIX}parallel//" \ |
---|
| 505 | sed -e "s/-l\${LIBPREFIX}orglob//" \ |
---|
| 506 | makelmdz_fcm.orig > makelmdz_fcm |
---|
| 507 | |
---|
| 508 | fi # of if [ "$pclinux" = 1 ] |
---|
| 509 | |
---|
| 510 | ################################################################## |
---|
| 511 | # Lance compilation de LMDZ |
---|
| 512 | ################################################################## |
---|
| 513 | ok_veget=false |
---|
| 514 | if [ "$veget" = 1 ] ; then ok_veget = true; fi |
---|
| 515 | if [ $compile_with_fcm = 1 ] ; then |
---|
| 516 | # Compilation avec makelmdz_fcm |
---|
| 517 | ./makelmdz_fcm -d ${grid_resolution} -arch local -v $ok_veget gcm |
---|
| 518 | else |
---|
[1590] | 519 | # Compilation avec makegcm: |
---|
| 520 | # 3 times! because some dependecies are not well resolved with makegcm |
---|
[1588] | 521 | ./makegcm -d ${grid_resolution} -v $ok_veget gcm |
---|
| 522 | ./makegcm -d ${grid_resolution} -v $ok_veget gcm |
---|
| 523 | ./makegcm -d ${grid_resolution} -v $ok_veget gcm |
---|
| 524 | fi |
---|
| 525 | |
---|
| 526 | if [ -f gcm.e ] || [ -f bin/gcm_${grid_resolution}_phylmd_seq_orch.e ] || [ -f bin/gcm_${grid_resolution}_phylmd_seq.e ] ; then |
---|
| 527 | echo '##########################################################' |
---|
| 528 | echo Compilation reussie |
---|
| 529 | echo '##########################################################' |
---|
| 530 | else |
---|
| 531 | echo Probleme de compilation |
---|
| 532 | exit |
---|
| 533 | fi |
---|
| 534 | |
---|
| 535 | ################################################################## |
---|
| 536 | # Ci dessous le lancement eventuel d'un cas test (si bench=0) |
---|
| 537 | ################################################################## |
---|
| 538 | if [ $bench = 0 ] ; then |
---|
| 539 | exit |
---|
| 540 | fi |
---|
| 541 | |
---|
| 542 | echo '##########################################################' |
---|
| 543 | echo Lancement d\'une simulation de test |
---|
| 544 | echo '##########################################################' |
---|
| 545 | |
---|
| 546 | \rm -r BENCH${grid_resolution} |
---|
| 547 | bench=bench_lmdz_${grid_resolution} |
---|
| 548 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/$bench.tar.gz |
---|
| 549 | gunzip $bench.tar.gz |
---|
| 550 | tar xvf $bench.tar |
---|
| 551 | |
---|
| 552 | if [ -f gcm.e ] ; then |
---|
| 553 | cp gcm.e BENCH${grid_resolution}/ |
---|
| 554 | elif [ -f bin/gcm_${grid_resolution}_phylmd_seq_orch.e ] ; then |
---|
| 555 | cp bin/gcm_${grid_resolution}_phylmd_seq_orch.e BENCH${grid_resolution}/gcm.e |
---|
| 556 | elif [ -f bin/gcm_${grid_resolution}_phylmd_seq.e ] ; then |
---|
| 557 | cp bin/gcm_${grid_resolution}_phylmd_seq.e BENCH${grid_resolution}/gcm.e |
---|
| 558 | else |
---|
| 559 | echo "No gcm.e found" |
---|
| 560 | exit |
---|
| 561 | fi |
---|
| 562 | |
---|
| 563 | if [ $hostname = brodie ] ; then |
---|
| 564 | echo POUR LANCER LE BENCH, IL FAUT SE LOGUER SUR BRODIE01 |
---|
| 565 | echo puis aller sur `pwd`/BENCH${grid_resolution} |
---|
| 566 | echo et lancer le gcm |
---|
| 567 | exit |
---|
| 568 | fi |
---|
| 569 | |
---|
| 570 | cd BENCH${grid_resolution} |
---|
| 571 | ./bench.sh > bench.out 2>&1 |
---|
| 572 | |
---|
| 573 | echo '##########################################################' |
---|
| 574 | echo ' Resultat du bench ' |
---|
| 575 | echo '##########################################################' |
---|
| 576 | |
---|
| 577 | cat ./bench.out |
---|
| 578 | |
---|
| 579 | echo '##########################################################' |
---|
| 580 | echo 'La simulation test est terminee sur' `pwd` |
---|
| 581 | echo 'vous pouvez la relancer : cd ' `pwd` ' ; gcm.e' |
---|
| 582 | echo 'ou ./bench.sh' |
---|
| 583 | echo '##########################################################' |
---|
| 584 | |
---|