Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_RFLO_SendRecvMetrics.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: driver to communicate buffer data of RFLO metrics, face centroids
26 ! and face normals, for adjacent regions on different processors.
27 !
28 ! Description: none.
29 !
30 ! Input: regions = data of all regions.
31 !
32 ! Output: buffer data for metrics.
33 !
34 ! Notes: None.
35 !
36 !******************************************************************************
37 !
38 ! $Id: PLAG_RFLO_SendRecvMetrics.F90,v 1.4 2008/12/06 08:44:35 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2004 by the University of Illinois
41 !
42 !******************************************************************************
43 
44 SUBROUTINE plag_rflo_sendrecvmetrics( regions )
45 
46  USE moddatatypes
47  USE moddatastruct, ONLY : t_region, t_level, t_dcelltransf
48  USE modglobal, ONLY : t_global
49  USE modpartlag, ONLY : t_plag
53  USE moderror
54  USE modmpi
55  USE modparameters
57  IMPLICIT NONE
58 
59 ! ... parameters
60  TYPE(t_region), POINTER :: regions(:)
61 
62 ! ... loop variables
63  INTEGER :: icorner, iedge, ijk, ilev, ir, ireg
64 
65 ! ... local variables
66  CHARACTER(CHRLEN) :: rcsidentstring
67 
68  INTEGER :: errorflag
69  INTEGER :: ncorners, nedges
70  INTEGER :: nfaces, nfacecentroidsize, nfacenormalsize, nmetricsbuff
71 
72  TYPE(t_level), POINTER :: plevel
73  TYPE(t_dcelltransf), POINTER :: psendeccell, precveccell
74  TYPE(t_plag), POINTER :: pplag
75  TYPE(t_global), POINTER :: global
76 
77 !******************************************************************************
78 
79  rcsidentstring = '$RCSfile: PLAG_RFLO_SendRecvMetrics.F90,v $ $Revision: 1.4 $'
80 
81  global => regions(1)%global
82 
83  CALL registerfunction( global,'PLAG_RFLO_SendRecvMetrics',&
84  'PLAG_RFLO_SendRecvMetrics.F90' )
85 
86 ! Set dimensions --------------------------------------------------------------
87 
88  ncorners = 8
89  nedges = 12
90  nfaces = 6
91 
92  nfacecentroidsize = zcoord*kcoord
93  nfacenormalsize = 3*kcoord
94  nmetricsbuff = nfaces*(nfacecentroidsize + nfacenormalsize)
95 
96 ! Allocate communicaton buffers ===============================================
97 
98  DO ireg = 1, global%nRegions
99  IF ( regions(ireg)%procid==global%myProcid .AND. & ! region active and
100  regions(ireg)%active==active .AND. & ! on my processor
101  global%nProcAlloc > 1 ) THEN ! only if multiple processors
102 
103  DO ilev=1,regions(ireg)%nGridLevels
104  pplag => regions(ireg)%levels(ilev)%plag
105  pplag%nRequestsMetrics = 0
106 
107  DO ir=1,global%nRegions
108  psendeccell => regions(ireg)%levels(ilev)%sendEcCells(ir)
109  precveccell => regions(ireg)%levels(ilev)%recvEcCells(ir)
110 
111  IF ( psendeccell%nCells > 0 ) THEN
112  pplag%nRequestsMetrics = pplag%nRequestsMetrics+1
113  psendeccell%iRequestMetrics = pplag%nRequestsMetrics
114  ALLOCATE( psendeccell%buffMetrics(psendeccell%nCells*nmetricsbuff), &
115  stat=errorflag )
116  global%error = errorflag
117  IF ( global%error /= err_none ) &
118  CALL errorstop( global,err_allocate,__line__ )
119  ENDIF ! pSendEcCell%nCells
120 
121  IF ( precveccell%nCells > 0 ) THEN
122  precveccell%iRequestMetrics = -999999
123  ALLOCATE( precveccell%buffMetrics(precveccell%nCells*nmetricsbuff), &
124  stat=errorflag )
125  global%error = errorflag
126  IF ( global%error /= err_none ) &
127  CALL errorstop( global,err_allocate,__line__ )
128  ENDIF ! pRecvEcCell%nCell
129  ENDDO ! ir
130 
131  ALLOCATE(pplag%requestsMetrics(pplag%nRequestsMetrics), stat=errorflag )
132  global%error = errorflag
133  IF ( global%error /= err_none ) &
134  CALL errorstop( global,err_allocate,__line__ )
135 
136  ENDDO ! iLev
137 
138  ENDIF ! regions
139  ENDDO ! iReg
140 
141 ! synchronize through an MPI barrier ------------------------------------------
142 
143 #ifdef MPI
144  CALL mpi_barrier( global%mpiComm,global%mpierr )
145  IF ( global%mpierr /= err_none ) &
146  CALL errorstop( global,err_mpi_trouble,__line__ )
147 #endif
148 
149 ! communicate buffer ----------------------------------------------------------
150 
151 ! send buffer------------------------------------------------------------------
152 
153  DO ireg = 1, global%nRegions
154  IF (regions(ireg)%procid==global%myProcid .AND. & ! region active and
155  regions(ireg)%active==active) THEN ! on my processor
156  CALL plag_rflo_sendmetrics(regions, ireg)
157  ENDIF ! regions
158  ENDDO ! iReg
159 
160 ! receive buffer --------------------------------------------------------------
161 
162  DO ireg = 1, global%nRegions
163  IF (regions(ireg)%procid==global%myProcid .AND. & ! region active and
164  regions(ireg)%active==active) THEN ! on my processor
165  CALL plag_rflo_recvmetrics(regions, ireg)
166  ENDIF ! regions
167  ENDDO ! iReg
168 
169 ! wait for data being received by other processors ----------------------------
170 
171  DO ireg = 1, global%nRegions
172  IF (regions(ireg)%procid==global%myProcid .AND. & ! region active and
173  regions(ireg)%active==active) THEN ! on my processor
174  CALL plag_rflo_clearsendrequests(regions, ireg)
175  ENDIF ! regions
176  ENDDO ! iReg
177 
178 ! synchronize through an MPI barrier ------------------------------------------
179 
180 #ifdef MPI
181  CALL mpi_barrier( global%mpiComm,global%mpierr )
182  IF ( global%mpierr /= err_none ) &
183  CALL errorstop( global,err_mpi_trouble,__line__ )
184 #endif
185 
186 ! deallocate communicaton buffers ---------------------------------------------
187 
188  DO ireg = 1, global%nRegions
189  IF ( regions(ireg)%procid==global%myProcid .AND. & ! region active and
190  regions(ireg)%active==active .AND. & ! on my processor
191  global%nProcAlloc > 1 ) THEN ! only if multiple processors
192 
193  DO ilev=1,regions(ireg)%nGridLevels
194  pplag => regions(ireg)%levels(ilev)%plag
195 
196  DO ir=1,global%nRegions
197  psendeccell => regions(ireg)%levels(ilev)%sendEcCells(ir)
198  precveccell => regions(ireg)%levels(ilev)%recvEcCells(ir)
199 
200  IF ( psendeccell%nCells > 0 ) THEN
201  DEALLOCATE( psendeccell%buffMetrics, stat=errorflag )
202  global%error = errorflag
203  IF ( global%error /= err_none ) &
204  CALL errorstop( global,err_deallocate,__line__ )
205  ENDIF ! pSendEcCell%nCells
206 
207  IF ( precveccell%nCells > 0 ) THEN
208  DEALLOCATE( precveccell%buffMetrics, stat=errorflag )
209  global%error = errorflag
210  IF ( global%error /= err_none ) &
211  CALL errorstop( global,err_deallocate,__line__ )
212  ENDIF ! pRecvEcCell%nCell
213  ENDDO ! ir
214 
215  DEALLOCATE(pplag%requestsMetrics, stat=errorflag )
216  global%error = errorflag
217  IF ( global%error /= err_none ) &
218  CALL errorstop( global,err_deallocate,__line__ )
219 
220  ENDDO ! iLev
221 
222  ENDIF ! regions
223  ENDDO ! iReg
224 
225 ! synchronize through an MPI barrier ------------------------------------------
226 
227 #ifdef MPI
228  CALL mpi_barrier( global%mpiComm,global%mpierr )
229  IF ( global%mpierr /= err_none ) &
230  CALL errorstop( global,err_mpi_trouble,__line__ )
231 #endif
232 
233 ! finalize --------------------------------------------------------------------
234 
235  CALL deregisterfunction( global )
236 
237 END SUBROUTINE plag_rflo_sendrecvmetrics
238 
239 !******************************************************************************
240 !
241 ! RCS Revision history:
242 !
243 ! $Log: PLAG_RFLO_SendRecvMetrics.F90,v $
244 ! Revision 1.4 2008/12/06 08:44:35 mtcampbe
245 ! Updated license.
246 !
247 ! Revision 1.3 2008/11/19 22:17:47 mtcampbe
248 ! Added Illinois Open Source License/Copyright
249 !
250 ! Revision 1.2 2006/04/07 15:19:24 haselbac
251 ! Removed tabs
252 !
253 ! Revision 1.1 2004/12/01 20:58:14 fnajjar
254 ! Initial revision after changing case
255 !
256 ! Revision 1.1 2004/01/15 21:16:48 fnajjar
257 ! Initial import for corner-edge cell metrics
258 !
259 !******************************************************************************
260 
261 
262 
263 
264 
265 
266 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
IndexType nedges() const
Definition: Mesh.H:564
subroutine plag_rflo_sendrecvmetrics(regions)
IndexType nfaces() const
Definition: Mesh.H:641
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE icorner
subroutine plag_rflo_clearsendrequests(regions, iReg)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine plag_rflo_recvmetrics(regions, iReg)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine plag_rflo_sendmetrics(regions, iReg)