diff options
author | Robert Kim Yates <rkyates@llnl.gov> | 1998-02-03 15:29:05 (GMT) |
---|---|---|
committer | Robert Kim Yates <rkyates@llnl.gov> | 1998-02-03 15:29:05 (GMT) |
commit | 6cbd6722513cede31afd1826cb842b947ae8b996 (patch) | |
tree | 020426f7513d16da373bf4d785a4afc1dd0f4927 /src/H5Fmpio.c | |
parent | a6f59faa9deea96ed2a8500ea53f5ef0f0a565ce (diff) | |
download | hdf5-6cbd6722513cede31afd1826cb842b947ae8b996.zip hdf5-6cbd6722513cede31afd1826cb842b947ae8b996.tar.gz hdf5-6cbd6722513cede31afd1826cb842b947ae8b996.tar.bz2 |
[svn-r212] Fixed H5F_mpio_read's handling of number of bytes read,
and removed MPI_Init and MPI_Finalize from H5.c
(these should be done in the user program).
Diffstat (limited to 'src/H5Fmpio.c')
-rw-r--r-- | src/H5Fmpio.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/src/H5Fmpio.c b/src/H5Fmpio.c index b82e709..1ba2619 100644 --- a/src/H5Fmpio.c +++ b/src/H5Fmpio.c @@ -32,6 +32,11 @@ * * H5F_mpio_read * - always does independent read (not collective) + * - One implementation of MPI/MPI-IO causes MPI_Get_count + * to return (incorrectly) a negative count. + * I added code to detect this, and a kludge to pretend + * that the number of bytes read is always equal to the number + * requested. This kluge is activated by #ifdef MPI_KLUGE0202. * * H5F_MPIOff_to_haddr and H5F_haddr_to_MPIOff * - For now, we assume that MPI_Offset and haddr_t @@ -345,12 +350,12 @@ H5F_mpio_close(H5F_low_t *lf) static herr_t H5F_mpio_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf) { - MPI_Offset mpi_off, bytes_read; + MPI_Offset mpi_off; + int size_i, bytes_read, n; MPI_Status mpi_stat; int mpierr; char mpierrmsg[MPI_MAX_ERROR_STRING]; int msglen; - size_t n, br; FUNC_ENTER(H5F_mpio_read, FAIL); #ifdef DEBUG_MPIO @@ -363,10 +368,9 @@ H5F_mpio_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf) /* Read the data. */ mpi_off = H5F_haddr_to_MPIOff( *addr ); - fprintf(stdout, "In H5F_mpio_read, before calling MPI_File_read_at\n" ); + size_i = (int)size; mpierr = MPI_File_read_at( lf->u.mpio.f, mpi_off, (void*) buf, - (int) size, MPI_BYTE, &mpi_stat ); - fprintf(stdout, "In H5F_mpio_read, after calling MPI_File_read_at\n" ); + size_i, MPI_BYTE, &mpi_stat ); if (mpierr != MPI_SUCCESS) { MPI_Error_string( mpierr, mpierrmsg, &msglen ); HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, mpierrmsg ); @@ -374,15 +378,36 @@ H5F_mpio_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf) /* How many bytes were actually read? */ mpierr = MPI_Get_count( &mpi_stat, MPI_BYTE, &bytes_read ); +#ifdef DEBUG_MPIO + fprintf(stdout, + "In H5F_mpio_read after Get_count size_i=%d bytes_read=%d\n", + size_i, bytes_read ); +#endif if (mpierr != MPI_SUCCESS) { MPI_Error_string( mpierr, mpierrmsg, &msglen ); HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, mpierrmsg ); } +#ifdef MPI_KLUGE0202 + /* KLUGE rky 980202 MPI_Get_count incorrectly returns negative count; + fake a complete read */ + bytes_read = size_i; /* KLUGE rky 980202 */ +#endif + + if ((bytes_read<0) || (bytes_read > size_i)) { + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + "MPI_Get_count returned invalid count" ); + } + /* read zeroes past the end of the file */ - br = (size_t)bytes_read; - if ((n=(size-br)) > 0) - HDmemset( buf+br, 0, n); + if ((n=(size_i-bytes_read)) > 0) { +#ifdef DEBUG_MPIO + fprintf(stdout, + "In H5F_mpio_read before HDmemset size_i=%d bytes_read=%d n=%d\n", + size_i, bytes_read, n ); +#endif + HDmemset( buf+bytes_read, 0, (size_t)n ); + } #ifdef DEBUG_MPIO fprintf(stdout, "Leaving H5F_mpio_read\n" ); |