Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_DeallocateDataBuffers.F90
Go to the documentation of this file.
1 ! *********************************************************************
2 ! * Rocstar Simulation Suite *
3 ! * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4 ! * *
5 ! * Illinois Rocstar LLC *
6 ! * Champaign, IL *
7 ! * www.illinoisrocstar.com *
8 ! * sales@illinoisrocstar.com *
9 ! * *
10 ! * License: See LICENSE file in top level of distribution package or *
11 ! * http://opensource.org/licenses/NCSA *
12 ! *********************************************************************
13 ! *********************************************************************
14 ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15 ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16 ! * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17 ! * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18 ! * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 ! * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20 ! * Arising FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21 ! * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22 ! *********************************************************************
23 !******************************************************************************
24 !
25 ! Purpose: deallocate memory for variables associated with buffer datastructure
26 ! for all active regions on current processor.
27 !
28 ! Description: none.
29 !
30 ! Input: regions = all regions
31 ! iReg = region number.
32 !
33 ! Output: region%levels%patch%buffPlag = Buffplag variables
34 !
35 ! Notes: none.
36 !
37 !******************************************************************************
38 !
39 ! $Id: PLAG_DeallocateDataBuffers.F90,v 1.4 2008/12/06 08:44:33 mtcampbe Exp $
40 !
41 ! Copyright: (c) 2002 by the University of Illinois
42 !
43 !******************************************************************************
44 
45 SUBROUTINE plag_deallocatedatabuffers( regions, iReg )
46 
47  USE moddatatypes
48  USE modpartlag, ONLY : t_buffer_plag
49  USE modbndpatch, ONLY : t_patch
50  USE moddatastruct, ONLY : t_region, t_level
51  USE modglobal, ONLY : t_global
52  USE moderror
53  USE modparameters
55  IMPLICIT NONE
56 
57 ! ... parameters
58  TYPE(t_region), POINTER :: regions(:)
59 
60  INTEGER :: ireg
61 
62 ! ... loop variables
63  INTEGER :: ilev, ipatch
64 
65 ! ... local variables
66  CHARACTER(CHRLEN) :: rcsidentstring
67 
68  INTEGER :: bctype, errorflag, iregsrc, lbound, n1, n2, ncont, &
69  npatchsize, nbuffsizetot
70 
71  TYPE(t_patch), POINTER :: ppatch
72  TYPE(t_buffer_plag), POINTER :: pbuffplag
73  TYPE(t_global), POINTER :: global
74 
75 !******************************************************************************
76 
77  rcsidentstring = '$RCSfile: PLAG_DeallocateDataBuffers.F90,v $ $Revision: 1.4 $'
78 
79  global => regions(ireg)%global
80 
81  CALL registerfunction( global, 'PLAG_DeallocateDataBuffers',&
82  'PLAG_DeallocateDataBuffers.F90' )
83 
84 ! Get dimensions --------------------------------------------------------------
85 
86  nbuffsizetot = regions(ireg)%plagInput%nPclsBuffTot
87 
88 ! Loop over all grid levels ---------------------------------------------------
89 
90  DO ilev=1,regions(ireg)%nGridLevels
91  DO ipatch=1,regions(ireg)%nPatches
92 
93  ppatch => regions(ireg)%levels(ilev)%patches(ipatch)
94  bctype = ppatch%bcType
95  lbound = ppatch%lbound
96  iregsrc = ppatch%srcRegion
97 
98  n1 = abs(ppatch%l1end -ppatch%l1beg ) + 1
99  n2 = abs(ppatch%l2end -ppatch%l2beg ) + 1
100  npatchsize = n1*n2
101 
102  IF ((bctype>=bc_regionconf .AND. bctype<=bc_regionconf+bc_range) .OR. &
103  (bctype>=bc_tra_peri .AND. bctype<=bc_tra_peri +bc_range) .OR. &
104  (bctype>=bc_rot_peri .AND. bctype<=bc_rot_peri +bc_range)) THEN
105 
106  pbuffplag => ppatch%bufferPlag
107 
108  pbuffplag%nBuffSizeTot = nbuffsizetot
109 
110 ! - Deallocate data for same-processor communication --------------------------
111 
112  IF (regions(iregsrc)%procid == global%myProcid) THEN
113  DEALLOCATE( pbuffplag%aiv,stat=errorflag )
114  global%error = errorflag
115  IF (global%error /= err_none) THEN
116  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%aiv' )
117  END IF ! global%error
118 
119  DEALLOCATE( pbuffplag%arv,stat=errorflag )
120  global%error = errorflag
121  IF (global%error /= err_none) THEN
122  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%arv' )
123  END IF ! global%error
124 
125  DEALLOCATE( pbuffplag%cv,stat=errorflag )
126  global%error = errorflag
127  IF (global%error /= err_none) THEN
128  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%cv' )
129  END IF ! global%error
130 
131  DEALLOCATE( pbuffplag%dv,stat=errorflag )
132  global%error = errorflag
133  IF (global%error /= err_none) THEN
134  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%dv' )
135  END IF ! global%error
136 
137  DEALLOCATE( pbuffplag%tv,stat=errorflag )
138  global%error = errorflag
139  IF (global%error /= err_none) THEN
140  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%tv' )
141  END IF ! global%error
142 
143  DEALLOCATE( pbuffplag%aivOld,stat=errorflag )
144  global%error = errorflag
145  IF (global%error /= err_none) THEN
146  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%aivOld' )
147  END IF ! global%error
148 
149  DEALLOCATE( pbuffplag%arvOld,stat=errorflag )
150  global%error = errorflag
151  IF (global%error /= err_none) THEN
152  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%arvOld' )
153  END IF ! global%error
154 
155  DEALLOCATE( pbuffplag%cvOld,stat=errorflag )
156  global%error = errorflag
157  IF (global%error /= err_none) THEN
158  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%cvOld' )
159  END IF ! global%error
160  DEALLOCATE( pbuffplag%rhs,stat=errorflag )
161  global%error = errorflag
162  IF (global%error /= err_none) THEN
163  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%rhs' )
164  END IF ! global%error
165 
166  DEALLOCATE( pbuffplag%rhsSum,stat=errorflag )
167  global%error = errorflag
168  IF (global%error /= err_none) THEN
169  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%rhsSum' )
170  END IF ! global%error
171 
172  END IF !regions
173 
174 ! - Allocate data for off-processor communication -----------------------------
175 
176  IF (regions(iregsrc)%procid /= global%myProcid) THEN ! other processor
177 
178  DEALLOCATE( pbuffplag%sendBuffR,stat=errorflag )
179  global%error = errorflag
180  IF (global%error /= err_none) THEN
181  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%sendBuffR' )
182  END IF ! global%error
183 
184  DEALLOCATE( pbuffplag%recvBuffR,stat=errorflag )
185  global%error = errorflag
186  IF (global%error /= err_none) THEN
187  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%recvBuffR' )
188  END IF ! global%error
189 
190  DEALLOCATE( pbuffplag%sendBuffI,stat=errorflag )
191  global%error = errorflag
192  IF (global%error /= err_none) THEN
193  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%sendBuffI' )
194  END IF ! global%error
195 
196  DEALLOCATE( pbuffplag%recvBuffI,stat=errorflag )
197  global%error = errorflag
198  IF (global%error /= err_none) THEN
199  CALL errorstop( global, err_deallocate,__line__,'pBuffPlag%recvBuffI' )
200  END IF ! global%error
201 
202  ENDIF ! regions
203 
204  ELSE IF ((bctype>=bc_regionint .AND. bctype<=bc_regionint +bc_range) .OR. &
205  (bctype>=bc_regnonconf .AND. bctype<=bc_regnonconf+bc_range)) THEN
206  CALL errorstop( global,err_unknown_bc,__line__ ) ! #### TEMPORARY ####
207  ENDIF ! bcType
208 
209  ENDDO ! iPatch
210 
211  ENDDO ! iLev
212 
213 ! finalize
214 
215  CALL deregisterfunction( global )
216 
217 END SUBROUTINE plag_deallocatedatabuffers
218 
219 !******************************************************************************
220 !
221 ! RCS Revision history:
222 !
223 ! $Log: PLAG_DeallocateDataBuffers.F90,v $
224 ! Revision 1.4 2008/12/06 08:44:33 mtcampbe
225 ! Updated license.
226 !
227 ! Revision 1.3 2008/11/19 22:17:46 mtcampbe
228 ! Added Illinois Open Source License/Copyright
229 !
230 ! Revision 1.2 2006/04/07 15:19:23 haselbac
231 ! Removed tabs
232 !
233 ! Revision 1.1 2004/12/01 20:57:29 fnajjar
234 ! Initial revision after changing case
235 !
236 ! Revision 1.2 2003/05/27 19:19:57 fnajjar
237 ! Removed distPartBurning and all pertinent LOGICAL datastructure
238 !
239 ! Revision 1.1 2002/10/25 14:15:43 f-najjar
240 ! Initial Import of Rocpart
241 !
242 !
243 !******************************************************************************
244 
245 
246 
247 
248 
249 
250 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine plag_deallocatedatabuffers(regions, iReg)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469