xref: /petsc/src/sys/classes/viewer/interface/view.c (revision 5c6c1daec53e1d9ab0bec9db5309fd8fc7645b8d)
1*5c6c1daeSBarry Smith 
2*5c6c1daeSBarry Smith #include <petsc-private/viewerimpl.h>  /*I "petscsys.h" I*/
3*5c6c1daeSBarry Smith 
4*5c6c1daeSBarry Smith PetscClassId PETSC_VIEWER_CLASSID;
5*5c6c1daeSBarry Smith 
6*5c6c1daeSBarry Smith static PetscBool  PetscViewerPackageInitialized = PETSC_FALSE;
7*5c6c1daeSBarry Smith #undef __FUNCT__
8*5c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerFinalizePackage"
9*5c6c1daeSBarry Smith /*@C
10*5c6c1daeSBarry Smith   PetscViewerFinalizePackage - This function destroys everything in the Petsc interface to Mathematica. It is
11*5c6c1daeSBarry Smith   called from PetscFinalize().
12*5c6c1daeSBarry Smith 
13*5c6c1daeSBarry Smith   Level: developer
14*5c6c1daeSBarry Smith 
15*5c6c1daeSBarry Smith .keywords: Petsc, destroy, package, mathematica
16*5c6c1daeSBarry Smith .seealso: PetscFinalize()
17*5c6c1daeSBarry Smith @*/
18*5c6c1daeSBarry Smith PetscErrorCode  PetscViewerFinalizePackage(void)
19*5c6c1daeSBarry Smith {
20*5c6c1daeSBarry Smith   PetscFunctionBegin;
21*5c6c1daeSBarry Smith   PetscViewerPackageInitialized = PETSC_FALSE;
22*5c6c1daeSBarry Smith   PetscViewerList               = 0;
23*5c6c1daeSBarry Smith   PetscFunctionReturn(0);
24*5c6c1daeSBarry Smith }
25*5c6c1daeSBarry Smith 
26*5c6c1daeSBarry Smith #undef __FUNCT__
27*5c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerInitializePackage"
28*5c6c1daeSBarry Smith /*@C
29*5c6c1daeSBarry Smith   PetscViewerInitializePackage - This function initializes everything in the main PetscViewer package.
30*5c6c1daeSBarry Smith 
31*5c6c1daeSBarry Smith   Input Parameter:
32*5c6c1daeSBarry Smith   path - The dynamic library path, or PETSC_NULL
33*5c6c1daeSBarry Smith 
34*5c6c1daeSBarry Smith   Level: developer
35*5c6c1daeSBarry Smith 
36*5c6c1daeSBarry Smith .keywords: Petsc, initialize, package
37*5c6c1daeSBarry Smith .seealso: PetscInitialize()
38*5c6c1daeSBarry Smith @*/
39*5c6c1daeSBarry Smith PetscErrorCode  PetscViewerInitializePackage(const char path[])
40*5c6c1daeSBarry Smith {
41*5c6c1daeSBarry Smith   char              logList[256];
42*5c6c1daeSBarry Smith   char              *className;
43*5c6c1daeSBarry Smith   PetscBool         opt;
44*5c6c1daeSBarry Smith   PetscErrorCode    ierr;
45*5c6c1daeSBarry Smith 
46*5c6c1daeSBarry Smith   PetscFunctionBegin;
47*5c6c1daeSBarry Smith   if (PetscViewerPackageInitialized) PetscFunctionReturn(0);
48*5c6c1daeSBarry Smith   PetscViewerPackageInitialized = PETSC_TRUE;
49*5c6c1daeSBarry Smith   /* Register Classes */
50*5c6c1daeSBarry Smith   ierr = PetscClassIdRegister("Viewer",&PETSC_VIEWER_CLASSID);CHKERRQ(ierr);
51*5c6c1daeSBarry Smith 
52*5c6c1daeSBarry Smith   /* Register Constructors */
53*5c6c1daeSBarry Smith   ierr = PetscViewerRegisterAll(path);CHKERRQ(ierr);
54*5c6c1daeSBarry Smith 
55*5c6c1daeSBarry Smith   /* Process info exclusions */
56*5c6c1daeSBarry Smith   ierr = PetscOptionsGetString(PETSC_NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr);
57*5c6c1daeSBarry Smith   if (opt) {
58*5c6c1daeSBarry Smith     ierr = PetscStrstr(logList, "viewer", &className);CHKERRQ(ierr);
59*5c6c1daeSBarry Smith     if (className) {
60*5c6c1daeSBarry Smith       ierr = PetscInfoDeactivateClass(0);CHKERRQ(ierr);
61*5c6c1daeSBarry Smith     }
62*5c6c1daeSBarry Smith   }
63*5c6c1daeSBarry Smith   /* Process summary exclusions */
64*5c6c1daeSBarry Smith   ierr = PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr);
65*5c6c1daeSBarry Smith   if (opt) {
66*5c6c1daeSBarry Smith     ierr = PetscStrstr(logList, "viewer", &className);CHKERRQ(ierr);
67*5c6c1daeSBarry Smith     if (className) {
68*5c6c1daeSBarry Smith       ierr = PetscLogEventDeactivateClass(0);CHKERRQ(ierr);
69*5c6c1daeSBarry Smith     }
70*5c6c1daeSBarry Smith   }
71*5c6c1daeSBarry Smith #if defined(PETSC_HAVE_MATHEMATICA)
72*5c6c1daeSBarry Smith   ierr = PetscViewerMathematicaInitializePackage(PETSC_NULL);CHKERRQ(ierr);
73*5c6c1daeSBarry Smith #endif
74*5c6c1daeSBarry Smith   ierr = PetscRegisterFinalize(PetscViewerFinalizePackage);CHKERRQ(ierr);
75*5c6c1daeSBarry Smith   PetscFunctionReturn(0);
76*5c6c1daeSBarry Smith }
77*5c6c1daeSBarry Smith 
78*5c6c1daeSBarry Smith #undef __FUNCT__
79*5c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDestroy"
80*5c6c1daeSBarry Smith /*@
81*5c6c1daeSBarry Smith    PetscViewerDestroy - Destroys a PetscViewer.
82*5c6c1daeSBarry Smith 
83*5c6c1daeSBarry Smith    Collective on PetscViewer
84*5c6c1daeSBarry Smith 
85*5c6c1daeSBarry Smith    Input Parameters:
86*5c6c1daeSBarry Smith .  viewer - the PetscViewer to be destroyed.
87*5c6c1daeSBarry Smith 
88*5c6c1daeSBarry Smith    Level: beginner
89*5c6c1daeSBarry Smith 
90*5c6c1daeSBarry Smith .seealso: PetscViewerSocketOpen(), PetscViewerASCIIOpen(), PetscViewerCreate(), PetscViewerDrawOpen()
91*5c6c1daeSBarry Smith 
92*5c6c1daeSBarry Smith @*/
93*5c6c1daeSBarry Smith PetscErrorCode  PetscViewerDestroy(PetscViewer *viewer)
94*5c6c1daeSBarry Smith {
95*5c6c1daeSBarry Smith   PetscErrorCode ierr;
96*5c6c1daeSBarry Smith 
97*5c6c1daeSBarry Smith   PetscFunctionBegin;
98*5c6c1daeSBarry Smith   if (!*viewer) PetscFunctionReturn(0);
99*5c6c1daeSBarry Smith   PetscValidHeaderSpecific(*viewer,PETSC_VIEWER_CLASSID,1);
100*5c6c1daeSBarry Smith 
101*5c6c1daeSBarry Smith   ierr = PetscViewerFlush(*viewer);CHKERRQ(ierr);
102*5c6c1daeSBarry Smith   if (--((PetscObject)(*viewer))->refct > 0) {*viewer = 0; PetscFunctionReturn(0);}
103*5c6c1daeSBarry Smith 
104*5c6c1daeSBarry Smith   ierr = PetscObjectDepublish(*viewer);CHKERRQ(ierr);
105*5c6c1daeSBarry Smith 
106*5c6c1daeSBarry Smith   if ((*viewer)->ops->destroy) {
107*5c6c1daeSBarry Smith     ierr = (*(*viewer)->ops->destroy)(*viewer);CHKERRQ(ierr);
108*5c6c1daeSBarry Smith   }
109*5c6c1daeSBarry Smith   ierr = PetscHeaderDestroy(viewer);CHKERRQ(ierr);
110*5c6c1daeSBarry Smith   PetscFunctionReturn(0);
111*5c6c1daeSBarry Smith }
112*5c6c1daeSBarry Smith 
113*5c6c1daeSBarry Smith #undef __FUNCT__
114*5c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerGetType"
115*5c6c1daeSBarry Smith /*@C
116*5c6c1daeSBarry Smith    PetscViewerGetType - Returns the type of a PetscViewer.
117*5c6c1daeSBarry Smith 
118*5c6c1daeSBarry Smith    Not Collective
119*5c6c1daeSBarry Smith 
120*5c6c1daeSBarry Smith    Input Parameter:
121*5c6c1daeSBarry Smith .   viewer - the PetscViewer
122*5c6c1daeSBarry Smith 
123*5c6c1daeSBarry Smith    Output Parameter:
124*5c6c1daeSBarry Smith .  type - PetscViewer type (see below)
125*5c6c1daeSBarry Smith 
126*5c6c1daeSBarry Smith    Available Types Include:
127*5c6c1daeSBarry Smith .  PETSCVIEWERSOCKET - Socket PetscViewer
128*5c6c1daeSBarry Smith .  PETSCVIEWERASCII - ASCII PetscViewer
129*5c6c1daeSBarry Smith .  PETSCVIEWERBINARY - binary file PetscViewer
130*5c6c1daeSBarry Smith .  PETSCVIEWERSTRING - string PetscViewer
131*5c6c1daeSBarry Smith .  PETSCVIEWERDRAW - drawing PetscViewer
132*5c6c1daeSBarry Smith 
133*5c6c1daeSBarry Smith    Level: intermediate
134*5c6c1daeSBarry Smith 
135*5c6c1daeSBarry Smith    Note:
136*5c6c1daeSBarry Smith    See include/petscviewer.h for a complete list of PetscViewers.
137*5c6c1daeSBarry Smith 
138*5c6c1daeSBarry Smith    PetscViewerType is actually a string
139*5c6c1daeSBarry Smith 
140*5c6c1daeSBarry Smith .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType
141*5c6c1daeSBarry Smith 
142*5c6c1daeSBarry Smith @*/
143*5c6c1daeSBarry Smith PetscErrorCode  PetscViewerGetType(PetscViewer viewer,PetscViewerType *type)
144*5c6c1daeSBarry Smith {
145*5c6c1daeSBarry Smith   PetscFunctionBegin;
146*5c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
147*5c6c1daeSBarry Smith   PetscValidPointer(type,2);
148*5c6c1daeSBarry Smith   *type = ((PetscObject)viewer)->type_name;
149*5c6c1daeSBarry Smith   PetscFunctionReturn(0);
150*5c6c1daeSBarry Smith }
151*5c6c1daeSBarry Smith 
152*5c6c1daeSBarry Smith #undef __FUNCT__
153*5c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerSetOptionsPrefix"
154*5c6c1daeSBarry Smith /*@C
155*5c6c1daeSBarry Smith    PetscViewerSetOptionsPrefix - Sets the prefix used for searching for all
156*5c6c1daeSBarry Smith    PetscViewer options in the database.
157*5c6c1daeSBarry Smith 
158*5c6c1daeSBarry Smith    Logically Collective on PetscViewer
159*5c6c1daeSBarry Smith 
160*5c6c1daeSBarry Smith    Input Parameter:
161*5c6c1daeSBarry Smith +  viewer - the PetscViewer context
162*5c6c1daeSBarry Smith -  prefix - the prefix to prepend to all option names
163*5c6c1daeSBarry Smith 
164*5c6c1daeSBarry Smith    Notes:
165*5c6c1daeSBarry Smith    A hyphen (-) must NOT be given at the beginning of the prefix name.
166*5c6c1daeSBarry Smith    The first character of all runtime options is AUTOMATICALLY the hyphen.
167*5c6c1daeSBarry Smith 
168*5c6c1daeSBarry Smith    Level: advanced
169*5c6c1daeSBarry Smith 
170*5c6c1daeSBarry Smith .keywords: PetscViewer, set, options, prefix, database
171*5c6c1daeSBarry Smith 
172*5c6c1daeSBarry Smith .seealso: PetscViewerSetFromOptions()
173*5c6c1daeSBarry Smith @*/
174*5c6c1daeSBarry Smith PetscErrorCode  PetscViewerSetOptionsPrefix(PetscViewer viewer,const char prefix[])
175*5c6c1daeSBarry Smith {
176*5c6c1daeSBarry Smith   PetscErrorCode ierr;
177*5c6c1daeSBarry Smith 
178*5c6c1daeSBarry Smith   PetscFunctionBegin;
179*5c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
180*5c6c1daeSBarry Smith   ierr = PetscObjectSetOptionsPrefix((PetscObject)viewer,prefix);CHKERRQ(ierr);
181*5c6c1daeSBarry Smith   PetscFunctionReturn(0);
182*5c6c1daeSBarry Smith }
183*5c6c1daeSBarry Smith 
184*5c6c1daeSBarry Smith #undef __FUNCT__
185*5c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerAppendOptionsPrefix"
186*5c6c1daeSBarry Smith /*@C
187*5c6c1daeSBarry Smith    PetscViewerAppendOptionsPrefix - Appends to the prefix used for searching for all
188*5c6c1daeSBarry Smith    PetscViewer options in the database.
189*5c6c1daeSBarry Smith 
190*5c6c1daeSBarry Smith    Logically Collective on PetscViewer
191*5c6c1daeSBarry Smith 
192*5c6c1daeSBarry Smith    Input Parameters:
193*5c6c1daeSBarry Smith +  viewer - the PetscViewer context
194*5c6c1daeSBarry Smith -  prefix - the prefix to prepend to all option names
195*5c6c1daeSBarry Smith 
196*5c6c1daeSBarry Smith    Notes:
197*5c6c1daeSBarry Smith    A hyphen (-) must NOT be given at the beginning of the prefix name.
198*5c6c1daeSBarry Smith    The first character of all runtime options is AUTOMATICALLY the hyphen.
199*5c6c1daeSBarry Smith 
200*5c6c1daeSBarry Smith    Level: advanced
201*5c6c1daeSBarry Smith 
202*5c6c1daeSBarry Smith .keywords: PetscViewer, append, options, prefix, database
203*5c6c1daeSBarry Smith 
204*5c6c1daeSBarry Smith .seealso: PetscViewerGetOptionsPrefix()
205*5c6c1daeSBarry Smith @*/
206*5c6c1daeSBarry Smith PetscErrorCode  PetscViewerAppendOptionsPrefix(PetscViewer viewer,const char prefix[])
207*5c6c1daeSBarry Smith {
208*5c6c1daeSBarry Smith   PetscErrorCode ierr;
209*5c6c1daeSBarry Smith 
210*5c6c1daeSBarry Smith   PetscFunctionBegin;
211*5c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
212*5c6c1daeSBarry Smith   ierr = PetscObjectAppendOptionsPrefix((PetscObject)viewer,prefix);CHKERRQ(ierr);
213*5c6c1daeSBarry Smith   PetscFunctionReturn(0);
214*5c6c1daeSBarry Smith }
215*5c6c1daeSBarry Smith 
216*5c6c1daeSBarry Smith #undef __FUNCT__
217*5c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerGetOptionsPrefix"
218*5c6c1daeSBarry Smith /*@C
219*5c6c1daeSBarry Smith    PetscViewerGetOptionsPrefix - Sets the prefix used for searching for all
220*5c6c1daeSBarry Smith    PetscViewer options in the database.
221*5c6c1daeSBarry Smith 
222*5c6c1daeSBarry Smith    Not Collective
223*5c6c1daeSBarry Smith 
224*5c6c1daeSBarry Smith    Input Parameter:
225*5c6c1daeSBarry Smith .  viewer - the PetscViewer context
226*5c6c1daeSBarry Smith 
227*5c6c1daeSBarry Smith    Output Parameter:
228*5c6c1daeSBarry Smith .  prefix - pointer to the prefix string used
229*5c6c1daeSBarry Smith 
230*5c6c1daeSBarry Smith    Notes: On the fortran side, the user should pass in a string 'prefix' of
231*5c6c1daeSBarry Smith    sufficient length to hold the prefix.
232*5c6c1daeSBarry Smith 
233*5c6c1daeSBarry Smith    Level: advanced
234*5c6c1daeSBarry Smith 
235*5c6c1daeSBarry Smith .keywords: PetscViewer, get, options, prefix, database
236*5c6c1daeSBarry Smith 
237*5c6c1daeSBarry Smith .seealso: PetscViewerAppendOptionsPrefix()
238*5c6c1daeSBarry Smith @*/
239*5c6c1daeSBarry Smith PetscErrorCode  PetscViewerGetOptionsPrefix(PetscViewer viewer,const char *prefix[])
240*5c6c1daeSBarry Smith {
241*5c6c1daeSBarry Smith   PetscErrorCode ierr;
242*5c6c1daeSBarry Smith 
243*5c6c1daeSBarry Smith   PetscFunctionBegin;
244*5c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
245*5c6c1daeSBarry Smith   ierr = PetscObjectGetOptionsPrefix((PetscObject)viewer,prefix);CHKERRQ(ierr);
246*5c6c1daeSBarry Smith   PetscFunctionReturn(0);
247*5c6c1daeSBarry Smith }
248*5c6c1daeSBarry Smith 
249*5c6c1daeSBarry Smith #undef __FUNCT__
250*5c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerSetUp"
251*5c6c1daeSBarry Smith /*@
252*5c6c1daeSBarry Smith    PetscViewerSetUp - Sets up the internal viewer data structures for the later use.
253*5c6c1daeSBarry Smith 
254*5c6c1daeSBarry Smith    Collective on PetscViewer
255*5c6c1daeSBarry Smith 
256*5c6c1daeSBarry Smith    Input Parameters:
257*5c6c1daeSBarry Smith .  viewer - the PetscViewer context
258*5c6c1daeSBarry Smith 
259*5c6c1daeSBarry Smith    Notes:
260*5c6c1daeSBarry Smith    For basic use of the PetscViewer classes the user need not explicitly call
261*5c6c1daeSBarry Smith    PetscViewerSetUp(), since these actions will happen automatically.
262*5c6c1daeSBarry Smith 
263*5c6c1daeSBarry Smith    Level: advanced
264*5c6c1daeSBarry Smith 
265*5c6c1daeSBarry Smith .keywords: PetscViewer, setup
266*5c6c1daeSBarry Smith 
267*5c6c1daeSBarry Smith .seealso: PetscViewerCreate(), PetscViewerDestroy()
268*5c6c1daeSBarry Smith @*/
269*5c6c1daeSBarry Smith PetscErrorCode  PetscViewerSetUp(PetscViewer viewer)
270*5c6c1daeSBarry Smith {
271*5c6c1daeSBarry Smith   PetscFunctionBegin;
272*5c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
273*5c6c1daeSBarry Smith   PetscFunctionReturn(0);
274*5c6c1daeSBarry Smith }
275*5c6c1daeSBarry Smith 
276*5c6c1daeSBarry Smith #undef __FUNCT__
277*5c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerView"
278*5c6c1daeSBarry Smith /*@C
279*5c6c1daeSBarry Smith    PetscViewerView - Visualizes a viewer object.
280*5c6c1daeSBarry Smith 
281*5c6c1daeSBarry Smith    Collective on PetscViewer
282*5c6c1daeSBarry Smith 
283*5c6c1daeSBarry Smith    Input Parameters:
284*5c6c1daeSBarry Smith +  v - the viewer
285*5c6c1daeSBarry Smith -  viewer - visualization context
286*5c6c1daeSBarry Smith 
287*5c6c1daeSBarry Smith   Notes:
288*5c6c1daeSBarry Smith   The available visualization contexts include
289*5c6c1daeSBarry Smith +    PETSC_VIEWER_STDOUT_SELF - standard output (default)
290*5c6c1daeSBarry Smith .    PETSC_VIEWER_STDOUT_WORLD - synchronized standard
291*5c6c1daeSBarry Smith         output where only the first processor opens
292*5c6c1daeSBarry Smith         the file.  All other processors send their
293*5c6c1daeSBarry Smith         data to the first processor to print.
294*5c6c1daeSBarry Smith -     PETSC_VIEWER_DRAW_WORLD - graphical display of nonzero structure
295*5c6c1daeSBarry Smith 
296*5c6c1daeSBarry Smith    Level: beginner
297*5c6c1daeSBarry Smith 
298*5c6c1daeSBarry Smith .seealso: PetscViewerSetFormat(), PetscViewerASCIIOpen(), PetscViewerDrawOpen(),
299*5c6c1daeSBarry Smith           PetscViewerSocketOpen(), PetscViewerBinaryOpen(), PetscViewerLoad()
300*5c6c1daeSBarry Smith @*/
301*5c6c1daeSBarry Smith PetscErrorCode  PetscViewerView(PetscViewer v,PetscViewer viewer)
302*5c6c1daeSBarry Smith {
303*5c6c1daeSBarry Smith   PetscErrorCode    ierr;
304*5c6c1daeSBarry Smith   PetscBool         iascii;
305*5c6c1daeSBarry Smith   PetscViewerType   cstr;
306*5c6c1daeSBarry Smith   PetscViewerFormat format;
307*5c6c1daeSBarry Smith 
308*5c6c1daeSBarry Smith   PetscFunctionBegin;
309*5c6c1daeSBarry Smith   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
310*5c6c1daeSBarry Smith   PetscValidType(v,1);
311*5c6c1daeSBarry Smith   if (!viewer) {
312*5c6c1daeSBarry Smith     ierr = PetscViewerASCIIGetStdout(((PetscObject)v)->comm,&viewer);CHKERRQ(ierr);
313*5c6c1daeSBarry Smith   }
314*5c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2);
315*5c6c1daeSBarry Smith   PetscCheckSameComm(v,1,viewer,2);
316*5c6c1daeSBarry Smith 
317*5c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);CHKERRQ(ierr);
318*5c6c1daeSBarry Smith   if (iascii) {
319*5c6c1daeSBarry Smith     ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr);
320*5c6c1daeSBarry Smith     if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
321*5c6c1daeSBarry Smith       ierr = PetscObjectPrintClassNamePrefixType((PetscObject)v,viewer,"PetscViewer Object");CHKERRQ(ierr);
322*5c6c1daeSBarry Smith       ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
323*5c6c1daeSBarry Smith       ierr = PetscViewerGetType(v,&cstr);CHKERRQ(ierr);
324*5c6c1daeSBarry Smith       ierr = PetscViewerASCIIPrintf(viewer,"type=%s\n",cstr);CHKERRQ(ierr);
325*5c6c1daeSBarry Smith     }
326*5c6c1daeSBarry Smith   }
327*5c6c1daeSBarry Smith   if (!iascii) {
328*5c6c1daeSBarry Smith     SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"Viewer type %s not supported",((PetscObject)viewer)->type_name);
329*5c6c1daeSBarry Smith   } else {
330*5c6c1daeSBarry Smith     ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr);
331*5c6c1daeSBarry Smith     if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
332*5c6c1daeSBarry Smith       ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
333*5c6c1daeSBarry Smith     }
334*5c6c1daeSBarry Smith   }
335*5c6c1daeSBarry Smith   PetscFunctionReturn(0);
336*5c6c1daeSBarry Smith }
337