1 | import PETSc.package
|
---|
2 |
|
---|
3 | class Configure(PETSc.package.NewPackage):
|
---|
4 | def __init__(self, framework):
|
---|
5 | PETSc.package.NewPackage.__init__(self, framework)
|
---|
6 | self.download = ['http://ftp.mcs.anl.gov/pub/petsc/externalpackages/zoltan_distrib.tar.gz']
|
---|
7 | self.functions = ['Zoltan_LB_Partition']
|
---|
8 | self.includes = ['zoltan.h']
|
---|
9 | self.liblist = [['libzoltan.a']]
|
---|
10 | self.license = 'http://www.cs.sandia.gov/Zoltan/Zoltan.html'
|
---|
11 | return
|
---|
12 |
|
---|
13 | def setupDependencies(self, framework):
|
---|
14 | PETSc.package.NewPackage.setupDependencies(self, framework)
|
---|
15 | self.x = framework.require('PETSc.packages.X',self)
|
---|
16 | self.parmetis = framework.require('PETSc.packages.parmetis',self)
|
---|
17 | self.deps = [self.x, self.mpi, self.parmetis]
|
---|
18 | return
|
---|
19 |
|
---|
20 | def Install(self):
|
---|
21 | import os
|
---|
22 | self.framework.pushLanguage('C')
|
---|
23 | ccompiler=self.framework.getCompiler()
|
---|
24 | args = ['ZOLTAN_ARCH="'+self.arch+'"']
|
---|
25 | args.append('CC="'+self.framework.getCompiler()+'"')
|
---|
26 | args.append('CFLAGS="'+self.framework.getCompilerFlags()+'"')
|
---|
27 | self.framework.popLanguage()
|
---|
28 | if hasattr(self.compilers, 'CXX'):
|
---|
29 | self.framework.pushLanguage('Cxx')
|
---|
30 | args.append('CPPC="'+self.framework.getCompiler()+'"')
|
---|
31 | self.framework.popLanguage()
|
---|
32 | args.append('AR="'+self.compilers.AR+' '+self.compilers.AR_FLAGS+'"')
|
---|
33 | args.append('RANLIB="'+self.compilers.RANLIB+'"')
|
---|
34 | if self.x.found:
|
---|
35 | args.append('X_LIBS="'+str(self.x.lib)+'"')
|
---|
36 | if self.mpi.found:
|
---|
37 | if self.mpi.include:
|
---|
38 | args.append('MPI_INCPATH="'+' '.join([self.headers.getIncludeArgument(inc) for inc in self.mpi.include])+'"')
|
---|
39 | if self.mpi.lib:
|
---|
40 | args.append('MPI_LIB="'+' '.join([self.libraries.getLibArgument(lib) for lib in self.mpi.lib])+'"')
|
---|
41 | if self.parmetis.found:
|
---|
42 | if self.parmetis.include:
|
---|
43 | args.append('PARMETIS_INCPATH="'+' '.join([self.headers.getIncludeArgument(inc) for inc in self.parmetis.include])+'"')
|
---|
44 | if self.parmetis.lib:
|
---|
45 | args.append('PARMETIS_LIBPATH="'+' '.join([self.libraries.getLibArgument(lib) for lib in self.parmetis.lib])+'"')
|
---|
46 | args = ' '.join(args)
|
---|
47 |
|
---|
48 | fd = file(os.path.join(self.packageDir, 'Zoltanconfig'),'w')
|
---|
49 | fd.write(args)
|
---|
50 | fd.close()
|
---|
51 |
|
---|
52 | if self.installNeeded('Zoltanconfig'):
|
---|
53 | fd = file(os.path.join(self.packageDir, 'Utilities', 'Config', 'Config.'+self.arch), 'w')
|
---|
54 | fd.write('''
|
---|
55 | ##############################################################################
|
---|
56 | # Environment variables for compiling the Zoltan and test drivers using PETSc
|
---|
57 | ##############################################################################
|
---|
58 | # The location of the VTK libraries, built with OpenGL
|
---|
59 | # We do not do these correctly
|
---|
60 | VTK_LIBPATH =
|
---|
61 | VTK_INCPATH =
|
---|
62 | # The location of the GL or Mesa libraries, and the libraries
|
---|
63 | # We do not do these correctly
|
---|
64 | GL_LIBPATH = -L/usr/lib
|
---|
65 | GL_INCPATH = -I/usr/include
|
---|
66 | GL_LIBS = -lGL -lGLU
|
---|
67 | # Have no idea about VTK_OFFSCREEN_* and MESA_* stuff
|
---|
68 | ''')
|
---|
69 | fd.close()
|
---|
70 | try:
|
---|
71 | self.logPrintBox('Compiling zoltan; this may take several minutes')
|
---|
72 | output1,err1,ret1 = PETSc.package.NewPackage.executeShellCommand('rm -f '+self.installDir+'lib/libzoltan*', timeout=2500, log = self.framework.log)
|
---|
73 | output2,err2,ret2 = PETSc.package.NewPackage.executeShellCommand('cd '+self.packageDir+' && make clean && make '+args+' zoltan', timeout=2500, log = self.framework.log)
|
---|
74 | except RuntimeError, e:
|
---|
75 | raise RuntimeError('Error running make on ZOLTAN: '+str(e))
|
---|
76 |
|
---|
77 | output3,err3,ret3 = PETSc.package.NewPackage.executeShellCommand('mv -f '+os.path.join(self.packageDir, 'Obj_'+self.arch)+'/lib* '+os.path.join(self.installDir, 'lib'))
|
---|
78 | output4,err4,ret4 = PETSc.package.NewPackage.executeShellCommand('cp -f '+os.path.join(self.packageDir, 'include')+'/*.h '+os.path.join(self.installDir, 'include'))
|
---|
79 | self.postInstall(output1+err1+output2+err2+output3+err3+output4+err4,'Zoltanconfig')
|
---|
80 | return self.installDir
|
---|