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 def Install(self): 25 return self.installDir 26 27 def configureLibrary(self): 28 ''' Just assume the downloaded library will work''' 29 if self.framework.clArgDB.has_key('with-pflotran'): 30 raise RuntimeError('Pflotran does not support --with-pflotran; only --download-pflotran') 31 if self.framework.clArgDB.has_key('with-pflotran-dir'): 32 raise RuntimeError('Pflotran does not support --with-pflotran-dir; only --download-pflotran') 33 if self.framework.clArgDB.has_key('with-pflotran-include'): 34 raise RuntimeError('Pflotran does not support --with-pflotran-include; only --download-pflotran') 35 if self.framework.clArgDB.has_key('with-pflotran-lib'): 36 raise RuntimeError('Pflotran does not support --with-pflotran-lib; only --download-pflotran') 37 if self.framework.clArgDB.has_key('with-pflotran-shared'): 38 raise RuntimeError('Pflotran does not support --with-pflotran-shared') 39 40 self.checkDownload() 41 self.include = [os.path.join(self.installDir,'include')] 42 self.lib = [os.path.join(self.installDir,'lib','libpflotranchem.a'),os.path.join(self.installDir,'lib','libpflotran.a')] 43 self.found = 1 44 self.dlib = self.lib 45 if not hasattr(self.framework, 'packages'): 46 self.framework.packages = [] 47 self.framework.packages.append(self) 48 49 def postProcess(self): 50 self.compilePETSc() 51 52 try: 53 self.logPrintBox('Configure Pflotran; this may take several minutes') 54 if self.framework.argDB['prefix']: 55 PDIR = 'PETSC_DIR='+self.framework.argDB['prefix'] 56 PARCH = '' 57 PREFIX = '--prefix='+self.framework.argDB['prefix'] 58 else: 59 PDIR = 'PETSC_DIR='+self.petscdir.dir 60 PARCH = 'PETSC_ARCH='+self.arch 61 PREFIX = '--prefix='+os.path.join(self.petscdir.dir,self.arch) 62 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && '+PARCH+' '+PDIR+' ./configure all '+PREFIX,timeout=10, log = self.log) 63 self.log.write(output+err) 64 65 self.logPrintBox('Compiling Pflotran; this may take several minutes') 66 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && make all',timeout=1000, log = self.log) 67 self.log.write(output+err) 68 69 self.logPrintBox('Installing Pflotran; this may take several minutes') 70 self.installDirProvider.printSudoPasswordMessage(1) 71 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && '+self.installDirProvider.installSudo+' make install',timeout=100, log = self.log) 72 self.log.write(output+err) 73 except RuntimeError, e: 74 raise RuntimeError('Error configuring/compiling or installing Pflotran: '+str(e)) 75 76 77