xref: /petsc/config/BuildSystem/config/packages/xSDKTrilinos.py (revision 419beca1004e80ebaf01ed86ca4fa04d30fb35e8)
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         = '9fc43b7' # trilinos-release-12-6-branch
8    self.download          = ['https://github.com/trilinos/xSDKTrilinos/archive/'+self.gitcommit+'.tar.gz','git://https://github.com/trilinos/xSDKTrilinos.git']
9    self.downloaddirname   = 'xSDKTrilinos'
10    self.includes          = []
11    self.functions         = []
12    self.cxx               = 1
13    self.requirescxx11     = 1
14    self.downloadonWindows = 0
15    self.hastests          = 1
16    self.linkedbypetsc     = 0
17    return
18
19  def setupDependencies(self, framework):
20    config.package.CMakePackage.setupDependencies(self, framework)
21    self.arch            = framework.require('PETSc.options.arch', self.setCompilers)
22    self.petscdir        = framework.require('PETSc.options.petscdir', self.setCompilers)
23    self.installdir      = framework.require('PETSc.options.installDir',  self)
24    self.trilinos        = framework.require('config.packages.Trilinos',self)
25    self.hypre           = framework.require('config.packages.hypre',self)
26    self.x               = framework.require('config.packages.X',self)
27    self.ssl             = framework.require('config.packages.ssl',self)
28    self.exodusii        = framework.require('config.packages.exodusii',self)
29    #
30    # also requires the ./configure option --with-cxx-dialect=C++11
31    return
32
33  # the install is delayed until postProcess() since xSDKTrilinos requires PETSc
34  def Install(self):
35    return self.installDir
36
37  def configureLibrary(self):
38    ''' Just assume the downloaded library will work'''
39    if self.framework.clArgDB.has_key('with-xsdktrilinos'):
40      raise RuntimeError('Xsdktrilinos does not support --with-xsdktrilinos; only --download-xsdktrilinos')
41    if self.framework.clArgDB.has_key('with-xsdktrilinos-dir'):
42      raise RuntimeError('Xsdktrilinos does not support --with-xsdktrilinos-dir; only --download-xsdktrilinos')
43    if self.framework.clArgDB.has_key('with-xsdktrilinos-include'):
44      raise RuntimeError('Xsdktrilinos does not support --with-xsdktrilinos-include; only --download-xsdktrilinos')
45    if self.framework.clArgDB.has_key('with-xsdktrilinos-lib'):
46      raise RuntimeError('Xsdktrilinos does not support --with-xsdktrilinos-lib; only --download-xsdktrilinos')
47
48    self.checkDownload()
49    self.include = [os.path.join(self.installDir,'include')]
50    self.lib     = [os.path.join(self.installDir,'lib','libxsdktrilinos.a')]
51    self.found   = 1
52    self.dlib    = self.lib
53    if not hasattr(self.framework, 'packages'):
54      self.framework.packages = []
55    self.framework.packages.append(self)
56
57  def formCMakeConfigureArgs(self):
58    args = config.package.CMakePackage.formCMakeConfigureArgs(self)
59    args.append('-DUSE_XSDK_DEFAULTS=YES')
60    args.append('-DTRILINOS_INSTALL_DIR='+os.path.dirname(self.trilinos.include[0]))
61    args.append('-DTrilinos_INSTALL_DIR='+os.path.dirname(self.trilinos.include[0]))
62    if self.hypre.found:
63      args.append('-DTPL_ENABLE_HYPRE=ON')
64      args.append('-DTPL_HYPRE_LIBRARIES="'+self.libraries.toStringNoDupes(self.hypre.lib)+'"')
65      args.append('-DTPL_HYPRE_INCLUDE_DIRS='+self.headers.toStringNoDupes(self.hypre.include)[2:])
66
67    args.append('-DTPL_ENABLE_PETSC=ON')
68    # These are packages that PETSc may be using that Trilinos is not be using
69    plibs = self.exodusii.dlib+self.ssl.lib+self.x.lib
70
71    if not hasattr(self.compilers, 'FC'):
72      args.append('-DxSDKTrilinos_ENABLE_Fortran=OFF')
73
74    if self.framework.argDB['prefix']:
75       idir = os.path.join(self.installdir.dir,'lib')
76    else:
77       idir = os.path.join(self.petscdir.dir,self.arch,'lib')
78    if self.framework.argDB['with-single-library']:
79      plibs = self.libraries.toStringNoDupes(['-L'+idir,' -lpetsc']+plibs)
80    else:
81      plibs = self.libraries.toStringNoDupes(['-L'+idir,'-lpetscts -lpetscsnes -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetscsys']+plibs)
82
83    args.append('-DTPL_PETSC_LIBRARIES="'+plibs+'"')
84    args.append('-DTPL_PETSC_INCLUDE_DIRS='+os.path.join(self.petscdir.dir,'include'))
85
86    if self.compilerFlags.debugging:
87      args.append('-DCMAKE_BUILD_TYPE=DEBUG')
88      args.append('-DxSDKTrilinos_ENABLE_DEBUG=YES')
89    else:
90      args.append('-DCMAKE_BUILD_TYPE=RELEASE')
91      args.append('-DxSDKTrilinos_ENABLE_DEBUG=NO')
92
93    args.append('-DxSDKTrilinos_EXTRA_LINK_FLAGS="'+self.libraries.toStringNoDupes(self.libraries.math+self.compilers.flibs+self.compilers.cxxlibs)+' '+self.compilers.LIBS+'"')
94    args.append('-DxSDKTrilinos_ENABLE_TESTS=ON')
95    return args
96
97  def postProcess(self):
98    self.compilePETSc()
99    config.package.CMakePackage.Install(self)
100    if not self.argDB['with-batch']:
101      try:
102        self.logPrintBox('Testing xSDKTrilinos; this may take several minutes')
103        output,err,ret  = config.package.CMakePackage.executeShellCommand('cd '+os.path.join(self.packageDir,'build')+' && '+self.cmake.ctest,timeout=50, log = self.log)
104        output = output+err
105        self.log.write(output)
106        if output.find('Failure') > -1:
107          raise RuntimeError('Error running ctest on xSDKTrilinos: '+output)
108      except RuntimeError, e:
109        raise RuntimeError('Error running ctest on xSDKTrilinos: '+str(e))
110    else:
111      self.logClear()
112      self.logPrintDivider( debugSection = 'screen')
113      self.logPrint('Since this is a batch system xSDKTrilinos cannot run tests directly. To run a short test suite.', debugSection = 'screen')
114      self.logPrint('   Obtain an interactive session with your batch system', debugSection = 'screen')
115      self.logPrint('   cd to installxSDK/xsdk/petsc/arch-linux2-c-debug/externalpackages/git.xsdktrilinos/build', debugSection = 'screen')
116      self.logPrint('   ctest', debugSection = 'screen')
117      linewidth = self.linewidth
118      self.linewidth = -1
119      if self.hypre.found:
120        self.logPrint(os.path.join(os.getcwd(),self.packageDir,'build','hypre','test','xSDKTrilinos_HypreTest.exe'), debugSection = 'screen')
121      self.logPrint(os.path.join(os.getcwd(),self.packageDir,'build','petsc','test','xSDKTrilinos_PETScAIJMatrix.exe'), debugSection = 'screen')
122      self.linewidth = linewidth
123      self.logPrintDivider( debugSection = 'screen')
124      self.logPrint('', debugSection = 'screen')
125
126
127
128
129
130
131