# PetscViewerASCIIOpen

Opens an ASCII file as a PetscViewer.

### Synopsis

    #include "petsc.h"
    PetscErrorCode  PetscViewerASCIIOpen(MPI_Comm comm,const char name[],PetscViewer *lab)

Collective on MPI_Comm

### Input Parameters

| comm | - the communicator
| name | - the file name

### Output Parameter

lab -the PetscViewer to use with the specified file

### Notes

This PetscViewer can be destroyed with PetscViewerDestroy().

If a multiprocessor communicator is used (such as PETSC_COMM_WORLD), then only the first processor in the group opens the file. All other processors send their data to the first processor to print.

Each processor can instead write its own independent output by specifying the communicator PETSC_COMM_SELF.

As shown below, PetscViewerASCIIOpen() is useful in conjunction with MatView() and VecView()

         PetscViewerASCIIOpen(PETSC_COMM_WORLD,"mat.output",&viewer);
         MatView(matrix,viewer);

### See Also

MatView(), VecView(), PetscViewerDestroy(), PetscViewerBinaryOpen(),
PetscViewerASCIIGetPointer(), PetscViewerSetFormat(), PETSC_VIEWER_STDOUT_, PETSC_VIEWER_STDERR_, PETSC_VIEWER_STDOUT_WORLD, PETSC_VIEWER_STDOUT_SELF,

Level:beginner
Location: src/sys/viewer/impls/ascii/vcreatea.c
Index of all Viewer routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/ksp/ksp/examples/tutorials/ex29.c.html
src/snes/examples/tutorials/ex26.c.html