xref: /petsc/src/sys/classes/random/interface/dlregisrand.c (revision a3afe2d1ed14aa25e6e8bcdd861505b3816b69e5)
1 
2 #include <../src/sys/classes/random/randomimpl.h>
3 
4 static PetscBool PetscRandomPackageInitialized = PETSC_FALSE;
5 #undef __FUNCT__
6 #define __FUNCT__ "PetscRandomFinalizePackage"
7 /*@C
8   PetscRandomFinalizePackage - This function destroys everything in the Petsc interface to the Random package. It is
9   called from PetscFinalize().
10 
11   Level: developer
12 
13 .keywords: Petsc, destroy, package, mathematica
14 .seealso: PetscFinalize()
15 @*/
16 PetscErrorCode  PetscRandomFinalizePackage(void)
17 {
18   PetscErrorCode ierr;
19 
20   PetscFunctionBegin;
21   ierr = PetscFunctionListDestroy(&PetscRandomList);CHKERRQ(ierr);
22   PetscRandomPackageInitialized = PETSC_FALSE;
23   PetscRandomRegisterAllCalled  = PETSC_FALSE;
24   PetscFunctionReturn(0);
25 }
26 
27 #undef __FUNCT__
28 #define __FUNCT__ "PetscRandomInitializePackage"
29 /*@C
30   PetscRandomInitializePackage - This function initializes everything in the PetscRandom package. It is called
31   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscRandomCreate()
32   when using static libraries.
33 
34   Level: developer
35 
36 .keywords: PetscRandom, initialize, package
37 .seealso: PetscInitialize()
38 @*/
39 PetscErrorCode  PetscRandomInitializePackage(void)
40 {
41   PetscErrorCode ierr;
42 
43   PetscFunctionBegin;
44   if (PetscRandomPackageInitialized) PetscFunctionReturn(0);
45   PetscRandomPackageInitialized = PETSC_TRUE;
46   /* Register Class */
47   ierr = PetscClassIdRegister("PetscRandom",&PETSC_RANDOM_CLASSID);CHKERRQ(ierr);
48   ierr = PetscRandomRegisterAll();CHKERRQ(ierr);
49   ierr = PetscRegisterFinalize(PetscRandomFinalizePackage);CHKERRQ(ierr);
50   PetscFunctionReturn(0);
51 }
52 
53 
54 
55