Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_CECellsSendData.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: send buffer data from edge and corner cells to an adjacent region.
26 !
27 ! Description: kernel is pertinent when the other region is located
28 ! on a different processor.
29 !
30 ! Input:
31 ! regions = data of all regions
32 ! iReg = current region.
33 !
34 ! Output:
35 ! buffer data sent.
36 !
37 ! Notes: none.
38 !
39 !******************************************************************************
40 !
41 ! $Id: PLAG_CECellsSendData.F90,v 1.4 2009/03/02 00:19:36 mtcampbe Exp $
42 !
43 ! Copyright: (c) 2004 by the University of Illinois
44 !
45 !******************************************************************************
46 
47 SUBROUTINE plag_cecellssenddata( regions,iReg )
48 
49  USE moddatatypes
50  USE moderror
51  USE modmpi
52  USE modparameters
53  USE modglobal, ONLY : t_global
54  USE moddatastruct, ONLY : t_dcell, t_dcelltransf, t_region, t_level
55  USE modpartlag, ONLY : t_plag, t_buffer_plag
56 
58 
61 
62  IMPLICIT NONE
63 
64 ! ******************************************************************************
65 ! Definitions and declarations
66 ! ******************************************************************************
67 
68 ! ==============================================================================
69 ! Arguments
70 ! ==============================================================================
71 
72  TYPE(t_region), POINTER :: regions(:)
73 
74  INTEGER, INTENT(IN) :: ireg
75 
76 ! ==============================================================================
77 ! Locals
78 ! ==============================================================================
79 
80  CHARACTER(CHRLEN) :: rcsidentstring
81 
82  INTEGER :: dest,ilev,ir,iregdes,iregsrc,irequestplag,tagi,tagr
83  INTEGER :: nbuffsizecornsrc,nbuffsizeedgesrc,nbuffsizetotsrc
84  INTEGER :: narv,naiv,ncont,ncv,ndimi,ndimr,nsendbuffi,nsendbuffr
85  INTEGER, POINTER, DIMENSION(:) :: psendbuffi
86 
87  REAL(RFREAL), POINTER, DIMENSION(:) :: psendbuffr
88 
89  TYPE(t_dcelltransf), POINTER :: psendeccell
90  TYPE(t_global), POINTER :: global
91  TYPE(t_level), POINTER :: plevelsrc
92  TYPE(t_plag), POINTER :: pplag
93  TYPE(t_region), POINTER :: pregionsrc
94 
95 ! ******************************************************************************
96 ! Start
97 ! ******************************************************************************
98 
99  rcsidentstring = '$RCSfile: PLAG_CECellsSendData.F90,v $ $Revision: 1.4 $'
100 
101  global => regions(ireg)%global
102 
103  CALL registerfunction( global,'PLAG_CECellsSendData',&
104  'PLAG_CECellsSendData.F90' )
105 
106 ! ******************************************************************************
107 ! Get dimensions
108 ! ******************************************************************************
109 
110  ilev = regions(ireg)%currLevel
111 
112  nbuffsizeedgesrc = 0
113  nbuffsizecornsrc = 0
114  nbuffsizetotsrc = 0
115 
116 ! ******************************************************************************
117 ! Set pointers
118 ! ******************************************************************************
119 
120  pregionsrc => regions(ireg)
121  plevelsrc => pregionsrc%levels(ilev)
122  pplag => plevelsrc%plag
123 
124 ! ******************************************************************************
125 ! Set send buffer dimensions
126 ! ******************************************************************************
127 
128  naiv = pplag%nAiv
129  narv = pplag%nArv
130  ncv = pplag%nCv
131 
132  ndimi = naiv
133  ndimr = 2*narv +4*ncv
134 
135 ! ******************************************************************************
136 ! Load send buffer data
137 ! ******************************************************************************
138 
139  DO ir=1,global%nRegions
140  IF (regions(ir)%procid == global%myProcid) goto 999
141 
142  IF ( plevelsrc%sendEcCells(ir)%nCells > 0 ) THEN
143  psendeccell => plevelsrc%sendEcCells(ir)
144  psendbuffi => psendeccell%buffplagI
145  psendbuffr => psendeccell%buffplagR
146 
147 ! =============================================================================
148 ! Bypass MPI communication for null buffer size
149 ! =============================================================================
150 
151  IF ( psendeccell%nBuffSizePlag == 0 ) goto 1999
152 
153 ! =============================================================================
154 ! Load buffer data for edges
155 ! =============================================================================
156 
157  CALL plag_edgecellsloadsendbuff( regions,ireg,ir,nbuffsizeedgesrc )
158 
159 ! =============================================================================
160 ! Load buffer data for corners
161 ! =============================================================================
162 
163  CALL plag_corncellsloadsendbuff( regions,ireg,ir,nbuffsizeedgesrc, &
164  nbuffsizecornsrc )
165 
166 ! =============================================================================
167 ! Trap error for inconsistent buffer sizes
168 ! =============================================================================
169 
170  nbuffsizetotsrc= nbuffsizecornsrc+nbuffsizeedgesrc
171  IF ( nbuffsizetotsrc /= psendeccell%nBuffSizePlag ) THEN
172  WRITE(stdout,*) 'PLAG_CECellsSendData: Error inconsistent buffer sizes'
173  WRITE(stdout,*) ' nBuffSizeEdgeSrc = ', nbuffsizeedgesrc
174  WRITE(stdout,*) ' nBuffSizeCornSrc = ', nbuffsizecornsrc
175  WRITE(stdout,*) ' nBuffSizeTotSrc = ', nbuffsizetotsrc
176  WRITE(stdout,*) ' pSendEcCell%nBuffSizePlag = ', psendeccell%nBuffSizePlag
177 
178 ! TEMPORARY
179 ! CALL ErrorStop(global,ERR_PLAG_BUFFSIZE,__LINE__,errorString)
180 #ifdef MPI
181  CALL mpi_finalize(global%mpierr)
182 #endif
183  stop
184 ! END TEMPORARY
185  ENDIF ! nBuffSizeTotSrc
186 
187 ! =============================================================================
188 ! Send buffer data to destination processor
189 ! =============================================================================
190 
191  nsendbuffi = ndimi * psendeccell%nBuffSizePlag
192  nsendbuffr = ndimr * psendeccell%nBuffSizePlag
193 
194  irequestplag = psendeccell%iRequestPlag
195 
196 #ifdef MPI
197  dest = regions(ir)%procid
198 
199 !------------------------------------------------------------------------------
200 ! Integer buffer data
201 !------------------------------------------------------------------------------
202 
203  tagi = regions(ir)%localNumber +plag_tag_shift +mpi_patchoff +2000
204 
205  IF(tagi .gt. global%mpiTagMax) tagi = mod(tagi,global%mpiTagMax)
206 
207 #ifdef PLAG_CECELLS_MPI_DEBUG
208  WRITE(stdout,'(A,A,7(2X,I5))') &
209  ' PLAG_CECellsSendData-INT: iRegDes, iRegSrc, procDes, procSrc,',&
210  'tagSrc, nBuffSizePlag,nSendBuffI = ',&
211  ir, ireg, dest, global%myProcid,tagi, psendeccell%nBuffSizePlag,nsendbuffi
212 #endif
213 
214  CALL mpi_isend( psendbuffi,nsendbuffi,mpi_integer, &
215  dest,tagi,global%mpiComm, &
216  pplag%requestsCECellsI(irequestplag),global%mpierr )
217  IF ( global%mpierr /= err_none ) &
218  CALL errorstop( global,err_mpi_trouble,__line__ )
219 
220 !------------------------------------------------------------------------------
221 ! Real buffer data
222 !------------------------------------------------------------------------------
223 
224  tagr = regions(ir)%localNumber +plag_tag_shift +mpi_patchoff +3000
225  IF(tagr .gt. global%mpiTagMax) tagr = mod(tagr,global%mpiTagMax)
226 
227 #ifdef PLAG_CECELLS_MPI_DEBUG
228  WRITE(stdout,'(A,A,7(2X,I5))') &
229  ' PLAG_CECellsSendData-REAL: iRegDes, iRegSrc, procDes, procSrc,',&
230  'tagSrc, nBuffSizePlag,nSendBuffR = ',&
231  ir, ireg, dest, global%myProcid,tagr, psendeccell%nBuffSizePlag,nsendbuffr
232 #endif
233 
234  CALL mpi_isend( psendbuffr,nsendbuffr,mpi_rfreal, &
235  dest,tagr,global%mpiComm, &
236  pplag%requestsCECellsR(irequestplag),global%mpierr )
237  IF ( global%mpierr /= err_none ) &
238  CALL errorstop( global,err_mpi_trouble,__line__ )
239 
240 #endif
241 1999 CONTINUE
242  ENDIF ! some cells to send
243 
244 999 CONTINUE
245  ENDDO ! ir
246 
247 ! ******************************************************************************
248 ! finalize
249 ! ******************************************************************************
250 
251  CALL deregisterfunction( global )
252 
253 END SUBROUTINE plag_cecellssenddata
254 
255 !******************************************************************************
256 !
257 ! RCS Revision history:
258 !
259 ! $Log: PLAG_CECellsSendData.F90,v $
260 ! Revision 1.4 2009/03/02 00:19:36 mtcampbe
261 ! Added some ifdefs around Rocflo to disable particle injection on INFLOW
262 ! boundaries and added some checks around MPI tags utilizing a new global
263 ! data item, global%mpiTagMax.
264 !
265 ! Revision 1.3 2008/12/06 08:44:33 mtcampbe
266 ! Updated license.
267 !
268 ! Revision 1.2 2008/11/19 22:17:45 mtcampbe
269 ! Added Illinois Open Source License/Copyright
270 !
271 ! Revision 1.1 2004/12/01 20:57:17 fnajjar
272 ! Initial revision after changing case
273 !
274 ! Revision 1.2 2004/03/20 21:32:34 fnajjar
275 ! Added more writing statement for error trapping
276 !
277 ! Revision 1.1 2004/03/18 21:43:27 fnajjar
278 ! Initial import for MPI-based data buffer communication
279 !
280 !******************************************************************************
281 
282 
283 
284 
285 
286 
287 
subroutine plag_edgecellsloadsendbuff(regions, iReg, ir, nBuffSizeEdge)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine plag_cecellssenddata(regions, iReg)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine plag_corncellsloadsendbuff(regions, iReg, ir, nBuffSizeEdge, nBuffSizeCorn)