Skip to content

Commit 1868d8c

Browse files
committed
Fixed small error: variable root not initialized, now removed
1 parent c082338 commit 1868d8c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mpi/broadcast.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33

44
int main(int argc, char *argv[]) {
55
char message[60];
6-
int rank, size, root;
6+
int rank, size;
77
MPI_Status status;
88

99
MPI_Init(&argc, &argv);
1010
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
1111
MPI_Comm_size(MPI_COMM_WORLD, &size);
1212

1313
if (rank == 0) {
14-
sprintf(message, "Message from root (rank %d)", rank);
14+
sprintf(message, "Message from root (rank %d).", rank);
1515
}
1616

17-
MPI_Bcast(message, 60, MPI_CHAR, root, MPI_COMM_WORLD);
17+
MPI_Bcast(message, 60, MPI_CHAR, 0, MPI_COMM_WORLD);
1818
printf("The message sent/received at node %d is \"%s\"\n", rank, message);
1919

2020
MPI_Finalize();

0 commit comments

Comments
 (0)