xref: /petsc/config/BuildSystem/config/packages/SuperLU.py (revision 417c5e9afaacda2cf655e58897fdfc9d4dd1055e)
1import config.package
2
3class Configure(config.package.Package):
4  def __init__(self, framework):
5    config.package.Package.__init__(self, framework)
6    self.download         = ['http://crd.lbl.gov/~xiaoye/SuperLU/superlu_4.3.tar.gz',
7                            'http://ftp.mcs.anl.gov/pub/petsc/externalpackages/superlu_4.3.tar.gz']
8    self.functions        = ['set_default_options']
9    self.includes         = ['slu_ddefs.h']
10    self.liblist          = [['libsuperlu_4.3.a']]
11    # SuperLU has NO support for 64 bit integers, use SuperLU_Dist if you need that
12    self.requires32bitint = 1;  # 1 means that the package will not work with 64 bit integers
13    self.excludedDirs     = ['SuperLU_DIST','SuperLU_MT']
14    # SuperLU does not work with --download-fblaslapack with Compaqf90 compiler on windows.
15    # However it should work with intel ifort.
16    self.downloadonWindows= 1
17    self.hastests         = 1
18    self.hastestsdatafiles= 1
19    return
20
21  def setupDependencies(self, framework):
22    config.package.Package.setupDependencies(self, framework)
23    self.blasLapack = self.framework.require('config.packages.BlasLapack',self)
24    self.deps       = [self.blasLapack]
25    return
26
27  def Install(self):
28    import os
29    # Get the SUPERLU directories
30
31    g = open(os.path.join(self.packageDir,'make.inc'),'w')
32    g.write('SuperLUroot  = '+self.packageDir+'\n')
33    g.write('TMGLIB       = tmglib.'+self.setCompilers.AR_LIB_SUFFIX+'\n')
34    g.write('SUPERLULIB   = $(SuperLUroot)/lib/libsuperlu_4.3.'+self.setCompilers.AR_LIB_SUFFIX+'\n')
35    g.write('BLASLIB      = '+self.libraries.toString(self.blasLapack.dlib)+'\n')
36    g.write('BLASDEF      = -DUSE_VENDOR_BLAS\n')
37    g.write('LIBS         = $(SUPERLULIB) $(BLASLIB)\n')
38    g.write('ARCH         = '+self.setCompilers.AR+'\n')
39    g.write('ARCHFLAGS    = '+self.setCompilers.AR_FLAGS+'\n')
40    g.write('RANLIB       = '+self.setCompilers.RANLIB+'\n')
41    self.setCompilers.pushLanguage('C')
42    g.write('CC           = '+self.setCompilers.getCompiler()+'\n')
43    g.write('CFLAGS       = '+self.setCompilers.getCompilerFlags()+'\n')
44    g.write('LOADER       = '+self.setCompilers.getLinker()+'\n')
45    g.write('LOADOPTS     = \n')
46    self.setCompilers.popLanguage()
47
48    # set blas name mangling
49    if self.blasLapack.mangling == 'underscore':
50      g.write('CDEFS        = -DAdd_')
51    elif self.blasLapack.mangling == 'caps':
52      g.write('CDEFS   = -DUpCase')
53    else:
54      g.write('CDEFS   = -DNoChange')
55    g.write('\n')
56
57    g.write('MATLAB       =\n')
58    g.write('NOOPTS       = '+self.getSharedFlag(self.setCompilers.getCompilerFlags())+' '+self.getPointerSizeFlag(self.setCompilers.getCompilerFlags())+' '+self.getWindowsNonOptFlags(self.setCompilers.getCompilerFlags())+'\n')
59    g.close()
60    if self.installNeeded('make.inc'):
61      try:
62        self.logPrintBox('Compiling and installing superlu; this may take several minutes')
63        self.installDirProvider.printSudoPasswordMessage()
64        output,err,ret = config.package.Package.executeShellCommand(self.installSudo+'mkdir -p '+os.path.join(self.installDir,'lib'), timeout=2500, log=self.log)
65        output,err,ret = config.package.Package.executeShellCommand(self.installSudo+'mkdir -p '+os.path.join(self.installDir,'include'), timeout=2500, log=self.log)
66        if not os.path.exists(os.path.join(self.packageDir,'lib')):
67          os.makedirs(os.path.join(self.packageDir,'lib'))
68        output,err,ret = config.package.Package.executeShellCommand('cd '+self.packageDir+' && make clean && make superlulib LAAUX="" SLASRC="" DLASRC="" CLASRC="" ZLASRC="" SCLAUX="" DZLAUX="" && '+self.installSudo+'cp -f lib/*.'+self.setCompilers.AR_LIB_SUFFIX+' '+os.path.join(self.installDir,self.libdir,'')+' &&  '+self.installSudo+'cp -f SRC/*.h '+os.path.join(self.installDir,self.includedir,''), timeout=2500, log = self.log)
69      except RuntimeError, e:
70        raise RuntimeError('Error running make on SUPERLU: '+str(e))
71      self.postInstall(output+err,'make.inc')
72    return self.installDir
73
74  def consistencyChecks(self):
75    config.package.Package.consistencyChecks(self)
76    if self.argDB['with-'+self.package]:
77      if not self.blasLapack.checkForRoutine('slamch'):
78        raise RuntimeError('SuperLU requires the LAPACK routine slamch()')
79      self.log.write('Found slamch() in Lapack library as needed by SuperLU\n')
80
81      if not self.blasLapack.checkForRoutine('dlamch'):
82        raise RuntimeError('SuperLU requires the LAPACK routine dlamch()')
83      self.log.write('Found dlamch() in Lapack library as needed by SuperLU\n')
84
85      if not self.blasLapack.checkForRoutine('xerbla'):
86        raise RuntimeError('SuperLU requires the BLAS routine xerbla()')
87      self.log.write('Found xerbla() in BLAS library as needed by SuperLU\n')
88    return
89