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