From 6735f59f7d65a3d2d1821c5217fb3f9612cfed49 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Tue, 28 Oct 2014 11:59:36 -0500 Subject: [svn-r25750] use MPI_File_get_size() instead of stat when retrieving the file size for the MPIO driver. --- test/h5test.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test/h5test.c b/test/h5test.c index 61a9ae0..693760c 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -908,7 +908,7 @@ h5_get_file_size(const char *filename, hid_t fapl) { char temp[2048]; /* Temporary buffer for file names */ h5_stat_t sb; /* Structure for querying file info */ - int j = 0; + int j = 0; if(fapl == H5P_DEFAULT) { /* Get the file's statistics */ @@ -924,9 +924,6 @@ h5_get_file_size(const char *filename, hid_t fapl) /* Check for simple cases */ if(driver == H5FD_SEC2 || driver == H5FD_STDIO || driver == H5FD_CORE || -#ifdef H5_HAVE_PARALLEL - driver == H5FD_MPIO || -#endif /* H5_HAVE_PARALLEL */ #ifdef H5_HAVE_WINDOWS driver == H5FD_WINDOWS || #endif /* H5_HAVE_WINDOWS */ @@ -961,6 +958,22 @@ h5_get_file_size(const char *filename, hid_t fapl) /* Return total size */ return(tot_size); } /* end if */ +#ifdef H5_HAVE_PARALLEL + else if(driver == H5FD_MPIO) { + MPI_File fh; /* MPI file handle used to open the file and verify its size */ + int mpi_ret; + MPI_Offset file_size; + + mpi_ret = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh); + if (mpi_ret != MPI_SUCCESS) return -1; + mpi_ret = MPI_File_get_size(fh, &file_size); + if (mpi_ret != MPI_SUCCESS) return -1; + mpi_ret = MPI_File_close(&fh); + if (mpi_ret != MPI_SUCCESS) return -1; + + return file_size; + } +#endif /* H5_HAVE_PARALLEL */ else if(driver == H5FD_FAMILY) { h5_stat_size_t tot_size = 0; -- cgit v0.12