15c6c1daeSBarry Smith 25c6c1daeSBarry Smith #include <petscdraw.h> 32c1a2d08SJed Brown #include <petscviewer.h> 4*974a8051SSatish Balay #include <petsc/private/viewerimpl.h> 55c6c1daeSBarry Smith 627a32ea5SJed Brown extern PetscLogEvent PETSC_Barrier,PETSC_BuildTwoSided,PETSC_BuildTwoSidedF; 75c6c1daeSBarry Smith static PetscBool PetscSysPackageInitialized = PETSC_FALSE; 8d4c7638eSBarry Smith 95c6c1daeSBarry Smith /*@C 10d4c7638eSBarry Smith PetscSysFinalizePackage - This function destroys everything in the PETSc created internally in the system library portion of PETSc. 11d4c7638eSBarry Smith It is called from PetscFinalize(). 125c6c1daeSBarry Smith 135c6c1daeSBarry Smith Level: developer 145c6c1daeSBarry Smith 15d4c7638eSBarry Smith .keywords: Petsc, destroy, package 165c6c1daeSBarry Smith .seealso: PetscFinalize() 175c6c1daeSBarry Smith @*/ 185c6c1daeSBarry Smith PetscErrorCode PetscSysFinalizePackage(void) 195c6c1daeSBarry Smith { 20d4c7638eSBarry Smith PetscErrorCode ierr; 21d4c7638eSBarry Smith 225c6c1daeSBarry Smith PetscFunctionBegin; 23d4c7638eSBarry Smith if (Petsc_Viewer_keyval != MPI_KEYVAL_INVALID) { 24d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_keyval);CHKERRQ(ierr); 25d4c7638eSBarry Smith } 26d4c7638eSBarry Smith if (Petsc_Viewer_Stdout_keyval != MPI_KEYVAL_INVALID) { 27d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_Stdout_keyval);CHKERRQ(ierr); 28d4c7638eSBarry Smith } 29d4c7638eSBarry Smith if (Petsc_Viewer_Stderr_keyval != MPI_KEYVAL_INVALID) { 30d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_Stderr_keyval);CHKERRQ(ierr); 31d4c7638eSBarry Smith } 32d4c7638eSBarry Smith if (Petsc_Viewer_Binary_keyval != MPI_KEYVAL_INVALID) { 33d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_Binary_keyval);CHKERRQ(ierr); 34d4c7638eSBarry Smith } 35d4c7638eSBarry Smith if (Petsc_Viewer_Draw_keyval != MPI_KEYVAL_INVALID) { 36d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_Draw_keyval);CHKERRQ(ierr); 37d4c7638eSBarry Smith } 38d4c7638eSBarry Smith #if defined(PETSC_HAVE_HDF5) 39d4c7638eSBarry Smith if (Petsc_Viewer_HDF5_keyval != MPI_KEYVAL_INVALID) { 40d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_HDF5_keyval);CHKERRQ(ierr); 41d4c7638eSBarry Smith } 42d4c7638eSBarry Smith #endif 43d4c7638eSBarry Smith #if defined(PETSC_USE_SOCKETVIEWER) 44d4c7638eSBarry Smith if (Petsc_Viewer_Socket_keyval != MPI_KEYVAL_INVALID) { 45d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_Socket_keyval);CHKERRQ(ierr); 46d4c7638eSBarry Smith } 47d4c7638eSBarry Smith #endif 485c6c1daeSBarry Smith PetscSysPackageInitialized = PETSC_FALSE; 495c6c1daeSBarry Smith PetscFunctionReturn(0); 505c6c1daeSBarry Smith } 515c6c1daeSBarry Smith 525c6c1daeSBarry Smith /*@C 535c6c1daeSBarry Smith PetscSysInitializePackage - This function initializes everything in the main Petsc package. It is called 545c6c1daeSBarry Smith from PetscDLLibraryRegister() when using dynamic libraries, and on the call to PetscInitialize() 555c6c1daeSBarry Smith when using static libraries. 565c6c1daeSBarry Smith 575c6c1daeSBarry Smith Level: developer 585c6c1daeSBarry Smith 595c6c1daeSBarry Smith .keywords: Petsc, initialize, package 605c6c1daeSBarry Smith .seealso: PetscInitialize() 615c6c1daeSBarry Smith @*/ 62607a6623SBarry Smith PetscErrorCode PetscSysInitializePackage(void) 635c6c1daeSBarry Smith { 645c6c1daeSBarry Smith char logList[256]; 655c6c1daeSBarry Smith char *className; 665c6c1daeSBarry Smith PetscBool opt; 675c6c1daeSBarry Smith PetscErrorCode ierr; 685c6c1daeSBarry Smith 695c6c1daeSBarry Smith PetscFunctionBegin; 705c6c1daeSBarry Smith if (PetscSysPackageInitialized) PetscFunctionReturn(0); 715c6c1daeSBarry Smith PetscSysPackageInitialized = PETSC_TRUE; 725c6c1daeSBarry Smith /* Register Classes */ 735c6c1daeSBarry Smith ierr = PetscClassIdRegister("Object",&PETSC_OBJECT_CLASSID);CHKERRQ(ierr); 745c6c1daeSBarry Smith ierr = PetscClassIdRegister("Container",&PETSC_CONTAINER_CLASSID);CHKERRQ(ierr); 755c6c1daeSBarry Smith 765c6c1daeSBarry Smith /* Register Events */ 775c6c1daeSBarry Smith ierr = PetscLogEventRegister("PetscBarrier", PETSC_SMALLEST_CLASSID,&PETSC_Barrier);CHKERRQ(ierr); 783b3561c8SJed Brown ierr = PetscLogEventRegister("BuildTwoSided",PETSC_SMALLEST_CLASSID,&PETSC_BuildTwoSided);CHKERRQ(ierr); 7927a32ea5SJed Brown ierr = PetscLogEventRegister("BuildTwoSidedF",PETSC_SMALLEST_CLASSID,&PETSC_BuildTwoSidedF);CHKERRQ(ierr); 805c6c1daeSBarry Smith /* Process info exclusions */ 81c5929fdfSBarry Smith ierr = PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr); 825c6c1daeSBarry Smith if (opt) { 835c6c1daeSBarry Smith ierr = PetscStrstr(logList, "null", &className);CHKERRQ(ierr); 845c6c1daeSBarry Smith if (className) { 855c6c1daeSBarry Smith ierr = PetscInfoDeactivateClass(0);CHKERRQ(ierr); 865c6c1daeSBarry Smith } 875c6c1daeSBarry Smith } 885c6c1daeSBarry Smith /* Process summary exclusions */ 897bf5a629SBarry Smith ierr = PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);CHKERRQ(ierr); 905c6c1daeSBarry Smith if (opt) { 915c6c1daeSBarry Smith ierr = PetscStrstr(logList, "null", &className);CHKERRQ(ierr); 925c6c1daeSBarry Smith if (className) { 935c6c1daeSBarry Smith ierr = PetscLogEventDeactivateClass(0);CHKERRQ(ierr); 945c6c1daeSBarry Smith } 955c6c1daeSBarry Smith } 965c6c1daeSBarry Smith ierr = PetscRegisterFinalize(PetscSysFinalizePackage);CHKERRQ(ierr); 975c6c1daeSBarry Smith PetscFunctionReturn(0); 985c6c1daeSBarry Smith } 995c6c1daeSBarry Smith 100aa2d57e9SJed Brown #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) 1015c6c1daeSBarry Smith 1025c6c1daeSBarry Smith #if defined(PETSC_USE_SINGLE_LIBRARY) 103607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscvec(void); 104607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscmat(void); 105607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void); 106607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void); 107607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void); 108607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void); 1095c6c1daeSBarry Smith #endif 1105c6c1daeSBarry Smith 1115c6c1daeSBarry Smith #if defined(PETSC_USE_SINGLE_LIBRARY) 1125c6c1daeSBarry Smith #else 1135c6c1daeSBarry Smith #endif 1145c6c1daeSBarry Smith /* 1155c6c1daeSBarry Smith PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. 1165c6c1daeSBarry Smith 1175c6c1daeSBarry Smith This one registers all the draw and PetscViewer objects. 1185c6c1daeSBarry Smith 1195c6c1daeSBarry Smith */ 1205c6c1daeSBarry Smith #if defined(PETSC_USE_SINGLE_LIBRARY) 121607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petsc(void) 1225c6c1daeSBarry Smith #else 123607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsys(void) 1245c6c1daeSBarry Smith #endif 1255c6c1daeSBarry Smith { 1265c6c1daeSBarry Smith PetscErrorCode ierr; 1275c6c1daeSBarry Smith 1285c6c1daeSBarry Smith PetscFunctionBegin; 1295c6c1daeSBarry Smith /* 1305c6c1daeSBarry Smith If we got here then PETSc was properly loaded 1315c6c1daeSBarry Smith */ 132607a6623SBarry Smith ierr = PetscSysInitializePackage();CHKERRQ(ierr); 133607a6623SBarry Smith ierr = PetscDrawInitializePackage();CHKERRQ(ierr); 134607a6623SBarry Smith ierr = PetscViewerInitializePackage();CHKERRQ(ierr); 135607a6623SBarry Smith ierr = PetscRandomInitializePackage();CHKERRQ(ierr); 1365c6c1daeSBarry Smith 1375c6c1daeSBarry Smith #if defined(PETSC_USE_SINGLE_LIBRARY) 138607a6623SBarry Smith ierr = PetscDLLibraryRegister_petscvec();CHKERRQ(ierr); 139607a6623SBarry Smith ierr = PetscDLLibraryRegister_petscmat();CHKERRQ(ierr); 140607a6623SBarry Smith ierr = PetscDLLibraryRegister_petscdm();CHKERRQ(ierr); 141607a6623SBarry Smith ierr = PetscDLLibraryRegister_petscksp();CHKERRQ(ierr); 142607a6623SBarry Smith ierr = PetscDLLibraryRegister_petscsnes();CHKERRQ(ierr); 143607a6623SBarry Smith ierr = PetscDLLibraryRegister_petscts();CHKERRQ(ierr); 1445c6c1daeSBarry Smith #endif 1455c6c1daeSBarry Smith PetscFunctionReturn(0); 1465c6c1daeSBarry Smith } 147aa2d57e9SJed Brown #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */ 148