<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi All,<div class=""><br class=""></div><div class="">I had the necessity to read data on another node of a Vector Petsc. </div><div class="">I followed the structure showed in the tutorial of <span style="color: rgb(76, 191, 87); font-family: Menlo; font-size: 11px;" class="">VecScatterCreateToAll.</span></div><div class="">I call the function below 2 times with 2 different vectors vec1 and vec2.</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">void Scatter(Vec vec, PetscScalar &value, vector<int> NeighboursIndex, int NeighNumber){</div><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> Vec V_SEQ;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> VecScatter ctx;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> PetscScalar *vecArray;</div><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> VecScatterCreateToAll(vec,&ctx,&V_SEQ);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> VecScatterBegin(ctx,vec,V_SEQ,INSERT_VALUES,SCATTER_FORWARD);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> VecScatterEnd(ctx,vec,V_SEQ,INSERT_VALUES,SCATTER_FORWARD);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> ierr = VecGetArray(V_SEQ,&vecArray);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> for(int i=0; i<NeighNumber;i++){</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> PetscInt index=NeighboursIndex[i];</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> value = vecArray[index];</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> if(NeighboursIndex[0]==869 && (index==363 || index == 364 || index ==365) ){</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> cout << endl << index << " inside function " << value;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> //</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> ierr = VecRestoreArray(V_SEQ,&vecArray);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> VecScatterDestroy(&ctx);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> VecDestroy(&V_SEQ);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> return; </div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">}</div></div><div class=""><br class=""></div><div class="">When I run my code with one node i have a result coherent but if I use 2 nodes the vectors are inverted in values.</div><div class="">I used for a test a vector of 1 and a vector of 0 and I concentrated the output on a point that communicates with the other node.</div><div class=""><br class=""></div><div class="">Can you explain me what is effectively wrong when I call the vecscatter routines? I can’t see a reason coherent with a simple inversion of values from 2 vectors. </div><div class=""><br class=""></div><div class="">Example of output</div><div class="">1 node:</div><div class="">first call vec1</div><div class=""><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">364 inside function 87.797</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">363 inside function 89.0416</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">365 inside function 86.4618</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">second call vec2</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">364 inside function 0.0268704</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">363 inside function 0.0322394</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">365 inside function 0.0199141</div></div><div class=""><br class=""></div><div class="">2 nodes:</div><div class="">first call vec1</div><div class=""><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">364 inside function 0.0268704</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">363 inside function 0.0322394</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">365 inside function 0.0199141</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">second call vec2</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">364 inside function 87.797</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">363 inside function 89.0416</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">365 inside function 86.4618</div></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><b class="">Many Thanks</b></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><b class="">Alice Raeli</b></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><b style="color: rgb(136, 136, 136); font-family: Helvetica; font-size: 12px;" class="">I</b><span style="color: rgb(136, 136, 136); font-family: Helvetica; font-size: 12px;" class="">nstitut de </span><b style="color: rgb(136, 136, 136); font-family: Helvetica; font-size: 12px;" class="">M</b><span style="color: rgb(136, 136, 136); font-family: Helvetica; font-size: 12px;" class="">athématiques de </span><b style="color: rgb(136, 136, 136); font-family: Helvetica; font-size: 12px;" class="">B</b><span style="color: rgb(136, 136, 136); font-family: Helvetica; font-size: 12px;" class="">ordeaux </span><b style="color: rgb(136, 136, 136); font-family: Helvetica; font-size: 12px;" class="">(IMB)</b><br style="color: rgb(136, 136, 136); font-family: Helvetica; font-size: 12px;" class=""><br style="color: rgb(136, 136, 136); font-family: Helvetica; font-size: 12px;" class=""><a href="mailto:alice.raeli@math.u-bordeaux1.fr" target="_blank" style="font-family: Helvetica; font-size: 12px;" class="">alice.raeli@math.u-bordeaux1.fr</a><br style="color: rgb(136, 136, 136); font-family: Helvetica; font-size: 12px;" class=""><br style="color: rgb(136, 136, 136); font-family: Helvetica; font-size: 12px;" class=""><a href="mailto:alice.raeli@u-bordeaux.fr" target="_blank" style="font-family: Helvetica; font-size: 12px;" class="">alice.raeli@u-bordeaux.fr</a></div></body></html>