summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/ppopen-appl-fem/package.py
blob: c8be0bd0941871e786622cd3766091f6edaffe53 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)


import os

from spack import *


class PpopenApplFem(MakefilePackage):
    """
    ppOpen-APPL/FEM (ppohFEM) is a middleware to allow a Finite Element
    Method (FEM) analysis code developer to devote himself to development of
    the application software by offering a function commonly used in FEM.
    """

    homepage = "http://ppopenhpc.cc.u-tokyo.ac.jp/ppopenhpc/"
    git = "https://github.com/Post-Peta-Crest/ppOpenHPC.git"

    version('master', branch='APPL/FEM')

    depends_on('mpi')
    depends_on('metis')

    # gcc does not support OpenMP atomic to same structure reference.
    # For example a%b = a%b - a%c
    # To avoid this, the patch is replace as follows:
    #   tmp = a%c
    #   !%omp atomic
    #   a%b = a%b - a%c
    patch('gcc_struct_atomic.patch', when='%gcc')
    parallel = False

    def edit(self, spec, prefix):
        fflags = ['-O3', '-I.', self.compiler.openmp_flag]
        if spec.satisfies('%gcc'):
            fflags.extend(['-cpp', '-ffree-line-length-none'])
        makefile_in = FileFilter('Makefile.in')
        makefile_in.filter(
            r'^PREFIX *=.*$',
            'PREFIX = {0}'.format(prefix)
        )
        makefile_in.filter(
            r'^F90OPTFLAGS *=.*$',
            'F90OPTFLAGS = {0}'.format(' '.join(fflags))
        )
        makefile_in.filter(
            r'^METISDIR *=.*$',
            'METISDIR = {0}'.format(spec['metis'].prefix)
        )
        makefile_in.filter('mpicc', spec['mpi'].mpicc)
        makefile_in.filter('mpif90', spec['mpi'].mpifc)
        mkdirp(join_path('ppohFEM', 'bin'))

    def install(self, spec, prefix):
        for d in ['ppohFEM', 'app_flow', 'app_heat', 'app_struct']:
            with working_dir(d):
                for install_dir in ['bin', 'lib', 'include']:
                    if os.path.isdir(install_dir):
                        install_tree(
                            install_dir,
                            join_path(prefix, install_dir)
                        )