/* this file is from lam-mpi.org website */ #include #include #include int main(int argc, char *argv[]) { int rank, size, myn, i, N; double *vector, *myvec, sum, mysum, total; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); /* the root process reads the vector size and stuff */ if (rank == 0) { printf("Enter the vector length: "); scanf("%d", &N); vector = (double *)malloc(sizeof(double) * N ); for ( i=0,sum=0; i