From c3b8b7217ff955078d74cfc462dba57e741b6725 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Tue, 18 Nov 2014 13:02:45 +0100 Subject: [PATCH] Fix uninitialized variables in Utilities::MPI::MinMaxAvg --- include/deal.II/base/mpi.h | 2 ++ source/base/mpi.cc | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/deal.II/base/mpi.h b/include/deal.II/base/mpi.h index a6943e3691..75a5667f2f 100644 --- a/include/deal.II/base/mpi.h +++ b/include/deal.II/base/mpi.h @@ -216,6 +216,8 @@ namespace Utilities */ struct MinMaxAvg { + MinMaxAvg(); + double sum; double min; double max; diff --git a/source/base/mpi.cc b/source/base/mpi.cc index e24043da95..dd05f4361c 100644 --- a/source/base/mpi.cc +++ b/source/base/mpi.cc @@ -186,8 +186,7 @@ namespace Utilities namespace { - // custom MIP_Op for - // calculate_collective_mpi_min_max_avg + // custom MIP_Op for calculate_collective_mpi_min_max_avg void max_reduce ( const void *in_lhs_, void *inout_rhs_, int *len, @@ -206,7 +205,7 @@ namespace Utilities } else if (inout_rhs->min == in_lhs->min) { - // choose lower cpu index when tied to make operator cumutative + // choose lower cpu index when tied to make operator commutative if (inout_rhs->min_index > in_lhs->min_index) inout_rhs->min_index = in_lhs->min_index; } @@ -218,7 +217,7 @@ namespace Utilities } else if (inout_rhs->max == in_lhs->max) { - // choose lower cpu index when tied to make operator cumutative + // choose lower cpu index when tied to make operator commutative if (inout_rhs->max_index > in_lhs->max_index) inout_rhs->max_index = in_lhs->max_index; } @@ -227,6 +226,18 @@ namespace Utilities + MinMaxAvg::MinMaxAvg () + : + sum (0.), + min (std::numeric_limits::max()), + max (-min), + min_index (0), + max_index (0), + avg (0) + {} + + + MinMaxAvg min_max_avg(const double my_value, const MPI_Comm &mpi_communicator) -- 2.39.5