diff --git a/src/h5core/h5_mpi.c b/src/h5core/h5_mpi.c index 9ff6bce..d1d5dcc 100644 --- a/src/h5core/h5_mpi.c +++ b/src/h5core/h5_mpi.c @@ -2,13 +2,18 @@ #include "h5_core_private.h" #ifdef PARALLEL_IO + +const char* ERR_GATHER = "Cannot gather data."; +const char* ERR_COMM_SIZE = "Cannot get number of processes in my group."; +const char* ERR_COMM_RANK = "Cannot get rank of the calling process."; + h5_err_t h5priv_mpi_allgather ( - h5_file_t * const f, - void * sendbuf, + h5_file_t* const f, + void* sendbuf, const int sendcount, const MPI_Datatype sendtype, - void * recvbuf, + void* recvbuf, const int recvcount, const MPI_Datatype recvtype, const MPI_Comm comm @@ -20,45 +25,34 @@ h5priv_mpi_allgather ( recvbuf, recvcount, recvtype, - comm ); - if ( err != MPI_SUCCESS ) - return h5_error ( - f, - H5_ERR_MPI, - "Cannot gather data." ); + comm); + if (err != MPI_SUCCESS) + return h5_error (f, H5_ERR_MPI, ERR_GATHER); return H5_SUCCESS; } h5_err_t h5priv_mpi_comm_size ( - h5_file_t * const f, + h5_file_t* const f, MPI_Comm comm, - int *size + int* size ) { - int err = MPI_Comm_size ( comm, size ); - if ( err != MPI_SUCCESS ) - h5_error ( - f, - H5_ERR_MPI, - "Cannot get number of processes in my group." ); - + int err = MPI_Comm_size (comm, size); + if (err != MPI_SUCCESS) + return h5_error (f, H5_ERR_MPI, ERR_COMM_SIZE); return H5_SUCCESS; } h5_err_t h5priv_mpi_comm_rank ( - h5_file_t * const f, + h5_file_t* const f, MPI_Comm comm, - int *rank + int* rank ) { - int err = MPI_Comm_rank ( comm, rank ); - if ( err != MPI_SUCCESS ) - h5_error ( - f, - H5_ERR_MPI, - "Cannot get rank of the calling process in my group." ); - + int err = MPI_Comm_rank (comm, rank); + if (err != MPI_SUCCESS) + return h5_error (f, H5_ERR_MPI, ERR_COMM_RANK); return H5_SUCCESS; } #endif