Question: Code Below: // #include #include #include using std::cout; using std::ios; using std::cerr; #include using std::ifstream; #define MAXSIZE 1000 // using namespace std; // int main(int

Code Below:

// #include  #include  #include  using std::cout; using std::ios; using std::cerr; #include  using std::ifstream; #define MAXSIZE 1000 // using namespace std; // int main(int argc, char **argv) { int myid, numprocs, greatest, data[MAXSIZE], i, x, low, high, result, packet[2]; // [0] = local sum, [1] = local max // // ofstream DebugFile; // Debug file. // // MPI initialization routines. // MPI_Status status; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myid); // // Activity for root process, 0. // if (myid == 0) { // // Read file containing MAXSIZE numbers. // std::ifstream infile("rand_data.txt", ios::in); // //DebugFile.open ("rand_dataV1.txt"); //DebugFile << "Writing this to a file. "; // if( !infile ) { // checks for file access cerr << "File could not be opened "; return( 1 ); } //if( numprocs != 10 ) // // Check that the number of subdivisions of the file is a multiple of // the number of processes. // if( MAXSIZE%numprocs != 0 ) { cerr << " !!! WARNING - This program requires MAXSIZE%numprocs == 0 processes "; return( 2 ); } for(i = 0; i < MAXSIZE; i++) // load data from file into an array { infile >> data[i]; // // DebugFile< packet[1] ) packet[1] = data[i]; packet[0] += data[i]; // // Error check output. // // DebugFile<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!