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.hghash = '611092f80ddb' 8 self.download = ['hg://https://bitbucket.org/pflotran/pflotran-xsdk'] 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, self.hdf5] 22 return 23 24 # the install is delayed until postProcess() since pflotran install requires PETSc to be installed before pflotran can be built 25 def Install(self): 26 return self.installDir 27 28 def configureLibrary(self): 29 ''' Since pflotran cannot be built until after PETSc is compiled we need to just assume the downloaded library will work''' 30 if self.framework.clArgDB.has_key('with-pflotran'): 31 raise RuntimeError('Pflotran does not support --with-pflotran; only --download-pflotran') 32 if self.framework.clArgDB.has_key('with-pflotran-dir'): 33 raise RuntimeError('Pflotran does not support --with-pflotran-dir; only --download-pflotran') 34 if self.framework.clArgDB.has_key('with-pflotran-include'): 35 raise RuntimeError('Pflotran does not support --with-pflotran-include; only --download-pflotran') 36 if self.framework.clArgDB.has_key('with-pflotran-lib'): 37 raise RuntimeError('Pflotran does not support --with-pflotran-lib; only --download-pflotran') 38 if self.framework.clArgDB.has_key('with-pflotran-shared'): 39 raise RuntimeError('Pflotran does not support --with-pflotran-shared') 40 41 self.checkDownload() 42 self.include = [os.path.join(self.installDir,'include')] 43 self.lib = [os.path.join(self.installDir,'lib','libpflotranchem.a'),os.path.join(self.installDir,'lib','libpflotran.a')] 44 self.found = 1 45 self.dlib = self.lib 46 if not hasattr(self.framework, 'packages'): 47 self.framework.packages = [] 48 self.framework.packages.append(self) 49 50 def postProcess(self): 51 self.compilePETSc() 52 53 try: 54 self.logPrintBox('Configure Pflotran; this may take several minutes') 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=10, 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 self.installDirProvider.printSudoPasswordMessage(1) 72 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && '+self.installDirProvider.installSudo+' make install',timeout=100, log = self.log) 73 self.log.write(output+err) 74 except RuntimeError, e: 75 raise RuntimeError('Error configuring/compiling or installing Pflotran: '+str(e)) 76 77 78