-
Notifications
You must be signed in to change notification settings - Fork 3
/
tea_leaf_cg.f90
161 lines (125 loc) · 5.36 KB
/
tea_leaf_cg.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
MODULE tea_leaf_cg_module
USE tea_leaf_cg_kernel_module
USE definitions_module
IMPLICIT NONE
CONTAINS
SUBROUTINE tea_leaf_cg_init(rro)
IMPLICIT NONE
INTEGER :: t
REAL(KIND=8) :: rro,tile_rro
rro = 0.0_8
IF (use_fortran_kernels) THEN
!$OMP PARALLEL PRIVATE(tile_rro) REDUCTION(+:rro)
!$OMP DO
DO t=1,tiles_per_task
tile_rro = 0.0_8
CALL tea_leaf_cg_init_kernel(chunk%tiles(t)%field%x_min, &
chunk%tiles(t)%field%x_max, &
chunk%tiles(t)%field%y_min, &
chunk%tiles(t)%field%y_max, &
chunk%halo_exchange_depth, &
chunk%tiles(t)%field%vector_p, &
chunk%tiles(t)%field%vector_r, &
chunk%tiles(t)%field%vector_Mi, &
chunk%tiles(t)%field%vector_z, &
chunk%tiles(t)%field%vector_Kx, &
chunk%tiles(t)%field%vector_Ky, &
chunk%tiles(t)%field%vector_Di, &
chunk%tiles(t)%field%tri_cp, &
chunk%tiles(t)%field%tri_bfp, &
chunk%tiles(t)%field%rx, &
chunk%tiles(t)%field%ry, &
tile_rro, tl_preconditioner_type)
rro = rro + tile_rro
ENDDO
!$OMP END DO NOWAIT
!$OMP END PARALLEL
ENDIF
END SUBROUTINE tea_leaf_cg_init
SUBROUTINE tea_leaf_cg_calc_w( pw)
IMPLICIT NONE
INTEGER :: t
REAL(KIND=8) :: pw, tile_pw
pw = 0.0_08
IF (use_fortran_kernels) THEN
!$OMP PARALLEL PRIVATE(tile_pw) REDUCTION(+:pw)
!$OMP DO
DO t=1,tiles_per_task
tile_pw = 0.0_8
CALL tea_leaf_cg_calc_w_kernel(chunk%tiles(t)%field%x_min,&
chunk%tiles(t)%field%x_max, &
chunk%tiles(t)%field%y_min, &
chunk%tiles(t)%field%y_max, &
chunk%halo_exchange_depth, &
chunk%tiles(t)%field%vector_p, &
chunk%tiles(t)%field%vector_w, &
chunk%tiles(t)%field%vector_Kx, &
chunk%tiles(t)%field%vector_Ky, &
chunk%tiles(t)%field%vector_Di, &
chunk%tiles(t)%field%rx, &
chunk%tiles(t)%field%ry, &
tile_pw)
pw = pw + tile_pw
ENDDO
!$OMP END DO NOWAIT
!$OMP END PARALLEL
ENDIF
END SUBROUTINE tea_leaf_cg_calc_w
SUBROUTINE tea_leaf_cg_calc_ur( alpha, rrn)
IMPLICIT NONE
INTEGER :: t
REAL(KIND=8) :: alpha, rrn, tile_rrn
rrn = 0.0_8
IF (use_fortran_kernels) THEN
!$OMP PARALLEL PRIVATE(tile_rrn) REDUCTION(+:rrn)
!$OMP DO
DO t=1,tiles_per_task
tile_rrn = 0.0_8
CALL tea_leaf_cg_calc_ur_kernel(chunk%tiles(t)%field%x_min,&
chunk%tiles(t)%field%x_max, &
chunk%tiles(t)%field%y_min, &
chunk%tiles(t)%field%y_max, &
chunk%halo_exchange_depth, &
chunk%tiles(t)%field%u, &
chunk%tiles(t)%field%vector_p, &
chunk%tiles(t)%field%vector_r, &
chunk%tiles(t)%field%vector_Mi, &
chunk%tiles(t)%field%vector_w, &
chunk%tiles(t)%field%vector_z, &
chunk%tiles(t)%field%tri_cp, &
chunk%tiles(t)%field%tri_bfp, &
chunk%tiles(t)%field%vector_Kx, &
chunk%tiles(t)%field%vector_Ky, &
chunk%tiles(t)%field%vector_Di, &
chunk%tiles(t)%field%rx, &
chunk%tiles(t)%field%ry, &
alpha, tile_rrn, tl_preconditioner_type)
rrn = rrn + tile_rrn
ENDDO
!$OMP END DO NOWAIT
!$OMP END PARALLEL
ENDIF
END SUBROUTINE tea_leaf_cg_calc_ur
SUBROUTINE tea_leaf_cg_calc_p( beta)
IMPLICIT NONE
INTEGER :: t
REAL(KIND=8) :: beta
IF (use_fortran_kernels) THEN
!$OMP PARALLEL
!$OMP DO
DO t=1,tiles_per_task
CALL tea_leaf_cg_calc_p_kernel(chunk%tiles(t)%field%x_min,&
chunk%tiles(t)%field%x_max, &
chunk%tiles(t)%field%y_min, &
chunk%tiles(t)%field%y_max, &
chunk%halo_exchange_depth, &
chunk%tiles(t)%field%vector_p, &
chunk%tiles(t)%field%vector_r, &
chunk%tiles(t)%field%vector_z, &
beta, tl_preconditioner_type)
ENDDO
!$OMP END DO NOWAIT
!$OMP END PARALLEL
ENDIF
END SUBROUTINE tea_leaf_cg_calc_p
END MODULE tea_leaf_cg_module