/*
 * Author:  Matt Massie (massie@cs.berkeley.edu)
 * 
 * Originally Copied from:
 * http://now.CS.Berkeley.EDU/Fastcomm/MPI/howto/hello-world/hello-world.c
 * by Frederick Wong (fredwong@cs.berkeley.edu)
 */
#include <stdio.h>
#include "mpi.h"

int
main(int argc, char **argv) {

  int rank;
  char msg[20];
  
  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  
  if (rank==0) {
    printf("I am the master.  I am sending the message.\n\n");
    strcpy(msg,"Hello World!");
    MPI_Bcast(msg, 13, MPI_CHAR, rank, MPI_COMM_WORLD);
  } else {
    MPI_Bcast(msg, 13, MPI_CHAR, 0, MPI_COMM_WORLD);
    printf("I am the slave.  I am receiving the message.\n");
    printf("The message is: %s\n", msg);
  }

  MPI_Finalize();
}
