/****************************************************************************** C-DAC Tech Workshop : hyPACK-2013 October 15-18, 2013 Example 2.2 : mpicpp-scatter.C Objective : To Scatter an integer array of size "n by 1" using MPI Collective communication library call (MPI_Scatter) Input : Input Data file "sdata.inp". Output : Print the scattered array on all processes. Necessary Condition : Number of processes should be less than or equal to 8. Created : August-2013 E-mail : hpcfte@cdac.in **************************************************************************/ #include #include #include #include #include"mpi.h" using namespace std; int main(int argc,char *argv[]) { int root = 0,myrank,numprocs,source,destination,index; int dest_tag,source_tag; int sum = 0,value = 0; int dsize,scat_size; int *input_buffer,*recev_buffer; MPI::Status status; /*......MPI intializing .....*/ MPI::Init(argc,argv); numprocs=MPI::COMM_WORLD.Get_size(); myrank=MPI::COMM_WORLD.Get_rank(); /* checking that data can be distributed uniformly...*/ if(dsize % numprocs != 0) { if(myrank == 0) cout<<"\nInput Cannot be Distributed Evenly....."< "<<" "<