5 #define TARGET_VALUE 42
7 int main (int argc, char **argv) {
9 int value = INIT_VALUE;
10 MPI_Init(&argc, &argv);
11 MPI_Comm_size(MPI_COMM_WORLD, &size);
12 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
16 fprintf(stderr,"node %d has value %d before broadcast\n", rank, value);
17 MPI_Bcast(&value, 1, MPI_INT, 0, MPI_COMM_WORLD);
18 fprintf(stderr,"node %d has value %d after broadcast\n", rank, value);
19 if (value != TARGET_VALUE) {
20 fprintf(stderr,"node %d don't have the target value after broadcast!!\n", rank);