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