/*
** A broadcast example
** Copyright Rolf Riesen 2008
**
*/
#include <stdio.h>
#include <mpi.h>



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

int my_rank, nproc;
int my_value;
int root;
int count;



    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &nproc);
    MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);

    /* Send a value from node 0 to all others */
    root= 0;
    count= 1;
    if (my_rank == root)   {
	my_value= 12;
    } else   {
	/* Initialize my_value at the receivers. */
	my_value= 0;
    }

    MPI_Bcast(&my_value, count, MPI_INT, root, MPI_COMM_WORLD);

    printf("Node %3d: My value is %d\n", my_rank, my_value);

    MPI_Finalize();
    return 0;

}  /* end of main() */
