1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
#include <stdio.h>
#include "mpi.h"
int main(int argc, char *argv[])
{
MPI_Comm intercomm;
char str[10];
int err, rank;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_get_parent(&intercomm);
if (rank == 3) {
err = MPI_Send("hi", 3, MPI_CHAR, 3, 0, intercomm);
err = MPI_Recv(str, 4, MPI_CHAR, 3, 0, intercomm, MPI_STATUS_IGNORE);
printf("Child received from parent: %s\n", str);
fflush(stdout);
}
MPI_Finalize();
return 0;
}
|