15c6c1daeSBarry Smith 25c6c1daeSBarry Smith #include <petscdraw.h> 32c1a2d08SJed Brown #include <petscviewer.h> 45c6c1daeSBarry Smith 527a32ea5SJed Brown extern PetscLogEvent PETSC_Barrier,PETSC_BuildTwoSided,PETSC_BuildTwoSidedF; 65c6c1daeSBarry Smith static PetscBool PetscSysPackageInitialized = PETSC_FALSE; 7*d4c7638eSBarry Smith PETSC_EXTERN PetscMPIInt Petsc_Viewer_keyval; 8*d4c7638eSBarry Smith PETSC_EXTERN PetscMPIInt Petsc_Viewer_Stdout_keyval; 9*d4c7638eSBarry Smith PETSC_EXTERN PetscMPIInt Petsc_Viewer_Stderr_keyval; 10*d4c7638eSBarry Smith PETSC_EXTERN PetscMPIInt Petsc_Viewer_Binary_keyval; 11*d4c7638eSBarry Smith PETSC_EXTERN PetscMPIInt Petsc_Viewer_Draw_keyval; 12*d4c7638eSBarry Smith #if defined(PETSC_HAVE_HDF5) 13*d4c7638eSBarry Smith PETSC_EXTERN PetscMPIInt Petsc_Viewer_HDF5_keyval; 14*d4c7638eSBarry Smith #endif 15*d4c7638eSBarry Smith #if defined(PETSC_USE_SOCKETVIEWER) 16*d4c7638eSBarry Smith PETSC_EXTERN PetscMPIInt Petsc_Viewer_Socket_keyval; 17*d4c7638eSBarry Smith #endif 18*d4c7638eSBarry Smith 195c6c1daeSBarry Smith /*@C 20*d4c7638eSBarry Smith PetscSysFinalizePackage - This function destroys everything in the PETSc created internally in the system library portion of PETSc. 21*d4c7638eSBarry Smith It is called from PetscFinalize(). 225c6c1daeSBarry Smith 235c6c1daeSBarry Smith Level: developer 245c6c1daeSBarry Smith 25*d4c7638eSBarry Smith .keywords: Petsc, destroy, package 265c6c1daeSBarry Smith .seealso: PetscFinalize() 275c6c1daeSBarry Smith @*/ 285c6c1daeSBarry Smith PetscErrorCode PetscSysFinalizePackage(void) 295c6c1daeSBarry Smith { 30*d4c7638eSBarry Smith PetscErrorCode ierr; 31*d4c7638eSBarry Smith 325c6c1daeSBarry Smith PetscFunctionBegin; 33*d4c7638eSBarry Smith if (Petsc_Viewer_keyval != MPI_KEYVAL_INVALID) { 34*d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_keyval);CHKERRQ(ierr); 35*d4c7638eSBarry Smith } 36*d4c7638eSBarry Smith if (Petsc_Viewer_Stdout_keyval != MPI_KEYVAL_INVALID) { 37*d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_Stdout_keyval);CHKERRQ(ierr); 38*d4c7638eSBarry Smith } 39*d4c7638eSBarry Smith if (Petsc_Viewer_Stderr_keyval != MPI_KEYVAL_INVALID) { 40*d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_Stderr_keyval);CHKERRQ(ierr); 41*d4c7638eSBarry Smith } 42*d4c7638eSBarry Smith if (Petsc_Viewer_Binary_keyval != MPI_KEYVAL_INVALID) { 43*d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_Binary_keyval);CHKERRQ(ierr); 44*d4c7638eSBarry Smith } 45*d4c7638eSBarry Smith if (Petsc_Viewer_Draw_keyval != MPI_KEYVAL_INVALID) { 46*d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_Draw_keyval);CHKERRQ(ierr); 47*d4c7638eSBarry Smith } 48*d4c7638eSBarry Smith #if defined(PETSC_HAVE_HDF5) 49*d4c7638eSBarry Smith if (Petsc_Viewer_HDF5_keyval != MPI_KEYVAL_INVALID) { 50*d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_HDF5_keyval);CHKERRQ(ierr); 51*d4c7638eSBarry Smith } 52*d4c7638eSBarry Smith #endif 53*d4c7638eSBarry Smith #if defined(PETSC_USE_SOCKETVIEWER) 54*d4c7638eSBarry Smith if (Petsc_Viewer_Socket_keyval != MPI_KEYVAL_INVALID) { 55*d4c7638eSBarry Smith ierr = MPI_Keyval_free(&Petsc_Viewer_Socket_keyval);CHKERRQ(ierr); 56*d4c7638eSBarry Smith } 57*d4c7638eSBarry Smith #endif 585c6c1daeSBarry Smith PetscSysPackageInitialized = PETSC_FALSE; 595c6c1daeSBarry Smith PetscFunctionReturn(0); 605c6c1daeSBarry Smith } 615c6c1daeSBarry Smith 625c6c1daeSBarry Smith /*@C 635c6c1daeSBarry Smith PetscSysInitializePackage - This function initializes everything in the main Petsc package. It is called 645c6c1daeSBarry Smith from PetscDLLibraryRegister() when using dynamic libraries, and on the call to PetscInitialize() 655c6c1daeSBarry Smith when using static libraries. 665c6c1daeSBarry Smith 675c6c1daeSBarry Smith Level: developer 685c6c1daeSBarry Smith 695c6c1daeSBarry Smith .keywords: Petsc, initialize, package 705c6c1daeSBarry Smith .seealso: PetscInitialize() 715c6c1daeSBarry Smith @*/ 72607a6623SBarry Smith PetscErrorCode PetscSysInitializePackage(void) 735c6c1daeSBarry Smith { 745c6c1daeSBarry Smith char logList[256]; 755c6c1daeSBarry Smith char *className; 765c6c1daeSBarry Smith PetscBool opt; 775c6c1daeSBarry Smith PetscErrorCode ierr; 785c6c1daeSBarry Smith 795c6c1daeSBarry Smith PetscFunctionBegin; 805c6c1daeSBarry Smith if (PetscSysPackageInitialized) PetscFunctionReturn(0); 815c6c1daeSBarry Smith PetscSysPackageInitialized = PETSC_TRUE; 825c6c1daeSBarry Smith /* Register Classes */ 835c6c1daeSBarry Smith ierr = PetscClassIdRegister("Object",&PETSC_OBJECT_CLASSID);CHKERRQ(ierr); 845c6c1daeSBarry Smith ierr = PetscClassIdRegister("Container",&PETSC_CONTAINER_CLASSID);CHKERRQ(ierr); 855c6c1daeSBarry Smith 865c6c1daeSBarry Smith /* Register Events */ 875c6c1daeSBarry Smith ierr = PetscLogEventRegister("PetscBarrier", PETSC_SMALLEST_CLASSID,&PETSC_Barrier);CHKERRQ(ierr); 883b3561c8SJed Brown ierr = PetscLogEventRegister("BuildTwoSided",PETSC_SMALLEST_CLASSID,&PETSC_BuildTwoSided);CHKERRQ(ierr); 8927a32ea5SJed Brown ierr = PetscLogEventRegister("BuildTwoSidedF",PETSC_SMALLEST_CLASSID,&PETSC_BuildTwoSidedF);CHKERRQ(ierr); 905c6c1daeSBarry Smith /* Process info exclusions */ 91c5929fdfSBarry Smith ierr = PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr); 925c6c1daeSBarry Smith if (opt) { 935c6c1daeSBarry Smith ierr = PetscStrstr(logList, "null", &className);CHKERRQ(ierr); 945c6c1daeSBarry Smith if (className) { 955c6c1daeSBarry Smith ierr = PetscInfoDeactivateClass(0);CHKERRQ(ierr); 965c6c1daeSBarry Smith } 975c6c1daeSBarry Smith } 985c6c1daeSBarry Smith /* Process summary exclusions */ 997bf5a629SBarry Smith ierr = PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);CHKERRQ(ierr); 1005c6c1daeSBarry Smith if (opt) { 1015c6c1daeSBarry Smith ierr = PetscStrstr(logList, "null", &className);CHKERRQ(ierr); 1025c6c1daeSBarry Smith if (className) { 1035c6c1daeSBarry Smith ierr = PetscLogEventDeactivateClass(0);CHKERRQ(ierr); 1045c6c1daeSBarry Smith } 1055c6c1daeSBarry Smith } 1065c6c1daeSBarry Smith ierr = PetscRegisterFinalize(PetscSysFinalizePackage);CHKERRQ(ierr); 1075c6c1daeSBarry Smith PetscFunctionReturn(0); 1085c6c1daeSBarry Smith } 1095c6c1daeSBarry Smith 110aa2d57e9SJed Brown #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) 1115c6c1daeSBarry Smith 1125c6c1daeSBarry Smith #if defined(PETSC_USE_SINGLE_LIBRARY) 113607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscvec(void); 114607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscmat(void); 115607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void); 116607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void); 117607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void); 118607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void); 1195c6c1daeSBarry Smith #endif 1205c6c1daeSBarry Smith 1215c6c1daeSBarry Smith #if defined(PETSC_USE_SINGLE_LIBRARY) 1225c6c1daeSBarry Smith #else 1235c6c1daeSBarry Smith #endif 1245c6c1daeSBarry Smith /* 1255c6c1daeSBarry Smith PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. 1265c6c1daeSBarry Smith 1275c6c1daeSBarry Smith This one registers all the draw and PetscViewer objects. 1285c6c1daeSBarry Smith 1295c6c1daeSBarry Smith */ 1305c6c1daeSBarry Smith #if defined(PETSC_USE_SINGLE_LIBRARY) 131607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petsc(void) 1325c6c1daeSBarry Smith #else 133607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsys(void) 1345c6c1daeSBarry Smith #endif 1355c6c1daeSBarry Smith { 1365c6c1daeSBarry Smith PetscErrorCode ierr; 1375c6c1daeSBarry Smith 1385c6c1daeSBarry Smith PetscFunctionBegin; 1395c6c1daeSBarry Smith /* 1405c6c1daeSBarry Smith If we got here then PETSc was properly loaded 1415c6c1daeSBarry Smith */ 142607a6623SBarry Smith ierr = PetscSysInitializePackage();CHKERRQ(ierr); 143607a6623SBarry Smith ierr = PetscDrawInitializePackage();CHKERRQ(ierr); 144607a6623SBarry Smith ierr = PetscViewerInitializePackage();CHKERRQ(ierr); 145607a6623SBarry Smith ierr = PetscRandomInitializePackage();CHKERRQ(ierr); 1465c6c1daeSBarry Smith 1475c6c1daeSBarry Smith #if defined(PETSC_USE_SINGLE_LIBRARY) 148607a6623SBarry Smith ierr = PetscDLLibraryRegister_petscvec();CHKERRQ(ierr); 149607a6623SBarry Smith ierr = PetscDLLibraryRegister_petscmat();CHKERRQ(ierr); 150607a6623SBarry Smith ierr = PetscDLLibraryRegister_petscdm();CHKERRQ(ierr); 151607a6623SBarry Smith ierr = PetscDLLibraryRegister_petscksp();CHKERRQ(ierr); 152607a6623SBarry Smith ierr = PetscDLLibraryRegister_petscsnes();CHKERRQ(ierr); 153607a6623SBarry Smith ierr = PetscDLLibraryRegister_petscts();CHKERRQ(ierr); 1545c6c1daeSBarry Smith #endif 1555c6c1daeSBarry Smith PetscFunctionReturn(0); 1565c6c1daeSBarry Smith } 157aa2d57e9SJed Brown #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */ 158