HelloWorld, continued
- if( rank == 0 ) { # We are on "root" -- Process 0
- strcpy(message,"Hello MPI World"); # Generate message
- for(i=1; i<size; i++) # Send message to the size-1 other processes
- MPI_Send(message, strlen(message)+1, MPI_CHAR, i, tag, MPI_COMM_WORLD); }
- else { # Any processor except root -- Process 0
- MPI_Recv(message,20, MPI_CHAR, 0, tag, MPI_COMM_WORLD, &status); }
- printf("This is a message from node %d saying %s\n", rank, message);
- MPI_Finalize();