Skip to content

remove C MPI wrapper function for MPI_Cart_coords #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/mpi.f90
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,25 @@ subroutine MPI_Cart_create_proc(comm, ndims, dims, periods, reorder, newcomm, ie
end subroutine

subroutine MPI_Cart_coords_proc(comm, rank, maxdims, coords, ierror)
use mpi_c_bindings, only: c_mpi_cart_coords
use iso_c_binding, only: c_int, c_ptr
use mpi_c_bindings, only: c_mpi_cart_coords, c_mpi_comm_f2c
integer, intent(in) :: comm
integer, intent(in) :: rank, maxdims
integer, intent(out) :: coords(maxdims)
integer, optional, intent(out) :: ierror
call c_mpi_cart_coords(comm, rank, maxdims, coords, ierror)
type(c_ptr) :: c_comm
integer(c_int) :: local_ierr

c_comm = c_mpi_comm_f2c(comm)
local_ierr = c_mpi_cart_coords(c_comm, rank, maxdims, coords)

if (present(ierror)) then
ierror = local_ierr
else
if (local_ierr /= MPI_SUCCESS) then
print *, "MPI_Barrier failed with error code: ", local_ierr
end if
end if
end subroutine

subroutine MPI_Cart_shift_proc(comm, direction, disp, rank_source, rank_dest, ierror)
Expand Down
12 changes: 7 additions & 5 deletions src/mpi_c_bindings.f90
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,13 @@ subroutine c_mpi_cart_create(comm, ndims, dims, periods, reorder, newcomm, ierro
integer(c_int), intent(out) :: newcomm, ierror
end subroutine

subroutine c_mpi_cart_coords(comm, rank, maxdims, coords, ierror) bind(C, name="mpi_cart_coords_wrapper")
use iso_c_binding, only: c_int
integer(c_int), intent(in) :: comm, rank, maxdims
integer(c_int), intent(out) :: coords(*), ierror
end subroutine
function c_mpi_cart_coords(comm, rank, maxdims, coords) bind(C, name="MPI_Cart_coords")
use iso_c_binding, only: c_int, c_ptr
type(c_ptr), value :: comm
integer(c_int), value :: rank, maxdims
integer(c_int), intent(out) :: coords(*)
integer(c_int) :: c_mpi_cart_coords
end function

subroutine c_mpi_cart_shift(comm, direction, disp, rank_source, rank_dest, ierror) bind(C, name="mpi_cart_shift_wrapper")
use iso_c_binding, only: c_int
Expand Down
6 changes: 0 additions & 6 deletions src/mpi_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,6 @@ void mpi_cart_create_wrapper(int * comm_f, int * ndims, int * dims, int * period
*newcomm_f = MPI_Comm_c2f(newcomm);
}

void mpi_cart_coords_wrapper(int * comm_f, int * rank, int * maxdims, int * coords, int * ierror)
{
MPI_Comm comm = get_c_comm_from_fortran(*comm_f);
*ierror = MPI_Cart_coords(comm, *rank, *maxdims, coords);
}

void mpi_cart_shift_wrapper(int * comm_f, int * dir, int * disp, int * rank_source, int * rank_dest, int * ierror)
{
MPI_Comm comm = get_c_comm_from_fortran(*comm_f);
Expand Down