diff --git a/src/TNL/MPI/Utils.h b/src/TNL/MPI/Utils.h index 85fbaae1c65cc3ecee55eadf3d49d5a7784a2850..21b4b075850990305f51a097c62e2e6c0786eff5 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 )