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.buildLanguages = ['FC'] # 1 means requires fortran 13 self.linkedbypetsc = 0 14 self.useddirectly = 0 15 self.skippackagelibincludedirs = 1 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 'with-pflotran' in self.framework.clArgDB: 33 raise RuntimeError('Pflotran does not support --with-pflotran; only --download-pflotran') 34 if 'with-pflotran-dir' in self.framework.clArgDB: 35 raise RuntimeError('Pflotran does not support --with-pflotran-dir; only --download-pflotran') 36 if 'with-pflotran-shared' in self.framework.clArgDB: 37 raise RuntimeError('Pflotran does not support --with-pflotran-shared') 38 39 self.checkDownload() 40 self.include = [os.path.join(self.installDir,'include')] 41 self.lib = [os.path.join(self.installDir,'lib','libpflotranchem.a'),os.path.join(self.installDir,'lib','libpflotran.a')] 42 self.found = 1 43 self.dlib = self.lib 44 if not hasattr(self.framework, 'packages'): 45 self.framework.packages = [] 46 self.framework.packages.append(self) 47 48 def postProcess(self): 49 self.compilePETSc() 50 51 try: 52 self.logPrintBox('Configure Pflotran; this may take several minutes') 53 # TODO: remove this prefix code and use the mechanisms in package.py for selecting the destination directory; currently if postProcess is used 54 # TODO: package.py may not allow installing in prefix location 55 if self.framework.argDB['prefix']: 56 PDIR = 'PETSC_DIR='+self.framework.argDB['prefix'] 57 PARCH = '' 58 PREFIX = '--prefix='+self.framework.argDB['prefix'] 59 else: 60 PDIR = 'PETSC_DIR='+self.petscdir.dir 61 PARCH = 'PETSC_ARCH='+self.arch 62 PREFIX = '--prefix='+os.path.join(self.petscdir.dir,self.arch) 63 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && '+PARCH+' '+PDIR+' ./configure all '+PREFIX,timeout=60, log = self.log) 64 self.log.write(output+err) 65 66 self.logPrintBox('Compiling Pflotran; this may take several minutes') 67 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && make all',timeout=1000, log = self.log) 68 self.log.write(output+err) 69 70 self.logPrintBox('Installing Pflotran; this may take several minutes') 71 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && make install',timeout=100, log = self.log) 72 self.log.write(output+err) 73 except RuntimeError as e: 74 raise RuntimeError('Error configuring/compiling or installing Pflotran: '+str(e)) 75