PetscViewerASCIIOpen#
Opens an ASCII file for writing as a PETSCVIEWERASCII
PetscViewer
.
Synopsis#
#include "petscviewer.h"
PetscErrorCode PetscViewerASCIIOpen(MPI_Comm comm, const char name[], PetscViewer *viewer)
Collective
Input Parameters#
comm - the communicator
name - the file name
Output Parameter#
viewer - the
PetscViewer
to use with the specified file
Notes#
This routine only opens files for writing. To open a ASCII file as a PetscViewer
for reading use the sequence
PetscViewerCreate(comm,&viewer);
PetscViewerSetType(viewer,PETSCVIEWERASCII);
PetscViewerFileSetMode(viewer,FILE_MODE_READ);
PetscViewerFileSetName(viewer,name);
This PetscViewer
can be destroyed with PetscViewerDestroy()
.
The MPI communicator used here must match that used by the object viewed. For example if the
Mat was created with a PETSC_COMM_WORLD
, then viewer
must be created with PETSC_COMM_WORLD
As shown below, PetscViewerASCIIOpen()
is useful in conjunction with
MatView()
and VecView()
PetscViewerASCIIOpen(PETSC_COMM_WORLD,"mat.output",&viewer);
MatView(matrix,viewer);
Developer Note#
When called with NULL
, stdout
, or stderr
this does not return the same communicator as PetscViewerASCIIGetStdout()
or PetscViewerASCIIGetStderr()
but that is ok.
See Also#
Viewers: Looking at PETSc Objects, MatView()
, VecView()
, PetscViewerDestroy()
, PetscViewerBinaryOpen()
, PetscViewerASCIIRead()
, PETSCVIEWERASCII
PetscViewerASCIIGetPointer()
, PetscViewerPushFormat()
, PETSC_VIEWER_STDOUT_
, PETSC_VIEWER_STDERR_
,
PETSC_VIEWER_STDOUT_WORLD
, PETSC_VIEWER_STDOUT_SELF
, PetscViewerASCIIGetStdout()
, PetscViewerASCIIGetStderr()
Level#
beginner
Location#
Examples#
src/ksp/ksp/tutorials/ex76.c
src/snes/tutorials/ex1f.F90
src/ts/tutorials/ex9.c
src/ksp/ksp/tutorials/ex55.c
src/ksp/ksp/tutorials/ex72.c
src/ts/tutorials/ex14.c
src/ksp/ksp/tutorials/ex56.c
src/ksp/ksp/tutorials/ex54.c
src/snes/tutorials/ex48.c
src/snes/tutorials/ex70.c
Index of all Viewer routines
Table of Contents for all manual pages
Index of all manual pages