Skip to content

Commit

Permalink
Fix #3146 - Error in stat reduction for Function triggered `PeriodicE…
Browse files Browse the repository at this point in the history
…vent` (#3147)
  • Loading branch information
jafranc committed Jun 28, 2024
1 parent 399ec9d commit e5d8d92
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions src/coreComponents/events/PeriodicEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,28 @@ void PeriodicEvent::checkOptionalFunctionThreshold( real64 const time,
// (Note: this shouldn't occur very often, since it is only called if the base forecast <= 0)
#ifdef GEOSX_USE_MPI
real64 result_global;
MPI_Allreduce( &result, &result_global, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD );
result = result_global;
switch( m_functionStatOption )
{
case 0:
{
MPI_Allreduce( &result, &result_global, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD );
result = result_global;
break;
}
case 1:
{
int nprocs;
MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
MPI_Allreduce( &result, &result_global, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD );
result = result_global / nprocs;
break;
}
case 2:
{
MPI_Allreduce( &result, &result_global, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD );
result = result_global;
}
}
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/functions/FunctionBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ real64_array FunctionBase::evaluateStats( dataRepository::Group const & group,
{
result[0] = std::min( result[0], sub[ii] );
result[1] += sub[ii];
result[2] = std::max( result[0], sub[ii] );
result[2] = std::max( result[2], sub[ii] );
}
result[1] /= N;

Expand Down

0 comments on commit e5d8d92

Please sign in to comment.