Actual source code: amsopen.c
petsc-3.9.4 2018-09-11
2: #include <petsc/private/viewerimpl.h>
3: #include <petscviewersaws.h>
5: /*@C
6: PetscViewerSAWsOpen - Opens an SAWs PetscViewer.
8: Collective on MPI_Comm
10: Input Parameters:
11: . comm - the MPI communicator
13: Output Parameter:
14: . lab - the PetscViewer
16: Options Database Keys:
17: + -saws_port <port number> - port number where you are running SAWs client
18: . -xxx_view saws - publish the object xxx
19: - -xxx_saws_block - blocks the program at the end of a critical point (for KSP and SNES it is the end of a solve) until
20: the user unblocks the problem with an external tool that access the object with SAWS
22: Level: advanced
24: Fortran Note:
25: This routine is not supported in Fortran.
28: Notes:
29: Unlike other viewers that only access the object being viewed on the call to XXXView(object,viewer) the SAWs viewer allows
30: one to view the object asynchronously as the program continues to run. One can remove SAWs access to the object with a call to
31: PetscObjectSAWsViewOff().
33: Information about the SAWs is available via http://bitbucket.org/saws/saws
35: .seealso: PetscViewerDestroy(), PetscViewerStringSPrintf(), PETSC_VIEWER_SAWS_(), PetscObjectSAWsBlock(),
36: PetscObjectSAWsViewOff(), PetscObjectSAWsTakeAccess(), PetscObjectSAWsGrantAccess()
38: @*/
39: PetscErrorCode PetscViewerSAWsOpen(MPI_Comm comm,PetscViewer *lab)
40: {
44: PetscViewerCreate(comm,lab);
45: PetscViewerSetType(*lab,PETSCVIEWERSAWS);
46: return(0);
47: }
49: /*@C
50: PetscObjectViewSAWs - View the base portion of any object with an SAWs viewer
52: Collective on PetscObject
54: Input Parameters:
55: + obj - the Petsc variable
56: Thus must be cast with a (PetscObject), for example,
57: PetscObjectSetName((PetscObject)mat,name);
58: - viewer - the SAWs viewer
60: Level: advanced
62: Concepts: publishing object
64: Developer Note: Currently this is called only on rank zero of PETSC_COMM_WORLD
66: The object must have already been named before calling this routine since naming an
67: object can be collective.
70: .seealso: PetscObjectSetName(), PetscObjectSAWsViewOff()
72: @*/
73: PetscErrorCode PetscObjectViewSAWs(PetscObject obj,PetscViewer viewer)
74: {
76: char dir[1024];
77: PetscMPIInt rank;
81: if (obj->amsmem) return(0);
82: MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
83: if (rank) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Should only be being called on rank zero");
84: if (!obj->name) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Object must already have been named");
86: obj->amsmem = PETSC_TRUE;
87: PetscSNPrintf(dir,1024,"/PETSc/Objects/%s/Class",obj->name);
88: PetscStackCallSAWs(SAWs_Register,(dir,&obj->class_name,1,SAWs_READ,SAWs_STRING));
89: PetscSNPrintf(dir,1024,"/PETSc/Objects/%s/Type",obj->name);
90: PetscStackCallSAWs(SAWs_Register,(dir,&obj->type_name,1,SAWs_READ,SAWs_STRING));
91: PetscSNPrintf(dir,1024,"/PETSc/Objects/%s/__Id",obj->name);
92: PetscStackCallSAWs(SAWs_Register,(dir,&obj->id,1,SAWs_READ,SAWs_INT));
93: PetscSNPrintf(dir,1024,"/PETSc/Objects/%s/__ParentID",obj->name);
94: PetscStackCallSAWs(SAWs_Register,(dir,&obj->parentid,1,SAWs_READ,SAWs_INT));
95: return(0);
96: }