Assignment
Create a file named hello.c that contains the program shown below. Run the program using the steps given above.
hello.c
#include <stdio.h>
#include "mpi.h"
int main( int argc, char** argv )
{
  int rank, size;
  char name[80]; // character array to hold the name of each processor
  int len; // length of the name of the processor
  MPI_Init( &argc, &argv );
  MPI_Comm_size( MPI_COMM_WORLD, &size );
  MPI_Comm_rank( MPI_COMM_WORLD, &rank );
  MPI_Get_processor_name(name, &len);
  printf( "Hello from process %d of %d. Name=%s\n", rank, size, name );
  MPI_Finalize();
  return 0;
}
Sample Output
cc -o lab00 lab00.c
mpirun -np 5 lab00
Hello from process 1 of 5. Name=sn3313
Hello from process 2 of 5. Name=sn3313
Hello from process 4 of 5. Name=sn3313
Hello from process 3 of 5. Name=sn3313
Hello from process 0 of 5. Name=sn3313
mpirun -np 16 lab00
Hello from process 0 of 16. Name=sn3313
Hello from process 2 of 16. Name=sn3313
Hello from process 3 of 16. Name=sn3313
Hello from process 4 of 16. Name=sn3313
Hello from process 5 of 16. Name=sn3313
Hello from process 6 of 16. Name=sn3313
Hello from process 7 of 16. Name=sn3313
Hello from process 8 of 16. Name=sn3313
Hello from process 9 of 16. Name=sn3313
Hello from process 10 of 16. Name=sn3313
Hello from process 14 of 16. Name=sn3313
Hello from process 1 of 16. Name=sn3313
Hello from process 11 of 16. Name=sn3313
Hello from process 13 of 16. Name=sn3313
Hello from process 12 of 16. Name=sn3313