diff --git a/src/common.f90 b/src/common.f90 index ca99a2a5..8a6054c0 100644 --- a/src/common.f90 +++ b/src/common.f90 @@ -34,7 +34,53 @@ module m_common contains - integer function get_rdr_from_dirs(dir_from, dir_to) result(rdr_dir) + pure subroutine get_dirs_from_rdr(dir_from, dir_to, rdr_dir) + integer, intent(out) :: dir_from, dir_to + integer, intent(in) :: rdr_dir + + select case (rdr_dir) + case (RDR_X2Y) + dir_from = DIR_X + dir_to = DIR_Y + case (RDR_X2Z) + dir_from = DIR_X + dir_to = DIR_Z + case (RDR_Y2X) + dir_from = DIR_Y + dir_to = DIR_X + case (RDR_Y2Z) + dir_from = DIR_Y + dir_to = DIR_Z + case (RDR_Z2X) + dir_from = DIR_Z + dir_to = DIR_X + case (RDR_Z2Y) + dir_from = DIR_Z + dir_to = DIR_Y + case (RDR_C2X) + dir_from = DIR_C + dir_to = DIR_X + case (RDR_C2Y) + dir_from = DIR_C + dir_to = DIR_Y + case (RDR_C2Z) + dir_from = DIR_C + dir_to = DIR_Z + case (RDR_X2C) + dir_from = DIR_X + dir_to = DIR_C + case (RDR_Y2C) + dir_from = DIR_Y + dir_to = DIR_C + case (RDR_Z2C) + dir_from = DIR_Z + dir_to = DIR_C + end select + + + end subroutine + + pure integer function get_rdr_from_dirs(dir_from, dir_to) result(rdr_dir) !! Returns RDR_?2? value based on two direction inputs integer, intent(in) :: dir_from, dir_to diff --git a/src/ordering.f90 b/src/ordering.f90 index c9be3834..1273f473 100644 --- a/src/ordering.f90 +++ b/src/ordering.f90 @@ -1,6 +1,6 @@ module m_ordering - use m_common, only: dp, DIR_X, DIR_Y, DIR_Z, DIR_C, & + use m_common, only: dp, get_dirs_from_rdr, DIR_X, DIR_Y, DIR_Z, DIR_C, & RDR_X2Y, RDR_X2Z, RDR_Y2X, RDR_Y2Z, RDR_Z2X, RDR_Z2Y use m_mesh, only: mesh_t @@ -33,6 +33,10 @@ pure subroutine get_index_ijk(i, j, k, dir_i, dir_j, dir_k, dir, & i = mod(dir_k - 1, nx_padded/SZ)*SZ + dir_i j = 1 + (dir_k - 1)/(nx_padded/SZ) k = dir_j + case (DIR_C) + i = dir_i + j = dir_j + k = dir_k end select end subroutine get_index_ijk @@ -58,6 +62,10 @@ pure subroutine get_index_dir(dir_i, dir_j, dir_k, i, j, k, dir, & dir_i = mod(i - 1, SZ) + 1 dir_j = k dir_k = (nx_padded/SZ)*(j - 1) + 1 + (i - 1)/SZ + case (DIR_C) + dir_i = i + dir_j = j + dir_k = k end select end subroutine get_index_dir @@ -74,26 +82,7 @@ pure subroutine get_index_reordering(out_i, out_j, out_k, in_i, in_j, in_k, & integer :: dir_in, dir_out integer, dimension(3) :: dims_padded - select case (reorder_dir) - case (RDR_X2Y) - dir_in = DIR_X - dir_out = DIR_Y - case (RDR_X2Z) - dir_in = DIR_X - dir_out = DIR_Z - case (RDR_Y2X) - dir_in = DIR_Y - dir_out = DIR_X - case (RDR_Y2Z) - dir_in = DIR_Y - dir_out = DIR_Z - case (RDR_Z2X) - dir_in = DIR_Z - dir_out = DIR_X - case (RDR_Z2Y) - dir_in = DIR_Z - dir_out = DIR_Y - end select + call get_dirs_from_rdr(dir_in, dir_out, reorder_dir) dims_padded = mesh%get_padded_dims(DIR_C) call get_index_ijk(i, j, k, in_i, in_j, in_k, dir_in, mesh%get_sz(), &