/* MPI_Scatterv.c */ /* This program is used to demonstrate the use of MPI_Scatterv. */ /* mpicc scatterv MPI_scatterv.c */ /* mpirun -np 4 scatterv */ #include #include void main(int argv,char** argc) { int np,pid,*sbuf,stride; int rbuf[10], i, *lena, *loca; MPI_Init(&argv, &argc); MPI_Comm_size(MPI_COMM_WORLD, &np); MPI_Comm_rank(MPI_COMM_WORLD, &pid); if (np != 4) { printf("Error! # of processors must be equal to 4. \n" ); MPI_Finalize(); exit(0); } if (pid==0) { stride= 10; sbuf = (int *)malloc(np*stride*sizeof(int)); loca = (int *)malloc(np*sizeof(int)); lena = (int *)malloc(np*sizeof(int)); for (i=0; i