Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_BufferSizeSend.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 size to adjacent region on different processor.
26 !
27 ! Description: none.
28 !
29 ! Input: regions = data of all regions
30 ! iReg = index of current region.
31 !
32 ! Output: buffer size to other processors.
33 !
34 ! Notes: None.
35 !
36 !******************************************************************************
37 !
38 ! $Id: PLAG_BufferSizeSend.F90,v 1.4 2009/03/02 00:19:36 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2003 by the University of Illinois
41 !
42 !******************************************************************************
43 
44 SUBROUTINE plag_buffersizesend( regions, iReg )
45 
46  USE moddatatypes
47  USE modpartlag, ONLY : t_buffer_plag
48  USE modbndpatch, ONLY : t_patch
49  USE moddatastruct, ONLY : t_region
50  USE modglobal, ONLY : t_global
51  USE modpartlag, ONLY : t_plag
52  USE moderror
53  USE modmpi
54  USE modparameters
56  IMPLICIT NONE
57 
58 ! ... parameters
59  TYPE(t_region), POINTER :: regions(:)
60 
61  INTEGER :: ireg
62 
63 ! ... loop variables
64  INTEGER :: ipatch
65 
66 ! ... local variables
67  CHARACTER(CHRLEN) :: rcsidentstring
68 
69 #ifdef MPI
70  INTEGER :: statusplag(mpi_status_size)
71 #endif
72 
73  INTEGER :: bctype, ilev, ipatchdes,iregdes, irequestplag, &
74  narv, naiv, nbuffi, nbuffr, nbuffsizesrc, ncont, &
75  ncv, ndimbuffsize, ndv, npatches,nsendbuffi, &
76  nsendbuffr, ntv, procdes, tagdes
77 
78  TYPE(t_patch), POINTER :: patchsrc, patchdes
79  TYPE(t_plag), POINTER :: pplag
80  TYPE(t_global), POINTER :: global
81 
82 !******************************************************************************
83 
84  rcsidentstring = '$RCSfile: PLAG_BufferSizeSend.F90,v $ $Revision: 1.4 $'
85 
86  global => regions(ireg)%global
87 
88  CALL registerfunction( global,'PLAG_BufferSizeSend',&
89  'PLAG_BufferSizeSend.F90' )
90 
91 ! get dimensions and set pointer ----------------------------------------------
92 
93  ncont = regions(ireg)%plagInput%nCont
94  ncv = cv_plag_last + ncont
95  ndv = dv_plag_last
96  ntv = tv_plag_last
97  naiv = aiv_plag_last
98  narv = arv_plag_last
99 
100  nbuffi = 2*naiv
101  nbuffr = 2*narv +4*ncv +ndv +ntv
102  ndimbuffsize = 1
103 
104  ilev = regions(ireg)%currLevel
105  npatches = regions(ireg)%nPatches
106 
107  pplag => regions(ireg)%levels(ilev)%plag
108 
109 ! loop over patches -----------------------------------------------------------
110 
111  DO ipatch = 1, npatches
112 
113 ! - pointer is at Src region sending data to Des region -----------------------
114 
115  patchsrc => regions(ireg)%levels(ilev)%patches(ipatch)
116 
117  bctype = patchsrc%bcType
118  iregdes = patchsrc%srcRegion
119  ipatchdes = patchsrc%srcPatch
120 
121 ! - region interface for various boundary conditions --------------------------
122 
123  IF ( (bctype>=bc_regionconf .AND. bctype<=bc_regionconf+bc_range) .OR. &
124  (bctype>=bc_regionint .AND. bctype<=bc_regionint +bc_range) .OR. &
125  (bctype>=bc_regnonconf .AND. bctype<=bc_regnonconf+bc_range) .OR. &
126  (bctype>=bc_tra_peri .AND. bctype<=bc_tra_peri +bc_range) .OR. &
127  (bctype>=bc_rot_peri .AND. bctype<=bc_rot_peri +bc_range) ) THEN
128 
129  IF ( regions(iregdes)%procid /= global%myProcid ) THEN
130  patchdes => regions(iregdes)%levels(ilev)%patches(ipatchdes)
131 
132  nbuffsizesrc = patchsrc%bufferPlag%nBuffSize
133 
134  nsendbuffi = nbuffi *nbuffsizesrc
135  nsendbuffr = nbuffr *nbuffsizesrc
136 
137  patchsrc%bufferPlag%nSendBuffI = nsendbuffi
138  patchsrc%bufferPlag%nSendBuffR = nsendbuffr
139 
140  irequestplag = patchsrc%bufferPlag%iRequest
141 
142 #ifdef PLAG_MPI_DEBUG
143  IF( nbuffsizesrc /= 0 ) &
144  WRITE(stdout,*) ' PLAG_BufferSizeSend: iReg, nBuffSizeSrc, nDimBuffSize, iRequestPlag = ',&
145  ireg, nbuffsizesrc, ndimbuffsize, irequestplag
146 #endif
147 
148 #ifdef MPI
149  procdes = regions(iregdes)%procid
150  tagdes = regions(iregdes)%localNumber &
151  + plag_tag_shift +mpi_patchoff*ipatchdes*iregdes + procdes
152 
153  IF(tagdes .gt. global%mpiTagMax) tagdes = mod(tagdes,global%mpiTagMax)
154 
155 #ifdef PLAG_MPI_DEBUG
156  IF( nbuffsizesrc /= 0 ) &
157  WRITE(stdout,*) ' PLAG_BufferSizeSend: iReg, iRegDes, procDes, tagDes = ',&
158  ireg, iregdes, procdes,tagdes
159 #endif
160 
161  CALL mpi_isend( patchsrc%bufferPlag%nBuffSize, &
162  ndimbuffsize,mpi_integer, &
163  procdes,tagdes,global%mpiComm, &
164  pplag%requests(irequestplag),global%mpierr )
165 
166  IF (global%mpierr /= err_none) &
167  CALL errorstop( global,err_mpi_trouble,__line__ )
168 #endif
169 
170  ENDIF ! regions
171  ENDIF ! bcType
172 
173  ENDDO ! iPatch
174 
175 ! finalize --------------------------------------------------------------------
176 
177  CALL deregisterfunction( global )
178 
179 END SUBROUTINE plag_buffersizesend
180 
181 !******************************************************************************
182 !
183 ! RCS Revision history:
184 !
185 ! $Log: PLAG_BufferSizeSend.F90,v $
186 ! Revision 1.4 2009/03/02 00:19:36 mtcampbe
187 ! Added some ifdefs around Rocflo to disable particle injection on INFLOW
188 ! boundaries and added some checks around MPI tags utilizing a new global
189 ! data item, global%mpiTagMax.
190 !
191 ! Revision 1.3 2008/12/06 08:44:32 mtcampbe
192 ! Updated license.
193 !
194 ! Revision 1.2 2008/11/19 22:17:45 mtcampbe
195 ! Added Illinois Open Source License/Copyright
196 !
197 ! Revision 1.1 2004/12/01 20:56:59 fnajjar
198 ! Initial revision after changing case
199 !
200 ! Revision 1.10 2004/04/09 23:05:54 fnajjar
201 ! Added IF statement to activate only for non-null buffer size
202 !
203 ! Revision 1.9 2004/03/21 00:43:32 fnajjar
204 ! Fixed tags to be smaller number since Frost run-time system complains about size
205 !
206 ! Revision 1.8 2004/03/06 21:25:05 fnajjar
207 ! Added PLAG_TAG_SHIFT to MPI-based communication tags
208 !
209 ! Revision 1.7 2003/05/27 19:14:16 fnajjar
210 ! Removed distPartBurning and all pertinent LOGICAL datastructure
211 !
212 ! Revision 1.6 2003/05/07 00:15:05 fnajjar
213 ! Included I/O within ifdef PLAG_MPI_DEBUG construct
214 !
215 ! Revision 1.5 2003/01/24 23:10:15 f-najjar
216 ! Added to tagSrc and tagDes procId for Des region to avoid tag collision
217 !
218 ! Revision 1.4 2003/01/24 22:37:55 f-najjar
219 ! Made tagDes less prone to tag collision by multiplying by iRegDes
220 !
221 ! Revision 1.3 2003/01/24 22:33:35 f-najjar
222 ! Used generic ERR_NONE for MPI error trapping
223 !
224 ! Revision 1.2 2003/01/23 17:51:34 f-najjar
225 ! Add ModMPI for MPI communication
226 !
227 ! Revision 1.1 2003/01/23 17:31:22 f-najjar
228 ! Initial import for MPI
229 !
230 !******************************************************************************
231 
232 
233 
234 
235 
236 
237 
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 plag_buffersizesend(regions, iReg)