xref: /petsc/config/BuildSystem/config/packages/pflotran.py (revision 8208b9ae9936b534ffb14d7e4c50ae7ef117b6f5)
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.gitcommit         = 'xsdk-0.2.0-rc1'
8    #self.gitcommit        = 'origin/xsdk'
9    self.download          = ['git://https://github.com/petsc/pflotran']
10    self.functions         = []
11    self.includes          = []
12    self.hastests          = 1
13    self.fc                = 1    # 1 means requires fortran
14    self.linkedbypetsc     = 0
15    self.useddirectly      = 0
16    return
17
18  def setupDependencies(self, framework):
19    config.package.GNUPackage.setupDependencies(self, framework)
20    self.mpi      = framework.require('config.packages.MPI', self)
21    self.hdf5     = framework.require('config.packages.hdf5', self)
22    self.deps     = [self.mpi]
23    self.odeps    = [self.hdf5]
24    return
25
26  # the install is delayed until postProcess() since pflotran install requires PETSc to be installed before pflotran can be built
27  def Install(self):
28    return self.installDir
29
30  def configureLibrary(self):
31    ''' Since pflotran cannot be built until after PETSc is compiled we need to just assume the downloaded library will work'''
32    if self.framework.clArgDB.has_key('with-pflotran'):
33      raise RuntimeError('Pflotran does not support --with-pflotran; only --download-pflotran')
34    if self.framework.clArgDB.has_key('with-pflotran-dir'):
35      raise RuntimeError('Pflotran does not support --with-pflotran-dir; only --download-pflotran')
36    if self.framework.clArgDB.has_key('with-pflotran-include'):
37      raise RuntimeError('Pflotran does not support --with-pflotran-include; only --download-pflotran')
38    if self.framework.clArgDB.has_key('with-pflotran-lib'):
39      raise RuntimeError('Pflotran does not support --with-pflotran-lib; only --download-pflotran')
40    if self.framework.clArgDB.has_key('with-pflotran-shared'):
41      raise RuntimeError('Pflotran does not support --with-pflotran-shared')
42
43    self.checkDownload()
44    self.include = [os.path.join(self.installDir,'include')]
45    self.lib     = [os.path.join(self.installDir,'lib','libpflotranchem.a'),os.path.join(self.installDir,'lib','libpflotran.a')]
46    self.found   = 1
47    self.dlib    = self.lib
48    if not hasattr(self.framework, 'packages'):
49      self.framework.packages = []
50    self.framework.packages.append(self)
51
52  def postProcess(self):
53    self.compilePETSc()
54
55    try:
56      self.logPrintBox('Configure Pflotran; this may take several minutes')
57      if self.framework.argDB['prefix']:
58        PDIR   = 'PETSC_DIR='+self.framework.argDB['prefix']
59        PARCH  = ''
60        PREFIX = '--prefix='+self.framework.argDB['prefix']
61      else:
62        PDIR   = 'PETSC_DIR='+self.petscdir.dir
63        PARCH  = 'PETSC_ARCH='+self.arch
64        PREFIX = '--prefix='+os.path.join(self.petscdir.dir,self.arch)
65      output,err,ret  = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && '+PARCH+' '+PDIR+' ./configure all '+PREFIX,timeout=10, log = self.log)
66      self.log.write(output+err)
67
68      self.logPrintBox('Compiling Pflotran; this may take several minutes')
69      output,err,ret  = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && make all',timeout=1000, log = self.log)
70      self.log.write(output+err)
71
72      self.logPrintBox('Installing Pflotran; this may take several minutes')
73      self.installDirProvider.printSudoPasswordMessage(1)
74      output,err,ret  = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && '+self.installDirProvider.installSudo+' make install',timeout=100, log = self.log)
75      self.log.write(output+err)
76    except RuntimeError, e:
77      raise RuntimeError('Error configuring/compiling or installing Pflotran: '+str(e))
78
79
80