Plz Correct this code................<br><br><a class="ext-link" href="http://trac.guake-terminal.org/files/"><span class="icon">#include<iostream><br>#include<vector><br>#include "mpi.h"<br><br>using namespace std;<br>
<br>int main(int argc, char *argv[])<br>{<br> MPI::Status status;<br> MPI::Init();<br> int myrank = MPI::COMM_WORLD.Get_rank();<br> int numprocs = MPI::COMM_WORLD.Get_size();<br> vector<int> ourvector(2); <br>
if(myrank == 0){<br><br> ourvector[0] = 98; <br><br>// cout << "The max number the vector can hold is : " << ourvector.max_size();<br> <br><br>// cout << "\nourvector has : " << ourvector.capacity() << " elements in it";<br>
<br> ourvector.push_back(99); <br> <br> <br>// cout << "\nNow ourvector has : " << ourvector.size() << " elements in it";<br><br>// cout << "\nThe Value of the first vector element is : " << ourvector[0];<br>
<br><br>// cout << "\nThe Value of our second vector element is : " << ourvector.at(1) << endl;<br><br> MPI::COMM_WORLD.Send(&ourvector[0],2,MPI::INT, 1, 1);<br> // MPI::COMM_WORLD.Send(&ourvector[1],1,MPI::INT, 1, 1);<br>
}<br> else{<br> ourvector.reserve(2);<br> MPI::COMM_WORLD.Recv(&ourvector[0],2, MPI::INT,0,1);<br> // MPI::COMM_WORLD.Recv(&ourvector[1],1, MPI::INT,0,1);<br><br> //ourvector.pop_back();<br>
<br><br> cout << "ourvector now has : " << ourvector.capacity() << " elements" << endl;<br> cout << "\nNow ourvector has 1st : " << ourvector[0];<br>
cout << "\nNow ourvector has 2nd : " << ourvector[1]<< endl;<br>// cout << "Our fisrt element in ourvector is : " << ourvector.front() << endl;<br><br><br>
ourvector.resize(9);<br> <br> ourvector.at(8) = 99;<br><br>// cout << "Our last element in ourvect is : " << ourvector.back() << endl;<br><br>// cout << "ourvector now holds : " << ourvector.size() << " elements" << endl;<br>
}<br> MPI::Finalize();<br> return 0;<br>}</span></a><br><br><br>Now MY output is<br>$ mpirun -np 2 ./vec.out<br>ourvector now has : 2 elements<br><br>Now ourvector has 1st : 98<br>Now ourvector has 2nd :0<br>
<br>I want output like<a class="ext-link" href="http://trac.guake-terminal.org/files/"><span class="icon"> </span></a><br>$ mpirun -np 2 ./vec.out<br>ourvector now has : 2 elements<br>
<br>
Now ourvector has 1st : 98<br>
Now ourvector has 2nd :99<br>
<br><a class="ext-link" href="http://trac.guake-terminal.org/files/"><span class="icon"></span></a>