Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLO_MapRegionsProcessors.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: map regions to processors; assign local region numbers
26 ! on each processor.
27 !
28 ! Description: none.
29 !
30 ! Input: global = no. of processors, mapping type.
31 !
32 ! Output: regions = processor ID, local region number.
33 !
34 ! Notes: none.
35 !
36 !******************************************************************************
37 !
38 ! $Id: RFLO_MapRegionsProcessors.F90,v 1.3 2008/12/06 08:44:27 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2001 by the University of Illinois
41 !
42 !******************************************************************************
43 
44 SUBROUTINE rflo_mapregionsprocessors( regions )
45 
46  USE moddatatypes
47  USE moddatastruct, ONLY : t_region
48  USE modglobal, ONLY : t_global
49  USE modparameters
50  USE moderror
51  USE modmpi
52  IMPLICIT NONE
53 
54 ! ... parameters
55  TYPE(t_region), POINTER :: regions(:)
56 
57 ! ... loop variables
58  INTEGER :: iproc, ireg
59 
60 ! ... local variables
61  INTEGER :: iregbeg, iregend, local, iprat, ipmod
62 
63  TYPE(t_global), POINTER :: global
64 
65 !******************************************************************************
66 
67  global => regions(1)%global
68 
69  CALL registerfunction( global,'RFLO_MapRegionsProcessors',&
70  'RFLO_MapRegionsProcessors.F90' )
71 
72 ! "manual" region to processor mapping
73 
74  IF (global%nRegionsProc < 0) CALL errorstop( global,err_no_procmap,__line__ )
75 
76 ! automatic region to processor mapping
77 
78  IF (global%nRegionsProc == 0) THEN
79 
80  iprat = max(1,global%nRegions/global%nProcAlloc)
81  ipmod = mod(global%nRegions,global%nProcAlloc)
82 
83  iregbeg = 1
84  iregend = iprat
85  IF (ipmod > 0) THEN
86  iregend = iregend + 1
87  ipmod = ipmod - 1
88  ENDIF
89  DO iproc=0,global%nProcAlloc-1
90  local = 0
91  DO ireg=iregbeg,iregend ! regions on iproc
92  local = local + 1
93  IF (global%nProcAlloc>1 .AND. local>=mpi_patchoff) &
94  CALL errorstop( global,err_patch_offset,__line__ )
95  IF (global%nProcAlloc > 1) THEN
96  regions(ireg)%procid = iproc
97  ELSE
98  regions(ireg)%procid = masterproc
99  ENDIF
100  regions(ireg)%localNumber = local
101  ENDDO
102  iregbeg = iregend + 1
103  iregend = iregbeg + iprat - 1
104  IF (ipmod > 0) THEN
105  iregend = iregend + 1
106  ipmod = ipmod - 1
107  ENDIF
108  ENDDO
109 
110  ENDIF
111 
112 ! specified # of regions per processor
113 
114  IF (global%nRegionsProc > 0) THEN
115 
116  IF (global%nProcAlloc*global%nRegionsProc /= global%nRegions) &
117  CALL errorstop( global,err_no_procmatch,__line__ )
118 
119  iregbeg = 1
120  iregend = global%nRegionsProc
121 
122  DO iproc=0,global%nProcAlloc-1
123  local = 0
124  DO ireg=iregbeg,iregend ! regions on iproc
125  local = local + 1
126  IF (global%nProcAlloc>1 .AND. local>=mpi_patchoff) &
127  CALL errorstop( global,err_patch_offset,__line__ )
128  IF (global%nProcAlloc > 1) THEN
129  regions(ireg)%procid = iproc
130  ELSE
131  regions(ireg)%procid = masterproc
132  ENDIF
133  regions(ireg)%localNumber = local
134  ENDDO
135  iregbeg = iregend + 1
136  iregend = iregbeg + global%nRegionsProc - 1
137  ENDDO
138 
139  ENDIF
140 
141 ! finalize
142 
143  CALL deregisterfunction( global )
144 
145 END SUBROUTINE rflo_mapregionsprocessors
146 
147 !******************************************************************************
148 !
149 ! RCS Revision history:
150 !
151 ! $Log: RFLO_MapRegionsProcessors.F90,v $
152 ! Revision 1.3 2008/12/06 08:44:27 mtcampbe
153 ! Updated license.
154 !
155 ! Revision 1.2 2008/11/19 22:17:38 mtcampbe
156 ! Added Illinois Open Source License/Copyright
157 !
158 ! Revision 1.1 2004/11/29 20:51:39 wasistho
159 ! lower to upper case
160 !
161 ! Revision 1.6 2003/05/15 02:57:04 jblazek
162 ! Inlined index function.
163 !
164 ! Revision 1.5 2003/02/14 22:32:37 jblazek
165 ! Finished implementation of corener and edge cells.
166 !
167 ! Revision 1.4 2002/09/05 17:40:21 jblazek
168 ! Variable global moved into regions().
169 !
170 ! Revision 1.3 2002/06/07 16:40:37 jblazek
171 ! Grid & solution for all regions in one file.
172 !
173 ! Revision 1.2 2002/03/21 18:07:15 jblazek
174 ! Added check of MPI_PATCHOFF (for tags).
175 !
176 ! Revision 1.1 2002/02/21 23:25:06 jblazek
177 ! Blocks renamed as regions.
178 !
179 ! Revision 1.5 2002/02/09 01:47:01 jblazek
180 ! Added multi-probe option, residual smoothing, physical time step.
181 !
182 ! Revision 1.4 2002/01/11 17:20:19 jblazek
183 ! Added time stamp or iteration number to file names.
184 !
185 ! Revision 1.3 2001/12/22 00:09:39 jblazek
186 ! Added routines to store grid and solution.
187 !
188 ! Revision 1.2 2001/12/08 00:18:42 jblazek
189 ! Added routines to read BC input file.
190 !
191 ! Revision 1.1.1.1 2001/12/03 21:44:04 jblazek
192 ! Import of RocfluidMP
193 !
194 !******************************************************************************
195 
196 
197 
198 
199 
200 
201 
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine rflo_mapregionsprocessors(regions)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469