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