Actual source code: dlregisrand.c
1: #include <petsc/private/randomimpl.h>
3: static PetscBool PetscRandomPackageInitialized = PETSC_FALSE;
5: /*@C
6: PetscRandomFinalizePackage - This function frees everything in the `PetscRandom` package. It is
7: called from `PetscFinalize()`.
9: Level: developer
11: .seealso: `PetscFinalize()`
12: @*/
13: PetscErrorCode PetscRandomFinalizePackage(void)
14: {
15: PetscFunctionBegin;
16: PetscCall(PetscFunctionListDestroy(&PetscRandomList));
17: PetscRandomPackageInitialized = PETSC_FALSE;
18: PetscRandomRegisterAllCalled = PETSC_FALSE;
19: PetscFunctionReturn(PETSC_SUCCESS);
20: }
22: /*@C
23: PetscRandomInitializePackage - This function initializes everything in the `PetscRandom` package. It is called
24: from PetscDLLibraryRegister_petsc() when using dynamic libraries, and on the first call to `PetscRandomCreate()`
25: when using shared or static libraries.
27: Level: developer
29: .seealso: `PetscInitialize()`
30: @*/
31: PetscErrorCode PetscRandomInitializePackage(void)
32: {
33: char logList[256];
34: PetscBool opt, pkg;
36: PetscFunctionBegin;
37: if (PetscRandomPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
38: PetscRandomPackageInitialized = PETSC_TRUE;
39: /* Register Class */
40: PetscCall(PetscClassIdRegister("PetscRandom", &PETSC_RANDOM_CLASSID));
41: /* Register Constructors */
42: PetscCall(PetscRandomRegisterAll());
43: /* Process Info */
44: {
45: PetscClassId classids[1];
47: classids[0] = PETSC_RANDOM_CLASSID;
48: PetscCall(PetscInfoProcessClass("random", 1, classids));
49: }
50: /* Process summary exclusions */
51: PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
52: if (opt) {
53: PetscCall(PetscStrInList("random", logList, ',', &pkg));
54: if (pkg) PetscCall(PetscLogEventExcludeClass(PETSC_RANDOM_CLASSID));
55: }
56: /* Register package finalizer */
57: PetscCall(PetscRegisterFinalize(PetscRandomFinalizePackage));
58: PetscFunctionReturn(PETSC_SUCCESS);
59: }