summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2015-02-23 15:14:43 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2015-02-23 15:14:43 (GMT)
commit0c29ac42cd986762e1fa1f937cabe2037f0d53b5 (patch)
tree652be4a716ea8df3999143dcb40775a3309d7d62
parentf175fd25c8714b17b3f5912bfdc7eb78ab50a17d (diff)
downloadhdf5-0c29ac42cd986762e1fa1f937cabe2037f0d53b5.zip
hdf5-0c29ac42cd986762e1fa1f937cabe2037f0d53b5.tar.gz
hdf5-0c29ac42cd986762e1fa1f937cabe2037f0d53b5.tar.bz2
[svn-r26279] re-commit 26260 that Dana moved out fixing the versioning of functions to work with v16 default API.
-rw-r--r--MANIFEST2
-rw-r--r--src/H5.c80
-rw-r--r--testpar/CMakeLists.txt2
-rw-r--r--testpar/Makefile.am5
-rw-r--r--testpar/Makefile.in34
-rw-r--r--testpar/t_pflush1.c11
-rw-r--r--testpar/t_pflush2.c3
-rw-r--r--testpar/t_prestart.c138
-rw-r--r--testpar/t_pshutdown.c127
-rw-r--r--testpar/t_shapesame.c3
-rw-r--r--tools/perform/perf.c3
11 files changed, 363 insertions, 45 deletions
diff --git a/MANIFEST b/MANIFEST
index 34c60e4..cd8133c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1146,6 +1146,8 @@
./testpar/t_pflush2.c
./testpar/t_prop.c
./testpar/t_shapesame.c
+./testpar/t_pshutdown.c
+./testpar/t_prestart.c
./testpar/t_span_tree.c
./testpar/testpar.h
./testpar/testphdf5.c
diff --git a/src/H5.c b/src/H5.c
index af8b668..52dc566 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -52,7 +52,9 @@
/* Local Prototypes */
/********************/
static void H5_debug_mask(const char*);
-
+#ifdef H5_HAVE_PARALLEL
+static int H5_mpi_delete_cb(MPI_Comm comm, int keyval, void *attr_val, int *flag);
+#endif /*H5_HAVE_PARALLEL*/
/*********************/
/* Package Variables */
@@ -109,6 +111,43 @@ H5_init_library(void)
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
+
+#ifdef H5_HAVE_PARALLEL
+ {
+ int mpi_initialized;
+ int mpi_code;
+
+ MPI_Initialized(&mpi_initialized);
+
+#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;
+ }
+ }
+#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) {
+ int key_val;
+
+ if(MPI_SUCCESS != (mpi_code = MPI_Comm_create_keyval(MPI_NULL_COPY_FN,
+ (MPI_Comm_delete_attr_function *)H5_mpi_delete_cb,
+ &key_val, NULL)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Comm_create_keyval failed", mpi_code)
+
+ if(MPI_SUCCESS != (mpi_code = MPI_Comm_set_attr(MPI_COMM_SELF, key_val, NULL)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Comm_set_attr failed", mpi_code)
+ }
+ }
+#endif /*H5_HAVE_PARALLEL*/
+
/*
* Make sure the package information is updated.
*/
@@ -132,24 +171,6 @@ H5_init_library(void)
H5_debug_g.pkg[H5_PKG_V].name = "v";
H5_debug_g.pkg[H5_PKG_Z].name = "z";
-#ifdef H5_HAVE_MPE
- /* Initialize MPE instrumentation library. May need to move this
- * up earlier if any of the above initialization involves using
- * the instrumentation code.
- */
- if (!H5_MPEinit_g)
- {
- int mpe_code;
- int mpi_initialized;
- MPI_Initialized(&mpi_initialized);
- if (mpi_initialized){
- mpe_code = MPE_Init_log();
- HDassert(mpe_code >=0);
- H5_MPEinit_g = TRUE;
- }
- }
-#endif
-
/*
* Install atexit() library cleanup routines unless the H5dont_atexit()
* has been called. Once we add something to the atexit() list it stays
@@ -580,6 +601,27 @@ H5_debug_mask(const char *s)
}
} /* end H5_debug_mask() */
+#ifdef H5_HAVE_PARALLEL
+
+/*-------------------------------------------------------------------------
+ * Function: H5_mpi_delete_cb
+ *
+ * Purpose: Callback attribute on MPI_COMM_SELF to terminate the HDF5
+ * library when the communicator is destroyed, i.e. on MPI_Finalize.
+ *
+ * Return: MPI_SUCCESS
+ *
+ * Programmer: Mohamad Chaarawi, February 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static int H5_mpi_delete_cb(MPI_Comm UNUSED comm, int UNUSED keyval, void UNUSED *attr_val, int UNUSED *flag)
+{
+ H5_term_library();
+ return MPI_SUCCESS;
+}
+#endif /*H5_HAVE_PARALLEL*/
+
/*-------------------------------------------------------------------------
* Function: H5get_libversion
diff --git a/testpar/CMakeLists.txt b/testpar/CMakeLists.txt
index 11437c0..d1db0b7 100644
--- a/testpar/CMakeLists.txt
+++ b/testpar/CMakeLists.txt
@@ -46,6 +46,8 @@ set (H5P_TESTS
t_cache
t_pflush1
t_pflush2
+ t_pshutdown
+ t_prestart
t_shapesame
)
diff --git a/testpar/Makefile.am b/testpar/Makefile.am
index 448f745..1eae439 100644
--- a/testpar/Makefile.am
+++ b/testpar/Makefile.am
@@ -25,7 +25,7 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test
# Test programs. These are our main targets.
#
-TEST_PROG_PARA=t_mpi testphdf5 t_cache t_pflush1 t_pflush2 t_shapesame
+TEST_PROG_PARA=t_mpi testphdf5 t_cache t_pflush1 t_pflush2 t_pshutdown t_prestart t_shapesame
check_PROGRAMS = $(TEST_PROG_PARA)
@@ -39,7 +39,8 @@ LDADD = $(LIBH5TEST) $(LIBHDF5)
# Temporary files
# MPItest.h5 is from t_mpi
# Para*.h5 are from testphdf
+# shutdown.h5 is from t_pshutdown
# go is used for debugging. See testphdf5.c.
-CHECK_CLEANFILES+=MPItest.h5 Para*.h5 CacheTestDummy.h5 go
+CHECK_CLEANFILES+=MPItest.h5 Para*.h5 CacheTestDummy.h5 shutdown.h5 go
include $(top_srcdir)/config/conclude.am
diff --git a/testpar/Makefile.in b/testpar/Makefile.in
index 8857d47..959731e 100644
--- a/testpar/Makefile.in
+++ b/testpar/Makefile.in
@@ -112,7 +112,8 @@ CONFIG_HEADER = $(top_builddir)/src/H5config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__EXEEXT_1 = t_mpi$(EXEEXT) testphdf5$(EXEEXT) t_cache$(EXEEXT) \
- t_pflush1$(EXEEXT) t_pflush2$(EXEEXT) t_shapesame$(EXEEXT)
+ t_pflush1$(EXEEXT) t_pflush2$(EXEEXT) t_pshutdown$(EXEEXT) \
+ t_prestart$(EXEEXT) t_shapesame$(EXEEXT)
t_cache_SOURCES = t_cache.c
t_cache_OBJECTS = t_cache.$(OBJEXT)
t_cache_LDADD = $(LDADD)
@@ -133,6 +134,14 @@ t_pflush2_SOURCES = t_pflush2.c
t_pflush2_OBJECTS = t_pflush2.$(OBJEXT)
t_pflush2_LDADD = $(LDADD)
t_pflush2_DEPENDENCIES = $(LIBH5TEST) $(LIBHDF5)
+t_prestart_SOURCES = t_prestart.c
+t_prestart_OBJECTS = t_prestart.$(OBJEXT)
+t_prestart_LDADD = $(LDADD)
+t_prestart_DEPENDENCIES = $(LIBH5TEST) $(LIBHDF5)
+t_pshutdown_SOURCES = t_pshutdown.c
+t_pshutdown_OBJECTS = t_pshutdown.$(OBJEXT)
+t_pshutdown_LDADD = $(LDADD)
+t_pshutdown_DEPENDENCIES = $(LIBH5TEST) $(LIBHDF5)
t_shapesame_SOURCES = t_shapesame.c
t_shapesame_OBJECTS = t_shapesame.$(OBJEXT)
t_shapesame_LDADD = $(LDADD)
@@ -179,10 +188,10 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = t_cache.c t_mpi.c t_pflush1.c t_pflush2.c t_shapesame.c \
- $(testphdf5_SOURCES)
-DIST_SOURCES = t_cache.c t_mpi.c t_pflush1.c t_pflush2.c t_shapesame.c \
- $(testphdf5_SOURCES)
+SOURCES = t_cache.c t_mpi.c t_pflush1.c t_pflush2.c t_prestart.c \
+ t_pshutdown.c t_shapesame.c $(testphdf5_SOURCES)
+DIST_SOURCES = t_cache.c t_mpi.c t_pflush1.c t_pflush2.c t_prestart.c \
+ t_pshutdown.c t_shapesame.c $(testphdf5_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -687,13 +696,14 @@ TRACE = perl $(top_srcdir)/bin/trace
# Temporary files
# MPItest.h5 is from t_mpi
# Para*.h5 are from testphdf
+# shutdown.h5 is from t_pshutdown
# go is used for debugging. See testphdf5.c.
CHECK_CLEANFILES = *.chkexe *.chklog *.clog MPItest.h5 Para*.h5 \
- CacheTestDummy.h5 go
+ CacheTestDummy.h5 shutdown.h5 go
# Test programs. These are our main targets.
#
-TEST_PROG_PARA = t_mpi testphdf5 t_cache t_pflush1 t_pflush2 t_shapesame
+TEST_PROG_PARA = t_mpi testphdf5 t_cache t_pflush1 t_pflush2 t_pshutdown t_prestart t_shapesame
testphdf5_SOURCES = testphdf5.c t_dset.c t_file.c t_file_image.c t_mdset.c \
t_ph5basic.c t_coll_chunk.c t_span_tree.c t_chunk_alloc.c t_filter_read.c \
t_prop.c
@@ -782,6 +792,14 @@ t_pflush2$(EXEEXT): $(t_pflush2_OBJECTS) $(t_pflush2_DEPENDENCIES) $(EXTRA_t_pfl
@rm -f t_pflush2$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(t_pflush2_OBJECTS) $(t_pflush2_LDADD) $(LIBS)
+t_prestart$(EXEEXT): $(t_prestart_OBJECTS) $(t_prestart_DEPENDENCIES) $(EXTRA_t_prestart_DEPENDENCIES)
+ @rm -f t_prestart$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(t_prestart_OBJECTS) $(t_prestart_LDADD) $(LIBS)
+
+t_pshutdown$(EXEEXT): $(t_pshutdown_OBJECTS) $(t_pshutdown_DEPENDENCIES) $(EXTRA_t_pshutdown_DEPENDENCIES)
+ @rm -f t_pshutdown$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(t_pshutdown_OBJECTS) $(t_pshutdown_LDADD) $(LIBS)
+
t_shapesame$(EXEEXT): $(t_shapesame_OBJECTS) $(t_shapesame_DEPENDENCIES) $(EXTRA_t_shapesame_DEPENDENCIES)
@rm -f t_shapesame$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(t_shapesame_OBJECTS) $(t_shapesame_LDADD) $(LIBS)
@@ -808,7 +826,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_pflush1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_pflush2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_ph5basic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_prestart.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_prop.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_pshutdown.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_shapesame.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_span_tree.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testphdf5.Po@am__quote@
diff --git a/testpar/t_pflush1.c b/testpar/t_pflush1.c
index ebe5c38..1bcfeb8 100644
--- a/testpar/t_pflush1.c
+++ b/testpar/t_pflush1.c
@@ -164,12 +164,9 @@ main(int argc, char* argv[])
} /* end else */
/*
- * Some systems like Linux with mpich, if you just _exit without MPI_Finalize
- * called, it would terminate but left the launching process waiting forever.
- * OTHO, some systems like AIX do not like files not closed when MPI_Finalize
- * is called. So, we need to get the MPI file handles, close them by hand,
- * then MPI_Finalize. Then the _exit is still needed to stop at_exit from
- * happening in some systems.
+ * Some systems like AIX do not like files not closed when MPI_Finalize
+ * is called. So, we need to get the MPI file handles, close them by hand.
+ * Then the _exit is still needed to stop at_exit from happening in some systems.
* Note that MPIO VFD returns the address of the file-handle in the VFD struct
* because MPI_File_close wants to modify the file-handle variable.
*/
@@ -195,13 +192,11 @@ main(int argc, char* argv[])
fflush(stdout);
fflush(stderr);
- MPI_Finalize();
HD_exit(0);
error:
fflush(stdout);
fflush(stderr);
- MPI_Finalize();
HD_exit(1);
}
diff --git a/testpar/t_pflush2.c b/testpar/t_pflush2.c
index e450f75..03f7c82 100644
--- a/testpar/t_pflush2.c
+++ b/testpar/t_pflush2.c
@@ -209,9 +209,6 @@ main(int argc, char* argv[])
puts(" Test not compatible with current Virtual File Driver");
}
- /* close HDF5 library */
- H5close();
-
MPI_Finalize();
return 0;
diff --git a/testpar/t_prestart.c b/testpar/t_prestart.c
new file mode 100644
index 0000000..fab4a7c
--- /dev/null
+++ b/testpar/t_prestart.c
@@ -0,0 +1,138 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Mohamad Chaarawi
+ * February 2015
+ *
+ * Purpose: This test opens a file created by the t_pshutdown program
+ * and makes sure the objects created are there.
+ */
+
+#include "testphdf5.h"
+
+int nerrors = 0; /* errors count */
+
+const char *FILENAME[] = {
+ "shutdown",
+ NULL
+};
+
+int
+main (int argc, char **argv)
+{
+ hid_t file_id, dset_id, grp_id;
+ hid_t fapl, sid, mem_dataspace;
+ herr_t ret;
+ char filename[1024];
+ int mpi_size, mpi_rank, ndims, i, j;
+ MPI_Comm comm = MPI_COMM_WORLD;
+ MPI_Info info = MPI_INFO_NULL;
+ hsize_t dims[RANK];
+ hsize_t start[RANK];
+ hsize_t count[RANK];
+ hsize_t stride[RANK];
+ hsize_t block[RANK];
+ DATATYPE *data_array = NULL, *dataptr; /* data buffer */
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(comm, &mpi_size);
+ MPI_Comm_rank(comm, &mpi_rank);
+
+ if(MAINPROCESS)
+ TESTING("proper shutdown of HDF5 library");
+
+ /* Set up file access property list with parallel I/O access */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ VRFY((fapl >= 0), "H5Pcreate succeeded");
+ ret = H5Pset_fapl_mpio(fapl, comm, info);
+ VRFY((ret >= 0), "");
+
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl);
+ VRFY((file_id >= 0), "H5Fopen succeeded");
+
+ grp_id = H5Gopen2(file_id, "Group", H5P_DEFAULT);
+ VRFY((grp_id >= 0), "H5Gopen succeeded");
+
+ dset_id = H5Dopen2(grp_id, "Dataset", H5P_DEFAULT);
+ VRFY((dset_id >= 0), "H5Dopen succeeded");
+
+ sid = H5Dget_space(dset_id);
+ VRFY((dset_id >= 0), "H5Dget_space succeeded");
+
+ ndims = H5Sget_simple_extent_dims(sid, dims, NULL);
+ VRFY((ndims == 2), "H5Sget_simple_extent_dims succeeded");
+ VRFY(dims[0] == ROW_FACTOR*mpi_size, "Wrong dataset dimensions");
+ VRFY(dims[1] == COL_FACTOR*mpi_size, "Wrong dataset dimensions");
+
+ /* allocate memory for data buffer */
+ data_array = (DATATYPE *)HDmalloc(dims[0]*dims[1]*sizeof(DATATYPE));
+ VRFY((data_array != NULL), "data_array HDmalloc succeeded");
+
+ /* Each process takes a slabs of rows. */
+ block[0] = dims[0]/mpi_size;
+ block[1] = dims[1];
+ stride[0] = block[0];
+ stride[1] = block[1];
+ count[0] = 1;
+ count[1] = 1;
+ start[0] = mpi_rank*block[0];
+ start[1] = 0;
+
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block);
+ VRFY((ret >= 0), "H5Sset_hyperslab succeeded");
+
+ /* create a memory dataspace independently */
+ mem_dataspace = H5Screate_simple (RANK, block, NULL);
+ VRFY((mem_dataspace >= 0), "");
+
+ /* write data independently */
+ ret = H5Dread(dset_id, H5T_NATIVE_INT, mem_dataspace, sid,
+ H5P_DEFAULT, data_array);
+ VRFY((ret >= 0), "H5Dwrite succeeded");
+
+ dataptr = data_array;
+
+ for (i=0; i < block[0]; i++){
+ for (j=0; j < block[1]; j++){
+ if(*dataptr != mpi_rank+1) {
+ printf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %d, got %d\n",
+ (unsigned long)i, (unsigned long)j,
+ (unsigned long)(i+start[0]), (unsigned long)(j+start[1]),
+ mpi_rank+1, *(dataptr));
+ nerrors ++;
+ }
+ dataptr++;
+ }
+ }
+ MPI_Finalize();
+ HDremove(filename);
+
+ /* release data buffers */
+ if(data_array)
+ HDfree(data_array);
+
+ nerrors += GetTestNumErrs();
+
+ if(MAINPROCESS) {
+ if(0 == nerrors)
+ PASSED()
+ else
+ H5_FAILED()
+ }
+
+ return (nerrors!=0);
+}
diff --git a/testpar/t_pshutdown.c b/testpar/t_pshutdown.c
new file mode 100644
index 0000000..be9734f
--- /dev/null
+++ b/testpar/t_pshutdown.c
@@ -0,0 +1,127 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Mohamad Chaarawi
+ * February 2015
+ *
+ * Purpose: This test creates a file and a bunch of objects in the
+ * file and then calls MPI_Finalize without closing anything. The
+ * library should exercise the attribute callback destroy attached to
+ * MPI_COMM_SELF and terminate the HDF5 library closing all open
+ * objects. The t_prestart test will read back the file and make sure
+ * all created objects are there.
+ */
+
+#include "testphdf5.h"
+
+int nerrors = 0; /* errors count */
+
+const char *FILENAME[] = {
+ "shutdown",
+ NULL
+};
+
+int
+main (int argc, char **argv)
+{
+ hid_t file_id, dset_id, grp_id;
+ hid_t fapl, sid, mem_dataspace;
+ hsize_t dims[RANK], i;
+ herr_t ret;
+ char filename[1024];
+ int mpi_size, mpi_rank;
+ MPI_Comm comm = MPI_COMM_WORLD;
+ MPI_Info info = MPI_INFO_NULL;
+ hsize_t start[RANK];
+ hsize_t count[RANK];
+ hsize_t stride[RANK];
+ hsize_t block[RANK];
+ DATATYPE *data_array = NULL; /* data buffer */
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(comm, &mpi_size);
+ MPI_Comm_rank(comm, &mpi_rank);
+
+ if(MAINPROCESS)
+ TESTING("proper shutdown of HDF5 library");
+
+ /* Set up file access property list with parallel I/O access */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ VRFY((fapl >= 0), "H5Pcreate succeeded");
+ ret = H5Pset_fapl_mpio(fapl, comm, info);
+ VRFY((ret >= 0), "");
+
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ VRFY((file_id >= 0), "H5Fcreate succeeded");
+ grp_id = H5Gcreate2(file_id, "Group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ VRFY((grp_id >= 0), "H5Gcreate succeeded");
+
+ dims[0] = ROW_FACTOR*mpi_size;
+ dims[1] = COL_FACTOR*mpi_size;
+ sid = H5Screate_simple (RANK, dims, NULL);
+ VRFY((sid >= 0), "H5Screate_simple succeeded");
+
+ dset_id = H5Dcreate2(grp_id, "Dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ VRFY((dset_id >= 0), "H5Dcreate succeeded");
+
+ /* allocate memory for data buffer */
+ data_array = (DATATYPE *)HDmalloc(dims[0]*dims[1]*sizeof(DATATYPE));
+ VRFY((data_array != NULL), "data_array HDmalloc succeeded");
+
+ /* Each process takes a slabs of rows. */
+ block[0] = dims[0]/mpi_size;
+ block[1] = dims[1];
+ stride[0] = block[0];
+ stride[1] = block[1];
+ count[0] = 1;
+ count[1] = 1;
+ start[0] = mpi_rank*block[0];
+ start[1] = 0;
+
+ /* put some trivial data in the data_array */
+ for(i=0 ; i<dims[0]*dims[1]; i++)
+ data_array[i] = mpi_rank + 1;
+
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block);
+ VRFY((ret >= 0), "H5Sset_hyperslab succeeded");
+
+ /* create a memory dataspace independently */
+ mem_dataspace = H5Screate_simple (RANK, block, NULL);
+ VRFY((mem_dataspace >= 0), "");
+
+ /* write data independently */
+ ret = H5Dwrite(dset_id, H5T_NATIVE_INT, mem_dataspace, sid,
+ H5P_DEFAULT, data_array);
+ VRFY((ret >= 0), "H5Dwrite succeeded");
+
+ /* release data buffers */
+ if(data_array)
+ HDfree(data_array);
+
+ MPI_Finalize();
+
+ nerrors += GetTestNumErrs();
+
+ if(MAINPROCESS) {
+ if(0 == nerrors)
+ PASSED()
+ else
+ H5_FAILED()
+ }
+
+ return (nerrors!=0);
+}
diff --git a/testpar/t_shapesame.c b/testpar/t_shapesame.c
index d167687..9088470 100644
--- a/testpar/t_shapesame.c
+++ b/testpar/t_shapesame.c
@@ -5142,10 +5142,7 @@ int main(int argc, char **argv)
printf("Shape Same tests finished with no errors\n");
printf("===================================\n");
}
- /* close HDF5 library */
- H5close();
- /* MPI_Finalize must be called AFTER H5close which may use MPI calls */
MPI_Finalize();
/* cannot just return (nerrors) because exit code is limited to 1byte */
diff --git a/tools/perform/perf.c b/tools/perform/perf.c
index 58db6cc..1bd33b6 100644
--- a/tools/perform/perf.c
+++ b/tools/perform/perf.c
@@ -391,9 +391,6 @@ die_jar_jar_die:
free(tmp);
if (opt_correct) free(tmp2);
- /* close HDF5 library */
- H5close();
-
MPI_Finalize();
return(0);