From 7f50283cd92479e4d22d833500fa82debc4fc354 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 22 Dec 2010 20:41:47 -0600 Subject: CarpetLib: Check that MPI datatypes are defined before using them --- Carpet/CarpetLib/src/dist.cc | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'Carpet/CarpetLib/src/dist.cc') diff --git a/Carpet/CarpetLib/src/dist.cc b/Carpet/CarpetLib/src/dist.cc index 67ebe35a6..eb9adff32 100644 --- a/Carpet/CarpetLib/src/dist.cc +++ b/Carpet/CarpetLib/src/dist.cc @@ -43,18 +43,27 @@ namespace dist { #ifdef HAVE_CCTK_REAL4 CCTK_REAL4 dummy4; + assert (mpi_datatype(dummy4) != MPI_DATATYPE_NULL); MPI_Type_contiguous (2, mpi_datatype(dummy4), &mpi_complex8); MPI_Type_commit (&mpi_complex8); #endif #ifdef HAVE_CCTK_REAL8 CCTK_REAL8 dummy8; + assert (mpi_datatype(dummy8) != MPI_DATATYPE_NULL); MPI_Type_contiguous (2, mpi_datatype(dummy8), &mpi_complex16); MPI_Type_commit (&mpi_complex16); #endif #ifdef HAVE_CCTK_REAL16 CCTK_REAL16 dummy16; - MPI_Type_contiguous (2, mpi_datatype(dummy16), &mpi_complex32); - MPI_Type_commit (&mpi_complex32); + if (mpi_datatype(dummy16) != MPI_DATATYPE_NULL) { + MPI_Type_contiguous (2, mpi_datatype(dummy16), &mpi_complex32); + MPI_Type_commit (&mpi_complex32); + } else { + // CCTK_REAL16 is not supported by MPI + CCTK_WARN (CCTK_WARN_ALERT, + "CCTK_REAL16 support is enabled in Cactus, but is not supported by MPI. All MPI operations with this datatype will fail."); + mpi_complex32 = MPI_DATATYPE_NULL; + } #endif // Output startup time @@ -94,6 +103,16 @@ namespace dist { char const * const name, size_t const size) { DECLARE_CCTK_PARAMETERS; + for (size_t n=0; n