forked from KuangLab-Harvard/SAM_SRCv6.11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task_assign_bnd.f90
145 lines (108 loc) · 2.39 KB
/
task_assign_bnd.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
subroutine task_assign_bnd(f,dimx1,dimx2,dimy1,dimy2,dimz,buff,tag)
! this routine assignes the boundary info after MPI exchange
use grid
implicit none
integer dimx1, dimx2, dimy1, dimy2, dimz
real f(dimx1:dimx2, dimy1:dimy2, dimz)
real buff(*) ! buff for sending data
integer tag
integer i, j, k, n, proc
integer i1, i2, j1, j2
! The dimensions of the fields in common com3d. Needed by MPI
! Decode the tag:
i= tag/100000
i1 = (tag-i*100000)/10000
i2 = (tag-i*100000-i1*10000)/1000
j1 = (tag-i*100000-i1*10000-i2*1000)/100
j2 = (tag-i*100000-i1*10000-i2*1000-j1*100)/10
proc =tag-i*100000-i1*10000-i2*1000-j1*100-j2*10
! From "North":
if (proc.eq.1) then
n=0
do k=1,dimz
do j=nyp1,nyp1+j2
do i=1,nx
n = n+1
f(i,j,k) = buff(n)
end do
end do
end do
! From "North-East":
elseif(proc.eq.2) then
n=0
do k=1,dimz
do j=nyp1,nyp1+j2
do i=nxp1,nxp1+i2
n = n+1
f(i,j,k) = buff(n)
end do
end do
end do
! From "East":
elseif(proc.eq.3) then
n=0
do k=1,dimz
do j=1,ny
do i=nxp1,nxp1+i2
n = n+1
f(i,j,k) = buff(n)
end do
end do
end do
! From "South-East":
elseif(proc.eq.4) then
n=0
do k=1,dimz
do j=-j1,0
do i=nxp1,nxp1+i2
n = n+1
f(i,j,k) = buff(n)
end do
end do
end do
! From "South":
elseif(proc.eq.5) then
n=0
do k=1,dimz
do j=-j1,0
do i=1,nx
n = n+1
f(i,j,k) = buff(n)
end do
end do
end do
! From "South-West":
elseif(proc.eq.6) then
n=0
do k=1,dimz
do j=-j1,0
do i=-i1,0
n = n+1
f(i,j,k) = buff(n)
end do
end do
end do
! From "West":
elseif(proc.eq.7) then
n=0
do k=1,dimz
do j=1,ny
do i=-i1,0
n = n+1
f(i,j,k) = buff(n)
end do
end do
end do
! From "North-West":
elseif(proc.eq.8) then
n=0
do k=1,dimz
do j=nyp1,nyp1+j2
do i=-i1,0
n = n+1
f(i,j,k) = buff(n)
end do
end do
end do
endif
end