Blame examples/spawn_merge_child2.c
|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit |
0848f5 |
* See COPYRIGHT in top-level directory.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#include <stdio.h>
|
|
Packit |
0848f5 |
#include "mpi.h"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int main( int argc, char *argv[] )
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
MPI_Comm intercomm;
|
|
Packit |
0848f5 |
char str[10];
|
|
Packit |
0848f5 |
int err, rank;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Init(&argc, &argv);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Comm_get_parent(&intercomm);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (rank == 1){
|
|
Packit |
0848f5 |
err = MPI_Send("hi", 3, MPI_CHAR, 3, 0, intercomm);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
err = MPI_Recv(str, 4, MPI_CHAR, 3, 0, intercomm, MPI_STATUS_IGNORE);
|
|
Packit |
0848f5 |
printf("Child 2 received from parent (first child): %s\n", str);
|
|
Packit |
0848f5 |
fflush(stdout);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Finalize();
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
}
|