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