Actual source code: dlregispetsc.c

petsc-3.3-p7 2013-05-11
  2: #include <petscdraw.h>
  3: #include <petscsf.h>

  5: extern PetscLogEvent  PETSC_Barrier;

  7: static PetscBool  PetscSysPackageInitialized = PETSC_FALSE;
 10: /*@C
 11:   PetscSysFinalizePackage - This function destroys everything in the Petsc interface to Mathematica. It is
 12:   called from PetscFinalize().

 14:   Level: developer

 16: .keywords: Petsc, destroy, package, mathematica
 17: .seealso: PetscFinalize()
 18: @*/
 19: PetscErrorCode  PetscSysFinalizePackage(void)
 20: {
 22:   PetscSysPackageInitialized = PETSC_FALSE;
 23:   return(0);
 24: }

 28: /*@C
 29:   PetscSysInitializePackage - This function initializes everything in the main Petsc package. It is called
 30:   from PetscDLLibraryRegister() when using dynamic libraries, and on the call to PetscInitialize()
 31:   when using static libraries.

 33:   Input Parameter:
 34:   path - The dynamic library path, or PETSC_NULL

 36:   Level: developer

 38: .keywords: Petsc, initialize, package
 39: .seealso: PetscInitialize()
 40: @*/
 41: PetscErrorCode  PetscSysInitializePackage(const char path[])
 42: {
 43:   char              logList[256];
 44:   char              *className;
 45:   PetscBool         opt;
 46:   PetscErrorCode    ierr;

 49:   if (PetscSysPackageInitialized) return(0);
 50:   PetscSysPackageInitialized = PETSC_TRUE;
 51:   /* Register Classes */
 52:   PetscClassIdRegister("Object",&PETSC_OBJECT_CLASSID);
 53:   PetscClassIdRegister("Container",&PETSC_CONTAINER_CLASSID);

 55:   /* Register Events */
 56:   PetscLogEventRegister("PetscBarrier", PETSC_SMALLEST_CLASSID,&PETSC_Barrier);
 57:   /* Process info exclusions */
 58:   PetscOptionsGetString(PETSC_NULL, "-info_exclude", logList, 256, &opt);
 59:   if (opt) {
 60:     PetscStrstr(logList, "null", &className);
 61:     if (className) {
 62:       PetscInfoDeactivateClass(0);
 63:     }
 64:   }
 65:   /* Process summary exclusions */
 66:   PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);
 67:   if (opt) {
 68:     PetscStrstr(logList, "null", &className);
 69:     if (className) {
 70:       PetscLogEventDeactivateClass(0);
 71:     }
 72:   }
 73:   PetscRegisterFinalize(PetscSysFinalizePackage);
 74:   return(0);
 75: }

 77: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
 78: EXTERN_C_BEGIN

 80: #if defined(PETSC_USE_SINGLE_LIBRARY)
 81: extern PetscErrorCode PetscDLLibraryRegister_petscvec(const char[]);
 82: extern PetscErrorCode PetscDLLibraryRegister_petscmat(const char[]);
 83: extern PetscErrorCode PetscDLLibraryRegister_petscdm(const char[]);
 84: extern PetscErrorCode PetscDLLibraryRegister_petscksp(const char[]);
 85: extern PetscErrorCode PetscDLLibraryRegister_petscsnes(const char[]);
 86: extern PetscErrorCode PetscDLLibraryRegister_petscts(const char[]);
 87: #endif

 90: #if defined(PETSC_USE_SINGLE_LIBRARY)
 92: #else
 94: #endif
 95: /*
 96:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

 98:   This one registers all the draw and PetscViewer objects.

100:   Input Parameter:
101:   path - library path
102:  */
103: #if defined(PETSC_USE_SINGLE_LIBRARY)
104: PetscErrorCode  PetscDLLibraryRegister_petsc(const char path[])
105: #else
106: PetscErrorCode  PetscDLLibraryRegister_petscsys(const char path[])
107: #endif
108: {

112:   /*
113:       If we got here then PETSc was properly loaded
114:   */
115:   PetscSysInitializePackage(path);
116:   PetscShellInitializePackage(path);
117:   PetscDrawInitializePackage(path);
118:   PetscViewerInitializePackage(path);
119:   PetscRandomInitializePackage(path);
120:   PetscSFInitializePackage(path);

122: #if defined(PETSC_USE_SINGLE_LIBRARY)
123:   PetscDLLibraryRegister_petscvec(path);
124:   PetscDLLibraryRegister_petscmat(path);
125:   PetscDLLibraryRegister_petscdm(path);
126:   PetscDLLibraryRegister_petscksp(path);
127:   PetscDLLibraryRegister_petscsnes(path);
128:   PetscDLLibraryRegister_petscts(path);
129: #endif
130:   return(0);
131: }
132: EXTERN_C_END
133: #endif