| [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"'/' \ |
|---|
| [1621] | 290 | -e 's:g95.*.NCDF_INC.*.$:g95 NCDF_INC= '"$ncdfdir"'/include:' \ |
|---|
| 291 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdf:' \ |
|---|
| [1588] | 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 |
|---|
| [1621] | 321 | # Build IOIPSL modules and library |
|---|
| [1588] | 322 | make clean |
|---|
| 323 | make |
|---|
| 324 | if [ $compilo = gfortran ] ; then # copy module files to lib |
|---|
| 325 | cp -f *.mod ../../../lib |
|---|
| 326 | fi |
|---|
| [1621] | 327 | # Build IOIPSL tools (ie: "rebuild", if present) |
|---|
| 328 | if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then |
|---|
| 329 | cd $MODEL/modipsl/modeles/IOIPSL/tools |
|---|
| 330 | # adapt Makefile & rebuild script if in bash |
|---|
| 331 | if [ "$use_shell" = "bash" ] ; then |
|---|
| 332 | cp Makefile Makefile.ksh |
|---|
| 333 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
|---|
| 334 | cp rebuild rebuild.ksh |
|---|
| 335 | sed -e 's:/bin/ksh:/bin/bash:g' \ |
|---|
| 336 | -e 's:print -u2:echo:g' \ |
|---|
| 337 | -e 's:print:echo:g' rebuild.ksh > rebuild |
|---|
| 338 | fi |
|---|
| 339 | make clean |
|---|
| 340 | make |
|---|
| 341 | fi |
|---|
| [1588] | 342 | else |
|---|
| 343 | # we're on brodie |
|---|
| 344 | sxgmake clean |
|---|
| 345 | sxgmake |
|---|
| 346 | fi |
|---|
| 347 | |
|---|
| 348 | if [ "$veget" = 1 ] ; then |
|---|
| 349 | echo '########################################################' |
|---|
| 350 | echo Compilation de ORCHIDEE, modele des surface continentales |
|---|
| 351 | echo '########################################################' |
|---|
| 352 | cd $MODEL/modipsl/modeles/ORCHIDEE |
|---|
| 353 | cd src_parameters |
|---|
| 354 | # Une petite astuce pour ORCHIDEE suivant qu'on est en real*4 ou real*8 |
|---|
| [1589] | 355 | |
|---|
| 356 | |
|---|
| [1588] | 357 | \cp reqdprec.$real reqdprec.f90 |
|---|
| 358 | make |
|---|
| 359 | if [ $compilo = gfortran ] ; then # copy module files to lib |
|---|
| 360 | cp -f *.mod ../../../lib |
|---|
| 361 | fi |
|---|
| 362 | cd ../src_stomate |
|---|
| 363 | make |
|---|
| 364 | if [ $compilo = gfortran ] ; then # copy module files to lib |
|---|
| 365 | cp -f *.mod ../../../lib |
|---|
| 366 | fi |
|---|
| 367 | cd ../src_sechiba |
|---|
| 368 | make |
|---|
| 369 | if [ $compilo = gfortran ] ; then # copy module files to lib |
|---|
| 370 | cp -f *.mod ../../../lib |
|---|
| 371 | fi |
|---|
| 372 | fi |
|---|
| 373 | fi |
|---|
| 374 | |
|---|
| 375 | |
|---|
| 376 | # Ehouarn: it may be directory LMDZ4 or LMDZ5 depending on tar file... |
|---|
| 377 | if [[ -d $MODEL/modipsl/modeles/LMDZ4 ]] ; then |
|---|
| 378 | echo '##########################################################' |
|---|
| 379 | echo 'Compilation de LMDZ4' |
|---|
| 380 | echo '##########################################################' |
|---|
| 381 | cd $MODEL/modipsl/modeles/LMDZ4 |
|---|
| 382 | else |
|---|
| 383 | if [[ -d $MODEL/modipsl/modeles/LMDZ5 ]] ; then |
|---|
| 384 | echo '##########################################################' |
|---|
| 385 | echo 'Compilation de LMDZ5' |
|---|
| 386 | echo '##########################################################' |
|---|
| 387 | cd $MODEL/modipsl/modeles/LMDZ5 |
|---|
| 388 | else |
|---|
| 389 | echo "ERROR: No LMDZ4 (or LMDZ5) directory !!!" |
|---|
| 390 | exit |
|---|
| 391 | fi |
|---|
| 392 | fi |
|---|
| 393 | |
|---|
| 394 | if [ "$pclinux" = 1 ] ; then |
|---|
| 395 | if [ $compilo = gfortran ] ; then |
|---|
| 396 | sed \ |
|---|
| 397 | -e 's:\#setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
|---|
| 398 | -e 's:\#setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
|---|
| 399 | -e 's:setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
|---|
| 400 | -e 's:setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
|---|
| 401 | -e 's/set FC_LINUX.*.$/set FC_LINUX='$compilo'/' \ |
|---|
| 402 | -e 's/g95/gfortran/g' \ |
|---|
| 403 | -e 's/-fmod=/-I/g' \ |
|---|
| 404 | -e 's/-fno-second-underscore//' -e 's/-fstatic//' \ |
|---|
| 405 | -e 's/-lparallel//' \ |
|---|
| 406 | -e 's/-lorglob//' \ |
|---|
| 407 | -e 's/-ffixed-form//' -e 's/-ffree-form//' \ |
|---|
| [1589] | 408 | -e 's/set OPT_LINUX.*.$/set OPT_LINUX=\"'"$OPTIMGCM"\"'/' makegcm.orig >| makegcm |
|---|
| [1590] | 409 | elif [ $compilo = ifort ] ; then |
|---|
| 410 | sed \ |
|---|
| 411 | -e 's:\#setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
|---|
| 412 | -e 's:\#setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
|---|
| 413 | -e 's:setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
|---|
| 414 | -e 's:setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
|---|
| 415 | -e 's/set FC_LINUX.*.$/set FC_LINUX='$compilo'/' \ |
|---|
| 416 | -e 's/g95/ifort/g' \ |
|---|
| 417 | -e 's/-fmod=/-module /g' \ |
|---|
| 418 | -e 's/-fno-second-underscore//' -e 's/-fstatic//' \ |
|---|
| 419 | -e 's/-lparallel//' \ |
|---|
| 420 | -e 's/-lorglob//' \ |
|---|
| 421 | -e 's/-ffixed-form//' -e 's/-ffree-form//' \ |
|---|
| 422 | -e 's/set OPT_LINUX.*.$/set OPT_LINUX=\"'"$OPTIMGCM"\"'/' makegcm.orig >| makegcm |
|---|
| [1588] | 423 | else # g95 or pgf90 |
|---|
| 424 | sed \ |
|---|
| 425 | -e 's:\#setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
|---|
| 426 | -e 's:\#setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
|---|
| 427 | -e 's:setenv NCDFINC.*.$:setenv NCDFINC '"$ncdfdir"'/include:' \ |
|---|
| 428 | -e 's:setenv NCDFLIB.*.$:setenv NCDFLIB '"$ncdfdir"'/lib:' \ |
|---|
| 429 | -e 's/set FC_LINUX.*.$/set FC_LINUX='$compilo'/' \ |
|---|
| 430 | -e 's/-fno-second-underscore//' -e 's/-fstatic//' \ |
|---|
| 431 | -e 's/-lparallel//' \ |
|---|
| 432 | -e 's/-lorglob//' \ |
|---|
| 433 | -e 's/-ffixed-form//' -e 's/-ffree-form//' \ |
|---|
| [1589] | 434 | -e 's/set OPT_LINUX.*.$/set OPT_LINUX=\"'"$OPTIMGCM"\"'/' makegcm.orig >| makegcm |
|---|
| [1588] | 435 | fi |
|---|
| 436 | else |
|---|
| 437 | sed \ |
|---|
| 438 | -e 's/-lparallel//' \ |
|---|
| 439 | -e 's/-lorglob//' \ |
|---|
| 440 | -e 's/-lsxorglob//' \ |
|---|
| 441 | -e 's/-lsxparallel//' \ |
|---|
| 442 | -e 's/-lsxioipsl/-lioipsl/g' \ |
|---|
| 443 | makegcm.orig >| makegcm |
|---|
| 444 | fi |
|---|
| 445 | |
|---|
| 446 | chmod +x makegcm |
|---|
| 447 | |
|---|
| 448 | ########################################################### |
|---|
| 449 | # Pour ceux qui voudraient utiliser fcm et pouvoir faire : |
|---|
| 450 | # makelmdz_fcm -arch local ..... |
|---|
| 451 | ############################################################ |
|---|
| 452 | |
|---|
| 453 | if [ "$pclinux" = 1 ] ; then |
|---|
| 454 | # creation de fichiers 'arch' locaux (si sur PC Linx): |
|---|
| 455 | cd arch |
|---|
| 456 | # fichier arch-local.path |
|---|
| [1590] | 457 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdf\"" > arch-local.path |
|---|
| 458 | echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path |
|---|
| [1588] | 459 | echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
|---|
| 460 | echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
|---|
| 461 | echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
|---|
| 462 | echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
|---|
| 463 | # fichier arch-local.fcm (adaptation de arch-linux-32bit.fcm) |
|---|
| 464 | if [ $compilo = g95 ] ; then |
|---|
| 465 | sed -e s:"%COMPILER pgf95":"%COMPILER g95":1 \ |
|---|
| 466 | -e s:"%LINK pgf95":"%LINK g95":1 \ |
|---|
| [1590] | 467 | -e s:"%PROD_FFLAGS -fast":"%PROD_FFLAGS $OPTIM":1 \ |
|---|
| 468 | -e s:"%BASE_FFLAGS ":"%BASE_FFLAGS $OPTPREC":1 \ |
|---|
| [1588] | 469 | arch-linux-32bit.fcm > arch-local.fcm |
|---|
| [1589] | 470 | if [ $real = r8 ] ; then |
|---|
| [1588] | 471 | sed -e s:"%FPP_DEF ":"%FPP_DEF NC_DOUBLE":1 \ |
|---|
| 472 | arch-local.fcm > arch-local.fcm.new |
|---|
| 473 | mv -f arch-local.fcm.new arch-local.fcm |
|---|
| 474 | fi |
|---|
| 475 | elif [ $compilo = gfortran ] ; then |
|---|
| 476 | sed -e s:"%COMPILER pgf95":"%COMPILER gfortran":1 \ |
|---|
| 477 | -e s:"%LINK pgf95":"%LINK gfortran":1 \ |
|---|
| [1590] | 478 | -e s:"%PROD_FFLAGS -fast":"%PROD_FFLAGS $OPTIM":1 \ |
|---|
| 479 | -e s:"%BASE_FFLAGS ":"%BASE_FFLAGS $OPTPREC":1 \ |
|---|
| [1588] | 480 | arch-linux-32bit.fcm > arch-local.fcm |
|---|
| [1589] | 481 | if [ $real = r8 ] ; then |
|---|
| [1588] | 482 | sed -e s:"%FPP_DEF ":"%FPP_DEF NC_DOUBLE":1 \ |
|---|
| 483 | arch-local.fcm > arch-local.fcm.new |
|---|
| 484 | mv -f arch-local.fcm.new arch-local.fcm |
|---|
| 485 | fi |
|---|
| 486 | elif [ $compilo = pgf90 ] ; then |
|---|
| 487 | sed -e s:"-Wl,-Bstatic -L/usr/lib/gcc-lib/i386-linux/2.95.2":" ":1 \ |
|---|
| [1590] | 488 | -e s:"%PROD_FFLAGS -fast":"%PROD_FFLAGS $OPTIM":1 \ |
|---|
| 489 | -e s:"%BASE_FFLAGS ":"%BASE_FFLAGS $OPTPREC":1 \ |
|---|
| [1588] | 490 | arch-linux-32bit.fcm > arch-local.fcm |
|---|
| [1590] | 491 | if [ $real = r8 ] ; then |
|---|
| [1588] | 492 | sed -e s:"%FPP_DEF ":"%FPP_DEF NC_DOUBLE":1 \ |
|---|
| 493 | arch-local.fcm > arch-local.fcm.new |
|---|
| 494 | mv -f arch-local.fcm.new arch-local.fcm |
|---|
| 495 | fi |
|---|
| [1590] | 496 | elif [ $compilo = ifort ] ; then |
|---|
| 497 | sed -e s:"%COMPILER pgf95":"%COMPILER ifort":1 \ |
|---|
| 498 | -e s:"%LINK pgf95":"%LINK ifort":1 \ |
|---|
| 499 | -e s:"-Wl,-Bstatic -L/usr/lib/gcc-lib/i386-linux/2.95.2":" ":1 \ |
|---|
| 500 | -e s:"%PROD_FFLAGS -fast":"%PROD_FFLAGS $OPTIM":1 \ |
|---|
| 501 | -e s:"%BASE_FFLAGS ":"%BASE_FFLAGS $OPTPREC":1 \ |
|---|
| 502 | -e s:"%DEBUG_FFLAGS -g -O0 -Kieee -Ktrap=fp -Mbounds":"%DEBUG_FFLAGS -g -no-ftz -traceback -ftrapuv -fp-stack-check -check":1 \ |
|---|
| 503 | arch-linux-32bit.fcm > arch-local.fcm |
|---|
| 504 | if [ $real = r8 ] ; then |
|---|
| 505 | sed -e s:"%FPP_DEF ":"%FPP_DEF NC_DOUBLE":1 \ |
|---|
| 506 | arch-local.fcm > arch-local.fcm.new |
|---|
| 507 | mv -f arch-local.fcm.new arch-local.fcm |
|---|
| 508 | fi |
|---|
| [1588] | 509 | else |
|---|
| 510 | echo Le compilateur $compilo pas prevu ; exit |
|---|
| 511 | fi # of if [ $compilo = g95 ] elif [ $compilo = pgf90 ] |
|---|
| 512 | cd .. |
|---|
| 513 | ### Adaptation de "bld.cfg" (ajout du shell): |
|---|
| 514 | whereisthatshell=$(which ${use_shell}) |
|---|
| 515 | echo "bld::tool::SHELL $whereisthatshell" >> bld.cfg |
|---|
| 516 | |
|---|
| 517 | ### Modification de makelmdz_fcm pour utilisation de ORCHIDEE dans cette bench: |
|---|
| 518 | ### on enleve liborglob.a et libparallel.a |
|---|
| 519 | cp makelmdz_fcm makelmdz_fcm.orig |
|---|
| 520 | sed -e "s/-l\${LIBPREFIX}parallel//" \ |
|---|
| 521 | sed -e "s/-l\${LIBPREFIX}orglob//" \ |
|---|
| 522 | makelmdz_fcm.orig > makelmdz_fcm |
|---|
| 523 | |
|---|
| 524 | fi # of if [ "$pclinux" = 1 ] |
|---|
| 525 | |
|---|
| 526 | ################################################################## |
|---|
| 527 | # Lance compilation de LMDZ |
|---|
| 528 | ################################################################## |
|---|
| 529 | ok_veget=false |
|---|
| 530 | if [ "$veget" = 1 ] ; then ok_veget = true; fi |
|---|
| 531 | if [ $compile_with_fcm = 1 ] ; then |
|---|
| 532 | # Compilation avec makelmdz_fcm |
|---|
| 533 | ./makelmdz_fcm -d ${grid_resolution} -arch local -v $ok_veget gcm |
|---|
| 534 | else |
|---|
| [1590] | 535 | # Compilation avec makegcm: |
|---|
| 536 | # 3 times! because some dependecies are not well resolved with makegcm |
|---|
| [1588] | 537 | ./makegcm -d ${grid_resolution} -v $ok_veget gcm |
|---|
| 538 | ./makegcm -d ${grid_resolution} -v $ok_veget gcm |
|---|
| 539 | ./makegcm -d ${grid_resolution} -v $ok_veget gcm |
|---|
| 540 | fi |
|---|
| 541 | |
|---|
| 542 | if [ -f gcm.e ] || [ -f bin/gcm_${grid_resolution}_phylmd_seq_orch.e ] || [ -f bin/gcm_${grid_resolution}_phylmd_seq.e ] ; then |
|---|
| 543 | echo '##########################################################' |
|---|
| 544 | echo Compilation reussie |
|---|
| 545 | echo '##########################################################' |
|---|
| 546 | else |
|---|
| 547 | echo Probleme de compilation |
|---|
| 548 | exit |
|---|
| 549 | fi |
|---|
| 550 | |
|---|
| 551 | ################################################################## |
|---|
| 552 | # Ci dessous le lancement eventuel d'un cas test (si bench=0) |
|---|
| 553 | ################################################################## |
|---|
| 554 | if [ $bench = 0 ] ; then |
|---|
| 555 | exit |
|---|
| 556 | fi |
|---|
| 557 | |
|---|
| 558 | echo '##########################################################' |
|---|
| 559 | echo Lancement d\'une simulation de test |
|---|
| 560 | echo '##########################################################' |
|---|
| 561 | |
|---|
| 562 | \rm -r BENCH${grid_resolution} |
|---|
| 563 | bench=bench_lmdz_${grid_resolution} |
|---|
| 564 | wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/$bench.tar.gz |
|---|
| 565 | gunzip $bench.tar.gz |
|---|
| 566 | tar xvf $bench.tar |
|---|
| 567 | |
|---|
| 568 | if [ -f gcm.e ] ; then |
|---|
| 569 | cp gcm.e BENCH${grid_resolution}/ |
|---|
| 570 | elif [ -f bin/gcm_${grid_resolution}_phylmd_seq_orch.e ] ; then |
|---|
| 571 | cp bin/gcm_${grid_resolution}_phylmd_seq_orch.e BENCH${grid_resolution}/gcm.e |
|---|
| 572 | elif [ -f bin/gcm_${grid_resolution}_phylmd_seq.e ] ; then |
|---|
| 573 | cp bin/gcm_${grid_resolution}_phylmd_seq.e BENCH${grid_resolution}/gcm.e |
|---|
| 574 | else |
|---|
| 575 | echo "No gcm.e found" |
|---|
| 576 | exit |
|---|
| 577 | fi |
|---|
| 578 | |
|---|
| 579 | if [ $hostname = brodie ] ; then |
|---|
| 580 | echo POUR LANCER LE BENCH, IL FAUT SE LOGUER SUR BRODIE01 |
|---|
| 581 | echo puis aller sur `pwd`/BENCH${grid_resolution} |
|---|
| 582 | echo et lancer le gcm |
|---|
| 583 | exit |
|---|
| 584 | fi |
|---|
| 585 | |
|---|
| 586 | cd BENCH${grid_resolution} |
|---|
| 587 | ./bench.sh > bench.out 2>&1 |
|---|
| 588 | |
|---|
| 589 | echo '##########################################################' |
|---|
| 590 | echo ' Resultat du bench ' |
|---|
| 591 | echo '##########################################################' |
|---|
| 592 | |
|---|
| 593 | cat ./bench.out |
|---|
| 594 | |
|---|
| 595 | echo '##########################################################' |
|---|
| 596 | echo 'La simulation test est terminee sur' `pwd` |
|---|
| 597 | echo 'vous pouvez la relancer : cd ' `pwd` ' ; gcm.e' |
|---|
| 598 | echo 'ou ./bench.sh' |
|---|
| 599 | echo '##########################################################' |
|---|
| 600 | |
|---|