Actual source code: amsopen.c

petsc-3.7.7 2017-09-25
Report Typos and Errors
  2: #include <petsc/private/viewerimpl.h>   /*I  "petscsys.h"  */
  3: #include <petscviewersaws.h>

  7: /*@C
  8:     PetscViewerSAWsOpen - Opens an SAWs PetscViewer.

 10:     Collective on MPI_Comm

 12:     Input Parameters:
 13: .   comm - the MPI communicator

 15:     Output Parameter:
 16: .   lab - the PetscViewer

 18:     Options Database Keys:
 19: +   -saws_port <port number> - port number where you are running SAWs client
 20: .   -xxx_view saws - publish the object xxx
 21: -   -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
 22:                     the user unblocks the problem with an external tool that access the object with SAWS

 24:     Level: advanced

 26:     Fortran Note:
 27:     This routine is not supported in Fortran.


 30:     Notes:
 31:     Unlike other viewers that only access the object being viewed on the call to XXXView(object,viewer) the SAWs viewer allows
 32:     one to view the object asynchronously as the program continues to run. One can remove SAWs access to the object with a call to
 33:     PetscObjectSAWsViewOff().

 35:     Information about the SAWs is available via http://bitbucket.org/saws/saws

 37: .seealso: PetscViewerDestroy(), PetscViewerStringSPrintf(), PETSC_VIEWER_SAWS_(), PetscObjectSAWsBlock(),
 38:           PetscObjectSAWsViewOff(), PetscObjectSAWsTakeAccess(), PetscObjectSAWsGrantAccess()

 40: @*/
 41: PetscErrorCode PetscViewerSAWsOpen(MPI_Comm comm,PetscViewer *lab)
 42: {

 46:   PetscViewerCreate(comm,lab);
 47:   PetscViewerSetType(*lab,PETSCVIEWERSAWS);
 48:   return(0);
 49: }

 53: /*@C
 54:    PetscObjectViewSAWs - View the base portion of any object with an SAWs viewer

 56:    Collective on PetscObject

 58:    Input Parameters:
 59: +  obj - the Petsc variable
 60:          Thus must be cast with a (PetscObject), for example,
 61:          PetscObjectSetName((PetscObject)mat,name);
 62: -  viewer - the SAWs viewer

 64:    Level: advanced

 66:    Concepts: publishing object

 68:    Developer Note: Currently this is called only on rank zero of PETSC_COMM_WORLD

 70:    The object must have already been named before calling this routine since naming an
 71:    object can be collective.


 74: .seealso: PetscObjectSetName(), PetscObjectSAWsViewOff()

 76: @*/
 77: PetscErrorCode  PetscObjectViewSAWs(PetscObject obj,PetscViewer viewer)
 78: {
 80:   char           dir[1024];
 81:   PetscMPIInt    rank;

 85:   if (obj->amsmem) return(0);
 86:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
 87:   if (rank) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Should only be being called on rank zero");
 88:   if (!obj->name) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Object must already have been named");

 90:   obj->amsmem = PETSC_TRUE;
 91:   PetscSNPrintf(dir,1024,"/PETSc/Objects/%s/Class",obj->name);
 92:   PetscStackCallSAWs(SAWs_Register,(dir,&obj->class_name,1,SAWs_READ,SAWs_STRING));
 93:   PetscSNPrintf(dir,1024,"/PETSc/Objects/%s/Type",obj->name);
 94:   PetscStackCallSAWs(SAWs_Register,(dir,&obj->type_name,1,SAWs_READ,SAWs_STRING));
 95:   PetscSNPrintf(dir,1024,"/PETSc/Objects/%s/__Id",obj->name);
 96:   PetscStackCallSAWs(SAWs_Register,(dir,&obj->id,1,SAWs_READ,SAWs_INT));
 97:   PetscSNPrintf(dir,1024,"/PETSc/Objects/%s/__ParentID",obj->name);
 98:   PetscStackCallSAWs(SAWs_Register,(dir,&obj->parentid,1,SAWs_READ,SAWs_INT));
 99:   return(0);
100: }