On Tue, Nov 10, 2009 at 6:32 AM, Wienand Drenth <span dir="ltr"><<a href="mailto:w.drenth@gmail.com">w.drenth@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
As a follow-up of my previous email, I have tried the following:<br>
<br>
bvec is a Fortran array<br>
bseq2 is a sequential PetSc vector created only on processor 0<br>
b is the parallel PetSc vector I use in KSPSolve<br>
<br>
I fill bvec with bvec(i) = i, and b gets initialized to all ones.<br>
<br>
then I do<br>
if (rank.eq.0) then<br>
call VecPlaceArray(bseq2, bvec, ierr)<br>
do my_i=1,m*n<br>
II=my_i-1<br>
call VecGetValues(bseq2,1,II,v,ierr)<br>
write(*,*) "bseq2 rhs: ", II, ": ", v, " for rank ", rank<br>
enddo<br>
endif<br>
<br>
this prints nice 1, 2, etc<br>
<br>
Next I want my parallel vector b to be filled. So I use VecScatterCreatertoZero.<br>
<br>
call VecScatterCreateToZero(b,vscat,bseq2,ierr)<br></blockquote><div><br>This call creates bseq2, so it will wipe out the values. Put them in afterwards.<br><br> Matt<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
call VecScatterBegin(vscat, bseq2,b,INSERT_VALUES,<br>
> SCATTER_REVERSE,ierr)<br>
call VecScatterEnd(vscat,bseq2,b,INSERT_VALUES,<br>
> SCATTER_REVERSE,ierr)<br>
call VecScatterDestroy(vscat, ierr)<br>
<br>
However, now b is filled with zeros. (If I would change the order in<br>
the VecScatterBegin and VecScatterEnd (first b, then bseq2), possible<br>
in combination with SCATTER_FORWARD, then b will still have its<br>
original ones.)<br>
<br>
I cannot immediately see what I did wrong here, so I hope somebody<br>
could give a further hint.<br>
<font color="#888888"><br>
Wienand<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>