forked from KuangLab-Harvard/SAM_SRCv6.11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_ranks.f90
75 lines (52 loc) · 1.28 KB
/
task_ranks.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
subroutine task_ranks
use grid
implicit none
integer i, j, i1, j1
! "Coordinates" of the current subdomain:
j = rank/nsubdomains_x + 1
i = rank+1 - (j-1)*nsubdomains_x
! Northen neighbour:
i1 = i
j1 = j + 1
if(j1.gt.nsubdomains_y) j1 = 1
ranknn = i1 + (j1-1)*nsubdomains_x - 1
! North-Eastern neighbour:
i1 = i + 1
j1 = j + 1
if(j1.gt.nsubdomains_y) j1 = 1
if(i1.gt.nsubdomains_x) i1 = 1
rankne = i1 + (j1-1)*nsubdomains_x - 1
! Eastern neighbour:
i1 = i + 1
j1 = j
if(i1.gt.nsubdomains_x) i1 = 1
rankee = i1 + (j1-1)*nsubdomains_x - 1
! South-Eastern neighbour:
i1 = i + 1
j1 = j - 1
if(j1.lt.1) j1 = nsubdomains_y
if(i1.gt.nsubdomains_x) i1 = 1
rankse = i1 + (j1-1)*nsubdomains_x - 1
! Southern neighbour:
i1 = i
j1 = j - 1
if(j1.lt.1) j1 = nsubdomains_y
rankss = i1 + (j1-1)*nsubdomains_x - 1
! South-Western neighbour:
i1 = i - 1
j1 = j - 1
if(j1.lt.1) j1 = nsubdomains_y
if(i1.lt.1) i1 = nsubdomains_x
ranksw = i1 + (j1-1)*nsubdomains_x - 1
! Western neighbour:
i1 = i - 1
j1 = j
if(i1.lt.1) i1 = nsubdomains_x
rankww = i1 + (j1-1)*nsubdomains_x - 1
! North-Western neighbour:
i1 = i - 1
j1 = j + 1
if(j1.gt.nsubdomains_y) j1 = 1
if(i1.lt.1) i1 = nsubdomains_x
ranknw = i1 + (j1-1)*nsubdomains_x - 1
end