xref: /petsc/config/BuildSystem/config/packages/xSDKTrilinos.py (revision 7b5fd022a6ba26727040df7457b27566b4c6742d) !
1import config.package
2import os
3
4class Configure(config.package.CMakePackage):
5  def __init__(self, framework):
6    config.package.CMakePackage.__init__(self, framework)
7    self.gitcommit         = '0ddbf6e' # master
8    self.download          = ['https://github.com/trilinos/xSDKTrilinos/archive/'+self.gitcommit+'.tar.gz','git://https://github.com/trilinos/xSDKTrilinos.git']
9    self.downloaddirnames  = ['xSDKTrilinos']
10    self.includes          = []
11    self.functions         = []
12    self.buildLanguages    = ['Cxx']
13    self.hastests          = 1
14    self.linkedbypetsc     = 0
15    self.useddirectly      = 0
16    self.skippackagelibincludedirs = 1
17    return
18
19  def setupDependencies(self, framework):
20    config.package.CMakePackage.setupDependencies(self, framework)
21    self.trilinos = framework.require('config.packages.Trilinos',self)
22    self.hypre    = framework.require('config.packages.hypre',self)
23    self.x        = framework.require('config.packages.X',self)
24    self.ssl      = framework.require('config.packages.ssl',self)
25    self.triangle = framework.require('config.packages.Triangle',self)
26    self.exodusii = framework.require('config.packages.ExodusII',self)
27    self.flibs    = framework.require('config.packages.flibs',self)
28    self.cxxlibs  = framework.require('config.packages.cxxlibs',self)
29    self.mathlib  = framework.require('config.packages.mathlib',self)
30    return
31
32  # the install is delayed until postProcess() since xSDKTrilinos install requires PETSc to be installed before xSDKTrilinos can be built
33  def Install(self):
34    return self.installDir
35
36  def configureLibrary(self):
37    ''' Since xSDKTrilinos cannot be built until after PETSc is compiled we need to just assume the downloaded library will work'''
38    if 'with-xsdktrilinos' in self.framework.clArgDB:
39      raise RuntimeError('Xsdktrilinos does not support --with-xsdktrilinos; only --download-xsdktrilinos')
40    if 'with-xsdktrilinos-dir' in self.framework.clArgDB:
41      raise RuntimeError('Xsdktrilinos does not support --with-xsdktrilinos-dir; only --download-xsdktrilinos')
42
43    self.checkDownload()
44    self.include = [os.path.join(self.installDir,'include')]
45    self.lib     = [os.path.join(self.installDir,'lib','libxsdktrilinos.a')]
46    self.found   = 1
47    self.dlib    = self.lib
48    if not hasattr(self.framework, 'packages'):
49      self.framework.packages = []
50    self.framework.packages.append(self)
51
52  def formCMakeConfigureArgs(self):
53    args = config.package.CMakePackage.formCMakeConfigureArgs(self)
54    args.append('-DUSE_XSDK_DEFAULTS=YES')
55    args.append('-DTRILINOS_INSTALL_DIR='+os.path.dirname(self.trilinos.include[0]))
56    args.append('-DTrilinos_INSTALL_DIR='+os.path.dirname(self.trilinos.include[0]))
57    if self.hypre.found:
58      args.append('-DTPL_ENABLE_HYPRE=ON')
59      args.append('-DTPL_HYPRE_LIBRARIES="'+self.libraries.toStringNoDupes(self.hypre.lib)+'"')
60      args.append('-DTPL_HYPRE_INCLUDE_DIRS='+self.headers.toStringNoDupes(self.hypre.include)[2:])
61
62    args.append('-DTPL_ENABLE_PETSC=ON')
63    # These are packages that PETSc may be using that Trilinos is not be using
64    plibs = self.exodusii.dlib+self.triangle.lib+self.ssl.lib+self.x.lib
65
66    if not hasattr(self.compilers, 'FC'):
67      args.append('-DxSDKTrilinos_ENABLE_Fortran=OFF')
68
69    if self.framework.argDB['prefix']:
70       idir = os.path.join(self.getDefaultInstallDir(),'lib')
71    else:
72       idir = os.path.join(self.petscdir.dir,self.getArch(),'lib')
73    if self.framework.argDB['with-single-library']:
74      plibs = self.libraries.toStringNoDupes(['-L'+idir,' -lpetsc']+plibs)
75    else:
76      plibs = self.libraries.toStringNoDupes(['-L'+idir,'-lpetscts -lpetscsnes -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetscsys']+plibs)
77
78    args.append('-DTPL_PETSC_LIBRARIES="'+plibs+'"')
79    args.append('-DTPL_PETSC_INCLUDE_DIRS='+os.path.join(self.petscdir.dir,'include'))
80
81    if self.compilerFlags.debugging:
82      args.append('-DxSDKTrilinos_ENABLE_DEBUG=YES')
83    else:
84      args.append('-DxSDKTrilinos_ENABLE_DEBUG=NO')
85
86    args.append('-DxSDKTrilinos_EXTRA_LINK_FLAGS="'+self.libraries.toStringNoDupes(self.flibs.lib+self.cxxlibs.lib+self.mathlib.lib)+' '+self.compilers.LIBS+'"')
87    args.append('-DxSDKTrilinos_ENABLE_TESTS=ON')
88    return args
89
90  def postProcess(self):
91    self.compilePETSc()
92    config.package.CMakePackage.Install(self)
93    if not self.argDB['with-batch']:
94      try:
95        self.logPrintBox('Testing xSDKTrilinos; this may take several minutes')
96        output,err,ret  = config.package.CMakePackage.executeShellCommand('cd '+os.path.join(self.packageDir,'petsc-build')+' && '+self.cmake.ctest,timeout=60, log = self.log)
97        output = output+err
98        self.log.write(output)
99        if output.find('Failure') > -1:
100          raise RuntimeError('Error running ctest on xSDKTrilinos: '+output)
101      except RuntimeError as e:
102        raise RuntimeError('Error running ctest on xSDKTrilinos: '+str(e))
103    else:
104      self.logClear()
105      self.logPrintDivider( debugSection = 'screen')
106      self.logPrint('Since this is a batch system xSDKTrilinos cannot run tests directly. To run a short test suite.', debugSection = 'screen')
107      self.logPrint('   Obtain an interactive session with your batch system', debugSection = 'screen')
108      self.logPrint('   cd to '+os.path.join(self.packageDir,'petsc-build'), debugSection = 'screen')
109      self.logPrint('   ctest', debugSection = 'screen')
110      linewidth = self.linewidth
111      self.linewidth = -1
112      if self.hypre.found:
113        self.logPrint(os.path.join(os.getcwd(),self.packageDir,'petsc-build','hypre','test','xSDKTrilinos_HypreTest.exe'), debugSection = 'screen')
114      self.logPrint(os.path.join(os.getcwd(),self.packageDir,'petsc-build','petsc','test','xSDKTrilinos_PETScAIJMatrix.exe'), debugSection = 'screen')
115      self.linewidth = linewidth
116      self.logPrintDivider( debugSection = 'screen')
117      self.logPrint('', debugSection = 'screen')
118