-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModPatchOld.f90
executable file
·321 lines (240 loc) · 6.45 KB
/
ModPatchOld.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
MODULE ModPatch
CONTAINS
SUBROUTINE AllocatePatches
USE module_variables
USE ModDecomp
IMPLICIT NONE
DO i = 1, Nz
DO j = 1, Nr
DO k = 1, 1
is_it_i_patch(i,j,k) = 0
is_it_j_patch(i,j,k) = 0
which_i_patch(i,j,k) = 0
which_j_patch(i,j,k) = 0
ENDDO
ENDDO
ENDDO
total_no_bcs = 0
reason = 0
bcno = 0
OPEN(UNIT=10,FILE=bc_file)
DO WHILE (abs(reason) .eq. 0)
READ(10,*,IOSTAT=reason)dummy_int, dummy_int, dummy_int, dummy_int, dummy_int, dummy_int
total_no_bcs = total_no_bcs + 1
ENDDO
CLOSE(10)
total_no_bcs = total_no_bcs - 1
no_bcs = 0
OPEN(UNIT=10,FILE=bc_file)
DO bcno = 1, total_no_bcs
READ(10,*)dummy_int, bctype, bcdir, bcistart, bciend, bcjstart, bcjend, dummy_int, dummy_int
!PRINT*, bcno, bcdir
IF(bcistart .eq. -1)THEN
bcistart = Nz_grid
ENDIF
IF(bcjstart .eq. -1)THEN
bcjstart = Nr_grid
ENDIF
IF(bciend .eq. -1)THEN
bciend = Nz_grid
ENDIF
IF(bcjend .eq. -1)THEN
bcjend = Nr_grid
ENDIF
IF(abs(bcdir) .eq. 1)THEN
IF(bcistart .ge. istart .and. bcistart .le. iend)THEN
IF(bcjstart .ge. jstart .and. bcjstart .le. jend)THEN
IF(bcjend .ge. jstart .and. bcjend .le. jend)THEN
PRINT*, rank, bcno
no_bcs = no_bcs+1
ELSE
PRINT*, rank, bcno
no_bcs = no_bcs+1
ENDIF
ELSEIF(bcjend .ge. jstart .and. bcjend .le. jend)THEN
PRINT*, rank, bcno
no_bcs = no_bcs + 1
ENDIF
ENDIF
IF(istart .eq. bcistart .or. iend .eq. bcistart)THEN
IF(jstart .gt. bcjstart .and. jend .lt. bcjend)THEN
PRINT*, rank, bcno
no_bcs = no_bcs+1
ENDIF
ENDIF
ENDIF
IF(abs(bcdir) .eq. 2)THEN
IF(bcjstart .ge. jstart .and. bcjstart .le. jend)THEN
IF(bcistart .ge. istart .and. bcistart .le. iend)THEN
IF(bciend .ge. istart .and. bciend .le. iend)THEN
PRINT*, rank, bcno
no_bcs = no_bcs+1
ELSE
PRINT*, rank, bcno
no_bcs = no_bcs+1
ENDIF
ELSEIF(bciend .ge. istart .and. bciend .le. iend)THEN
PRINT*, rank, bcno
no_bcs = no_bcs + 1
ENDIF
ENDIF
IF(jstart .eq. bcjstart .or. jend .eq. bcjstart)THEN
IF(istart .gt. bcistart .and. iend .lt. bciend)THEN
PRINT*, rank, bcno
no_bcs = no_bcs+1
ENDIF
ENDIF
ENDIF
ENDDO
CLOSE(10)
!PRINT*, rank, no_bcs
CALL MPI_Barrier(MPI_COMM_WORLD,ierr)
!CALL StopTheCode
ALLOCATE(patch(no_bcs))
END SUBROUTINE AllocatePatches
SUBROUTINE CreateAllPatches
USE module_variables
USE ModDecomp
IMPLICIT NONE
CALL AllocatePatches
CALL MPI_Barrier(MPI_COMM_WORLD,ierr)
!PRINT*, "Rank and bcs", rank, no_bcs
OPEN(UNIT=10,FILE=bc_file)
bcno = 1
DO i = 1, total_no_bcs
READ(10,*)dummy_int, bctype, bcdir, bcistart, bciend, bcjstart, bcjend, dummy_int, dummy_int
IF(bcistart .eq. -1)THEN
bcistart = Nz_grid
ENDIF
IF(bcjstart .eq. -1)THEN
bcjstart = Nr_grid
ENDIF
IF(bciend .eq. -1)THEN
bciend = Nz_grid
ENDIF
IF(bcjend .eq. -1)THEN
bcjend = Nr_grid
ENDIF
IF(abs(bcdir) .eq. 1)THEN
IF(bcistart .ge. istart .and. bcistart .le. iend)THEN
IF(bcjstart .ge. jstart .and. bcjstart .le. jend)THEN
IF(bcjend .ge. jstart .and. bcjend .le. jend)THEN
procistart = bcistart
prociend = bcistart
procjstart = bcjstart
procjend = bcjend
CALL PatchCreation
bcno = bcno + 1
ELSE
procistart = bcistart
prociend = bcistart
procjstart = bcjstart
procjend = jend
CALL PatchCreation
bcno = bcno + 1
ENDIF
ELSEIF(bcjend .ge. jstart .and. bcjend .le. jend)THEN
procistart = bcistart
prociend = bcistart
procjstart = jstart
procjend = bcjend
CALL PatchCreation
bcno = bcno + 1
ENDIF
ENDIF
IF(istart .eq. bcistart .or. iend .eq. bcistart)THEN
IF(jstart .gt. bcjstart .and. jend .lt. bcjend)THEN
procistart = bcistart
prociend = bcistart
procjstart = jstart
procjend = jend
CALL PatchCreation
bcno = bcno + 1
ENDIF
ENDIF
ENDIF
IF(abs(bcdir) .eq. 2)THEN
IF(bcjstart .ge. jstart .and. bcjstart .le. jend)THEN
IF(bcistart .ge. istart .and. bcistart .le. iend)THEN
IF(bciend .ge. istart .and. bciend .le. iend)THEN
procistart = bcistart
prociend = bciend
procjstart = bcjstart
procjend = bcjstart
CALL PatchCreation
bcno = bcno + 1
ELSE
procistart = bcistart
prociend = iend
procjstart = bcjstart
procjend = bcjstart
CALL PatchCreation
bcno = bcno + 1
ENDIF
ELSEIF(bciend .ge. istart .and. bciend .le. iend)THEN
procistart = istart
prociend = bciend
procjstart = bcjstart
procjend = bcjstart
CALL PatchCreation
bcno = bcno + 1
ENDIF
ENDIF
IF(jstart .eq. bcjstart .or. jend .eq. bcjstart)THEN
IF(istart .gt. bcistart .and. iend .lt. bciend)THEN
procistart = istart
prociend = iend
procjstart = bcjstart
procjend = bcjstart
CALL PatchCreation
bcno = bcno + 1
ENDIF
ENDIF
ENDIF
ENDDO
CLOSE(10)
WRITE(sol_file,101)rank
101 FORMAT("patch_data.",I3.3)
OPEN(UNIT=10,FILE=sol_file)
DO bcno = 1, no_bcs
WRITE(10,1)bcno, patch(bcno)%bc_dir, patch(bcno)%i_start, patch(bcno)%i_end, patch(bcno)%j_start, patch(bcno)%j_end
ENDDO
CLOSE(10)
1 FORMAT(6(I))
END SUBROUTINE CreateAllPatches
SUBROUTINE PatchCreation
USE module_variables
IMPLICIT NONE
! bc, bc_dir, i_start, i_end, j_start, j_end
patch(bcno)%bc = bctype
patch(bcno)%bc_dir = bcdir
istartval = procistart - istart + 1
iendval = prociend - istart + 1
jstartval = procjstart - jstart + 1
jendval = procjend - jstart + 1
IF(bcdir .eq. 1)THEN
patch(bcno)%i_start = istartval
patch(bcno)%i_end = istartval+3
patch(bcno)%j_start = jstartval
patch(bcno)%j_end = jendval
ENDIF
IF(bcdir .eq. -1)THEN
patch(bcno)%i_start = iendval-3
patch(bcno)%i_end = iendval
patch(bcno)%j_start = jstartval
patch(bcno)%j_end = jendval
ENDIF
IF(bcdir .eq. 2)THEN
patch(bcno)%i_start = istartval
patch(bcno)%i_end = iendval
patch(bcno)%j_start = jstartval
patch(bcno)%j_end = jstartval+3
ENDIF
IF(bcdir .eq. -2)THEN
patch(bcno)%i_start = istartval
patch(bcno)%i_end = iendval
patch(bcno)%j_start = jendval-3
patch(bcno)%j_end = jendval
ENDIF
END SUBROUTINE PatchCreation
END MODULE ModPatch