use of VecPlaceArray in parallel with fortran

Matthew Knepley knepley at gmail.com
Tue Nov 10 06:36:53 CST 2009


On Tue, Nov 10, 2009 at 6:32 AM, Wienand Drenth <w.drenth at gmail.com> wrote:

> As a follow-up of my previous email, I have tried the following:
>
> bvec is a Fortran array
> bseq2 is a sequential PetSc vector created only on processor 0
> b is the parallel PetSc vector I use in KSPSolve
>
> I fill bvec with bvec(i) = i, and b gets initialized to all ones.
>
> then I do
>      if (rank.eq.0) then
>        call VecPlaceArray(bseq2, bvec, ierr)
>        do my_i=1,m*n
>            II=my_i-1
>           call VecGetValues(bseq2,1,II,v,ierr)
>           write(*,*) "bseq2 rhs: ", II, ": ", v, " for rank ", rank
>        enddo
>     endif
>
> this prints nice 1, 2, etc
>
> Next I want my parallel vector b to be filled. So I use
> VecScatterCreatertoZero.
>
>      call VecScatterCreateToZero(b,vscat,bseq2,ierr)
>

This call creates bseq2, so it will wipe out the values. Put them in
afterwards.

  Matt


>      call VecScatterBegin(vscat, bseq2,b,INSERT_VALUES,
>     >    SCATTER_REVERSE,ierr)
>      call VecScatterEnd(vscat,bseq2,b,INSERT_VALUES,
>     >      SCATTER_REVERSE,ierr)
>      call VecScatterDestroy(vscat, ierr)
>
> However, now b is filled with zeros. (If I would change the order in
> the VecScatterBegin and VecScatterEnd (first b, then bseq2), possible
> in combination with SCATTER_FORWARD, then b will still have its
> original ones.)
>
> I cannot immediately see what I did wrong here, so I hope somebody
> could give a further hint.
>
> Wienand
>



-- 
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20091110/91a210dc/attachment.htm>


More information about the petsc-users mailing list