Commit a9a3e51e authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Clarify Fortran interface of xt_xmap_intersection_pos_new.

parent 635033f3
......@@ -107,9 +107,9 @@ MODULE xt_xmap_intersection
FUNCTION xmi_pos_new_f2c(num_src_msg, src_com, num_dst_msg, dst_com, comm) &
RESULT(xmap) &
BIND(c, name='xt_xmap_intersection_pos_new_f2c')
IMPORT :: c_int, c_ptr, xt_mpi_fint_kind
IMPORT :: c_int, c_ptr, xt_mpi_fint_kind, xt_com_pos_c
INTEGER(c_int), VALUE, INTENT(in) :: num_src_msg, num_dst_msg
TYPE(c_ptr), VALUE, INTENT(in) :: src_com, dst_com
TYPE(xt_com_pos_c), INTENT(in) :: src_com(*), dst_com(*)
INTEGER(xt_mpi_fint_kind), VALUE, INTENT(in) :: comm
TYPE(c_ptr) :: xmap
END FUNCTION xmi_pos_new_f2c
......@@ -223,60 +223,61 @@ CONTAINS
INTEGER(c_int) :: num_src_msg_c, num_dst_msg_c
TYPE(xt_com_pos_c), ALLOCATABLE :: src_com_c(:), dst_com_c(:)
INTEGER(c_int), ALLOCATABLE :: pos_buffer(:)
INTEGER(c_size_t) :: pos_buffer_offset
INTEGER(c_int), TARGET, ALLOCATABLE :: pos_buffer(:)
INTEGER :: pos_buffer_offset, num_pos_total
ALLOCATE(pos_buffer(get_total_num_transfer_pos(num_src_msg, src_com) + &
get_total_num_transfer_pos(num_dst_msg, dst_com)))
num_pos_total = get_total_num_transfer_pos(num_src_msg, src_com) + &
get_total_num_transfer_pos(num_dst_msg, dst_com)
ALLOCATE(pos_buffer(num_pos_total))
num_src_msg_c = INT(num_src_msg, c_int)
num_dst_msg_c = INT(num_dst_msg, c_int)
pos_buffer_offset = 1
CALL generate_xt_com_pos_c( &
num_src_msg, src_com, src_com_c, pos_buffer, pos_buffer_offset)
CALL generate_xt_com_pos_c( &
num_dst_msg, dst_com, dst_com_c, pos_buffer, pos_buffer_offset)
pos_buffer_offset = 0
CALL generate_xt_com_pos_c(num_src_msg, src_com, src_com_c, &
num_pos_total, pos_buffer, pos_buffer_offset)
CALL generate_xt_com_pos_c(num_dst_msg, dst_com, dst_com_c, &
num_pos_total, pos_buffer, pos_buffer_offset)
xmap = &
xt_xmap_c2f( &
xmi_pos_new_f2c(&
num_src_msg_c, C_LOC(src_com_c), num_dst_msg_c, C_LOC(dst_com_c), comm))
xt_xmap_c2f(xmi_pos_new_f2c(&
num_src_msg_c, src_com_c, num_dst_msg_c, dst_com_c, comm))
CONTAINS
FUNCTION get_total_num_transfer_pos(num_msg, com_pos) &
RESULT(total_num_transfer_pos)
INTEGER, INTENT(in) :: num_msg
TYPE(xt_com_pos), TARGET, INTENT(in) :: com_pos(:)
TYPE(xt_com_pos), INTENT(in) :: com_pos(:)
INTEGER :: i
INTEGER(c_size_t) :: total_num_transfer_pos
INTEGER :: total_num_transfer_pos
total_num_transfer_pos = 0
DO i = 1, num_msg
total_num_transfer_pos = &
total_num_transfer_pos + SIZE(com_pos(i)%transfer_pos, 1, c_size_t)
total_num_transfer_pos = total_num_transfer_pos &
+ SIZE(com_pos(i)%transfer_pos)
END DO
END FUNCTION get_total_num_transfer_pos
SUBROUTINE generate_xt_com_pos_c( &
num_msg, com_pos, com_pos_c, pos_buffer, pos_buffer_offset)
SUBROUTINE generate_xt_com_pos_c(num_msg, com_pos, com_pos_c, &
pos_buffer_size, pos_buffer, &
pos_buffer_offset)
INTEGER, INTENT(in) :: num_msg
TYPE(xt_com_pos), TARGET, INTENT(in) :: com_pos(:)
TYPE(xt_com_pos_c), ALLOCATABLE, INTENT(inout) :: com_pos_c(:)
INTEGER(c_int), TARGET, INTENT(inout) :: pos_buffer(:)
INTEGER(c_size_t), INTENT(inout) :: pos_buffer_offset
INTEGER :: i
INTEGER(c_size_t) :: j, curr_num_transfer_pos
TYPE(xt_com_pos_c), ALLOCATABLE, INTENT(out) :: com_pos_c(:)
INTEGER, INTENT(in) :: pos_buffer_size
INTEGER(c_int), TARGET, INTENT(inout) :: pos_buffer(pos_buffer_size)
INTEGER, INTENT(inout) :: pos_buffer_offset
INTEGER :: i, j, curr_num_transfer_pos
ALLOCATE(com_pos_c(num_msg))
DO i = 1, num_msg
curr_num_transfer_pos = SIZE(com_pos(i)%transfer_pos, 1, c_size_t)
DO j = 0, curr_num_transfer_pos - 1
curr_num_transfer_pos = SIZE(com_pos(i)%transfer_pos)
DO j = 1, curr_num_transfer_pos
pos_buffer(pos_buffer_offset + j) = &
INT(com_pos(i)%transfer_pos(j+1), c_int)
INT(com_pos(i)%transfer_pos(j), c_int)
END DO
com_pos_c(i)%transfer_pos = C_LOC(pos_buffer(pos_buffer_offset))
com_pos_c(i)%transfer_pos = C_LOC(pos_buffer(pos_buffer_offset+1))
com_pos_c(i)%num_transfer_pos = INT(curr_num_transfer_pos, c_int)
com_pos_c(i)%rank = INT(com_pos(i)%rank, c_int)
pos_buffer_offset = pos_buffer_offset + curr_num_transfer_pos
......@@ -286,7 +287,7 @@ CONTAINS
END FUNCTION xmi_pos_new_i_a_i_a
FUNCTION xmi_pos_new_a_a(src_com, dst_com, comm) RESULT(xmap)
TYPE(xt_com_pos), TARGET, INTENT(in) :: src_com(:), dst_com(:)
TYPE(xt_com_pos), INTENT(in) :: src_com(:), dst_com(:)
INTEGER, INTENT(in) :: comm
TYPE(xt_xmap) :: xmap
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment