def Check(conf, vars, cmake, tmpdir, directory, libs): if petscconf.SCALAR == 'complex': log.Exit('ERROR: BLZPACK does not support complex numbers.') if (petscconf.PRECISION != 'single') & (petscconf.PRECISION != 'double'): log.Exit( 'ERROR: BLZPACK is supported only in single or double precision.') if petscconf.IND64: log.Exit('ERROR: cannot use external packages with 64-bit indices.') if petscconf.PRECISION == 'single': functions = ['blzdrs'] else: functions = ['blzdrd'] if libs: libs = [libs] else: libs = [['-lblzpack']] if directory: dirs = [directory] else: dirs = check.GenerateGuesses('Blzpack') return check.FortranLib(tmpdir, conf, vars, cmake, 'BLZPACK', dirs, libs, functions)
def Check(conf, vars, cmake, tmpdir, directory, libs): if (petscconf.PRECISION != 'single') & (petscconf.PRECISION != 'double'): log.Exit( 'ERROR: ARPACK is supported only in single or double precision.') if petscconf.IND64: log.Exit('ERROR: cannot use external packages with 64-bit indices.') if petscconf.MPIUNI: if petscconf.SCALAR == 'real': if petscconf.PRECISION == 'single': functions = ['snaupd', 'sneupd', 'ssaupd', 'sseupd'] else: functions = ['dnaupd', 'dneupd', 'dsaupd', 'dseupd'] else: if petscconf.PRECISION == 'single': functions = ['cnaupd', 'cneupd'] else: functions = ['znaupd', 'zneupd'] else: if petscconf.SCALAR == 'real': if petscconf.PRECISION == 'single': functions = ['psnaupd', 'psneupd', 'pssaupd', 'psseupd'] else: functions = ['pdnaupd', 'pdneupd', 'pdsaupd', 'pdseupd'] else: if petscconf.PRECISION == 'single': functions = ['pcnaupd', 'pcneupd'] else: functions = ['pznaupd', 'pzneupd'] if libs: libs = [libs] else: if petscconf.MPIUNI: libs = [['-larpack'], ['-larpack_LINUX'], ['-larpack_SUN4']] else: libs = [['-lparpack', '-larpack'], ['-lparpack_MPI', '-larpack'], ['-lparpack_MPI-LINUX', '-larpack_LINUX'], ['-lparpack_MPI-SUN4', '-larpack_SUN4']] if directory: dirs = [directory] else: dirs = check.GenerateGuesses('Arpack') return check.FortranLib(tmpdir, conf, vars, cmake, 'ARPACK', dirs, libs, functions)
def Check(conf,vars,cmake,tmpdir,directory,libs): log.write('='*80) log.Println('Checking PRIMME library...') if petscconf.PRECISION != 'double': log.Exit('ERROR: PRIMME is supported only in double precision.') if petscconf.IND64: log.Exit('ERROR: cannot use external packages with 64-bit indices.') functions_base = ['primme_set_method','primme_Free','primme_initialize'] if directory: dirs = [directory] else: dirs = check.GenerateGuesses('Primme') include = 'PRIMMESRC/COMMONSRC' if not libs: libs = ['-lprimme'] if petscconf.SCALAR == 'real': functions = functions_base + ['dprimme'] else: functions = functions_base + ['zprimme'] for d in dirs: if d: if 'rpath' in petscconf.SLFLAG: l = [petscconf.SLFLAG + d] + ['-L' + d] + libs else: l = ['-L' + d] + libs f = ['-I' + d + '/' + include] else: l = libs f = [] if check.Link(tmpdir,functions,[],l+f): conf.write('#ifndef SLEPC_HAVE_PRIMME\n#define SLEPC_HAVE_PRIMME 1\n#endif\n\n') vars.write('PRIMME_LIB = ' + str.join(' ', l) + '\n') vars.write('PRIMME_FLAGS = ' + str.join(' ', f) + '\n') cmake.write('set (SLEPC_HAVE_PRIMME YES)\n') cmake.write('find_library (PRIMME_LIB primme HINTS '+ d +')\n') cmake.write('find_path (PRIMME_INCLUDE primme.h ' + d + '/PRIMMESRC/COMMONSRC)\n') return l+f log.Println('ERROR: Unable to link with PRIMME library') log.Println('ERROR: In directories '+''.join([s+' ' for s in dirs])) log.Println('ERROR: With flags '+''.join([s+' ' for s in libs])) log.Exit('')
def FortranLib(tmpdir, conf, vars, cmake, name, dirs, libs, functions, callbacks=[]): log.write('=' * 80) log.Println('Checking ' + name + ' library...') error = '' mangling = '' for d in dirs: for l in libs: if d: if 'rpath' in petscconf.SLFLAG: flags = [petscconf.SLFLAG + d] + ['-L' + d] + l else: flags = ['-L' + d] + l else: flags = l (mangling, output) = FortranLink(tmpdir, functions, callbacks, flags) error += output if mangling: break if mangling: break if mangling: log.write(output) else: log.write(error) log.Println('ERROR: Unable to link with library ' + name) log.Println('ERROR: In directories ' + ''.join([s + ' ' for s in dirs])) log.Println('ERROR: With flags ' + ''.join([s + ' ' for s in flags])) log.Exit('') conf.write('#ifndef SLEPC_HAVE_' + name + '\n#define SLEPC_HAVE_' + name + ' 1\n#define SLEPC_' + name + '_HAVE_' + mangling + ' 1\n#endif\n\n') vars.write(name + '_LIB = ' + str.join(' ', flags) + '\n') cmake.write('set (SLEPC_HAVE_' + name + ' YES)\n') libname = ''.join([s.lstrip('-l') + ' ' for s in l]) cmake.write( 'set (' + name + '_LIB "")\nforeach (libname ' + libname + ')\n string (TOUPPER ${libname} LIBNAME)\n find_library (${LIBNAME}LIB ${libname} HINTS ' + d + ')\n list (APPEND ' + name + '_LIB "${${LIBNAME}LIB}")\nendforeach()\n') return flags
def Check(conf,vars,cmake,tmpdir,directory,libs): if petscconf.SCALAR != 'complex': log.Exit('ERROR: FEAST is supported only with complex numbers.') if (petscconf.PRECISION != 'single') & (petscconf.PRECISION != 'double'): log.Exit('ERROR: FEAST is supported only in single or double precision.') if petscconf.IND64: log.Exit('ERROR: cannot use external packages with 64-bit indices.') functions = ['feastinit'] if petscconf.SCALAR == 'real': if petscconf.PRECISION == 'single': functions += ['sfeast_srci'] else: functions += ['dfeast_srci'] else: if petscconf.PRECISION == 'single': functions += ['cfeast_hrci'] else: functions += ['zfeast_hrci'] if libs: libs = [libs] else: if petscconf.MPIUNI: libs = [['-lpfeast']] else: libs = [['-lfeast']] if directory: dirs = [directory] else: dirs = check.GenerateGuesses('Feast') return check.FortranLib(tmpdir,conf,vars,cmake,'FEAST',dirs,libs,functions)
def Install(conf, vars, cmake, tmpdir, url, archdir): ''' Download and uncompress the BLOPEX tarball ''' log.write('=' * 80) log.Println('Installing BLOPEX...') if petscconf.PRECISION != 'double': log.Exit('ERROR: BLOPEX is supported only in double precision.') if petscconf.IND64: log.Exit('ERROR: cannot use external packages with 64-bit indices.') packagename = 'blopex-1.1.2' externdir = archdir + '/externalpackages' builddir = os.sep.join([externdir, packagename]) # Create externalpackages directory if not os.path.exists(externdir): try: os.mkdir(externdir) except: sys.exit('ERROR: cannot create directory ' + externdir) # Check if source is already available if os.path.exists(builddir): log.Println('Using ' + builddir) else: # Download tarball if url == '': url = 'http://www.grycap.upv.es/slepc/download/external/' + packagename + '.tar.gz' archiveZip = 'blopex.tar.gz' localFile = os.sep.join([externdir, archiveZip]) log.Println('Downloading ' + url + ' to ' + localFile) if os.path.exists(localFile): os.remove(localFile) try: urllib.urlretrieve(url, localFile) except Exception, e: name = 'blopex' filename = os.path.basename(urlparse.urlparse(url)[2]) failureMessage = '''\ Unable to download package %s from: %s * If your network is disconnected - please reconnect and rerun config/configure.py * Alternatively, you can download the above URL manually, to /yourselectedlocation/%s and use the configure option: --download-%s=/yourselectedlocation/%s ''' % (name, url, filename, name, filename) raise RuntimeError(failureMessage) # Uncompress tarball log.Println('Uncompressing ' + localFile + ' to directory ' + builddir) if os.path.exists(builddir): for root, dirs, files in os.walk(builddir, topdown=False): for name in files: os.remove(os.path.join(root, name)) for name in dirs: os.rmdir(os.path.join(root, name)) try: if sys.version_info >= (2, 5): import tarfile tar = tarfile.open(localFile, "r:gz") tar.extractall(path=externdir) tar.close() os.remove(localFile) else: result, output = commands.getstatusoutput( 'cd ' + externdir + '; gunzip ' + archiveZip + '; tar -xf ' + archiveZip.split('.gz')[0]) os.remove(localFile.split('.gz')[0]) except RuntimeError, e: raise RuntimeError('Error uncompressing ' + archiveZip + ': ' + str(e))
pkg.requested for pkg in externalpackages): log.Print( '\nWARNING: forcing --with-clean=1 because previous configuration had external packages' ) slepc.clean = True except: pass if slepc.clean: log.Print('\nCleaning arch dir ' + archdir + '...') try: for root, dirs, files in os.walk(archdir, topdown=False): for name in files: if name != 'configure.log': os.remove(os.path.join(root, name)) except: log.Exit('ERROR: Cannot remove existing files in ' + archdir) for rdir in ['obj', 'externalpackages']: try: shutil.rmtree(os.path.join(archdir, rdir)) except: pass # Create other directories and configuration files if not slepc.prefixdir: slepc.prefixdir = archdir includedir = CreateDir(archdir, 'include', log) modulesdir = CreateDirTwo(confdir, 'modules', 'slepc', log) pkgconfdir = CreateDir(libdir, 'pkgconfig', log) slepcvars = CreateFile(confdir, 'slepcvariables', log) slepcconf = CreateFile(includedir, 'slepcconf.h', log) pkgconfig = CreateFile(pkgconfdir, 'SLEPc.pc', log)
# Check if PETSc is working log.Println('Checking PETSc installation...') if petscversion.VERSION > slepcversion.VERSION: log.Println('WARNING: PETSc version ' + petscversion.VERSION + ' is newer than SLEPc version ' + slepcversion.VERSION) if petscversion.RELEASE != slepcversion.RELEASE: sys.exit( 'ERROR: Cannot mix release and development versions of SLEPc and PETSc' ) if petscconf.ISINSTALL: if os.path.realpath(petscconf.DESTDIR) != os.path.realpath(petscdir): log.Println( 'WARNING: PETSC_DIR does not point to PETSc installation path') if not check.Link(tmpdir, [], [], []): log.Exit('ERROR: Unable to link with PETSc') # Single library installation if petscconf.SINGLELIB: slepcvars.write('SHLIBS = libslepc\n') slepcvars.write('LIBNAME = ${INSTALL_LIB_DIR}/libslepc.${AR_LIB_SUFFIX}\n') for module in ['SYS', 'MFN', 'EPS', 'SVD', 'PEP', 'NEP']: slepcvars.write( 'SLEPC_' + module + '_LIB = ${CC_LINKER_SLFLAG}${SLEPC_LIB_DIR} -L${SLEPC_LIB_DIR} -lslepc ${SLEPC_EXTERNAL_LIB} ${PETSC_KSP_LIB}\n' ) slepcvars.write( 'SLEPC_LIB = ${CC_LINKER_SLFLAG}${SLEPC_LIB_DIR} -L${SLEPC_LIB_DIR} -lslepc ${SLEPC_EXTERNAL_LIB} ${PETSC_KSP_LIB}\n' ) # Check for external packages
pkg.requested for pkg in externalpackages): log.Print( '\nWARNING: forcing --with-clean=1 because previous configuration had external packages' ) slepc.clean = True except: pass if slepc.clean: log.Print('\nCleaning arch dir ' + archdir + '...') try: for root, dirs, files in os.walk(archdir, topdown=False): for name in files: if name != 'configure.log': os.remove(os.path.join(root, name)) except: log.Exit('ERROR: Cannot remove existing files in ' + archdir) for rdir in ['CMakeFiles', 'obj', 'externalpackages']: try: shutil.rmtree(os.path.join(archdir, rdir)) except: pass # Create other directories and configuration files if not slepc.prefixdir: slepc.prefixdir = archdir includedir = CreateDir(archdir, 'include', log) modulesdir = CreateDirTwo(confdir, 'modules', 'slepc', log) pkgconfdir = CreateDir(libdir, 'pkgconfig', log) slepcvars = CreateFile(confdir, 'slepcvariables', log) slepcrules = CreateFile(confdir, 'slepcrules', log) slepcconf = CreateFile(includedir, 'slepcconf.h', log)