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-dev'] 9 self.functions = [] 10 self.includes = [] 11 self.hastests = 1 12 self.fc = 1 # 1 means requires fortran 13 self.linkedbypetsc = 0 14 return 15 16 def setupDependencies(self, framework): 17 config.package.GNUPackage.setupDependencies(self, framework) 18 self.mpi = framework.require('config.packages.MPI', self) 19 self.hdf5 = framework.require('config.packages.hdf5', self) 20 self.deps = [self.mpi, self.hdf5] 21 return 22 23 def Install(self): 24 return self.installDir 25 26 def configureLibrary(self): 27 ''' Just assume the downloaded library will work''' 28 if self.framework.clArgDB.has_key('with-pflotran'): 29 raise RuntimeError('Pflotran does not support --with-pflotran; only --download-pflotran') 30 if self.framework.clArgDB.has_key('with-pflotran-dir'): 31 raise RuntimeError('Pflotran does not support --with-pflotran-dir; only --download-pflotran') 32 if self.framework.clArgDB.has_key('with-pflotran-include'): 33 raise RuntimeError('Pflotran does not support --with-pflotran-include; only --download-pflotran') 34 if self.framework.clArgDB.has_key('with-pflotran-lib'): 35 raise RuntimeError('Pflotran does not support --with-pflotran-lib; only --download-pflotran') 36 if self.framework.clArgDB.has_key('with-pflotran-shared'): 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')] 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 # Patch the PETSc paths so that older versions of PFlotran can find Fortran include files and configuration files 52 try: 53 if not os.path.isdir(os.path.join(self.petscdir.dir,'include','finclude')): 54 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+os.path.join(self.petscdir.dir,'include')+' && ln -s petsc/finclude finclude',timeout=10, log = self.log) 55 if not os.path.isdir(os.path.join(self.petscdir.dir,'conf')): 56 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+self.petscdir.dir+' && ln -s lib/petsc/conf conf',timeout=10, log = self.log) 57 except RuntimeError, e: 58 raise RuntimeError('Unable to make links required by older versions of PFlotran') 59 try: 60 self.logPrintBox('Compiling Pflotran; this may take several minutes') 61 # uses the regular PETSc library builder and then moves result 62 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+os.path.join(self.packageDir,'src','pflotran')+' && '+self.make.make+' have_hdf5=1 use_matseqaij_fix=1 PETSC_DIR='+self.petscdir.dir+' PETSC_ARCH='+self.arch+' libpflotranchem.a',timeout=1000, log = self.log) 63 self.log.write(output+err) 64 self.logPrintBox('Installing Pflotran; this may take several minutes') 65 self.installDirProvider.printSudoPasswordMessage(1) 66 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && '+self.installDirProvider.installSudo+'cp -f '+os.path.join('src','pflotran','libpflotran*.a')+' '+os.path.join(self.installDir,'lib'),timeout=1000, log = self.log) 67 self.log.write(output+err) 68 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+self.packageDir+' && '+self.installDirProvider.installSudo+'cp -f '+os.path.join('src','pflotran','*.mod')+' '+self.include[0],timeout=100, log = self.log) 69 self.log.write(output+err) 70 except RuntimeError, e: 71 raise RuntimeError('Error running make on Pflotran: '+str(e)) 72 73 74