mpi-receive-example.c 387 B

123456789101112131415161718
  1. #include "mpi.h"
  2. int msglen, again=1;
  3. void *buf;
  4. MPI_Datatype datatype
  5. MPI_Comm comm;
  6. MPI_Status status;
  7. ...
  8. while (again) {
  9. MPI_Probe(ROOT, MPI_ANY_TAG, comm, &status);
  10. MPI_Get_count(&status, datatype, &msglen);
  11. buf=malloc(msglen*sizeof(int));
  12. MPI_Recv(buf, msglen, datatype, status.MPI_SOURCE,
  13. status.MPI_TAG, comm, &status);
  14. ...
  15. }
  16. ...