Skip to content

Commit

Permalink
index_reduce fix don't use MPI unless initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
burlen committed Nov 29, 2020
1 parent 5ce49c5 commit 7baf167
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions core/teca_index_reduce.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,24 @@ void block_decompose(MPI_Comm comm, unsigned long n_indices, unsigned long n_ran
if (verbose)
{
std::vector<unsigned long> decomp = {block_start, block_size};
if (rank == 0)
{
decomp.resize(2*n_ranks);
#if defined(TECA_HAS_MPI)
MPI_Gather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, decomp.data(),
2, MPI_UNSIGNED_LONG, 0, comm);
}
else
int is_init = 0;
MPI_Initialized(&is_init);
if (is_init)
{
MPI_Gather(decomp.data(), 2, MPI_UNSIGNED_LONG, nullptr,
0, MPI_DATATYPE_NULL, 0, comm);
#endif
if (rank == 0)
{
decomp.resize(2*n_ranks);
MPI_Gather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
decomp.data(), 2, MPI_UNSIGNED_LONG, 0, comm);
}
else
{
MPI_Gather(decomp.data(), 2, MPI_UNSIGNED_LONG,
nullptr, 0, MPI_DATATYPE_NULL, 0, comm);
}
}
#endif
if (rank == 0)
{
std::ostringstream oss;
Expand All @@ -108,8 +113,7 @@ void block_decompose(MPI_Comm comm, unsigned long n_indices, unsigned long n_ran
oss << i << " : " << decomp[ii] << " - " << decomp[ii] + decomp[ii+1] -1
<< (i < n_ranks-1 ? "\n" : "");
}
TECA_STATUS("map index decomposition:"
<< std::endl << oss.str())
TECA_STATUS("map index decomposition:" << std::endl << oss.str())
}
}
}
Expand Down

0 comments on commit 7baf167

Please sign in to comment.