summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/bufr/package.py
blob: aec108852f35689245f7ede1c3ff4c82bb9e5bb3 (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
# Copyright 2013-2022 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.package import *


class Bufr(CMakePackage):
    """The NOAA bufr library contains subroutines, functions and other
    utilities that can be used to read (decode) and write (encode)
    data in BUFR, which is a WMO standard format for the exchange of
    meteorological data. This is part of the NCEPLIBS project.

    """

    homepage = "https://noaa-emc.github.io/NCEPLIBS-bufr"
    url      = "https://github.com/NOAA-EMC/NCEPLIBS-bufr/archive/refs/tags/bufr_v11.5.0.tar.gz"

    maintainers = ['t-brown', 'kgerheiser', 'edwardhartnett', 'Hang-Lei-NOAA',
                   'jbathegit']

    version('11.5.0', sha256='d154839e29ef1fe82e58cf20232e9f8a4f0610f0e8b6a394b7ca052e58f97f43')

    def _setup_bufr_environment(self, env, suffix):
        libname = 'libufr_{0}'.format(suffix)
        lib = find_libraries(libname, root=self.prefix,
                             shared=False, recursive=True)
        lib_envname = 'BUFR_LIB{0}'.format(suffix)
        inc_envname = 'BUFR_INC{0}'.format(suffix)
        include_dir = 'include_{0}'.format(suffix)

        env.set(lib_envname, lib[0])
        env.set(inc_envname, include_dir)

        # Bufr has _DA (dynamic allocation) libs in versions <= 11.5.0
        if self.spec.satisfies('@:11.5.0'):
            da_lib = find_libraries(libname + "_DA", root=self.prefix,
                                    shared=False, recursive=True)
            env.set(lib_envname + '_DA', da_lib[0])
            env.set(inc_envname + '_DA', include_dir)

    def setup_run_environment(self, env):
        for suffix in ('4', '8', 'd'):
            self._setup_bufr_environment(env, suffix)