This source file includes following definitions.
- main
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <mpi.h>
5
6 int main (int argc, char **argv){
7 char buff[30];
8 MPI_Status st;
9 MPI_Comm comm;
10 int errcodes[1];
11
12 MPI_Init(&argc, &argv);
13 int level = 0;
14 printf("level %d\n", level);
15
16 sprintf(argv[0], "%d", level+1);
17 MPI_Comm_spawn("ch_rec", argv, 1, MPI_INFO_NULL, 0, MPI_COMM_SELF,
18 &comm, errcodes);
19 sprintf(buff,"level %d (pid:%d)", level, getpid());
20 MPI_Send(&buff, sizeof(char)*30, MPI_CHAR, 0, 100, comm);
21
22 MPI_Recv(&buff, sizeof(char)*30, MPI_CHAR, MPI_ANY_SOURCE,
23 MPI_ANY_TAG, comm, &st);
24 printf("Child sent: %s\n", buff);
25
26 MPI_Finalize();
27 return 0;
28 }