matrix_block_aux.F90 coverage: 57.14 %func 48.89 %block
1) module Matrix_Block_Aux_module
2)
3) ! this module cannot depend on any other modules beside Option_module
4)
5) use PFLOTRAN_Constants_module
6)
7) implicit none
8)
9) private
10)
11) #include "petsc/finclude/petscsys.h"
12)
13) type, public :: matrix_block_auxvar_type
14)
15) PetscReal, pointer :: dtotal(:,:,:)
16)
17) end type matrix_block_auxvar_type
18)
19) type, public :: matrix_block_info_type
20) PetscInt :: dim1
21) PetscInt :: dim2
22) PetscInt :: dim3
23) end type matrix_block_info_type
24)
25) interface MatrixBlockAuxVarInit
26) module procedure MatrixBlockAuxVarInit1
27) module procedure MatrixBlockAuxVarInit2
28) end interface MatrixBlockAuxVarInit
29)
30) public :: MatrixBlockAuxVarCreate, &
31) MatrixBlockAuxVarInit, &
32) MatrixBlockAuxVarCopy, &
33) MatrixBlockAuxVarDestroy, &
34) MatrixBlockInfoCreate, &
35) MatrixBlockInfoDestroy
36)
37) contains
38)
39) ! ************************************************************************** !
40)
41) function MatrixBlockAuxVarCreate(option)
42) !
43) ! MatrixBlockAuxCreate: Allocate and initialize auxiliary object
44) !
45) ! Author: Glenn Hammond
46) ! Date: 03/04/2010
47) !
48)
49) use Option_module
50)
51) implicit none
52)
53) type(option_type) :: option
54) type(matrix_block_auxvar_type), pointer :: MatrixBlockAuxVarCreate
55)
56) type(matrix_block_auxvar_type), pointer :: aux
57)
58) allocate(aux)
59) nullify(aux%dtotal)
60)
61) MatrixBlockAuxVarCreate => aux
62)
63) end function MatrixBlockAuxVarCreate
64)
65) ! ************************************************************************** !
66)
67) subroutine MatrixBlockAuxVarInit1(auxvar,dim1,dim2,dim3,option)
68) !
69) ! Initialize auxiliary object
70) !
71) ! Author: Glenn Hammond
72) ! Date: 03/04/2010
73) !
74)
75) use Option_module
76)
77) implicit none
78)
79) type(matrix_block_auxvar_type) :: auxvar
80) type(matrix_block_info_type) :: matrix_info
81) PetscInt :: dim1
82) PetscInt :: dim2
83) PetscInt :: dim3
84) type(option_type) :: option
85)
86) allocate(auxvar%dtotal(dim1,dim2,dim3))
87) auxvar%dtotal = 0.d0
88)
89) end subroutine MatrixBlockAuxVarInit1
90)
91) ! ************************************************************************** !
92)
93) subroutine MatrixBlockAuxVarInit2(auxvar,matrix_info,option)
94) !
95) ! Initialize auxiliary object
96) !
97) ! Author: Glenn Hammond
98) ! Date: 03/04/2010
99) !
100)
101) use Option_module
102)
103) implicit none
104)
105) type(matrix_block_auxvar_type) :: auxvar
106) type(matrix_block_info_type) :: matrix_info
107) type(option_type) :: option
108)
109) allocate(auxvar%dtotal(matrix_info%dim1,matrix_info%dim2,matrix_info%dim3))
110) auxvar%dtotal = 0.d0
111)
112) end subroutine MatrixBlockAuxVarInit2
113)
114) ! ************************************************************************** !
115)
116) subroutine MatrixBlockAuxVarCopy(auxvar,auxvar2,option)
117) !
118) ! Copys an auxiliary object
119) !
120) ! Author: Glenn Hammond
121) ! Date: 03/04/2010
122) !
123)
124) use Option_module
125)
126) implicit none
127)
128) type(matrix_block_auxvar_type) :: auxvar, auxvar2
129) type(option_type) :: option
130)
131) auxvar%dtotal = auxvar2%dtotal
132)
133) end subroutine MatrixBlockAuxVarCopy
134)
135) ! ************************************************************************** !
136)
137) subroutine MatrixBlockAuxVarDestroy(auxvar)
138) !
139) ! Deallocates a matrix block auxiliary object
140) !
141) ! Author: Glenn Hammond
142) ! Date: 03/04/2010
143) !
144) use Utility_module, only : DeallocateArray
145)
146) implicit none
147)
148) type(matrix_block_auxvar_type), pointer :: auxvar
149)
150) if (.not.associated(auxvar)) return
151)
152) call DeallocateArray(auxvar%dtotal)
153)
154) deallocate(auxvar)
155) nullify(auxvar)
156)
157) end subroutine MatrixBlockAuxVarDestroy
158)
159) ! ************************************************************************** !
160)
161) function MatrixBlockInfoCreate(dim1,dim2,dim3,option)
162) !
163) ! Allocate and initialize matrix block info object
164) !
165) ! Author: Glenn Hammond
166) ! Date: 03/09/2010
167) !
168)
169) use Option_module
170)
171) implicit none
172)
173) PetscInt :: dim1
174) PetscInt :: dim2
175) PetscInt :: dim3
176) type(option_type) :: option
177)
178) type(matrix_block_info_type), pointer :: MatrixBlockInfoCreate
179)
180) type(matrix_block_info_type), pointer :: info
181)
182) allocate(info)
183) info%dim1 = dim1
184) info%dim2 = dim2
185) info%dim3 = dim3
186)
187) MatrixBlockInfoCreate => info
188)
189) end function MatrixBlockInfoCreate
190)
191) ! ************************************************************************** !
192)
193) subroutine MatrixBlockInfoDestroy(matrix_info)
194) !
195) ! Deallocates a matrix block info object
196) !
197) ! Author: Glenn Hammond
198) ! Date: 03/08/2010
199) !
200)
201) implicit none
202)
203) type(matrix_block_info_type), pointer :: matrix_info
204)
205) if (.not.associated(matrix_info)) return
206)
207) if (associated(matrix_info))deallocate(matrix_info)
208) nullify(matrix_info)
209)
210) end subroutine MatrixBlockInfoDestroy
211)
212) end module Matrix_Block_Aux_module