Tonio Herrmann <[email protected]> writes:

> Hello,
> during my attempts to learn PETSc, I am trying to understand the relation
> between global and local vectors on a DMDA. There is a problem in my code
> below, which only returns zeros when I try to access the local values,
> although VecView shows that the values are correctly transferred from the
> global vector g to the local vector l.
> Is it obvious, what I am doing wrong?
>
> Another question, I was expecting that "VecView(l,PETSC_VIEWER_STDOUT_WORLD);"
> would print l synchronized from each process, but only l from process #0 is
> shown. How can I see the other parts of l?

They're there, you just botched the format string.

>   PetscSynchronizedPrintf(PETSC_COMM_WORLD,"VecGetValues on rank
> %d:\n",rank);
>   for (int k=0;k<sz;k++) PetscSynchronizedPrintf(PETSC_COMM_WORLD,"%d
> ",data[k]);

%d is for integers, but you're passing scalars.  Use %g or %f, for example.

Attachment: signature.asc
Description: PGP signature

Reply via email to