summaryrefslogtreecommitdiffstats
path: root/testpar/t_pflush1.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2006-10-25 00:09:25 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2006-10-25 00:09:25 (GMT)
commit84bd65e8fcfc28a6a15d062d9a3d36eff674aa9b (patch)
treee0279d1e98441f49f8097031a9c05fb056dd38c2 /testpar/t_pflush1.c
parent2104bb380da40cd8ceae6277a297dd0ed35a618f (diff)
downloadhdf5-84bd65e8fcfc28a6a15d062d9a3d36eff674aa9b.zip
hdf5-84bd65e8fcfc28a6a15d062d9a3d36eff674aa9b.tar.gz
hdf5-84bd65e8fcfc28a6a15d062d9a3d36eff674aa9b.tar.bz2
[svn-r12811] Purpose:
Bug fix. Description: AIX complained if some files are still open when MPI_Finalize is called, so code called _exit without calling MPI_Finalize. But in Linux hosts with MPICH, the MPI processes terminated but the launch processes got stuck waiting for those processes to end properly and they would hang on forever. As more tests ran, more processes got stuck. Solution: In order to please both AIX and MPICH, the MPI file handles are retrieved and closed outside of the HDF5 library, then call MPI_Finalize and then _exit. Tested: in heping and copper.
Diffstat (limited to 'testpar/t_pflush1.c')
-rw-r--r--testpar/t_pflush1.c54
1 files changed, 44 insertions, 10 deletions
diff --git a/testpar/t_pflush1.c b/testpar/t_pflush1.c
index b0bff95..3973a28 100644
--- a/testpar/t_pflush1.c
+++ b/testpar/t_pflush1.c
@@ -123,7 +123,9 @@ error:
int
main(int argc, char* argv[])
{
- hid_t file, fapl;
+ hid_t file1, file2, fapl;
+ MPI_File mpifh=-2;
+ int *mpifh_p = NULL;
char name[1024];
const char *envval = NULL;
int mpi_size, mpi_rank;
@@ -145,13 +147,13 @@ main(int argc, char* argv[])
if (HDstrcmp(envval, "split")) {
/* Create the file */
h5_fixname(FILENAME[0], fapl, name, sizeof name);
- file = create_file(name, fapl);
+ file1 = create_file(name, fapl);
/* Flush and exit without closing the library */
- if (H5Fflush(file, H5F_SCOPE_GLOBAL)<0) goto error;
+ if (H5Fflush(file1, H5F_SCOPE_GLOBAL)<0) goto error;
/* Create the other file which will not be flushed */
h5_fixname(FILENAME[1], fapl, name, sizeof name);
- file = create_file(name, fapl);
+ file2 = create_file(name, fapl);
if(mpi_rank == 0)
@@ -165,12 +167,44 @@ main(int argc, char* argv[])
puts(" Test not compatible with current Virtual File Driver");
}
- /* AIX doesn't like it when you try to call MPI_Finalize without closing all files. */
-/* MPI_Finalize();*/
- HD_exit(0);
+ /*
+ * 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.
+ * 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.
+ */
+
+ /* close file1 */
+ if (H5Fget_vfd_handle(file1, fapl, (void **)&mpifh_p)<0){
+ printf("H5Fget_vfd_handle for file1 failed\n");
+ goto error;
+ }
+ if (MPI_File_close(mpifh_p)!=MPI_SUCCESS){
+ printf("MPI_File_close for file1 failed\n");
+ goto error;
+ }
+ /* close file2 */
+ if (H5Fget_vfd_handle(file2, fapl, (void **)&mpifh_p)<0){
+ printf("H5Fget_vfd_handle for file2 failed\n");
+ goto error;
+ }
+ if (MPI_File_close(mpifh_p)!=MPI_SUCCESS){
+ printf("MPI_File_close for file2 failed\n");
+ goto error;
+ }
- error:
- HD_exit(1);
- return 1;
+ fflush(stdout);
+ fflush(stderr);
+ MPI_Finalize();
+ HD_exit(0);
+error:
+ fflush(stdout);
+ fflush(stderr);
+ MPI_Finalize();
+ HD_exit(1);
}