Lines Matching refs:self
34 def __init__(self, framework):
35 config.base.Configure.__init__(self, framework)
36 self.headerPrefix = ''
37 self.substPrefix = ''
38 self.location = None
39 self.trial = {}
40 self.working = {}
43 def __str__(self):
44 if self.found:
46 desc.append(' Type: '+self.name)
47 desc.append(' Version: '+self.version)
48 desc.append(' Includes: '+str(self.include))
49 desc.append(' Library: '+str(self.lib))
54 def setupHelp(self, help):
66 def setupPackageDependencies(self, framework):
70 for (name, (petscDir, petscArch)) in self.getLocations():
76 self.logPrint('Loaded PETSc-AS configuration ('+name+') from '+confPath)
77 self.location = (petscDir, petscArch)
78 self.trial[self.location] = name
81 self.logPrint('PETSc-AS has no cached configuration in '+confPath)
86 self.downloadPETSc()
90 def setupDependencies(self, framework):
91 config.base.Configure.setupDependencies(self, framework)
92 self.languages = framework.require('PETSc.options.languages', self)
93 self.compilers = framework.require('config.compilers', self)
94 self.headers = framework.require('config.headers', self)
95 self.libraries = framework.require('config.libraries', self)
96 self.blaslapack = framework.require('config.packages.BlasLapack', self)
97 self.mpi = framework.require('config.packages.MPI', self)
100 def getPETScArch(self, petscDir):
102 if 'with-petsc-arch' in self.framework.argDB:
103 yield self.framework.argDB['with-petsc-arch']
110 def getLocations(self):
112 if hasattr(self, '_configured'):
113 key =(self.dir, self.arch)
114 yield (self.working[key], key)
116 if self.framework.argDB['download-petsc'] == 1:
117 yield self.downloadPETSc()
119 if 'with-petsc-dir' in self.framework.argDB:
120 petscDir = self.framework.argDB['with-petsc-dir']
121 for petscArch in self.getPETScArch(petscDir):
126 for petscArch in self.getPETScArch(petscDir):
130 for petscArch in self.getPETScArch(petscDir):
134 for packageDir in self.framework.argDB['with-packages-search-path']:
151 def downloadPETSc(self):
152 if self.framework.argDB['download-petsc'] == 0:
158 def getDir(self):
159 if self.location:
160 return self.location[0]
164 def getArch(self):
165 if self.location:
166 return self.location[1]
170 def getFound(self):
171 return self.location and self.location in self.working
174 def getName(self):
175 if self.location and self.location in self.working:
176 return self.working[self.location][0]
180 def getInclude(self, useTrial = 0):
181 if self.location and self.location in self.working:
182 return self.working[self.location][1]
183 elif useTrial and self.location and self.location in self.trial:
184 return self.trial[self.location][1]
188 def getLib(self, useTrial = 0):
189 if self.location and self.location in self.working:
190 return self.working[self.location][2]
191 elif useTrial and self.location and self.location in self.trial:
192 return self.trial[self.location][2]
196 def getVersion(self):
197 if self.location and self.location in self.working:
198 return self.working[self.location][3]
202 def getOtherIncludes(self):
203 if not hasattr(self, '_otherIncludes'):
205 includes.extend([self.headers.getIncludeArgument(inc) for inc in self.mpi.include])
207 return self._otherIncludes
208 def setOtherIncludes(self, otherIncludes):
209 self._otherIncludes = otherIncludes
212 def getOtherLibs(self):
213 if not hasattr(self, '_otherLibs'):
214 libs = self.compilers.flibs[:]
215 libs.extend(self.mpi.lib)
216 libs.extend(self.blaslapack.lib)
218 return self._otherLibs
219 def setOtherLibs(self, otherLibs):
220 self._otherLibs = otherLibs
223 def checkLib(self, libraries):
234 oldLibs = self.compilers.LIBS
235 self.libraries.pushLanguage(self.languages.clanguage)
236 found = (self.libraries.check(libraries, 'PetscInitializeNoArguments', otherLibs = self.otherLibs, prototype = 'int PetscInitializeNoArguments(void);') and
237 self.libraries.check(libraries, 'VecDestroy', otherLibs = self.otherLibs, prototype = 'typedef struct _p_Vec *Vec;int VecDestroy(Vec*);', call = 'VecDestroy((Vec*) 0)') and
238 self.libraries.check(libraries, 'MatDestroy', otherLibs = self.otherLibs, prototype = 'typedef struct _p_Mat *Mat;int MatDestroy(Mat*);', call = 'MatDestroy((Mat*) 0)') and
239 self.libraries.check(libraries, 'DMDestroy', otherLibs = self.otherLibs, prototype = 'typedef struct _p_DM *DA;int DMDestroy(DA*);', call = 'DMDestroy((DA*) 0)') and
240 self.libraries.check(libraries, 'KSPDestroy', otherLibs = self.otherLibs, prototype = 'typedef struct _p_KSP *KSP;int KSPDestroy(KSP*);', call = 'KSPDestroy((KSP*) 0)') and
241 self.libraries.check(libraries, 'SNESDestroy', otherLibs = self.otherLibs, prototype = 'typedef struct _p_SNES *SNES;int SNESDestroy(SNES*);', call = 'SNESDestroy((SNES*) 0)') and
242 self.libraries.check(libraries, 'TSDestroy', otherLibs = self.otherLibs, prototype = 'typedef struct _p_TS *TS;int TSDestroy(TS*);', call = 'TSDestroy((TS*) 0)'))
243 self.libraries.popLanguage()
244 self.compilers.LIBS = oldLibs
247 def checkInclude(self, includeDir):
249 oldFlags = self.compilers.CPPFLAGS
250 self.compilers.CPPFLAGS += ' '.join([self.headers.getIncludeArgument(inc) for inc in includeDir])
251 if self.otherIncludes:
252 self.compilers.CPPFLAGS += ' '+self.otherIncludes
253 self.pushLanguage(self.languages.clanguage)
254 found = self.checkPreprocess('#include <petscsys.h>\n')
255 self.popLanguage()
256 self.compilers.CPPFLAGS = oldFlags
259 def checkPETScLink(self, includes, body, cleanup = 1, codeBegin = None, codeEnd = None, shared = None):
262 oldFlags = self.compilers.CPPFLAGS
263 self.compilers.CPPFLAGS += ' '.join([self.headers.getIncludeArgument(inc) for inc in self.getInclude(useTrial = 1)])
264 if self.otherIncludes:
265 self.compilers.CPPFLAGS += ' '+self.otherIncludes
266 oldLibs = self.compilers.LIBS
267 self.compilers.LIBS = ' '.join([self.libraries.getLibArgument(lib) for lib in self.getLib(useTrial = 1)+self.otherLibs])+' '+self.compilers.LIBS
268 if self.checkLink(includes, body, cleanup, codeBegin, codeEnd, shared):
270 self.compilers.CPPFLAGS = oldFlags
271 self.compilers.LIBS = oldLibs
274 def checkWorkingLink(self):
276 self.pushLanguage(self.languages.clanguage)
277 if not self.checkPETScLink('#include <petsctime.h>\n', 'PetscLogDouble time;\n\nPetscCall(PetscTime(&time));\n'):
278 self.logPrint('PETSc cannot link, which indicates a problem with the PETSc installation')
280 self.logPrint('PETSc can link with '+self.languages.clanguage)
281 self.popLanguage()
283 if hasattr(self.compilers, 'CXX') and self.languages.clanguage == 'C':
284 self.pushLanguage('C++')
285 self.sourceExtension = '.C'
286 if not self.checkPETScLink('#include <petsctime.h>\n', 'PetscLogDouble time;\n\nPetscCall(PetscTime(&time));\n'):
287 self.logPrint('PETSc cannot link C++ but can link C, which indicates a problem with the PETSc installation')
288 self.popLanguage()
290 self.popLanguage()
291 self.logPrint('PETSc can link with C++')
293 if hasattr(self.compilers, 'FC'):
294 self.pushLanguage('FC')
295 self.sourceExtension = '.F'
296 if not self.checkPETScLink('', ' integer ierr\n real time\n call PetscTime(time, ierr)\n'):
297 self.logPrint('PETSc cannot link Fortran, but can link C, which indicates a problem with the PETSc installation\nRun with -with-fc=0 if you do not wish to use Fortran')
298 self.popLanguage()
300 self.popLanguage()
301 self.logPrint('PETSc can link with Fortran')
304 def checkSharedLibrary(self, libraries):
306 if config.setCompilers.Configure.isDarwin(self.log):
309 self.setOtherLibs([])
310 self.pushLanguage(self.languages.clanguage)
311 isShared = self.libraries.checkShared('#include <petscsys.h>\n', 'PetscInitialize', 'PetscInitialized', 'PetscFinalize', checkLink = self.checkPETScLink, libraries = libraries, initArgs = '&argc, &argv, 0, 0', boolType = 'PetscBool ', executor = self.mpi.mpiexec)
312 self.popLanguage()
315 def configureVersion(self):
321 input = open(os.path.join(self.dir, 'include', 'petscversion.h'))
326 self.date = 'Unknown'
340 self.date = time.strftime('%b %d, %Y', time.localtime(time.time()))
341 lines.append('#define PETSC_VERSION_DATE'+m5.group(1)+'"'+self.date+'"\n')
345 self.logPrint('Found PETSc version (%s,%s,%s) on %s' % (majorNum, minorNum, subminorNum, self.date))
348 def includeGuesses(self, path = None):
355 yield [dir, os.path.join(path, self.arch,'include')]
361 def libraryGuesses(self, root = None):
365 d = os.path.join(root, 'lib', self.arch)
367 self.logPrint('', 3, 'petsc')
374 def configureLibrary(self):
376 for location, name in self.trial.items():
377 self.framework.logPrintDivider()
378 self.framework.logPrint('Checking for a functional PETSc in '+name+', location/origin '+str(location))
382 for libraries in self.libraryGuesses(location[0]):
383 if self.checkLib(libraries):
385 for includeDir in self.includeGuesses(location[0]):
386 if self.checkInclude(includeDir):
388 self.trial[location] = (name, include, lib, 'Unknown')
389 if self.executeTest(self.checkWorkingLink):
393 self.framework.logPrintDivider(single = 1)
394 self.framework.logPrint('PETSc in '+name+', location/origin '+str(location)+' failed checkWorkingLink test')
396 self.framework.logPrintDivider(single = 1)
397 self.framework.logPrint('PETSc in '+name+', location/origin '+str(location)+' failed checkInclude test with includeDir: '+str(includeDir))
399 self.framework.logPrintDivider(single = 1)
400 self.framework.logPrint('PETSc in '+name+', location/origin '+str(location)+' failed checkIncludes test')
403 self.framework.logPrintDivider(single = 1)
404 self.framework.logPrint('PETSc in '+name+', location/origin '+str(location)+' failed checkLib test with libraries: '+str(libraries))
406 if self.framework.argDB['with-petsc-shared']:
407 if not self.executeTest(self.checkSharedLibrary, [libraries]):
408 self.framework.logPrintDivider(single = 1)
409 self.framework.logPrint('PETSc in '+name+', location/origin '+str(location)+' failed checkSharedLibrary test with libraries: '+str(libraries))
414 version = self.executeTest(self.configureVersion)
415 self.working[location] = (name, include, lib, version)
418 self.logPrint('Choose PETSc '+self.version+' in '+self.name)
423 def setOutput(self):
427 if self.found:
428 self.addDefine('HAVE_PETSC', 1)
429 self.addSubstitution('PETSC_INCLUDE', ' '.join([self.headers.getIncludeArgument(inc) for inc in self.include]))
430 self.addSubstitution('PETSC_LIB', ' '.join(map(self.libraries.getLibArgument, self.lib)))
433 def configure(self):
434 self.executeTest(self.configureLibrary)
435 self.setOutput()