xref: /petsc/include/petscviewer.h (revision 2bf49c77dedd4b28e6efd10dcebd37482390fa09)
1 /*
2      PetscViewers are objects where other objects can be looked at or stored.
3 */
4 
5 #if !defined(__PETSCVIEWER_H)
6 #define __PETSCVIEWER_H
7 
8 #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
9 extern "C" {
10 #endif
11 
12 /*S
13      PetscViewer - Abstract PETSc object that helps view (in ASCII, binary, graphically etc)
14          other PETSc objects
15 
16    Level: beginner
17 
18   Concepts: viewing
19 
20 .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType
21 S*/
22 typedef struct _p_PetscViewer* PetscViewer;
23 
24 #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
25 }
26 #endif
27 
28 #include <petscsys.h>
29 
30 PETSC_EXTERN PetscClassId PETSC_VIEWER_CLASSID;
31 
32 /*
33     petscsys.h must be included AFTER the definition of PetscViewer for ADIC to
34    process correctly.
35 */
36 /*J
37     PetscViewerType - String with the name of a PETSc PETScViewer
38 
39    Level: beginner
40 
41 .seealso: PetscViewerSetType(), PetscViewer
42 J*/
43 typedef const char* PetscViewerType;
44 #define PETSCVIEWERSOCKET       "socket"
45 #define PETSCVIEWERASCII        "ascii"
46 #define PETSCVIEWERBINARY       "binary"
47 #define PETSCVIEWERSTRING       "string"
48 #define PETSCVIEWERDRAW         "draw"
49 #define PETSCVIEWERVU           "vu"
50 #define PETSCVIEWERMATHEMATICA  "mathematica"
51 #define PETSCVIEWERNETCDF       "netcdf"
52 #define PETSCVIEWERHDF5         "hdf5"
53 #define PETSCVIEWERVTK          "vtk"
54 #define PETSCVIEWERMATLAB       "matlab"
55 #define PETSCVIEWERAMS          "ams"
56 
57 PETSC_EXTERN PetscFList PetscViewerList;
58 PETSC_EXTERN PetscErrorCode PetscViewerRegisterAll(const char *);
59 PETSC_EXTERN PetscErrorCode PetscViewerRegisterDestroy(void);
60 PETSC_EXTERN PetscErrorCode PetscViewerInitializePackage(const char[]);
61 
62 PETSC_EXTERN PetscErrorCode PetscViewerRegister(const char*,const char*,const char*,PetscErrorCode (*)(PetscViewer));
63 
64 /*MC
65    PetscViewerRegisterDynamic - Adds a viewer
66 
67    Synopsis:
68    PetscErrorCode PetscViewerRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(PetscViewer))
69 
70    Not Collective
71 
72    Input Parameters:
73 +  name_solver - name of a new user-defined viewer
74 .  path - path (either absolute or relative) the library containing this viewer
75 .  name_create - name of routine to create method context
76 -  routine_create - routine to create method context
77 
78    Level: developer
79 
80    Notes:
81    PetscViewerRegisterDynamic() may be called multiple times to add several user-defined viewers.
82 
83    If dynamic libraries are used, then the fourth input argument (routine_create)
84    is ignored.
85 
86    Sample usage:
87 .vb
88    PetscViewerRegisterDynamic("my_viewer_type",/home/username/my_lib/lib/libO/solaris/mylib.a,
89                "MyViewerCreate",MyViewerCreate);
90 .ve
91 
92    Then, your solver can be chosen with the procedural interface via
93 $     PetscViewerSetType(viewer,"my_viewer_type")
94    or at runtime via the option
95 $     -viewer_type my_viewer_type
96 
97   Concepts: registering^Viewers
98 
99 .seealso: PetscViewerRegisterAll(), PetscViewerRegisterDestroy()
100 M*/
101 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
102 #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,0)
103 #else
104 #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,d)
105 #endif
106 
107 PETSC_EXTERN PetscErrorCode PetscViewerCreate(MPI_Comm,PetscViewer*);
108 PETSC_EXTERN PetscErrorCode PetscViewerSetFromOptions(PetscViewer);
109 PETSC_EXTERN PetscErrorCode PetscViewerASCIIOpenWithFILE(MPI_Comm,FILE*,PetscViewer*);
110 
111 PETSC_EXTERN PetscErrorCode PetscViewerASCIIOpen(MPI_Comm,const char[],PetscViewer*);
112 PETSC_EXTERN PetscErrorCode PetscViewerASCIISetFILE(PetscViewer,FILE*);
113 PETSC_EXTERN PetscErrorCode PetscViewerBinaryOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
114 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetFlowControl(PetscViewer,PetscInt*);
115 PETSC_EXTERN PetscErrorCode PetscViewerBinarySetFlowControl(PetscViewer,PetscInt);
116 PETSC_EXTERN PetscErrorCode PetscViewerBinarySetMPIIO(PetscViewer);
117 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIO(PetscViewer,PetscBool *);
118 #if defined(PETSC_HAVE_MPIIO)
119 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIODescriptor(PetscViewer,MPI_File*);
120 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIOOffset(PetscViewer,MPI_Offset*);
121 PETSC_EXTERN PetscErrorCode PetscViewerBinaryAddMPIIOOffset(PetscViewer,MPI_Offset);
122 #endif
123 
124 PETSC_EXTERN PetscErrorCode PetscViewerSocketOpen(MPI_Comm,const char[],int,PetscViewer*);
125 PETSC_EXTERN PetscErrorCode PetscViewerStringOpen(MPI_Comm,char[],PetscInt,PetscViewer*);
126 PETSC_EXTERN PetscErrorCode PetscViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,PetscViewer*);
127 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaOpen(MPI_Comm, int, const char[], const char[], PetscViewer *);
128 PETSC_EXTERN PetscErrorCode PetscViewerSiloOpen(MPI_Comm, const char[], PetscViewer *);
129 PETSC_EXTERN PetscErrorCode PetscViewerMatlabOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
130 
131 PETSC_EXTERN PetscErrorCode PetscViewerGetType(PetscViewer,PetscViewerType*);
132 PETSC_EXTERN PetscErrorCode PetscViewerSetType(PetscViewer,PetscViewerType);
133 PETSC_EXTERN PetscErrorCode PetscViewerDestroy(PetscViewer*);
134 PETSC_EXTERN PetscErrorCode PetscViewerGetSingleton(PetscViewer,PetscViewer*);
135 PETSC_EXTERN PetscErrorCode PetscViewerRestoreSingleton(PetscViewer,PetscViewer*);
136 PETSC_EXTERN PetscErrorCode PetscViewerGetSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
137 PETSC_EXTERN PetscErrorCode PetscViewerRestoreSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
138 
139 PETSC_EXTERN PetscErrorCode PetscViewerSetUp(PetscViewer);
140 PETSC_EXTERN PetscErrorCode PetscViewerView(PetscViewer,PetscViewer);
141 
142 PETSC_EXTERN PetscErrorCode PetscViewerSetOptionsPrefix(PetscViewer,const char[]);
143 PETSC_EXTERN PetscErrorCode PetscViewerAppendOptionsPrefix(PetscViewer,const char[]);
144 PETSC_EXTERN PetscErrorCode PetscViewerGetOptionsPrefix(PetscViewer,const char*[]);
145 
146 /*E
147     PetscViewerFormat - Way a viewer presents the object
148 
149    Level: beginner
150 
151    The values below are also listed in finclude/petscviewer.h. If another values is added below it
152    must also be added there.
153 
154 .seealso: PetscViewerSetFormat(), PetscViewer, PetscViewerType, PetscViewerPushFormat(), PetscViewerPopFormat()
155 E*/
156 typedef enum {
157   PETSC_VIEWER_DEFAULT,
158   PETSC_VIEWER_ASCII_MATLAB,
159   PETSC_VIEWER_ASCII_MATHEMATICA,
160   PETSC_VIEWER_ASCII_IMPL,
161   PETSC_VIEWER_ASCII_INFO,
162   PETSC_VIEWER_ASCII_INFO_DETAIL,
163   PETSC_VIEWER_ASCII_COMMON,
164   PETSC_VIEWER_ASCII_SYMMODU,
165   PETSC_VIEWER_ASCII_INDEX,
166   PETSC_VIEWER_ASCII_DENSE,
167   PETSC_VIEWER_ASCII_MATRIXMARKET,
168   PETSC_VIEWER_ASCII_VTK,
169   PETSC_VIEWER_ASCII_VTK_CELL,
170   PETSC_VIEWER_ASCII_VTK_COORDS,
171   PETSC_VIEWER_ASCII_PCICE,
172   PETSC_VIEWER_ASCII_PYTHON,
173   PETSC_VIEWER_ASCII_FACTOR_INFO,
174   PETSC_VIEWER_ASCII_LATEX,
175   PETSC_VIEWER_DRAW_BASIC,
176   PETSC_VIEWER_DRAW_LG,
177   PETSC_VIEWER_DRAW_CONTOUR,
178   PETSC_VIEWER_DRAW_PORTS,
179   PETSC_VIEWER_VTK_VTS,
180   PETSC_VIEWER_VTK_VTU,
181   PETSC_VIEWER_NATIVE,
182   PETSC_VIEWER_NOFORMAT
183   } PetscViewerFormat;
184 PETSC_EXTERN const char *const PetscViewerFormats[];
185 
186 PETSC_EXTERN PetscErrorCode PetscViewerSetFormat(PetscViewer,PetscViewerFormat);
187 PETSC_EXTERN PetscErrorCode PetscViewerPushFormat(PetscViewer,PetscViewerFormat);
188 PETSC_EXTERN PetscErrorCode PetscViewerPopFormat(PetscViewer);
189 PETSC_EXTERN PetscErrorCode PetscViewerGetFormat(PetscViewer,PetscViewerFormat*);
190 PETSC_EXTERN PetscErrorCode PetscViewerFlush(PetscViewer);
191 
192 PETSC_EXTERN PetscErrorCode PetscOptionsGetViewer(MPI_Comm,const char[],const char[],PetscViewer*,PetscBool*);
193 PETSC_EXTERN PetscErrorCode PetscOptionsRestoreViewer(PetscViewer);
194 
195 /*
196    Operations explicit to a particular class of viewers
197 */
198 
199 PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetPointer(PetscViewer,FILE**);
200 PETSC_EXTERN PetscErrorCode PetscViewerFileGetMode(PetscViewer,PetscFileMode*);
201 PETSC_EXTERN PetscErrorCode PetscViewerFileSetMode(PetscViewer,PetscFileMode);
202 PETSC_EXTERN PetscErrorCode PetscViewerASCIIPrintf(PetscViewer,const char[],...);
203 PETSC_EXTERN PetscErrorCode PetscViewerASCIISynchronizedPrintf(PetscViewer,const char[],...);
204 PETSC_EXTERN PetscErrorCode PetscViewerASCIISynchronizedAllow(PetscViewer,PetscBool);
205 PETSC_EXTERN PetscErrorCode PetscViewerASCIIPushTab(PetscViewer);
206 PETSC_EXTERN PetscErrorCode PetscViewerASCIIPopTab(PetscViewer);
207 PETSC_EXTERN PetscErrorCode PetscViewerASCIIUseTabs(PetscViewer,PetscBool );
208 PETSC_EXTERN PetscErrorCode PetscViewerASCIISetTab(PetscViewer,PetscInt);
209 PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetTab(PetscViewer,PetscInt*);
210 PETSC_EXTERN PetscErrorCode PetscViewerASCIIAddTab(PetscViewer,PetscInt);
211 PETSC_EXTERN PetscErrorCode PetscViewerASCIISubtractTab(PetscViewer,PetscInt);
212 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetDescriptor(PetscViewer,int*);
213 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetInfoPointer(PetscViewer,FILE **);
214 PETSC_EXTERN PetscErrorCode PetscViewerBinaryRead(PetscViewer,void*,PetscInt,PetscDataType);
215 PETSC_EXTERN PetscErrorCode PetscViewerBinaryWrite(PetscViewer,void*,PetscInt,PetscDataType,PetscBool );
216 PETSC_EXTERN PetscErrorCode PetscViewerStringSPrintf(PetscViewer,const char[],...);
217 PETSC_EXTERN PetscErrorCode PetscViewerStringSetString(PetscViewer,char[],PetscInt);
218 PETSC_EXTERN PetscErrorCode PetscViewerDrawClear(PetscViewer);
219 PETSC_EXTERN PetscErrorCode PetscViewerDrawSetHold(PetscViewer,PetscBool);
220 PETSC_EXTERN PetscErrorCode PetscViewerDrawGetHold(PetscViewer,PetscBool*);
221 PETSC_EXTERN PetscErrorCode PetscViewerDrawSetPause(PetscViewer,PetscReal);
222 PETSC_EXTERN PetscErrorCode PetscViewerDrawGetPause(PetscViewer,PetscReal*);
223 PETSC_EXTERN PetscErrorCode PetscViewerDrawSetInfo(PetscViewer,const char[],const char[],int,int,int,int);
224 PETSC_EXTERN PetscErrorCode PetscViewerDrawResize(PetscViewer,int,int);
225 PETSC_EXTERN PetscErrorCode PetscViewerDrawSetBounds(PetscViewer,PetscInt,const PetscReal*);
226 PETSC_EXTERN PetscErrorCode PetscViewerDrawGetBounds(PetscViewer,PetscInt*,const PetscReal**);
227 PETSC_EXTERN PetscErrorCode PetscViewerSocketSetConnection(PetscViewer,const char[],int);
228 PETSC_EXTERN PetscErrorCode PetscViewerBinarySkipInfo(PetscViewer);
229 PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipOptions(PetscViewer,PetscBool );
230 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipOptions(PetscViewer,PetscBool *);
231 PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipHeader(PetscViewer,PetscBool);
232 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipHeader(PetscViewer,PetscBool*);
233 PETSC_EXTERN PetscErrorCode PetscViewerBinaryReadStringArray(PetscViewer,char***);
234 PETSC_EXTERN PetscErrorCode PetscViewerBinaryWriteStringArray(PetscViewer,char**);
235 
236 PETSC_EXTERN PetscErrorCode PetscViewerFileSetName(PetscViewer,const char[]);
237 PETSC_EXTERN PetscErrorCode PetscViewerFileGetName(PetscViewer,const char**);
238 
239 PETSC_EXTERN PetscErrorCode PetscViewerVUGetPointer(PetscViewer, FILE**);
240 PETSC_EXTERN PetscErrorCode PetscViewerVUSetVecSeen(PetscViewer, PetscBool );
241 PETSC_EXTERN PetscErrorCode PetscViewerVUGetVecSeen(PetscViewer, PetscBool  *);
242 PETSC_EXTERN PetscErrorCode PetscViewerVUPrintDeferred(PetscViewer, const char [], ...);
243 PETSC_EXTERN PetscErrorCode PetscViewerVUFlushDeferred(PetscViewer);
244 
245 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaInitializePackage(const char[]);
246 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaFinalizePackage(void);
247 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetName(PetscViewer, const char **);
248 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaSetName(PetscViewer, const char []);
249 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaClearName(PetscViewer);
250 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaSkipPackets(PetscViewer, int);
251 
252 PETSC_EXTERN PetscErrorCode PetscViewerSiloGetName(PetscViewer, char **);
253 PETSC_EXTERN PetscErrorCode PetscViewerSiloSetName(PetscViewer, const char []);
254 PETSC_EXTERN PetscErrorCode PetscViewerSiloClearName(PetscViewer);
255 PETSC_EXTERN PetscErrorCode PetscViewerSiloGetMeshName(PetscViewer, char **);
256 PETSC_EXTERN PetscErrorCode PetscViewerSiloSetMeshName(PetscViewer, const char []);
257 PETSC_EXTERN PetscErrorCode PetscViewerSiloClearMeshName(PetscViewer);
258 
259 PETSC_EXTERN PetscErrorCode PetscViewerNetcdfOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
260 PETSC_EXTERN PetscErrorCode PetscViewerNetcdfGetID(PetscViewer, int *);
261 
262 PETSC_EXTERN PetscErrorCode PetscViewerHDF5WriteSDS(PetscViewer,float *,int,int *,int);
263 
264 PETSC_EXTERN PetscErrorCode PetscViewerHDF5Open(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
265 PETSC_EXTERN PetscErrorCode PetscViewerHDF5PushGroup(PetscViewer,const char *);
266 PETSC_EXTERN PetscErrorCode PetscViewerHDF5PopGroup(PetscViewer);
267 PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetGroup(PetscViewer, const char **);
268 PETSC_EXTERN PetscErrorCode PetscViewerHDF5IncrementTimestep(PetscViewer);
269 PETSC_EXTERN PetscErrorCode PetscViewerHDF5SetTimestep(PetscViewer,PetscInt);
270 PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetTimestep(PetscViewer,PetscInt*);
271 #ifdef PETSC_HAVE_HDF5
272 #include <hdf5.h>
273 PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetFileId(PetscViewer,hid_t*);
274 PETSC_EXTERN PetscErrorCode PetscViewerHDF5OpenGroup(PetscViewer, hid_t *, hid_t *);
275 #endif
276 
277 typedef enum {PETSC_VTK_POINT_FIELD, PETSC_VTK_POINT_VECTOR_FIELD, PETSC_VTK_CELL_FIELD, PETSC_VTK_CELL_VECTOR_FIELD} PetscViewerVTKFieldType;
278 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*PetscViewerVTKWriteFunction)(PetscObject,PetscViewer);
279 PETSC_EXTERN PetscErrorCode PetscViewerVTKAddField(PetscViewer,PetscObject,PetscViewerVTKWriteFunction,PetscViewerVTKFieldType,PetscObject);
280 PETSC_EXTERN PetscErrorCode PetscViewerVTKOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
281 
282 /*
283      These are all the default viewers that do not have
284    to be explicitly opened
285 */
286 PETSC_EXTERN PetscViewer    PETSC_VIEWER_STDOUT_(MPI_Comm);
287 PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetStdout(MPI_Comm,PetscViewer*);
288 PETSC_EXTERN PetscViewer    PETSC_VIEWER_STDERR_(MPI_Comm);
289 PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetStderr(MPI_Comm,PetscViewer*);
290 PETSC_EXTERN PetscViewer    PETSC_VIEWER_DRAW_(MPI_Comm);
291 PETSC_EXTERN PetscViewer    PETSC_VIEWER_SOCKET_(MPI_Comm);
292 PETSC_EXTERN PetscViewer    PETSC_VIEWER_BINARY_(MPI_Comm);
293 PETSC_EXTERN PetscViewer    PETSC_VIEWER_MATLAB_(MPI_Comm);
294 PETSC_EXTERN PetscViewer   PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE;
295 
296 #define PETSC_VIEWER_STDERR_SELF  PETSC_VIEWER_STDERR_(PETSC_COMM_SELF)
297 #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD)
298 
299 /*MC
300   PETSC_VIEWER_STDOUT_WORLD  - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
301 
302   Level: beginner
303 M*/
304 #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)
305 
306 /*MC
307   PETSC_VIEWER_STDOUT_SELF  - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
308 
309   Level: beginner
310 M*/
311 #define PETSC_VIEWER_STDOUT_SELF  PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)
312 
313 /*MC
314   PETSC_VIEWER_DRAW_WORLD  - same as PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
315 
316   Level: intermediate
317 M*/
318 #define PETSC_VIEWER_DRAW_WORLD   PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)
319 
320 /*MC
321   PETSC_VIEWER_DRAW_SELF  - same as PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
322 
323   Level: intermediate
324 M*/
325 #define PETSC_VIEWER_DRAW_SELF    PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)
326 
327 /*MC
328   PETSC_VIEWER_SOCKET_WORLD  - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
329 
330   Level: intermediate
331 M*/
332 #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)
333 
334 /*MC
335   PETSC_VIEWER_SOCKET_SELF  - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
336 
337   Level: intermediate
338 M*/
339 #define PETSC_VIEWER_SOCKET_SELF  PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)
340 
341 /*MC
342   PETSC_VIEWER_BINARY_WORLD  - same as PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
343 
344   Level: intermediate
345 M*/
346 #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)
347 
348 /*MC
349   PETSC_VIEWER_BINARY_SELF  - same as PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
350 
351   Level: intermediate
352 M*/
353 #define PETSC_VIEWER_BINARY_SELF  PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)
354 
355 /*MC
356   PETSC_VIEWER_MATLAB_WORLD  - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)
357 
358   Level: intermediate
359 M*/
360 #define PETSC_VIEWER_MATLAB_WORLD PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)
361 
362 /*MC
363   PETSC_VIEWER_MATLAB_SELF  - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)
364 
365   Level: intermediate
366 M*/
367 #define PETSC_VIEWER_MATLAB_SELF  PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)
368 
369 #define PETSC_VIEWER_MATHEMATICA_WORLD (PetscViewerInitializeMathematicaWorld_Private(),PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE)
370 
371 #define PetscViewerFlowControlStart(viewer,mcnt,cnt)  (PetscViewerBinaryGetFlowControl(viewer,mcnt) || PetscViewerBinaryGetFlowControl(viewer,cnt))
372 #define PetscViewerFlowControlStepMaster(viewer,i,mcnt,cnt) ((i >= mcnt) ?  (mcnt += cnt,MPI_Bcast(&mcnt,1,MPIU_INT,0,((PetscObject)viewer)->comm)) : 0)
373 #define PetscViewerFlowControlEndMaster(viewer,mcnt) (mcnt = 0,MPI_Bcast(&mcnt,1,MPIU_INT,0,((PetscObject)viewer)->comm))
374 #define PetscViewerFlowControlStepWorker(viewer,rank,mcnt) 0; while (1) { PetscErrorCode _ierr; \
375     if (rank < mcnt) break;				\
376   _ierr = MPI_Bcast(&mcnt,1,MPIU_INT,0,((PetscObject)viewer)->comm);CHKERRQ(_ierr);\
377   }
378 #define PetscViewerFlowControlEndWorker(viewer,mcnt) 0; while (1) { PetscErrorCode _ierr; \
379   _ierr = MPI_Bcast(&mcnt,1,MPIU_INT,0,((PetscObject)viewer)->comm);CHKERRQ(_ierr);\
380     if (mcnt == 0) break;				\
381   }
382 
383 /*
384    PetscViewer writes to MATLAB .mat file
385 */
386 PETSC_EXTERN PetscErrorCode PetscViewerMatlabPutArray(PetscViewer,int,int,const PetscScalar*,const char*);
387 PETSC_EXTERN PetscErrorCode PetscViewerMatlabGetArray(PetscViewer,int,int,PetscScalar*,const char*);
388 PETSC_EXTERN PetscErrorCode PetscViewerMatlabPutVariable(PetscViewer,const char*,void*);
389 
390 /*S
391      PetscViewers - Abstract collection of PetscViewers. It is just an expandable array of viewers.
392 
393    Level: intermediate
394 
395   Concepts: viewing
396 
397 .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(),
398            PetscViewersGetViewer()
399 S*/
400 typedef struct _n_PetscViewers* PetscViewers;
401 PETSC_EXTERN PetscErrorCode PetscViewersCreate(MPI_Comm,PetscViewers*);
402 PETSC_EXTERN PetscErrorCode PetscViewersDestroy(PetscViewers*);
403 PETSC_EXTERN PetscErrorCode PetscViewersGetViewer(PetscViewers,PetscInt,PetscViewer*);
404 
405 #if defined(PETSC_HAVE_AMS)
406 #include <ams.h>
407 PETSC_EXTERN PetscErrorCode PetscViewerAMSSetCommName(PetscViewer,const char[]);
408 PETSC_EXTERN PetscErrorCode PetscViewerAMSGetAMSComm(PetscViewer,AMS_Comm *);
409 PETSC_EXTERN PetscErrorCode PetscViewerAMSOpen(MPI_Comm,const char[],PetscViewer*);
410 PETSC_EXTERN PetscErrorCode PetscViewerAMSLock(PetscViewer);
411 PETSC_EXTERN PetscViewer    PETSC_VIEWER_AMS_(MPI_Comm);
412 PETSC_EXTERN PetscErrorCode PETSC_VIEWER_AMS_Destroy(MPI_Comm);
413 #define PETSC_VIEWER_AMS_WORLD PETSC_VIEWER_AMS_(PETSC_COMM_WORLD)
414 #endif
415 
416 #endif
417