// array2MPI.c // Run this with multiple processors. Processor 0 creates an array of 'count' // numbers 1 to 'count. In this example 'count' is 100. // Processor n (n is not the root process) receives a portion of this array // from processor 0. #include #include "mpi.h" const int MAXNUMS = 100; int main(int argc, char **argv) { int rank, size; MPI_Status status; int data[MAXNUMS]; int i, count, local_start, local_finish; int sum=0, total; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); count = MAXNUMS; if (rank == 0) { srand(7); for (i=0;i