petsc I/O

Berend van Wachem berend at chalmers.se
Wed Sep 13 18:13:48 CDT 2006


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