Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PEUL_AllocateDataBuffers.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: allocate data buffers (send & receive) for inter-region
26 ! communication for PEUL module.
27 !
28 ! Description: none.
29 !
30 ! Input: regions = data of all regions
31 ! iReg = region number
32 !
33 ! Output: regions%levels%patches%bufferPeul%... = send & receive buffers
34 !
35 ! Notes: none.
36 !
37 !******************************************************************************
38 !
39 ! $Id: PEUL_AllocateDataBuffers.F90,v 1.3 2008/12/06 08:44:38 mtcampbe Exp $
40 !
41 ! Copyright: (c) 2003 by the University of Illinois
42 !
43 !******************************************************************************
44 
45 SUBROUTINE peul_allocatedatabuffers( regions,iReg ) ! PUBLIC
46 
47  USE moddatatypes
48  USE modparteul, ONLY : t_peul, t_buffer_peul
49  USE modbndpatch, ONLY : t_patch
50  USE moddatastruct, ONLY : t_region, t_level, t_dcelltransf
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, INTENT(IN) :: ireg
61 
62 ! ... loop variables
63  INTEGER :: ipatch, ilev, ir
64 
65 ! ... local variables
66  CHARACTER(CHRLEN) :: rcsidentstring
67 
68  INTEGER :: bctype, iregsrc, n1, n2, n1src, n2src, ncv, neqs, neqssrc
69  INTEGER :: ndc, ndcsrc, ndim, ndimsrc, errorflag
70 
71  TYPE(t_global), POINTER :: global
72  TYPE(t_level), POINTER :: level
73  TYPE(t_patch), POINTER :: ppatch
74  TYPE(t_buffer_peul), POINTER :: pbuffpeul
75  TYPE(t_peul), POINTER :: ppeul
76  TYPE(t_dcelltransf), POINTER :: sendeccell, recveccell
77  TYPE(t_dcelltransf), POINTER :: sndpeuleccell, rcvpeuleccell
78 
79 !******************************************************************************
80 
81  rcsidentstring = '$RCSfile: PEUL_AllocateDataBuffers.F90,v $ $Revision: 1.3 $'
82 
83  global => regions(ireg)%global
84 
85  CALL registerfunction( global,'RFLO_AllocateDataBuffers',&
86  'PEUL_AllocateDataBuffers.F90' )
87 
88 ! data buffers for patches
89 
90  DO ilev=1,regions(ireg)%nGridLevels
91 
92  ppeul => regions(ireg)%levels(ilev)%peul
93 
94  ppeul%nRequests = 0
95  ncv = ppeul%nCv
96 
97  DO ipatch=1,regions(ireg)%nPatches
98 
99  ppatch => regions(ireg)%levels(ilev)%patches(ipatch)
100  bctype = ppatch%bcType
101 
102  pbuffpeul => ppatch%bufferPeul
103 
104  IF ((bctype>=bc_regionconf .AND. bctype<=bc_regionconf+bc_range) .OR. &
105  (bctype>=bc_tra_peri .AND. bctype<=bc_tra_peri +bc_range) .OR. &
106  (bctype>=bc_rot_peri .AND. bctype<=bc_rot_peri +bc_range)) THEN
107  iregsrc = ppatch%srcRegion
108  IF (regions(iregsrc)%procid /= global%myProcid) THEN ! other processor
109  n1 = abs(ppatch%l1end -ppatch%l1beg ) + 2 ! large enough
110  n2 = abs(ppatch%l2end -ppatch%l2beg ) + 2 ! for NODES!
111  n1src = abs(ppatch%srcL1end-ppatch%srcL1beg) + 2
112  n2src = abs(ppatch%srcL2end-ppatch%srcL2beg) + 2
113  neqs = ncv
114  neqssrc = ncv
115  ndc = regions(ireg )%nDumCells
116  ndcsrc = regions(iregsrc)%nDumCells
117  ndim = n1*n2*neqs*ndc
118  ndimsrc = n1src*n2src*neqssrc*ndcsrc
119 
120  ALLOCATE( pbuffpeul%sendBuff(ndimsrc),stat=errorflag )
121  global%error = errorflag
122  IF (global%error /= err_none) &
123  CALL errorstop( global,err_allocate,__line__ )
124 
125  ALLOCATE( pbuffpeul%recvBuff(ndim ),stat=errorflag )
126  global%error = errorflag
127  IF (global%error /= err_none) &
128  CALL errorstop( global,err_allocate,__line__ )
129 
130  pbuffpeul%nSendBuff = ndimsrc
131  pbuffpeul%nRecvBuff = ndim
132  ppeul%nRequests = ppeul%nRequests + 1
133  pbuffpeul%iRequest = ppeul%nRequests
134  ENDIF
135  ELSE IF ((bctype>=bc_regionint .AND. bctype<=bc_regionint +bc_range) .OR. &
136  (bctype>=bc_regnonconf .AND. bctype<=bc_regnonconf+bc_range)) THEN
137  CALL errorstop( global,err_unknown_bc,__line__ ) ! #### TEMPORARY ####
138  ENDIF ! bcType
139 
140  ENDDO ! iPatch
141 
142 ! Allocate array for send requests --------------------------------------------
143 
144 #ifdef MPI
145  ALLOCATE( ppeul%requests(ppeul%nRequests),stat=errorflag )
146  global%error = errorflag
147  IF (global%error /= err_none) THEN
148  CALL errorstop( global, err_allocate,__line__,'pPeul%requests' )
149  END IF ! global%error
150 #endif
151 
152  ENDDO ! iLev
153 
154 ! data buffers for edge & corner cells
155 
156  IF (global%nProcAlloc > 1) THEN ! only if multiple processors
157 
158  DO ilev=1,regions(ireg)%nGridLevels
159 
160 ! --- allocate send and receive region data
161 
162  level => regions(ireg)%levels(ilev)
163  ncv = level%peul%nCv
164 
165  ALLOCATE( level%sndPeulEcCells(global%nRegions),stat=errorflag )
166  ALLOCATE( level%rcvPeulEcCells(global%nRegions),stat=errorflag )
167  global%error = errorflag
168  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
169 
170  DO ir=1,global%nRegions
171  sendeccell => regions(ireg)%levels(ilev)%sendEcCells(ir)
172  recveccell => regions(ireg)%levels(ilev)%recvEcCells(ir)
173  sndpeuleccell => regions(ireg)%levels(ilev)%sndPeulEcCells(ir)
174  rcvpeuleccell => regions(ireg)%levels(ilev)%rcvPeulEcCells(ir)
175  sndpeuleccell%nCells = sendeccell%nCells
176  rcvpeuleccell%nCells = recveccell%nCells
177 
178  IF (sndpeuleccell%nCells > 0) THEN
179  global%nRequests = global%nRequests + 1
180  sndpeuleccell%iRequest = global%nRequests
181  ALLOCATE( sndpeuleccell%buff(sndpeuleccell%nCells*ncv), &
182  stat=errorflag )
183  global%error = errorflag
184  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
185  ENDIF
186  IF (rcvpeuleccell%nCells > 0) THEN
187  rcvpeuleccell%iRequest = -999999
188  ALLOCATE( rcvpeuleccell%buff(rcvpeuleccell%nCells*ncv), &
189  stat=errorflag )
190  global%error = errorflag
191  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
192  ENDIF
193  ENDDO ! ir
194  ENDDO ! iLev
195 
196  ENDIF
197 
198 ! finalize --------------------------------------------------------------------
199 
200  CALL deregisterfunction( global )
201 
202 END SUBROUTINE peul_allocatedatabuffers
203 
204 !******************************************************************************
205 !
206 ! RCS Revision history:
207 !
208 ! $Log: PEUL_AllocateDataBuffers.F90,v $
209 ! Revision 1.3 2008/12/06 08:44:38 mtcampbe
210 ! Updated license.
211 !
212 ! Revision 1.2 2008/11/19 22:17:51 mtcampbe
213 ! Added Illinois Open Source License/Copyright
214 !
215 ! Revision 1.1 2004/12/01 21:09:12 haselbac
216 ! Initial revision after changing case
217 !
218 ! Revision 1.5 2004/04/15 16:04:03 jferry
219 ! minor formatting (removed trailing spaces)
220 !
221 ! Revision 1.4 2004/03/02 21:44:07 jferry
222 ! Added corner and edge cell data structures and routines
223 !
224 ! Revision 1.3 2003/05/05 21:58:29 fnajjar
225 ! Moved nRequests and nCv outside iPatch loop
226 !
227 ! Revision 1.2 2003/05/05 21:49:50 fnajjar
228 ! Moved pPeul pointer outside iPatch loop
229 !
230 ! Revision 1.1 2003/04/09 14:32:06 fnajjar
231 ! Initial Import of MPI-based rocsmoke
232 !
233 !******************************************************************************
234 
235 
236 
237 
238 
239 
240 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine peul_allocatedatabuffers(regions, iReg)