-
Notifications
You must be signed in to change notification settings - Fork 3
/
tea_leaf_common.f90
166 lines (134 loc) · 5.56 KB
/
tea_leaf_common.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
MODULE tea_leaf_common_module
USE tea_leaf_common_kernel_module
USE definitions_module
USE report_module
IMPLICIT NONE
CONTAINS
SUBROUTINE tea_leaf_init_common()
IMPLICIT NONE
INTEGER :: t
LOGICAL :: zero_boundary(4)
IF (use_fortran_kernels) THEN
!$OMP PARALLEL PRIVATE(zero_boundary)
!$OMP DO
DO t=1,tiles_per_task
chunk%tiles(t)%field%rx = dt/(chunk%tiles(t)%field%celldx(chunk%tiles(t)%field%x_min)**2)
chunk%tiles(t)%field%ry = dt/(chunk%tiles(t)%field%celldy(chunk%tiles(t)%field%y_min)**2)
WHERE (chunk%tiles(t)%tile_neighbours .EQ. EXTERNAL_FACE .AND. &
chunk%chunk_neighbours .EQ. EXTERNAL_FACE)
zero_boundary = .TRUE.
ELSE WHERE
zero_boundary = .FALSE.
END WHERE
CALL tea_leaf_common_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, &
zero_boundary, &
reflective_boundary, &
chunk%tiles(t)%field%density, &
chunk%tiles(t)%field%energy1, &
chunk%tiles(t)%field%u, &
chunk%tiles(t)%field%u0, &
chunk%tiles(t)%field%vector_r, &
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%tri_cp, &
chunk%tiles(t)%field%tri_bfp, &
chunk%tiles(t)%field%vector_Mi, &
chunk%tiles(t)%field%rx, &
chunk%tiles(t)%field%ry, &
tl_preconditioner_type, coefficient)
ENDDO
!$OMP END DO
!$OMP END PARALLEL
ENDIF
END SUBROUTINE tea_leaf_init_common
SUBROUTINE tea_leaf_calc_residual()
IMPLICIT NONE
INTEGER :: t
IF (use_fortran_kernels) THEN
!$OMP PARALLEL
!$OMP DO
DO t=1,tiles_per_task
CALL tea_leaf_calc_residual_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%u0, &
chunk%tiles(t)%field%vector_r, &
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)
ENDDO
!$OMP END DO
!$OMP END PARALLEL
ENDIF
END SUBROUTINE
SUBROUTINE tea_leaf_calc_2norm(norm_array, norm)
IMPLICIT NONE
INTEGER :: t, level, norm_array
REAL(KIND=8) :: norm, tile_norm
norm = 0.0_8
IF (use_fortran_kernels) THEN
!$OMP PARALLEL PRIVATE(tile_norm)
!$OMP DO REDUCTION(+:norm)
DO t=1,tiles_per_task
tile_norm = 0.0_8
! 0 = u0.u0
! 1 = r.r
! XXX add some parameters in defintions.f90?
IF (norm_array .EQ. 0) THEN
CALL tea_leaf_calc_2norm_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%u0, &
tile_norm)
ELSE IF (norm_array .EQ. 1) THEN
CALL tea_leaf_calc_2norm_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_r, &
tile_norm)
ELSE
CALL report_error("tea_leaf_common.f90", "Invalid value for norm_array")
ENDIF
norm = norm + tile_norm
ENDDO
!$OMP END DO
!$OMP END PARALLEL
ENDIF
END SUBROUTINE
SUBROUTINE tea_leaf_finalise()
IMPLICIT NONE
INTEGER :: t
IF (use_fortran_kernels) THEN
!$OMP PARALLEL
!$OMP DO
DO t=1,tiles_per_task
CALL tea_leaf_kernel_finalise(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%energy1, &
chunk%tiles(t)%field%density, &
chunk%tiles(t)%field%u)
ENDDO
!$OMP END DO
!$OMP END PARALLEL
ENDIF
END SUBROUTINE tea_leaf_finalise
END MODULE