NAME
MMPPIIGGeetteelleemmeennttss - Returns the number of basic elements in a data
type. SSYYNNTTAAXX CC SSyynnttaaxx#include
int MPIGetelements(MPIStatus *status, MPIDatatype datatype, int *count) FFoorrttrraann SSyynnttaaxx INCLUDE 'mpif.h'MPIGETELEMENTS(STATUS, DATATYPE, COUNT, IERROR)
INTEGER STATUS(MPISTATUSSIZE), DATATYPE, COUNT, IERROR
CC++++ SSyynnttaaxx#include
int Status::Getelements(const Datatype& datatype) const IINNPPUUTT PPAARRAAMMEETTEERRSS status Return status of receive operation (status). datatype Datatype used by receive operation (handle). OOUUTTPPUUTT PPAARRAAMMEETTEERRSS count Number of received basic elements (integer).IERROR Fortran only: Error status (integer).
DESCRIPTION
MPIGetelements behaves different from MPIGetcount, which returnsthe number of "top-level entries" received, i.e., the number of
"copies" of type datatype. MPIGetcount may return any integer value k, where 0 =< k =< count. If MPIGetcount returns k, then the numberof basic elements received (and the value returned by MPIGetele-
ments) is n * k, where n is the number of basic elements in the typemap of datatype. If the number of basic elements received is not a mul-
tiple of n, that is, if the receive operation has not received an inte-
gral number of datatype "copies," then MPIGetcount returns the value MPIUNDEFINED. EExxaammppllee:: Usage of MPIGetcount and MPIGetelement: ... CALL MPITYPECONTIGUOUS(2, MPIREAL, Type2, ierr) CALL MPITYPECOMMIT(Type2, ierr) ... CALL MPICOMMRANK(comm, rank, ierr) IF(rank.EQ.0) THEN CALL MPISEND(a, 2, MPIREAL, 1, 0, comm, ierr) CALL MPISEND(a, 3, MPIREAL, 1, 0, comm, ierr) ELSE CALL MPIRECV(a, 2, Type2, 0, 0, comm, stat, ierr) CALL MPIGETCOUNT(stat, Type2, i, ierr) ! returns i=1 CALL MPIGETELEMENTS(stat, Type2, i, ierr) ! returns i=2 CALL MPIRECV(a, 2, Type2, 0, 0, comm, stat, ierr) CALL MPIGETCOUNT(stat, Type2, i, ierr) ! returns i=MPIUNDEFINED CALL MPIGETELEMENTS(stat, Type2, i, ierr) ! returns i=3 END IF The function MPIGetelements can also be used after a probe to findthe number of elements in the probed message. Note that the two func-
tions MPIGetcount and MPIGetelements return the same values when they are used with primitive data types. EERRRROORRSS Almost all MPI routines return an error value; C routines as the valueof the function and Fortran routines in the last argument. C++ func-
tions do not return errors. If the default error handler is set toMPI::ERRORSTHROWEXCEPTIONS, then on error the C++ exception mechanism
will be used to throw an MPI:Exception object. Before the error value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job, except for I/O function errors. The error handler may be changed withMPICommseterrhandler; the predefined error handler MPIERRORSRETURN
may be used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error.SEE ALSO
MPIGetcount Open MPI 1.2 September 2006 MPIGetelements(3OpenMPI)