Basic HTML version of Foils prepared 19 September 98

Foil 39 HelloWorld, continued

From MPI Message Passing Interface Computational Science for Simulations -- Fall Semester 1998. by Geoffrey C. Fox, Nancy McCracken


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();
}



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Apr 11 1999