xref: /petsc/config/BuildSystem/config/packages/pflotran.py (revision d9293e7bd9ca63c09dc8211f3f44a7e9b14af8ae)
1import config.package
2import os
3
4class Configure(config.package.GNUPackage):
5  def __init__(self, framework):
6    config.package.GNUPackage.__init__(self, framework)
7    self.download          = ['ssh://hg@bitbucket.org/pflotran/pflotran-dev']
8    self.functions         = []
9    self.includes          = []
10    self.hastests          = 1
11    return
12
13  def setupDependencies(self, framework):
14    config.package.GNUPackage.setupDependencies(self, framework)
15    self.petscdir       = framework.require('PETSc.options.petscdir', self.setCompilers)
16    self.mpi   = framework.require('config.packages.MPI', self)
17    self.hdf5  = framework.require('config.packages.hdf5', self)
18    self.deps  = [self.mpi, self.hdf5]
19    return
20
21  def Install(self):
22    return self.installDir
23
24  def configureLibrary(self):
25    ''' Just assume the downloaded library will work'''
26    if self.framework.clArgDB.has_key('with-pflotran'):
27      raise RuntimeError('Pflotran does not support --with-pflotran; only --download-pflotran')
28    if self.framework.clArgDB.has_key('with-pflotran-dir'):
29      raise RuntimeError('Pflotran does not support --with-pflotran-dir; only --download-pflotran')
30    if self.framework.clArgDB.has_key('with-pflotran-include'):
31      raise RuntimeError('Pflotran does not support --with-pflotran-include; only --download-pflotran')
32    if self.framework.clArgDB.has_key('with-pflotran-lib'):
33      raise RuntimeError('Pflotran does not support --with-pflotran-lib; only --download-pflotran')
34    if self.framework.clArgDB.has_key('with-pflotran-shared'):
35      raise RuntimeError('Pflotran does not support --with-pflotran-shared')
36
37    self.checkDownload()
38    self.include = [os.path.join(self.installDir,'include')]
39    self.lib     = [os.path.join(self.installDir,'lib','libpflotran.a'),os.path.join(self.installDir,'lib','libpflotranchem.a')]
40    self.found   = 1
41    self.dlib    = self.lib
42    if not hasattr(self.framework, 'packages'):
43      self.framework.packages = []
44    self.framework.packages.append(self)
45
46  def postProcess(self):
47    try:
48      self.logPrintBox('Compiling Pflotran; this may take several minutes')
49      # uses the regular PETSc library builder and then moves result
50      output,err,ret  = config.package.GNUPackage.executeShellCommand('cd '+os.path.join(self.packageDir,'src','pflotran')+' && '+self.make.make+' use_matseqaij_fix=1 PETSC_DIR='+self.petscdir.dir+' PETSC_ARCH='+self.arch+' libpflotran.a libpflotranchem.a',timeout=1000, log = self.log)
51      self.log.write(output+err)
52      self.logPrintBox('Installing Pflotran; this may take several minutes')
53      self.installDirProvider.printSudoPasswordMessage(1)
54      output,err,ret  = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && '+self.installDirProvider.installSudo+'cp -f '+os.path.join('src','pflotran','libpflotran.a')+' '+self.lib[0],timeout=1000, log = self.log)
55      output,err,ret  = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && '+self.installDirProvider.installSudo+'cp -f '+os.path.join('src','pflotran','libpflotranchem.a')+' '+self.lib[1],timeout=1000, log = self.log)
56      self.log.write(output+err)
57      output,err,ret  = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && '+self.installDirProvider.installSudo+'cp -f '+os.path.join('src','pflotran','*.mod')+' '+self.include[0],timeout=1000, log = self.log)
58      self.log.write(output+err)
59    except RuntimeError, e:
60      raise RuntimeError('Error running make on Pflotran: '+str(e))
61
62
63