From c6f12b77806db7dab2894e943c82b8e19262cee3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkovsky@mmg.fjfi.cvut.cz>
Date: Wed, 5 Jan 2022 22:25:03 +0100
Subject: [PATCH] MPI: added function to broadcast a scalar value

---
 src/TNL/MPI/Utils.h | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/TNL/MPI/Utils.h b/src/TNL/MPI/Utils.h
index 85fbaae1c6..21b4b07585 100644
--- a/src/TNL/MPI/Utils.h
+++ b/src/TNL/MPI/Utils.h
@@ -205,11 +205,24 @@ sendrecv( const SendArray& sendArray,
    MPI::Sendrecv( sendArray.getData(), sendArray.getSize(), dest, sendTag, recvArray.getData(), recvArray.getSize(), src, recvTag, communicator );
 }
 
+/**
+ * \brief Broadcast a scalar value.
+ */
+template< typename T >
+std::enable_if_t< ! IsArrayType< T >::value, T >
+bcast( T value,
+       int root,
+       MPI_Comm communicator = MPI_COMM_WORLD )
+{
+   MPI::Bcast( &value, 1, root, communicator );
+   return value;
+}
+
 /**
  * \brief Broadcast an array (or a string).
  */
 template< typename Array >
-std::enable_if_t< ! IsViewType< Array >::value >
+std::enable_if_t< IsArrayType< Array >::value && ! IsViewType< Array >::value >
 bcast( Array& array,
        int root,
        MPI_Comm communicator = MPI_COMM_WORLD )
-- 
GitLab