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


class Mpi(Package):
    """Virtual package for the Message Passing Interface."""

    homepage = "https://www.mpi-forum.org/"
    virtual = True

    def test(self):
        for lang in ("c", "f"):
            filename = self.test_suite.current_test_data_dir.join("mpi_hello." + lang)

            compiler_var = "MPICC" if lang == "c" else "MPIF90"
            compiler = os.environ[compiler_var]

            exe_name = "mpi_hello_%s" % lang
            mpirun = join_path(self.prefix.bin, "mpirun")

            compiled = self.run_test(compiler, options=["-o", exe_name, filename])
            if compiled:
                self.run_test(
                    mpirun,
                    options=["-np", "1", exe_name],
                    expected=[r"Hello world! From rank \s*0 of \s*1"],
                )