use of VecPlaceArray in parallel with fortran
Wienand Drenth
w.drenth at gmail.com
Tue Nov 10 06:32:27 CST 2009
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)
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
More information about the petsc-users
mailing list