petsc I/O

Matthew Knepley knepley at gmail.com
Fri Sep 15 11:44:01 CDT 2006


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.
>
>


-- 
"Failure has a thousand explanations. Success doesn't need one" -- Sir Alec
Guiness
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20060915/68e34fd1/attachment.htm>


More information about the petsc-users mailing list