MPI_Datatype Sendtype; int npart, scount, i, rightedge; int Pindex[100], Pblock[100]; scount = 0; for (i=0;i<npart;i++) if (particle[i].x[0] > rightedge){ Pindex[scount] = i; Pblock[scount] = 1; scount++;} ierr = MPI_Type_index (scount, Pblock, Pindex, Ptype, &Sendtype); ierr = MPI_Type_commit (&Sendtype); ierr = MPI_Type_commit (&Ptype);