#include #include #include "mpi.h" int main ( int argc, char *argv[] ) { int ierr; int master = 0; int my_id; int num_procs; /* Initialize MPI. */ ierr = MPI_Init ( &argc, &argv ); /* Get the number of processes. */ ierr = MPI_Comm_size ( MPI_COMM_WORLD, &num_procs ); /* Get the individual process ID. */ ierr = MPI_Comm_rank ( MPI_COMM_WORLD, &my_id ); /* Print a message. */ if ( my_id == master ) { printf ( "\n" ); printf ( "HELLO_WORLD - Master process:\n" ); printf ( " A simple C program using MPI.\n" ); printf ( "\n" ); printf ( " The number of processes is %d\n", num_procs ); } printf ( "\n" ); printf ( " Process %d says 'Hello, world!'\n", my_id ); /* Shut down MPI. */ ierr = MPI_Finalize ( ); return 0; }