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 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')] 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 # Patch the PETSc paths so that older versions of PFlotran can find Fortran include files and configuration files 53 try: 54 if not os.path.isdir(os.path.join(self.petscdir.dir,'include','finclude')): 55 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) 56 if not os.path.isdir(os.path.join(self.petscdir.dir,'conf')): 57 output,err,ret = config.package.GNUPackage.executeShellCommand('cd '+self.petscdir.dir+' && ln -s lib/petsc/conf conf',timeout=10, log = self.log) 58 except RuntimeError, e: 59 raise RuntimeError('Unable to make links required by older versions of PFlotran') 60 try: 61 self.logPrintBox('Compiling Pflotran; this may take several minutes') 62 # uses the regular PETSc library builder and then moves result 63 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) 64 self.log.write(output+err) 65 self.logPrintBox('Installing Pflotran; this may take several minutes') 66 self.installDirProvider.printSudoPasswordMessage(1) 67 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) 68 self.log.write(output+err) 69 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) 70 self.log.write(output+err) 71 except RuntimeError, e: 72 raise RuntimeError('Error running make on Pflotran: '+str(e)) 73 74 75