1import config.package 2 3class Configure(config.package.Package): 4 def __init__(self, framework): 5 config.package.Package.__init__(self, framework) 6 self.gitcommit = 'v5.1.2-p1' 7 self.download = ['git://https://bitbucket.org/petsc/pkg-mumps.git', 8 'https://bitbucket.org/petsc/pkg-mumps/get/'+self.gitcommit+'.tar.gz'] 9 self.downloaddirnames = ['petsc-pkg-mumps'] 10 self.liblist = [['libcmumps.a','libdmumps.a','libsmumps.a','libzmumps.a','libmumps_common.a','libpord.a'], 11 ['libcmumps.a','libdmumps.a','libsmumps.a','libzmumps.a','libmumps_common.a','libpord.a','libpthread.a'], 12 ['libcmumps.a','libdmumps.a','libsmumps.a','libzmumps.a','libmumps_common.a','libpord.a','libmpiseq.a'], 13 ['libcmumps.a','libdmumps.a','libsmumps.a','libzmumps.a','libmumps_common.a','libpord.a','libpthread.a','libmpiseq.a']] 14 self.functions = ['dmumps_c'] 15 self.includes = ['dmumps_c.h'] 16 # 17 # Mumps does NOT work with 64 bit integers without a huge number of hacks we ain't making 18 self.precisions = ['single','double'] 19 self.requires32bitint = 1; # 1 means that the package will not work with 64 bit integers 20 self.downloadonWindows= 1 21 self.hastests = 1 22 self.hastestsdatafiles= 1 23 return 24 25 def setupHelp(self, help): 26 import nargs 27 config.package.Package.setupHelp(self, help) 28 help.addArgument('MUMPS', '-with-mumps-serial', nargs.ArgBool(None, 0, 'Use serial build of MUMPS')) 29 return 30 31 def setupDependencies(self, framework): 32 config.package.Package.setupDependencies(self, framework) 33 self.flibs = framework.require('config.packages.flibs',self) 34 self.blasLapack = framework.require('config.packages.BlasLapack',self) 35 self.mpi = framework.require('config.packages.MPI',self) 36 self.metis = framework.require('config.packages.metis',self) 37 self.parmetis = framework.require('config.packages.parmetis',self) 38 self.ptscotch = framework.require('config.packages.PTScotch',self) 39 self.scalapack = framework.require('config.packages.scalapack',self) 40 if self.argDB['with-mumps-serial']: 41 self.deps = [self.blasLapack,self.flibs] 42 self.odeps = [self.metis] 43 else: 44 self.deps = [self.scalapack,self.mpi,self.blasLapack,self.flibs] 45 self.odeps = [self.metis,self.parmetis,self.ptscotch] 46 return 47 48 def consistencyChecks(self): 49 config.package.Package.consistencyChecks(self) 50 if self.argDB['with-'+self.package] or self.argDB['download-'+self.package]: 51 if self.mpi.usingMPIUni and not self.argDB['with-mumps-serial']: 52 raise RuntimeError('Since you are building without MPI you must use --with-mumps-serial to install the correct MUMPS.') 53 if self.argDB['with-mumps-serial']: 54 if not self.mpi.usingMPIUni: 55 raise RuntimeError('Serial MUMPS version is only compatible with MPIUni\nReconfigure using --with-mpi=0') 56 return 57 58 def Install(self): 59 import os 60 61 if not hasattr(self.compilers, 'FC'): 62 raise RuntimeError('Cannot install '+self.name+' without Fortran, make sure you do NOT have --with-fc=0') 63 if not self.compilers.FortranDefineCompilerOption: 64 raise RuntimeError('Fortran compiler cannot handle preprocessing directives from command line.') 65 g = open(os.path.join(self.packageDir,'Makefile.inc'),'w') 66 g.write('LPORDDIR = $(topdir)/PORD/lib/\n') 67 g.write('IPORD = -I$(topdir)/PORD/include/\n') 68 g.write('LPORD = -L$(LPORDDIR) -lpord\n') 69 g.write('PLAT = \n') 70 orderingsc = '-Dpord' 71 orderingsf = self.compilers.FortranDefineCompilerOption+'pord' 72 # Disable threads on BGL 73 if self.libraries.isBGL(): 74 orderingsc += ' -DWITHOUT_PTHREAD' 75 if self.metis.found: 76 g.write('IMETIS = '+self.headers.toString(self.metis.include)+'\n') 77 g.write('LMETIS = '+self.libraries.toString(self.metis.lib)+'\n') 78 orderingsc += ' -Dmetis' 79 orderingsf += ' '+self.compilers.FortranDefineCompilerOption+'metis' 80 if self.parmetis.found: 81 g.write('IPARMETIS = '+self.headers.toString(self.parmetis.include)+'\n') 82 g.write('LPARMETIS = '+self.libraries.toString(self.parmetis.lib)+'\n') 83 orderingsc += ' -Dparmetis' 84 orderingsf += ' '+self.compilers.FortranDefineCompilerOption+'parmetis' 85 if self.ptscotch.found: 86 g.write('ISCOTCH = '+self.headers.toString(self.ptscotch.include)+'\n') 87 g.write('LSCOTCH = '+self.libraries.toString(self.ptscotch.lib)+'\n') 88 orderingsc += ' -Dscotch -Dptscotch' 89 orderingsf += ' '+self.compilers.FortranDefineCompilerOption+'scotch '+self.compilers.FortranDefineCompilerOption+'ptscotch' 90 91 g.write('ORDERINGSC = '+orderingsc+'\n') 92 g.write('ORDERINGSF = '+orderingsf+'\n') 93 g.write('LORDERINGS = $(LPARMETIS) $(LMETIS) $(LPORD) $(LSCOTCH)\n') 94 g.write('IORDERINGSC = $(IPARMETIS) $(IMETIS) $(IPORD) $(ISCOTCH)\n') 95 g.write('IORDERINGSF = $(ISCOTCH)\n') 96 97 g.write('RM = /bin/rm -f\n') 98 self.setCompilers.pushLanguage('C') 99 g.write('CC = '+self.setCompilers.getCompiler()+'\n') 100 g.write('OPTC = ' + self.removeWarningFlags(self.setCompilers.getCompilerFlags())+'\n') 101 g.write('OUTC = -o \n') 102 self.setCompilers.popLanguage() 103 if not self.compilers.fortranIsF90: 104 raise RuntimeError('Installing MUMPS requires a F90 compiler') 105 self.setCompilers.pushLanguage('FC') 106 g.write('FC = '+self.setCompilers.getCompiler()+'\n') 107 g.write('FL = '+self.setCompilers.getCompiler()+'\n') 108 g.write('OPTF = ' + self.setCompilers.getCompilerFlags().replace('-Wall','').replace('-Wshadow','').replace('-Mfree','') +'\n') 109 g.write('OUTF = -o \n') 110 self.setCompilers.popLanguage() 111 112 # set fortran name mangling 113 # this mangling information is for both BLAS and the Fortran compiler so cannot use the BlasLapack mangling flag 114 if self.compilers.fortranManglingDoubleUnderscore: 115 g.write('CDEFS = -DAdd__\n') 116 elif self.compilers.fortranMangling == 'underscore': 117 g.write('CDEFS = -DAdd_\n') 118 elif self.compilers.fortranMangling == 'caps': 119 g.write('CDEFS = -DUPPPER\n') 120 121 g.write('AR = '+self.setCompilers.AR+' '+self.setCompilers.AR_FLAGS+' \n') 122 g.write('LIBEXT = .'+self.setCompilers.AR_LIB_SUFFIX+'\n') 123 g.write('RANLIB = '+self.setCompilers.RANLIB+'\n') 124 g.write('SCALAP = '+self.libraries.toString(self.scalapack.lib)+'\n') 125 if not self.argDB['with-mumps-serial']: 126 g.write('INCPAR = '+self.headers.toString(self.mpi.include)+'\n') 127 g.write('LIBPAR = $(SCALAP) '+self.libraries.toString(self.mpi.lib)+'\n') 128 else: 129 g.write('INCPAR = -I../libseq\n') 130 g.write('INCSEQ = -I$(topdir)/libseq\n') 131 g.write('LIBSEQ = $(LAPACK) -L$(topdir)/libseq -lmpiseq\n') 132 g.write('LIBBLAS = '+self.libraries.toString(self.blasLapack.dlib)+'\n') 133 g.write('OPTL = -O -I.\n') 134 g.write('INCS = $(INCPAR)\n') 135 g.write('LIBS = $(LIBPAR)\n') 136 if self.argDB['with-mumps-serial']: 137 g.write('LIBSEQNEEDED = libseqneeded\n') 138 g.write('LIBS = $(LIBSEQ)\n') 139 else: 140 g.write('LIBSEQNEEDED =\n') 141 g.close() 142 if self.installNeeded('Makefile.inc'): 143 try: 144 output1,err1,ret1 = config.package.Package.executeShellCommand('cd '+self.packageDir+' && make clean', timeout=2500, log = self.log) 145 except RuntimeError, e: 146 pass 147 try: 148 self.logPrintBox('Compiling Mumps; this may take several minutes') 149 output2,err2,ret2 = config.package.Package.executeShellCommand('cd '+self.packageDir+' && make alllib',timeout=2500, log = self.log) 150 libDir = os.path.join(self.installDir, self.libdir) 151 includeDir = os.path.join(self.installDir, self.includedir) 152 self.logPrintBox('Installing Mumps; this may take several minutes') 153 self.installDirProvider.printSudoPasswordMessage() 154 output,err,ret = config.package.Package.executeShellCommand(self.installSudo+'mkdir -p '+os.path.join(self.installDir,self.libdir)+' && cd '+self.packageDir+' && '+self.installSudo+'cp -f lib/*.* '+libDir+'/. && '+self.installSudo+'mkdir -p '+includeDir+' && '+self.installSudo+'cp -f include/*.* '+includeDir+'/.', timeout=50, log = self.log) 155 if self.argDB['with-mumps-serial']: 156 output,err,ret = config.package.Package.executeShellCommand('cd '+self.packageDir+' && '+self.installSudo+'cp -f libseq/libmpiseq.a '+libDir+'/. ', timeout=25, log = self.log) 157 except RuntimeError, e: 158 raise RuntimeError('Error running make on MUMPS: '+str(e)) 159 self.postInstall(output1+err1+output2+err2,'Makefile.inc') 160 return self.installDir 161 162