summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2015-06-10 14:10:30 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2015-06-10 14:10:30 (GMT)
commit5ec5c1dd65c55d4e00545c41a39feaae072e323f (patch)
tree9890a14eec503ffb853da68ae5ce7fdc3f3800c4 /src
parent56c9297a5a7214db76dae8efdbbb2495e94f68b2 (diff)
downloadhdf5-5ec5c1dd65c55d4e00545c41a39feaae072e323f.zip
hdf5-5ec5c1dd65c55d4e00545c41a39feaae072e323f.tar.gz
hdf5-5ec5c1dd65c55d4e00545c41a39feaae072e323f.tar.bz2
[svn-r27179] Merge 27162 & 27163 from trunk:
fix for HDFFV-9412: - Check for mpi is_initialized and is_finalized before making MPI calls in init/terminate of HDF5. - Add a test to make sure we can make serial HDF5 calls from rank 0 after MPI_Finalize is called. tested with h5committest
Diffstat (limited to 'src')
-rw-r--r--src/H5.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/H5.c b/src/H5.c
index 4071d57..cc2dd85 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -111,26 +111,27 @@ H5_init_library(void)
#ifdef H5_HAVE_PARALLEL
{
int mpi_initialized;
+ int mpi_finalized;
int mpi_code;
MPI_Initialized(&mpi_initialized);
+ MPI_Finalized(&mpi_finalized);
#ifdef H5_HAVE_MPE
/* Initialize MPE instrumentation library. */
- if (!H5_MPEinit_g)
- {
- int mpe_code;
- if (mpi_initialized){
- mpe_code = MPE_Init_log();
- HDassert(mpe_code >=0);
- H5_MPEinit_g = TRUE;
- }
+ if (!H5_MPEinit_g) {
+ int mpe_code;
+ if (mpi_initialized && !mpi_finalized) {
+ mpe_code = MPE_Init_log();
+ HDassert(mpe_code >=0);
+ H5_MPEinit_g = TRUE;
}
+ }
#endif /*H5_HAVE_MPE*/
/* add an attribute on MPI_COMM_SELF to call H5_term_library
when it is destroyed, i.e. on MPI_Finalize */
- if (mpi_initialized) {
+ if (mpi_initialized && !mpi_finalized) {
int key_val;
if(MPI_SUCCESS != (mpi_code = MPI_Comm_create_keyval(MPI_NULL_COPY_FN,
@@ -332,11 +333,14 @@ H5_term_library(void)
* down if any of the below code involves using the instrumentation code.
*/
if(H5_MPEinit_g) {
- int mpe_code;
int mpi_initialized;
+ int mpi_finalized;
+ int mpe_code;
MPI_Initialized(&mpi_initialized);
- if(mpi_initialized) {
+ MPI_Finalized(&mpi_finalized);
+
+ if (mpi_initialized && !mpi_finalized) {
mpe_code = MPE_Finish_log("h5log");
HDassert(mpe_code >=0);
} /* end if */