petsc I/O

Matt Funk mafunk at nmsu.edu
Fri Sep 15 18:17:16 CDT 2006


Hi

The value are not local in general. So, true, it would entail communication. 

I just used MPI calls to do what i needed it to do. I was just wondering if 
PETSc had that functionality, that's all.

Also before i wrote the email, i did as Barry suggested by using the 
PetscSynchronizedPrintf() after getting the array via VecGetArray().
However, for me that hung the program (at least i believe this was the reason 
the program hung). Because for example, say i want to print (array-wise 
speaking) element 144,144,144. This element resides on one processor only. I 
use the DA object and hence use global(!!) indices to access the array. So 
that means the program looks for element 144,144,144 on all processor (since, 
as far as i understand it, PetscSynchronizedPrintf() gets the requested value 
from all processors and then prints it). However, this will mean that it is 
out of the scope of the local portion of the global vector for all processors 
except one (that is the processors on which this point lives). So i believe 
that was the reason it crashed. 

thanks
mat


On Friday 15 September 2006 10:44, Matthew Knepley wrote:
> On 9/15/06, Matt Funk <mafunk at nmsu.edu> wrote:
> > Hi,
> >
> > thanks for the answers first of all. I have another question though ...
> > :)
> >
> > Say, i want to print a specific element from a PETSc global vector. Is
> > there a
> > function (PetscSunchFPrintF does not do this i believe) to which i simply
> > pass the file handle, communicator, the vector and the element and it
> > writes
> > the value to the file?
>
> No, this function does not currently exist. Are these elements local? If
> not, it
> would entail communication. If so, you could use VecGetArray() and then
> just index in. Is that sufficient?
>
>   thanks,
>
>    Matt
>
> thanks
>
> > mat
> >
> > On Wednesday 13 September 2006 17:13, Berend van Wachem wrote:
> > > Hi Matt,
> > >
> > > > i need to read in an input file. So to open my file i use PETSCFOpen
> > > > which works fine. But then my problems begin ... :)
> > > >
> > > > I guess i need to tell only the first proc in the communicator to
> >
> > fscan.
> >
> > > > But is there a PETSC function that returns me the processor id?
> > > > And when i read the parameters in on the first proc i need to
> >
> > broadcast
> >
> > > > them to the other procs. Does PETSC have anything for this?
> > >
> > > For both issues you can use standard MPI:
> > >
> > > to get the processor ID:
> > > ierr=MPI_Comm_rank(MPI_Comm Communicator,int *rank);
> > >
> > > to broadcast information:
> > > ierr=MPI_Bcast ( void *buffer, int count, MPI_Datatype datatype, int
> > > root,  MPI_Comm comm )
> > >
> > > If possible, I would recommend you to use the PetscViewer interface for
> > > your IO handling; it is very easy.
> > >
> > > Good luck,
> > >
> > > Berend.




More information about the petsc-users mailing list