Пример #1
0
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
Пример #2
0
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('')
Пример #3
0
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))
Пример #4
0
def Check(conf,vars,cmake,tmpdir):
  log.write('='*80)
  log.Println('Checking LAPACK library...')

  # LAPACK standard functions
  l = ['laev2','gehrd','lanhs','lange','getri','trexc','trevc','geevx','ggevx','gelqf','gesdd','tgexc','tgevc','pbtrf','stedc','hsein','larfg','larf','trsen','tgsen','lacpy','lascl','lansy','laset']

  # LAPACK functions with different real and complex versions
  if petscconf.SCALAR == 'real':
    l += ['orghr','syevr','syevd','sytrd','sygvd','ormlq','orgqr','orgtr']
    if petscconf.PRECISION == 'single':
      prefix = 's'
    elif petscconf.PRECISION == '__float128':
      prefix = 'q'
    else:
      prefix = 'd'
  else:
    l += ['unghr','heevr','heevd','hetrd','hegvd','unmlq','ungqr','ungtr']
    if petscconf.PRECISION == 'single':
      prefix = 'c'
    elif petscconf.PRECISION == '__float128':
      prefix = 'w'
    else:
      prefix = 'z'

  # add prefix to LAPACK names
  functions = []
  for i in l:
    functions.append(prefix + i)

  # in this case, the real name represents both versions
  namesubst = {'unghr':'orghr', 'heevr':'syevr', 'heevd':'syevd', 'hetrd':'sytrd', 'hegvd':'sygvd', 'unmlq':'ormlq', 'ungqr':'orgqr', 'ungtr':'orgtr'}

  # LAPACK functions which are always used in real version
  if petscconf.PRECISION == 'single':
    functions += ['sstevr','sbdsdc','slamch','slag2','slasv2','slartg','slaln2','slaed4','slamrg','slapy2']
  elif petscconf.PRECISION == '__float128':
    functions += ['qstevr','qbdsdc','qlamch','qlag2','qlasv2','qlartg','qlaln2','qlaed4','qlamrg','qlapy2']
  else:
    functions += ['dstevr','dbdsdc','dlamch','dlag2','dlasv2','dlartg','dlaln2','dlaed4','dlamrg','dlapy2']

  # check for all functions at once
  all = []
  for i in functions:
    f =  '#if defined(PETSC_BLASLAPACK_UNDERSCORE)\n'
    f += i + '_\n'
    f += '#elif defined(PETSC_BLASLAPACK_CAPS) || defined(PETSC_BLASLAPACK_STDCALL)\n'
    f += i.upper() + '\n'
    f += '#else\n'
    f += i + '\n'
    f += '#endif\n'
    all.append(f)

  log.write('=== Checking all LAPACK functions...')
  if check.Link(tmpdir,all,[],[]):
    return []

  # check functions one by one
  missing = []
  for i in functions:
    f =  '#if defined(PETSC_BLASLAPACK_UNDERSCORE)\n'
    f += i + '_\n'
    f += '#elif defined(PETSC_BLASLAPACK_CAPS) || defined(PETSC_BLASLAPACK_STDCALL)\n'
    f += i.upper() + '\n'
    f += '#else\n'
    f += i + '\n'
    f += '#endif\n'

    log.write('=== Checking LAPACK '+i+' function...')
    if not check.Link(tmpdir,[f],[],[]):
      missing.append(i)
      # some complex functions are represented by their real names
      if i[1:] in namesubst:
        nf = namesubst[i[1:]]
      else:
        nf = i[1:]
      conf.write('#ifndef SLEPC_MISSING_LAPACK_' + nf.upper() + '\n#define SLEPC_MISSING_LAPACK_' + nf.upper() + ' 1\n#endif\n\n')
      cmake.write('set (SLEPC_MISSING_LAPACK_' + nf.upper() + ' YES)\n')

  if missing:
    cmake.write('mark_as_advanced (' + ''.join([s.upper()+' ' for s in missing]) + ')\n')
  return missing
Пример #5
0
    AddDefine(slepcconf, 'VERSION_GIT', slepc.gitrev)
    AddDefine(slepcconf, 'VERSION_DATE_GIT', slepc.gitdate)
    AddDefine(slepcconf, 'VERSION_BRANCH_GIT', slepc.branch)

# Create global configuration file for the case of empty PETSC_ARCH
if emptyarch:
    globconf = CreateFile(os.path.join(slepc.dir, 'lib', 'slepc', 'conf'),
                          'slepcvariables', log)
    globconf.write('SLEPC_DIR = ' + slepc.dir + '\n')
    globconf.write('PETSC_ARCH = ' + archname + '\n')
    globconf.close()

# Check if PETSc is working
log.NewSection('Checking PETSc installation...')
if petsc.nversion > slepc.nversion:
    log.Println('\nWARNING: PETSc version ' + petsc.version +
                ' is newer than SLEPc version ' + slepc.version)
if slepc.release == '1' and not petsc.release == '1':
    log.Exit(
        'ERROR: a release version of SLEPc requires a release version of PETSc, not a development version'
    )
if slepc.release == '0' and petsc.release == '1':
    log.Exit(
        'ERROR: a development version of SLEPc cannot be built with a release version of PETSc'
    )
if petsc.isinstall:
    if os.path.realpath(petsc.prefixdir) != os.path.realpath(petsc.dir):
        log.Println(
            '\nWARNING: PETSC_DIR does not point to PETSc installation path')
petsc.Check()
if not petsc.havepackage:
    log.Exit('ERROR: Unable to link with PETSc')
Пример #6
0
log.write('Configure Options: ' + str.join(' ', sys.argv))
log.write('Working directory: ' + os.getcwd())
log.write('Python version:\n' + sys.version)
log.write('make: ' + petscconf.MAKE)
log.write('PETSc source directory: ' + petscdir)
log.write('PETSc install directory: ' + petscconf.DESTDIR)
log.write('PETSc version: ' + petscversion.LVERSION)
if not emptyarch:
    log.write('PETSc architecture: ' + petscconf.ARCH)
log.write('SLEPc source directory: ' + slepcdir)
log.write('SLEPc install directory: ' + prefixdir)
log.write('SLEPc version: ' + slepcversion.LVERSION)
log.write('=' * 80)

# 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
Пример #7
0
    AddDefine(slepcconf, 'VERSION_GIT', slepc.gitrev)
    AddDefine(slepcconf, 'VERSION_DATE_GIT', slepc.gitdate)
    AddDefine(slepcconf, 'VERSION_BRANCH_GIT', slepc.branch)

# Create global configuration file for the case of empty PETSC_ARCH
if emptyarch:
    globconf = CreateFile(os.path.join(slepc.dir, 'lib', 'slepc', 'conf'),
                          'slepcvariables', log)
    globconf.write('SLEPC_DIR = ' + slepc.dir + '\n')
    globconf.write('PETSC_ARCH = ' + archname + '\n')
    globconf.close()

# Check if PETSc is working
log.NewSection('Checking PETSc installation...')
if petsc.version > slepc.version:
    log.Println('\nWARNING: PETSc version ' + petsc.version +
                ' is newer than SLEPc version ' + slepc.version)
if petsc.release != slepc.release:
    log.Exit(
        'ERROR: Cannot mix release and development versions of SLEPc and PETSc'
    )
if petsc.isinstall:
    if os.path.realpath(petsc.destdir) != os.path.realpath(petsc.dir):
        log.Println(
            '\nWARNING: PETSC_DIR does not point to PETSc installation path')
petsc.Check()
if not petsc.havepackage:
    log.Exit('ERROR: Unable to link with PETSc')

# Single library installation
if petsc.singlelib:
    slepcvars.write('SHLIBS = libslepc\n')