Update home authored by van Vliet's avatar van Vliet
...@@ -230,21 +230,19 @@ int main( int argc, char *argv[] ) ...@@ -230,21 +230,19 @@ int main( int argc, char *argv[] )
MPI_Comm_rank (MPI_COMM_WORLD, &myrank); MPI_Comm_rank (MPI_COMM_WORLD, &myrank);
MPI_Get_processor_name (processor_name, &namelen); MPI_Get_processor_name (processor_name, &namelen);
sprintf( greeting, "Hello world, from process %d of %d on %s", sprintf (greeting, "Hello world, from process %d of %d on %s", myrank, numprocs, processor_name);
myrank, numprocs, processor_name );
if ( myrank == 0 ) { if (myrank == 0)
{
printf ("%s\n", greeting); printf ("%s\n", greeting);
for ( i = 1; i < numprocs; i++ ) { for (i = 1; i < numprocs; i++ )
MPI_Recv( greeting, sizeof( greeting ), MPI_CHAR, {
i, 1, MPI_COMM_WORLD, &status ); MPI_Recv (greeting, sizeof (greeting), MPI_CHAR, i, 1, MPI_COMM_WORLD, &status);
printf ("%s\n", greeting); printf ("%s\n", greeting);
} }
} }
else { else
MPI_Send( greeting, strlen( greeting ) + 1, MPI_CHAR, MPI_Send (greeting, strlen (greeting) + 1, MPI_CHAR, 0, 1, MPI_COMM_WORLD);
0, 1, MPI_COMM_WORLD );
}
MPI_Finalize (); MPI_Finalize ();
return 0; return 0;
... ...
......