summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/picsarlite/package.py
blob: 5a5b5b58b260215a1bc21567d9b2f541bb68450e (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Copyright 2013-2018 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)

from spack import *


class Picsarlite(MakefilePackage):
    """PICSARlite is a self-contained proxy that adequately portrays the
       computational loads and dataflow of more complex PIC codes.
    """

    tags = ['proxy-app', 'ecp-proxy-app']

    homepage = "https://picsar.net"
    git      = "https://bitbucket.org/berkeleylab/picsar.git"

    version('develop', branch='PICSARlite')
    version('0.1', tag='PICSARlite-0.1')

    variant('prod', default=True, description='Production mode (without FFTW)')
    variant('prod_spectral', default=False,
            description='Production mode with spectral solver and FFTW')
    variant('debug', default=False, description='Debug mode')
    variant('vtune', default=False, description='Vtune profiling')
    variant('sde', default=False, description='sde profiling')
    variant('map', default=False, description='Allinea Map profiling')
    variant('library', default=False, 
            description='Create static and dynamic library')

    depends_on('mpi')
    depends_on('fftw@3.0: +mpi', when='+prod_spectral')

    @property
    def build_targets(self):
        targets = []
        targets.append('FC={0}'.format(self.spec['mpi'].mpifc))
        targets.append('CC={0}'.format(self.spec['mpi'].mpicc))

        comp = 'user'
        vendors = {'%gcc': 'gnu', '%intel': 'intel'}
        for key, value in vendors.items():
            if self.spec.satisfies(key):
                comp = value
        targets.append('COMP={0}'.format(comp))
        if comp is 'user':
            targets.append('FARGS={0}{1}'.format('-g -O3 ',
                           self.compiler.openmp_flag))

        if '+prod' in self.spec:
            mode = 'prod'
        elif '+prod_spectral' in self.spec:
            mode = 'prod_spectral'
        elif '+debug' in self.spec:
            mode = 'debug'
        elif '+vtune' in self.spec:
            mode = 'vtune'
        elif '+sde' in self.spec:
            mode = 'sde'
        elif '+map' in self.spec:
            mode = 'map'
        elif '+library' in self.spec:
            mode = 'library'
        targets.append('MODE = {0}'.format(mode))

        targets.append('SYS = default')

        return targets

    def build(self, spec, prefix):
        with working_dir('PICSARlite'):
            make(parallel=False)

    def install(self, spec, prefix):
        mkdirp(prefix.docs)
        install('PICSARlite/README.md', prefix.docs)

        mkdirp(prefix.bin)
        install('PICSARlite/bin/picsar', prefix.bin)