Exemple #1
0
def configure():
    INCLUDE_DIRS = []
    LIBRARY_DIRS = []
    LIBRARIES    = []

    # PETSc
    import os
    PETSC_DIR  = os.environ['PETSC_DIR']
    PETSC_ARCH = os.environ.get('PETSC_ARCH', '')
    from os.path import join, isdir
    if PETSC_ARCH and isdir(join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'include'),
                         join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'lib')]
    else:
        if PETSC_ARCH: pass # XXX should warn ...
        INCLUDE_DIRS += [join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [join(PETSC_DIR, 'lib')]
    LIBRARIES += ['petsc']

    # PETSc for Python
    INCLUDE_DIRS += [petsc4py.get_include()]

    # NumPy
    INCLUDE_DIRS += [numpy.get_include()]

    return dict(
        include_dirs=INCLUDE_DIRS + [os.curdir],
        libraries=LIBRARIES,
        library_dirs=LIBRARY_DIRS,
        runtime_library_dirs=LIBRARY_DIRS,
    )
Exemple #2
0
def configuration(parent_package='', top_path=None):
    INCLUDE_DIRS = []
    LIBRARY_DIRS = []
    LIBRARIES = []

    # PETSc
    import os
    PETSC_DIR = os.environ['PETSC_DIR']
    PETSC_ARCH = os.environ.get('PETSC_ARCH', '')
    from os.path import join, isdir
    if PETSC_ARCH and isdir(join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [
            join(PETSC_DIR, PETSC_ARCH, 'include'),
            join(PETSC_DIR, 'include')
        ]
        LIBRARY_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'lib')]
    else:
        if PETSC_ARCH: pass
        INCLUDE_DIRS += [join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [join(PETSC_DIR, 'lib')]
    LIBRARIES += [  #'petscts', 'petscsnes', 'petscksp',
        #'petscdm', 'petscmat',  'petscvec',
        'petsc'
    ]

    import os
    import petsc4py
    INCLUDE_DIRS += [petsc4py.get_include()]

    # Configuration
    from numpy.distutils.misc_util import Configuration

    config = Configuration('', parent_package, top_path)

    config.add_extension(
        'eSCAPE._fortran',
        sources=['fortran/functions.pyf', 'fortran/functions.F90'],
        depends=['fortran/functionsmodule.h'],
        # f2py_options=['--quiet'],
        define_macros=[],  #[('F2PY_REPORT_ON_ARRAY_COPY',0)],
        include_dirs=INCLUDE_DIRS + [os.curdir],
        libraries=LIBRARIES,
        library_dirs=LIBRARY_DIRS,
        extra_f90_compile_args=['-fPIC', '-O3'],
        #extra_f90_compile_args = ['-fPIC', '-O0', '-g', '-fbacktrace','-fcheck=all'],
        #extra_link_args = ['-shared '],
        runtime_library_dirs=LIBRARY_DIRS)
    #define_macros=[],
    #include_dirs=[os.curdir],
    # libraries=[],
    # library_dirs=[],
    # extra_f90_compile_args=['-fPIC','-O3'],
    # extra_link_args = ['-shared '],
    # runtime_library_dirs=[])

    return config
Exemple #3
0
 def dijitso_jit(jitable,
                 name,
                 params,
                 generate=None,
                 send=None,
                 receive=None,
                 wait=None):
     name = name.replace("dolfin", package_name)
     params["build"]["include_dirs"].append(mpi4py.get_include())
     params["build"]["include_dirs"].append(petsc4py.get_include())
     params["build"]["include_dirs"].extend(include_dirs)
     return original_dijitso_jit(jitable, name, params, generate, send,
                                 receive, wait)
Exemple #4
0
def configure():

    if any(e not in os.environ
           for e in ['PETSC_DIR', 'PETSC_ARCH', 'SLEPC_DIR']):
        raise ValueError('Must set environment variables PETSC_DIR, '
                         'PETSC_ARCH and SLEPC_DIR before installing! '
                         'If executing with sudo, you may want the -E '
                         'flag to pass environment variables through '
                         'sudo.')

    PETSC_DIR = os.environ['PETSC_DIR']
    PETSC_ARCH = os.environ['PETSC_ARCH']
    SLEPC_DIR = os.environ['SLEPC_DIR']

    include = []
    lib_paths = []

    include += [
        join(PETSC_DIR, PETSC_ARCH, 'include'),
        join(PETSC_DIR, 'include')
    ]
    lib_paths += [join(PETSC_DIR, PETSC_ARCH, 'lib')]

    include += [
        join(SLEPC_DIR, PETSC_ARCH, 'include'),
        join(SLEPC_DIR, 'include')
    ]
    lib_paths += [join(SLEPC_DIR, PETSC_ARCH, 'lib')]

    libs = ['petsc', 'slepc']

    # python package includes
    include += [
        petsc4py.get_include(),
        slepc4py.get_include(),
        numpy.get_include()
    ]

    object_files = ['dynamite/backend/backend_impl.o']

    # check if we have nvcc, and thus should link to
    # the CUDA code
    if HAVE_NVCC:
        object_files = ['dynamite/backend/cuda_shell.o'] + object_files

    return dict(include_dirs=include,
                libraries=libs,
                library_dirs=lib_paths,
                runtime_library_dirs=lib_paths,
                extra_objects=object_files)
Exemple #5
0
def configuration(parent_package='', top_path=None):
    INCLUDE_DIRS = []
    LIBRARY_DIRS = []
    LIBRARIES = []

    # PETSc
    import os
    PETSC_DIR = find_petsc_dir()
    PETSC_ARCH = os.environ.get('PETSC_ARCH', '')

    from os.path import join, isdir
    if PETSC_ARCH and isdir(join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [
            join(PETSC_DIR, PETSC_ARCH, 'include'),
            join(PETSC_DIR, 'include')
        ]
        LIBRARY_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'lib')]
    else:
        if PETSC_ARCH: pass  # XXX should warn ...
        INCLUDE_DIRS += [
            join(PETSC_DIR, 'include'),
            join(PETSC_DIR, 'include\\petsc\\mpiuni')
        ]
        LIBRARY_DIRS += [join(PETSC_DIR, 'lib')]
    LIBRARIES += ['petsc']

    # PETSc for Python
    import petsc4py
    INCLUDE_DIRS += [petsc4py.get_include()]

    # Configuration
    from numpy.distutils.misc_util import Configuration
    config = Configuration('', parent_package, top_path)
    config.add_extension(
        'CompositeSimple1D',
        sources=[
            'CompositeSimple1D.pyx', 'CompositeSimple1Dimpl.c',
            'multiblock/multiblock.c'
        ],
        depends=['CompositeSimple1Dimpl.h'],
        include_dirs=INCLUDE_DIRS + [os.curdir],
        libraries=LIBRARIES,
        library_dirs=LIBRARY_DIRS,
        extra_compile_args=["-Zi", "/Od"],
        extra_link_args=["-debug"],
    )
    #runtime_library_dirs=LIBRARY_DIRS)

    return config
Exemple #6
0
def configuration(parent_package='', top_path=None):
    INCLUDE_DIRS = [
        '/usr/lib/openmpi/include/',
        os.path.join(SUNDIALS_PATH, 'include')
    ]
    LIBRARY_DIRS = [os.path.join(SUNDIALS_PATH, 'lib')]
    LIBRARIES = [
        'sundials_cvodes', 'sundials_nvecparallel', 'sundials_nvecserial'
    ]

    # PETSc
    PETSC_DIR = os.environ.get('PETSC_DIR', '/usr/lib/petsc')
    PETSC_ARCH = os.environ.get('PETSC_ARCH', 'linux-gnu-c-opt')

    if os.path.isdir(os.path.join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [os.path.join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [os.path.join(PETSC_DIR, PETSC_ARCH, 'lib')]
    else:
        raise Exception('Seems PETSC_DIR or PETSC_ARCH are wrong!')
    LIBRARIES += [  #'petscts', 'petscsnes', 'petscksp',
        #'petscdm', 'petscmat',  'petscvec',
        'petsc'
    ]

    # PETSc for Python
    import petsc4py
    INCLUDE_DIRS += [petsc4py.get_include()]

    print "[DDD] INCLUDE_DIRS = {}".format(INCLUDE_DIRS)

    # Configuration
    from numpy.distutils.misc_util import Configuration
    config = Configuration('', parent_package, top_path)
    config.add_extension('cvode_petsc',
                         sources=['cvode_petsc.pyx'],
                         depends=[''],
                         include_dirs=INCLUDE_DIRS + [os.curdir],
                         libraries=LIBRARIES,
                         library_dirs=LIBRARY_DIRS,
                         runtime_library_dirs=LIBRARY_DIRS)

    config.add_extension('llg_petsc',
                         sources=['llg_petsc.pyx', 'llg.c'],
                         depends=[''],
                         include_dirs=INCLUDE_DIRS + [os.curdir],
                         libraries=LIBRARIES,
                         library_dirs=LIBRARY_DIRS,
                         runtime_library_dirs=LIBRARY_DIRS)
    return config
Exemple #7
0
def build_sources(cmd):
    from os.path import exists, isdir, join
    if (exists(join('src', 'slepc4py.SLEPc.c')) and
        not (isdir('.hg') or isdir('.git')) and
        not cmd.force): return
    # slepc4py.SLEPc
    source = 'slepc4py.SLEPc.pyx'
    depends = ("include/*/*.pxd",
               "SLEPc/*.pyx",
               "SLEPc/*.pxi",)
    import petsc4py
    includes = ['include', petsc4py.get_include()]
    destdir_h = os.path.join('include', 'slepc4py')
    run_cython(source, depends, includes,
               destdir_c=None, destdir_h=destdir_h, wdir='src',
               force=cmd.force, VERSION=CYTHON)
Exemple #8
0
def configuration(parent_package="", top_path=None):
    INCLUDE_DIRS = []
    LIBRARY_DIRS = []
    LIBRARIES = []

    # PETSc
    import os

    PETSC_DIR = os.environ["PETSC_DIR"]
    PETSC_ARCH = os.environ.get("PETSC_ARCH", "")
    from os.path import join, isdir

    if PETSC_ARCH and isdir(join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [join(PETSC_DIR, PETSC_ARCH, "include"), join(PETSC_DIR, "include")]
        LIBRARY_DIRS += [join(PETSC_DIR, PETSC_ARCH, "lib")]
    else:
        if PETSC_ARCH:
            pass  # XXX should warn ...
        INCLUDE_DIRS += [join(PETSC_DIR, "include")]
        LIBRARY_DIRS += [join(PETSC_DIR, "lib")]
    LIBRARIES += [  #'petscts', 'petscsnes', 'petscksp',
        #'petscdm', 'petscmat',  'petscvec',
        "petsc"
    ]

    # PETSc for Python
    import petsc4py

    INCLUDE_DIRS += [petsc4py.get_include()]

    # Configuration
    from numpy.distutils.misc_util import Configuration

    config = Configuration("", parent_package, top_path)
    config.add_extension(
        "Bratu2D",
        sources=["Bratu2D.pyf", "Bratu2D.F90"],
        depends=["Bratu2Dmodule.h"],
        f2py_options=["--quiet"],
        define_macros=[("F2PY_REPORT_ON_ARRAY_COPY", 1)],
        include_dirs=INCLUDE_DIRS + [os.curdir],
        libraries=LIBRARIES,
        library_dirs=LIBRARY_DIRS,
        runtime_library_dirs=LIBRARY_DIRS,
    )
    return config
Exemple #9
0
def get_ext_modules(Extension):
    from os   import walk, path
    from glob import glob
    depends = []
    for pth, dirs, files in walk('src'):
        depends += glob(path.join(pth, '*.h'))
        depends += glob(path.join(pth, '*.c'))
    try:
        import petsc4py
        petsc4py_includes = [petsc4py.get_include()]
    except ImportError:
        petsc4py_includes = []
    return [Extension('slepc4py.lib.SLEPc',
                      sources=['src/SLEPc.c',],
                      include_dirs=['src/include',
                                    ] + petsc4py_includes,
                      depends=depends)]
Exemple #10
0
def configuration(parent_package='',top_path=None):
    INCLUDE_DIRS = []
    LIBRARY_DIRS = []
    LIBRARIES    = []

    # PETSc
    import os
    PETSC_DIR  = os.environ['PETSC_DIR']
    PETSC_ARCH = os.environ.get('PETSC_ARCH', '')
    from os.path import join, isdir
    if PETSC_ARCH and isdir(join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'include'),
                         join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'lib')]
    else:
        if PETSC_ARCH: pass # XXX should warn ...
        INCLUDE_DIRS += [join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [join(PETSC_DIR, 'lib')]
    def haslibrary(basename):
        return (   os.path.exists(join(PETSC_DIR,PETSC_ARCH,'lib','%s.so' % basename))
                or os.path.exists(join(PETSC_DIR,PETSC_ARCH,'lib','%s.dylib' % basename)))
    if haslibrary('libpetsc'):
        LIBRARIES += ['petsc']
    elif haslibrary('libpetscts'):
        LIBRARIES += ['petscts','petscsnes','petscksp','petscdm','petscmat','petscvec','petscsys']
    else: raise DistutilsError('Cannot find valid PETSc libraries in PETSC_DIR=%s PETSC_ARCH=%s',PETSC_DIR,PETSC_ARCH)

    # PETSc for Python
    import petsc4py
    INCLUDE_DIRS += [petsc4py.get_include()]

    # Configuration
    from numpy.distutils.misc_util import Configuration
    module = 'assembly'
    config = Configuration('', parent_package, top_path)
    config.add_extension(module,
                         sources = [module+'.pyx',
                                    module+'impl.c'],
                         depends = [module+'impl.h'],
                         include_dirs=INCLUDE_DIRS + [os.curdir],
                         libraries=LIBRARIES,
                         library_dirs=LIBRARY_DIRS,
                         runtime_library_dirs=LIBRARY_DIRS)
    return config
Exemple #11
0
def configuration(parent_package='', top_path=None):
    INCLUDE_DIRS = []
    LIBRARY_DIRS = []
    LIBRARIES = []

    # PETSc
    import os
    PETSC_DIR = os.environ['PETSC_DIR']
    PETSC_ARCH = os.environ.get('PETSC_ARCH', '')
    from os.path import join, isdir
    if PETSC_ARCH and isdir(join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [
            join(PETSC_DIR, PETSC_ARCH, 'include'),
            join(PETSC_DIR, 'include')
        ]
        LIBRARY_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'lib')]
    else:
        if PETSC_ARCH: pass  # XXX should warn ...
        INCLUDE_DIRS += [join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [join(PETSC_DIR, 'lib')]
    LIBRARIES += [  #'petscts', 'petscsnes', 'petscksp',
        #'petscdm', 'petscmat',  'petscvec',
        'petsc'
    ]

    # PETSc for Python
    import petsc4py
    INCLUDE_DIRS += [petsc4py.get_include()]
    print INCLUDE_DIRS

    # Configuration
    from numpy.distutils.misc_util import Configuration
    config = Configuration('', parent_package, top_path)
    config.add_extension('CavityFlow2D',
                         sources=['CavityFlow2D.pyx', 'CavityFlow2Dimpl.c'],
                         depends=['CavityFlow2Dimpl.h'],
                         include_dirs=INCLUDE_DIRS + [os.curdir],
                         libraries=LIBRARIES,
                         library_dirs=LIBRARY_DIRS,
                         runtime_library_dirs=LIBRARY_DIRS)
    return config
Exemple #12
0
def configuration(parent_package='',top_path=None):
    INCLUDE_DIRS = []
    LIBRARY_DIRS = []
    LIBRARIES    = []

    # PETSc
    import os
    PETSC_DIR  = os.environ['PETSC_DIR']
    PETSC_ARCH = os.environ.get('PETSC_ARCH', '')
    from os.path import join, isdir
    if PETSC_ARCH and isdir(join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'include'),
                         join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'lib')]
    else:
        if PETSC_ARCH: pass # XXX should warn ...
        INCLUDE_DIRS += [join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [join(PETSC_DIR, 'lib')]
    LIBRARIES += [#'petscts', 'petscsnes', 'petscksp',
                  #'petscdm', 'petscmat',  'petscvec',
                  'petsc']

    # PETSc for Python
    import petsc4py
    INCLUDE_DIRS += [petsc4py.get_include()]

    # Configuration
    from numpy.distutils.misc_util import Configuration
    config = Configuration('', parent_package, top_path)
    config.add_extension('Bratu2D',
                         sources = ['Bratu2D.pyf',
                                    'Bratu2D.F90'],
                         depends = ['Bratu2Dmodule.h'],
                         f2py_options=['--quiet'],
                         define_macros=[('F2PY_REPORT_ON_ARRAY_COPY',1)],
                         include_dirs=INCLUDE_DIRS + [os.curdir],
                         libraries=LIBRARIES,
                         library_dirs=LIBRARY_DIRS,
                         runtime_library_dirs=LIBRARY_DIRS)
    return config
Exemple #13
0
def configuration(parent_package='',top_path=None):
    INCLUDE_DIRS = []
    LIBRARY_DIRS = []
    LIBRARIES    = []

    # PETSc
    import os
    PETSC_DIR  = os.environ['PETSC_DIR']
    PETSC_ARCH = os.environ.get('PETSC_ARCH', '')
    from os.path import join, isdir
    if PETSC_ARCH and isdir(join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'include'),
                         join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'lib')]
    else:
        if PETSC_ARCH: pass # XXX should warn ...
        INCLUDE_DIRS += [join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [join(PETSC_DIR, 'lib')]
    LIBRARIES += [#'petscts', 'petscsnes', 'petscksp',
                  #'petscdm', 'petscmat',  'petscvec',
                  'petsc']

    # PETSc for Python
    import petsc4py
    INCLUDE_DIRS += [petsc4py.get_include()]
    print INCLUDE_DIRS

    # Configuration
    from numpy.distutils.misc_util import Configuration
    config = Configuration('', parent_package, top_path)
    config.add_extension('CavityFlow2D',
                         sources = ['CavityFlow2D.pyx',
                                    'CavityFlow2Dimpl.c'],
                         depends = ['CavityFlow2Dimpl.h'],
                         include_dirs=INCLUDE_DIRS + [os.curdir],
                         libraries=LIBRARIES,
                         library_dirs=LIBRARY_DIRS,
                         runtime_library_dirs=LIBRARY_DIRS)
    return config
Exemple #14
0
from os.path import join, isdir
if PETSC_ARCH and isdir(join(PETSC_DIR, PETSC_ARCH)):
    INCLUDE_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'include'),
                     join(PETSC_DIR, 'include')]
    LIBRARY_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'lib')]
else:
    if PETSC_ARCH: pass # XXX should warn ...
    INCLUDE_DIRS += [join(PETSC_DIR, 'include')]
    LIBRARY_DIRS += [join(PETSC_DIR, 'lib')]
LIBRARIES += [#'petscts', 'petscsnes', 'petscksp',
              #'petscdm', 'petscmat',  'petscvec',
              'petsc']

# PETSc for Python
import petsc4py
INCLUDE_DIRS += [petsc4py.get_include()]

# CUDA
from setup_cuda import locate_cuda
CUDA = locate_cuda()
print CUDA
LIBRARY_DIRS += [CUDA['lib64']]
LIBRARIES += ['cudart']
INCLUDE_DIRS += [CUDA['include']]

# Obtain the numpy include directory:
import numpy
numpy_include = numpy.get_include() 
INCLUDE_DIRS += [numpy_include]

ext = Extension('GPUArray',
}

namespace pybind11
{
  namespace detail
  {
    PETSC_CASTER_MACRO(IS, is);
  }
}
"""

# Load and wrap compiled function dofmap_dofs_is
path = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
module_dofs = compile_cpp_code(dofmap_dofs_is_cpp_code,
                               include_dirs=[path,
                                             petsc4py.get_include()])


def dofmap_dofs_is(dofmap):
    """Converts DofMap::dofs() to IS.

    This function is intended to circumvent NumPy which would be
    involved in code like::

        iset = PETSc.IS().createGeneral(dofmap.dofs(),
                                        comm=dofmap.index_map().mpi_comm())
    """
    iset = module_dofs.dofmap_dofs_is(dofmap)
    iset.decRef()
    assert iset.getRefCount() == 1
    return iset
Exemple #16
0
def MPIpackage(config):
    try:
        from numpy.distutils.fcompiler import FCompiler
        def runtime_library_dir_option(self, dir):
            return self.c_compiler.runtime_library_dir_option(dir)
        FCompiler.runtime_library_dir_option = \
            runtime_library_dir_option
    except Exception:
        pass
    
    INCLUDE_DIRS = []
    LIBRARY_DIRS = []
    LIBRARIES   = []
    
    # Get PETSc environment variables
    try:
        PETSC_ARCH = os.environ.get('PETSC_ARCH', '')
        PETSC_DIR  = os.environ['PETSC_DIR']
        if PETSC_DIR == '':
            raise KeyError
        elif not (os.path.isfile(PETSC_DIR+'/'+PETSC_ARCH+'/lib/libpetsc.so') or os.path.isfile(PETSC_DIR+'/'+PETSC_ARCH+'/lib/libpetsc.a')):
            raise dirError
    except KeyError:
        raise Exception("ERROR: PETSC_DIR environment variable not set")
    except dirError:
        raise Exception("ERROR: PETSC_DIR does not point towards a valid directory")
    
    # get PETSc include and library directories
    if PETSC_ARCH and os.path.isdir(os.path.join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [os.path.join(PETSC_DIR, PETSC_ARCH, 'include'),
                         os.path.join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [os.path.join(PETSC_DIR, PETSC_ARCH, 'lib')]
    else:
        if PETSC_ARCH: pass
        INCLUDE_DIRS += [os.path.join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [os.path.join(PETSC_DIR, 'lib')]
    LIBRARIES += ['petsc']

    # PETSc for Python
    try:
        import petsc4py
    except ImportError:
        raise Exception("""ERROR: petsc4py 3.4 not installed. 
This can be installed by running 
pip install https://bitbucket.org/petsc/petsc4py/downloads/petsc4py-3.4.tar.gz
Please see http://pythonhosted.org/petsc4py/ for more info.""")
        
    INCLUDE_DIRS += [petsc4py.get_include()]
                  
    # Get SLEPc environment variables
    try:
        SLEPC_DIR  = os.environ['SLEPC_DIR']
        if SLEPC_DIR == '':
            raise KeyError
        elif not (os.path.isfile(SLEPC_DIR+'/'+PETSC_ARCH+'/lib/libslepc.so') or os.path.isfile(SLEPC_DIR+'/'+PETSC_ARCH+'/lib/libslepc.a')):
            raise dirError
    except KeyError:
        raise Exception("ERROR: SLEPC_DIR environment variable not set")
    except dirError:
        raise Exception("ERROR: SLEPC_DIR does not point towards a valid directory")
    
    # get SLEPc include and library directories 
    if PETSC_ARCH and os.path.isdir(os.path.join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [os.path.join(SLEPC_DIR, PETSC_ARCH, 'include'),
                         os.path.join(SLEPC_DIR, 'include')]
        LIBRARY_DIRS += [os.path.join(SLEPC_DIR, PETSC_ARCH, 'lib')]
    else:
        INCLUDE_DIRS += [os.path.join(SLEPC_DIR, 'include')]
        LIBRARY_DIRS += [os.path.join(SLEPC_DIR, 'lib')]
    LIBRARIES += ['slepc']
    
    # set the compiler to mpi
    if os.getenv('LDSHARED', '') == '':
        os.environ["CC"] = "mpicc"
        os.environ["F90"] = "mpif90"
        os.environ["LDSHARED"] = "mpif90"
    
    # create the extension  
    config.add_extension('libpyctqw_MPI',
                 sources = ['src/ctqwMPI.F90','src/ctqwMPI.pyf'],
                 f2py_options=['--quiet'],
                 extra_f90_compile_args=['-Wno-unused-variable','-Wno-conversion','-Wno-unused-dummy-argument'],
                 #define_macros=[('F2PY_REPORT_ON_ARRAY_COPY',1)],
                 include_dirs=INCLUDE_DIRS + [os.curdir],
                 libraries=LIBRARIES,
                 library_dirs=LIBRARY_DIRS,
                 runtime_library_dirs=LIBRARY_DIRS)
    return config
Exemple #17
0
                try:
                    os.remove(output)
                except OSError:
                    pass
            return 1
        # move ouputs
        for destdir, outputs in ((destdir_c, outputs_c), (destdir_h,
                                                          outputs_h)):
            if destdir is None: continue
            for output in outputs:
                dest = os.path.join(destdir, os.path.basename(output))
                try:
                    os.remove(dest)
                except OSError:
                    pass
                os.rename(output, dest)
        #
        return 0
    #
    finally:
        os.chdir(cwd)


if __name__ == "__main__":
    import petsc4py
    sys.exit(
        cythonize('slepc4py.SLEPc.pyx',
                  includes=['include', petsc4py.get_include()],
                  destdir_h=os.path.join('include', 'slepc4py'),
                  wdir='src'))
Exemple #18
0
    mg_sources = ["firedrake/mg/impl.pyx"]
except ImportError:
    # No cython, dmplex.c must be generated in distributions.
    dmplex_sources = ["firedrake/dmplex.c"]
    spatialindex_sources = ["firedrake/spatialindex.cpp"]
    h5iface_sources = ["firedrake/hdf5interface.c"]
    mg_sources = ["firedrake/mg/impl.c"]

if 'CC' not in env:
    env['CC'] = "mpicc"

if 'CXX' not in env:
    env['CXX'] = "mpic++"

petsc_dirs = get_petsc_dir()
include_dirs = [np.get_include(), petsc4py.get_include()]
include_dirs += ["%s/include" % d for d in petsc_dirs]

setup(name='firedrake',
      version=versioneer.get_version(),
      cmdclass=cmdclass,
      description="""Firedrake is an automated system for the portable solution
          of partial differential equations using the finite element method
          (FEM)""",
      author="Imperial College London and others",
      author_email="*****@*****.**",
      url="http://firedrakeproject.org",
      packages=["firedrake", "firedrake.mg"],
      package_data={"firedrake": ["firedrake_geometry.h",
                                  "evaluate.h",
                                  "locate.cpp"]},
Exemple #19
0
        join(PETSC_DIR, 'include')
    ]
    LIBRARY_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'lib')]
else:
    if PETSC_ARCH: pass  # XXX should warn ...
    INCLUDE_DIRS += [join(PETSC_DIR, 'include')]
    LIBRARY_DIRS += [join(PETSC_DIR, 'lib')]

LIBRARIES += ['petsc']

# NumPy
INCLUDE_DIRS += [numpy.get_include()]

# PETSc for Python
import petsc4py
INCLUDE_DIRS += [petsc4py.get_include()]

# Intel MPI
IMPI_DIR = '/afs/@cell/common/soft/intel/ics2013/impi/4.1.3/intel64'

if isdir(IMPI_DIR):
    INCLUDE_DIRS += [join(IMPI_DIR, 'include')]
    LIBRARY_DIRS += [join(IMPI_DIR, 'lib')]

# MacPorts OpenMPI
if isdir('/opt/local/include/openmpi-gcc6'):
    INCLUDE_DIRS += ['/opt/local/include/openmpi-gcc6']
if isdir('/opt/local/lib/openmpi-gcc6'):
    LIBRARY_DIRS += ['/opt/local/lib/openmpi-gcc6']

# MPI library
Exemple #20
0
]

dep_links = ['git+https://github.com/coneoproject/COFFEE#egg=COFFEE-dev']

version = sys.version_info[:2]
if version < (2, 7) or (3, 0) <= version <= (3, 1):
    install_requires += ['argparse', 'ordereddict']

test_requires = [
    'flake8>=2.1.0',
    'pytest>=2.3',
]

petsc_dirs = get_petsc_dir()
numpy_includes = [np.get_include()]
includes = numpy_includes + [petsc4py.get_include()]
includes += ["%s/include" % d for d in petsc_dirs]

if 'CC' not in env:
    env['CC'] = "mpicc"


class sdist(_sdist):
    def run(self):
        # Make sure the compiled Cython files in the distribution are up-to-date
        from Cython.Build import cythonize
        cythonize(sparsity_sources, language="c", include_path=includes)
        cythonize(computeind_sources)
        _sdist.run(self)

Exemple #21
0
class MakeBuildExt(build_ext):
    def run(self):
        # build the backend_impl.o object file
        make = check_output(['make', 'backend_impl.o'], cwd='dynamite/backend')
        print(make.decode())

        # if we have nvcc, build the CUDA backend
        if HAVE_NVCC:
            make = check_output(['make', 'cuda_shell.o'],
                                cwd='dynamite/backend')
            print(make.decode())

        build_ext.run(self)


setup(name="dynamite",
      version="0.0.2",
      author="Greg Meyer",
      author_email="*****@*****.**",
      description="Fast direct evolution of quantum spin chains.",
      packages=['dynamite'],
      classifiers=[
          "Development Status :: 4 - Beta",
      ],
      ext_modules=cythonize(
          extensions(),
          include_path=[petsc4py.get_include(),
                        slepc4py.get_include()]),
      cmdclass={'build_ext': MakeBuildExt})
Exemple #22
0
        INCLUDE_DIRS += [join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [join(PETSC_DIR, 'lib')]
    LIBRARIES += ['petsc']

    # PETSc for Python
    INCLUDE_DIRS += [petsc4py.get_include()]

    # NumPy
    INCLUDE_DIRS += [numpy.get_include()]

    return dict(
        include_dirs=INCLUDE_DIRS + [os.curdir],
        libraries=LIBRARIES,
        library_dirs=LIBRARY_DIRS,
        runtime_library_dirs=LIBRARY_DIRS,
    )


extensions = [
    Extension(
        'pcdeflation',
        sources=['pcdeflation.pyx'],
        #depends = ['Bratu3Dimpl.h'],
        **configure()),
]

setup(
    name="pcdeflation",
    ext_modules=cythonize(extensions, include_path=[petsc4py.get_include()]),
)
Exemple #23
0
    'mpi4py',
    'numpy>=1.6',
]

version = sys.version_info[:2]
if version < (2, 7) or (3, 0) <= version <= (3, 1):
    install_requires += ['argparse', 'ordereddict']

test_requires = [
    'flake8>=2.1.0',
    'pytest>=2.3',
]

petsc_dirs = get_petsc_dir()
numpy_includes = [np.get_include()]
includes = numpy_includes + [petsc4py.get_include()]
includes += ["%s/include" % d for d in petsc_dirs]

if 'CC' not in env:
    env['CC'] = "mpicc"


class sdist(_sdist):
    def run(self):
        # Make sure the compiled Cython files in the distribution are up-to-date
        from Cython.Build import cythonize
        cythonize(plan_sources)
        cythonize(sparsity_sources, language="c++", include_path=includes)
        cythonize(computeind_sources)
        _sdist.run(self)
Exemple #24
0
import os
import petsc4py
import numpy

include_dirs = [os.path.join(os.getenv('PETSC_DIR'), 'include'),
                petsc4py.get_include(),numpy.get_include(),
                # May need to add extras here depending on your environment
                '/usr/lib/openmpi/include', '/usr/lib/openmpi/include/openmpi',
                ]
                
swig_include_dirs = [petsc4py.get_include()]
library_dirs = [os.path.join(os.getenv('PETSC_DIR'),'lib')] # os.getenv('PETSC_ARCH')
libraries = ['petsc']
Exemple #25
0
     os.getenv("FOAM_SRC") + "/transportModels/compressible/lnInclude",
     os.getenv("FOAM_SRC") + "/thermophysicalModels/basic/lnInclude",
     os.getenv("FOAM_SRC") +
     "/TurbulenceModels/turbulenceModels/lnInclude",
     os.getenv("FOAM_SRC") + "/TurbulenceModels/compressible/lnInclude",
     os.getenv("FOAM_SRC") + "/finiteVolume/cfdTools",
     os.getenv("FOAM_SRC") + "/finiteVolume/lnInclude",
     os.getenv("FOAM_SRC") + "/meshTools/lnInclude",
     os.getenv("FOAM_SRC") + "/sampling/lnInclude",
     # These are common for all OpenFOAM executives
     os.getenv("FOAM_SRC") + "/OpenFOAM/lnInclude",
     os.getenv("FOAM_SRC") + "/OSspecific/POSIX/lnInclude",
     os.getenv("FOAM_LIBBIN"),
     # DAFoam include
     os.getenv("PETSC_DIR") + "/include",
     petsc4py.get_include(),
     os.getenv("PETSC_DIR") + "/" + os.getenv("PETSC_ARCH") +
     "/include",
     "../../ofLibs/adjoint/lnInclude",
     "../../ofLibs/boundaryConditions/tractionDisplacement",
     "./"
     "../../include"
 ],
 # These are from Make/options:EXE_LIBS
 libraries=[
     "compressibleTransportModels", "fluidThermophysicalModels",
     "specie", "turbulenceModels", "compressibleTurbulenceModels",
     "finiteVolume", "sampling", "meshTools", "fvOptions",
     "AdjointDerivativeCompressible", "petsc"
 ],
 # These are pathes of linked libraries
Exemple #26
0
def MPIpackage(config):
    try:
        from numpy.distutils.fcompiler import FCompiler

        def runtime_library_dir_option(self, dir):
            return self.c_compiler.runtime_library_dir_option(dir)
        FCompiler.runtime_library_dir_option = \
            runtime_library_dir_option
    except Exception:
        pass

    INCLUDE_DIRS = []
    LIBRARY_DIRS = []
    LIBRARIES = []

    # Get PETSc environment variables
    try:
        PETSC_ARCH = os.environ.get('PETSC_ARCH', '')
        PETSC_DIR = os.environ['PETSC_DIR']
        if PETSC_DIR == '':
            raise KeyError
        elif not (os.path.isfile(PETSC_DIR + '/' + PETSC_ARCH +
                                 '/lib/libpetsc.so')
                  or os.path.isfile(PETSC_DIR + '/' + PETSC_ARCH +
                                    '/lib/libpetsc.a')):
            raise dirError
    except KeyError:
        raise Exception("ERROR: PETSC_DIR environment variable not set")
    except dirError:
        raise Exception(
            "ERROR: PETSC_DIR does not point towards a valid directory")

    # get PETSc include and library directories
    if PETSC_ARCH and os.path.isdir(os.path.join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [
            os.path.join(PETSC_DIR, PETSC_ARCH, 'include'),
            os.path.join(PETSC_DIR, 'include')
        ]
        LIBRARY_DIRS += [os.path.join(PETSC_DIR, PETSC_ARCH, 'lib')]
    else:
        if PETSC_ARCH: pass
        INCLUDE_DIRS += [os.path.join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [os.path.join(PETSC_DIR, 'lib')]
    LIBRARIES += ['petsc']

    # PETSc for Python
    try:
        import petsc4py
    except ImportError:
        raise Exception("""ERROR: petsc4py 3.4 not installed. 
This can be installed by running 
pip install https://bitbucket.org/petsc/petsc4py/downloads/petsc4py-3.4.tar.gz
Please see http://pythonhosted.org/petsc4py/ for more info.""")

    INCLUDE_DIRS += [petsc4py.get_include()]

    # Get SLEPc environment variables
    try:
        SLEPC_DIR = os.environ['SLEPC_DIR']
        if SLEPC_DIR == '':
            raise KeyError
        elif not (os.path.isfile(SLEPC_DIR + '/' + PETSC_ARCH +
                                 '/lib/libslepc.so')
                  or os.path.isfile(SLEPC_DIR + '/' + PETSC_ARCH +
                                    '/lib/libslepc.a')):
            raise dirError
    except KeyError:
        raise Exception("ERROR: SLEPC_DIR environment variable not set")
    except dirError:
        raise Exception(
            "ERROR: SLEPC_DIR does not point towards a valid directory")

    # get SLEPc include and library directories
    if PETSC_ARCH and os.path.isdir(os.path.join(PETSC_DIR, PETSC_ARCH)):
        INCLUDE_DIRS += [
            os.path.join(SLEPC_DIR, PETSC_ARCH, 'include'),
            os.path.join(SLEPC_DIR, 'include')
        ]
        LIBRARY_DIRS += [os.path.join(SLEPC_DIR, PETSC_ARCH, 'lib')]
    else:
        INCLUDE_DIRS += [os.path.join(SLEPC_DIR, 'include')]
        LIBRARY_DIRS += [os.path.join(SLEPC_DIR, 'lib')]
    LIBRARIES += ['slepc']

    # set the compiler to mpi
    if os.getenv('LDSHARED', '') == '':
        os.environ["CC"] = "mpicc"
        os.environ["F90"] = "mpif90"
        os.environ["LDSHARED"] = "mpif90"

    # create the extension
    config.add_extension(
        'libpyctqw_MPI',
        sources=['src/ctqwMPI.F90', 'src/ctqwMPI.pyf'],
        f2py_options=['--quiet'],
        extra_f90_compile_args=[
            '-Wno-unused-variable', '-Wno-conversion',
            '-Wno-unused-dummy-argument'
        ],
        #define_macros=[('F2PY_REPORT_ON_ARRAY_COPY',1)],
        include_dirs=INCLUDE_DIRS + [os.curdir],
        libraries=LIBRARIES,
        library_dirs=LIBRARY_DIRS,
        runtime_library_dirs=LIBRARY_DIRS)
    return config
Exemple #27
0
    except KeyError:
        try:
            import petsc
            return (petsc.get_petsc_dir(), )
        except ImportError:
            sys.exit("""Error: Could not find PETSc library.

Set the environment variable PETSC_DIR / PETSC_ARCH to your local
PETSc base directory or install PETSc via pip.""")


if 'CC' not in env:
    env['CC'] = "mpicc"

petsc_dirs = get_petsc_dir()
include_dirs = [np.get_include(), petsc4py.get_include()]
include_dirs += ["%s/include" % d for d in petsc_dirs]

link_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "ssc"))

setup(name='ssc',
      cmdclass={'build_ext': build_ext},
      packages=["ssc"],
      ext_modules=[Extension('ssc.PatchPC',
                             sources=["ssc/PatchPC.pyx"],
                             include_dirs=include_dirs,
                             extra_link_args=["-L" + link_dir] +
                             ["-Wl,-rpath," + link_dir],
                             extra_compile_args=["-O3"],
                             libraries=["ssc"])])
Exemple #28
0
        if PETSC_ARCH: pass # XXX should warn ...
        INCLUDE_DIRS += [join(PETSC_DIR, 'include')]
        LIBRARY_DIRS += [join(PETSC_DIR, 'lib')]
    LIBRARIES += ['petsc']

    # PETSc for Python
    INCLUDE_DIRS += [petsc4py.get_include()]

    # NumPy
    INCLUDE_DIRS += [numpy.get_include()]

    return dict(
        include_dirs=INCLUDE_DIRS + [os.curdir],
        libraries=LIBRARIES,
        library_dirs=LIBRARY_DIRS,
        runtime_library_dirs=LIBRARY_DIRS,
    )

extensions = [
    Extension('Bratu3D',
              sources = ['Bratu3D.pyx',
                         'Bratu3Dimpl.c'],
              depends = ['Bratu3Dimpl.h'],
              **configure()),
]

setup(name = "Bratu3D",
      ext_modules = cythonize(
          extensions, include_path=[petsc4py.get_include()]),
)