#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#include <math.h>
#ifdef _CIVL
#include <civlc.cvh>
#endif
 
/************************************************************
This is a simple broadcast program in MPI
************************************************************/

int main(argc,argv)
int argc;
char *argv[];
{
    int i,myid, numprocs;
    int source,count;
    int buffer[4];
    MPI_Status status;
    MPI_Request request;
 
    MPI_Init(&argc,&argv);
    MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
    MPI_Comm_rank(MPI_COMM_WORLD,&myid);
    source=0;
    count=4;
    if(myid == source){
      for(i=0;i<count;i++)
        buffer[i]=i;
    }
    MPI_Bcast(buffer,count,MPI_INT,source,MPI_COMM_WORLD);
    for(i=0;i<count;i++)
      printf("%d ",buffer[i]);
    printf("\n");
#ifdef _CIVL
    $assert($forall(int k: 0 .. count-1) buffer[k]==k);
#endif
    MPI_Finalize();
}
