source: issm/trunk-jpl/externalpackages/petsc-dev/src/config/PETSc/packages/SCALAPACK.py@ 11896

Last change on this file since 11896 was 11896, checked in by habbalf, 13 years ago

petsc-dev : Petsc development code in external packages. Mercurial updates

File size: 5.0 KB
Line 
1import PETSc.package
2
3class Configure(PETSc.package.NewPackage):
4 def __init__(self, framework):
5 PETSc.package.NewPackage.__init__(self, framework)
6 # use the version from PETSc ftp site - it has lapack removed
7 self.download = ['http://ftp.mcs.anl.gov/pub/petsc/externalpackages/SCALAPACK-1.7.tar.gz']
8 self.includes = []
9 self.liblist = [[],['libscalapack.a']]
10 self.functions = ['pssytrd']
11 self.requires32bitint = 0
12 self.functionsFortran = 1
13 self.complex = 1
14 self.useddirectly = 0 # PETSc does not use ScaLAPACK, it is only used by MUMPS
15 self.worksonWindows = 1
16 self.downloadonWindows= 1
17 return
18
19 def setupDependencies(self, framework):
20 PETSc.package.NewPackage.setupDependencies(self, framework)
21 self.blasLapack = framework.require('config.packages.BlasLapack',self)
22 self.blacs = framework.require('PETSc.packages.blacs',self)
23 self.deps = [self.blacs, self.mpi, self.blasLapack]
24 return
25
26 def Install(self):
27 import os
28 if not hasattr(self.setCompilers, 'FC'):
29 raise RuntimeError('SCALAPACK requires Fortran for automatic installation')
30
31 g = open(os.path.join(self.packageDir,'SLmake.inc'),'w')
32 g.write('SHELL = /bin/sh\n')
33 g.write('home = '+self.getDir()+'\n')
34 g.write('USEMPI = -DUsingMpiBlacs\n')
35 g.write('SENDIS = -DSndIsLocBlk\n')
36 if (self.mpi.commf2c):
37 g.write('WHATMPI = -DUseMpi2\n')
38 else:
39 g.write('WHATMPI = -DCSAMEF77\n')
40 g.write('BLACSDBGLVL = -DBlacsDebugLvl=1\n')
41 g.write('BLACSLIB = '+self.libraries.toString(self.blacs.lib)+'\n')
42 g.write('SMPLIB = '+self.libraries.toString(self.mpi.lib)+'\n')
43 g.write('SCALAPACKLIB = '+os.path.join(self.installDir,self.libdir,'libscalapack.'+self.setCompilers.AR_LIB_SUFFIX)+' \n')
44 g.write('CBLACSLIB = $(BLACSCINIT) $(BLACSLIB) $(BLACSCINIT)\n')
45 g.write('FBLACSLIB = $(BLACSFINIT) $(BLACSLIB) $(BLACSFINIT)\n')
46 # this mangling information is for both BLAS and the Fortran compiler so cannot use the BlasLapack mangling flag
47 if self.compilers.fortranManglingDoubleUnderscore:
48 blah = 'f77IsF2C'
49 elif self.compilers.fortranMangling == 'underscore':
50 blah = 'Add_'
51 elif self.compilers.fortranMangling == 'caps':
52 blah = 'UpCase'
53 else:
54 blah = 'NoChange'
55 g.write('CDEFS =-D'+blah+' -DUsingMpiBlacs\n')
56 g.write('PBLASdir = $(home)/PBLAS\n')
57 g.write('SRCdir = $(home)/SRC\n')
58 g.write('TOOLSdir = $(home)/TOOLS\n')
59 g.write('REDISTdir = $(home)/REDIST\n')
60 self.setCompilers.pushLanguage('FC')
61 g.write('F77 = '+self.setCompilers.getCompiler()+'\n')
62 g.write('F77FLAGS = '+self.setCompilers.getCompilerFlags().replace('-Wall','').replace('-Wshadow','').replace('-Mfree','')+'\n')
63 g.write('F77LOADER = '+self.setCompilers.getLinker()+'\n')
64 g.write('F77LOADFLAGS = '+self.setCompilers.getLinkerFlags()+'\n')
65 self.setCompilers.popLanguage()
66 self.setCompilers.pushLanguage('C')
67 g.write('CC = '+self.setCompilers.getCompiler()+'\n')
68 g.write('CCFLAGS = '+self.setCompilers.getCompilerFlags().replace('-Wall','').replace('-Wshadow','')+'\n')
69 g.write('CCLOADER = '+self.setCompilers.getLinker()+'\n')
70 g.write('CCLOADFLAGS = '+self.setCompilers.getLinkerFlags()+'\n')
71 self.setCompilers.popLanguage()
72 g.write('ARCH = '+self.setCompilers.AR+'\n')
73 g.write('ARCHFLAGS = '+self.setCompilers.AR_FLAGS+'\n')
74 g.write('RANLIB = '+self.setCompilers.RANLIB+'\n')
75 g.close()
76
77 if self.installNeeded('SLmake.inc'):
78 try:
79 output,err,ret = PETSc.package.NewPackage.executeShellCommand('cd '+self.packageDir+' && make cleanlib', timeout=2500, log = self.framework.log)
80 except RuntimeError, e:
81 pass
82 try:
83 self.logPrintBox('Compiling Scalapack; this may take several minutes')
84 output,err,ret = PETSc.package.NewPackage.executeShellCommand('cd '+self.packageDir+' && make', timeout=2500, log = self.framework.log)
85 except RuntimeError, e:
86 raise RuntimeError('Error running make on SCALAPACK: '+str(e))
87 self.postInstall(output,'SLmake.inc')
88 return self.installDir
89
90 def checkLib(self, lib, func, mangle, otherLibs = []):
91 oldLibs = self.compilers.LIBS
92 found = self.libraries.check(lib,func, otherLibs = otherLibs+self.mpi.lib+self.blasLapack.lib+self.compilers.flibs,fortranMangle=mangle)
93 self.compilers.LIBS = oldLibs
94 if found:
95 self.framework.log.write('Found function '+str(func)+' in '+str(lib)+'\n')
96 return found
97
98 def consistencyChecks(self):
99 PETSc.package.NewPackage.consistencyChecks(self)
100 if self.framework.argDB['with-'+self.package]:
101 # SCALAPACK requires ALL of BLAS/LAPACK
102 if self.blasLapack.f2c:
103 raise RuntimeError('SCALAPACK requires a COMPLETE BLAS and LAPACK, it cannot be used with the --download-f2cblaslapack\nUse --download-f-blas-lapack option instead.')
104 return
Note: See TracBrowser for help on using the repository browser.