Skip to content

Commit 294d6fb

Browse files
committed
refactor: Make all transpose operations work on a single field.
1 parent 9928ea6 commit 294d6fb

File tree

4 files changed

+25
-31
lines changed

4 files changed

+25
-31
lines changed

src/backend.f90

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ module m_base_backend
2828
procedure(transeq_ders), deferred :: transeq_y
2929
procedure(transeq_ders), deferred :: transeq_z
3030
procedure(tds_solve), deferred :: tds_solve
31-
procedure(transposer), deferred :: trans_x2y
32-
procedure(transposer), deferred :: trans_x2z
31+
procedure(trans_d2d), deferred :: trans_x2y
32+
procedure(trans_d2d), deferred :: trans_x2z
3333
procedure(trans_d2d), deferred :: trans_y2z
3434
procedure(trans_d2d), deferred :: trans_z2y
3535
procedure(trans_d2d), deferred :: trans_y2x
@@ -81,20 +81,6 @@ end subroutine tds_solve
8181
end interface
8282

8383
abstract interface
84-
subroutine transposer(self, u_, v_, w_, u, v, w)
85-
!! transposer subroutines are straightforward, they rearrange
86-
!! data into our specialist data structure so that regardless
87-
!! of the direction tridiagonal systems are solved efficiently
88-
!! and fast.
89-
import :: base_backend_t
90-
import :: field_t
91-
implicit none
92-
93-
class(base_backend_t) :: self
94-
class(field_t), intent(inout) :: u_, v_, w_
95-
class(field_t), intent(in) :: u, v, w
96-
end subroutine transposer
97-
9884
subroutine trans_d2d(self, u_, u)
9985
!! transposer subroutines are straightforward, they rearrange
10086
!! data into our specialist data structure so that regardless

src/cuda/backend.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,21 +415,21 @@ subroutine tds_solve_dist(self, du, u, dirps, tdsops, blocks, threads)
415415

416416
end subroutine tds_solve_dist
417417

418-
subroutine trans_x2y_cuda(self, u_y, v_y, w_y, u, v, w)
418+
subroutine trans_x2y_cuda(self, u_y, u)
419419
implicit none
420420

421421
class(cuda_backend_t) :: self
422-
class(field_t), intent(inout) :: u_y, v_y, w_y
423-
class(field_t), intent(in) :: u, v, w
422+
class(field_t), intent(inout) :: u_y
423+
class(field_t), intent(in) :: u
424424

425425
end subroutine trans_x2y_cuda
426426

427-
subroutine trans_x2z_cuda(self, u_z, v_z, w_z, u, v, w)
427+
subroutine trans_x2z_cuda(self, u_z, u)
428428
implicit none
429429

430430
class(cuda_backend_t) :: self
431-
class(field_t), intent(inout) :: u_z, v_z, w_z
432-
class(field_t), intent(in) :: u, v, w
431+
class(field_t), intent(inout) :: u_z
432+
class(field_t), intent(in) :: u
433433

434434
end subroutine trans_x2z_cuda
435435

src/omp/backend.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,21 @@ subroutine tds_solve_omp(self, du, u, dirps, tdsops)
164164

165165
end subroutine tds_solve_omp
166166

167-
subroutine trans_x2y_omp(self, u_, v_, w_, u, v, w)
167+
subroutine trans_x2y_omp(self, u_, u)
168168
implicit none
169169

170170
class(omp_backend_t) :: self
171-
class(field_t), intent(inout) :: u_, v_, w_
172-
class(field_t), intent(in) :: u, v, w
171+
class(field_t), intent(inout) :: u_
172+
class(field_t), intent(in) :: u
173173

174174
end subroutine trans_x2y_omp
175175

176-
subroutine trans_x2z_omp(self, u_, v_, w_, u, v, w)
176+
subroutine trans_x2z_omp(self, u_, u)
177177
implicit none
178178

179179
class(omp_backend_t) :: self
180-
class(field_t), intent(inout) :: u_, v_, w_
181-
class(field_t), intent(in) :: u, v, w
180+
class(field_t), intent(inout) :: u_
181+
class(field_t), intent(in) :: u
182182

183183
end subroutine trans_x2z_omp
184184

src/solver.f90

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ subroutine transeq(self, du, dv, dw, u, v, w)
185185
dw_y => self%backend%allocator%get_block()
186186

187187
! reorder data from x orientation to y orientation
188-
call self%backend%trans_x2y(u_y, v_y, w_y, u, v, w)
188+
call self%backend%trans_x2y(u_y, u)
189+
call self%backend%trans_x2y(v_y, v)
190+
call self%backend%trans_x2y(w_y, w)
191+
189192
! similar to the x direction, obtain derivatives in y.
190193
call self%backend%transeq_y(du_y, dv_y, dw_y, u_y, v_y, w_y, self%ydirps)
191194

@@ -206,7 +209,10 @@ subroutine transeq(self, du, dv, dw, u, v, w)
206209
dw_z => self%backend%allocator%get_block()
207210

208211
! reorder from x to z
209-
call self%backend%trans_x2z(u_z, v_z, w_z, u, v, w)
212+
call self%backend%trans_x2z(u_z, u)
213+
call self%backend%trans_x2z(v_z, v)
214+
call self%backend%trans_x2z(w_z, w)
215+
210216
! get the derivatives in z
211217
call self%backend%transeq_z(du_z, dv_z, dw_z, u_z, v_z, w_z, self%zdirps)
212218

@@ -261,7 +267,9 @@ subroutine divergence(self, div_u, u, v, w)
261267
w_y => self%backend%allocator%get_block()
262268

263269
! reorder data from x orientation to y orientation
264-
call self%backend%trans_x2y(u_y, v_y, w_y, du_x, dv_x, dw_x)
270+
call self%backend%trans_x2y(u_y, du_x)
271+
call self%backend%trans_x2y(v_y, dv_x)
272+
call self%backend%trans_x2y(w_y, dw_x)
265273

266274
call self%backend%allocator%release_block(du_x)
267275
call self%backend%allocator%release_block(dv_x)

0 commit comments

Comments
 (0)