/* Example MPI program in C for use with MPE */ /* 2008-01-15*/ # include # include # include # include # define nmax 1000000 void main (int argc, char *argv[]) { float x[nmax], y[nmax], sum; int npart, nrest, index, iproc; int error, rank, size, i; MPI_Status status; error=MPI_Init(&argc, &argv); /* Initialize MPI */ error=MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* Get my rank */ error=MPI_Comm_size(MPI_COMM_WORLD, &size); /* Get the total number of processors */ npart = nmax/size; nrest = nmax - npart*size; if (nrest != 0){ printf(" size = %d should be a factor of nmax = %d\n",size,nmax); MPI_Finalize(); exit(0); } if(rank == 0){ for(i=0; i 1){ for(iproc=1;iproc 1){ for(iproc=1;iproc