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