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