/* simple brodcast */
#include <stdio.h>
#include <mpi.h>

main (int argc, char **argv) {

  int myrank, size, count, i;
  MPI_Status status;
  double a[100];

  MPI_Init(&argc, &argv);  /* Initialize MPI */
  MPI_Comm_rank(MPI_COMM_WORLD, &myrank); /* Get rank */
  MPI_Comm_size(MPI_COMM_WORLD, &size);   /* Get the total
					     number of processors */
  printf("Processor %d of %d: Hello World!\n", myrank, size);

  if( myrank == 0 ) {        /* Initialize vector */
    for (i=0;i<100;++i)
      a[i]= (double)i;
  }
  // Broadcast to all other nodes
  MPI_Bcast( a, 100, MPI_DOUBLE, 0, MPI_COMM_WORLD );
  printf("Processor %d of %d: Received data\n", myrank, size);
  for (i=0;i<100;++i)
    printf("%.2f ", a[i]);
  printf("\n");

  MPI_Finalize();          /* Terminate MPI */
}
