BUG: UPstream::shutdown misbehaves with external initialisation (fixes #2808)

- freeCommmunicatorComponents needs an additional bounds check.
  When MPI is initialized outside of OpenFOAM, there are no
  UPstream communicator equivalents
This commit is contained in:
Mark Olesen
2023-06-20 08:40:07 +02:00
parent 67bd9119ee
commit 3de090e602

View File

@ -695,11 +695,20 @@ void Foam::UPstream::freeCommunicatorComponents(const label index)
}
// Not touching the first two communicators (SELF, WORLD)
if (index > 1)
// or anything out-of bounds.
//
// No UPstream communicator indices when MPI is initialized outside
// of OpenFOAM - thus needs a bounds check too!
if
(
index > 1
&& index < PstreamGlobals::MPICommunicators_.size()
)
{
if
(
(true == PstreamGlobals::pendingMPIFree_[index])
PstreamGlobals::pendingMPIFree_[index]
&& (MPI_COMM_NULL != PstreamGlobals::MPICommunicators_[index])
)
{