Skip to content

remove C MPI wrapper function for MPI_Dims_create #59

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
12 changes: 11 additions & 1 deletion src/mpi.f90
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,21 @@ subroutine MPI_Cart_shift_proc(comm, direction, disp, rank_source, rank_dest, ie
end subroutine

subroutine MPI_Dims_create_proc(nnodes, ndims, dims, ierror)
use iso_c_binding, only: c_int, c_ptr
use mpi_c_bindings, only: c_mpi_dims_create
integer, intent(in) :: nnodes, ndims
integer, intent(out) :: dims(ndims)
integer, optional, intent(out) :: ierror
call c_mpi_dims_create(nnodes, ndims, dims, ierror)
integer(c_int) :: local_ierr

local_ierr = c_mpi_dims_create(nnodes, ndims, dims)
if (present(ierror)) then
ierror = local_ierr
else
if (local_ierr /= MPI_SUCCESS) then
print *, "MPI_Dims_create failed with error code: ", local_ierr
end if
end if
end subroutine

subroutine MPI_Cart_sub_proc (comm, remain_dims, newcomm, ierror)
Expand Down
11 changes: 6 additions & 5 deletions src/mpi_c_bindings.f90
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,12 @@ subroutine c_mpi_cart_shift(comm, direction, disp, rank_source, rank_dest, ierro
integer(c_int), intent(out) :: rank_source, rank_dest, ierror
end subroutine

subroutine c_mpi_dims_create(nnodes, ndims, dims, ierror) bind(C, name="mpi_dims_create_wrapper")
use iso_c_binding, only: c_int
integer(c_int), intent(in) :: nnodes, ndims
integer(c_int), intent(inout) :: dims(*), ierror
end subroutine
function c_mpi_dims_create(nnodes, ndims, dims) bind(C, name="MPI_Dims_create")
use iso_c_binding, only: c_int, c_ptr
integer(c_int), value :: nnodes, ndims
integer(c_int), intent(inout) :: dims(*)
integer(c_int) :: c_mpi_dims_create
end function

subroutine c_mpi_cart_sub(comm, remain_dims, newcomm, ierror) bind(C, name ="mpi_cart_sub_wrapper")
use iso_c_binding, only: c_int
Expand Down
5 changes: 0 additions & 5 deletions src/mpi_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,6 @@ void mpi_cart_shift_wrapper(int * comm_f, int * dir, int * disp, int * rank_sour
*ierror = MPI_Cart_shift(comm, *dir, *disp, rank_source, rank_dest);
}

void mpi_dims_create_wrapper(int * nnodes, int * ndims, int * dims, int * ierror)
{
*ierror = MPI_Dims_create(*nnodes, *ndims, dims);
}

void mpi_cart_sub_wrapper(int * comm_f, int * rmains_dims, int * newcomm_f, int * ierror) {
MPI_Comm comm = get_c_comm_from_fortran(*comm_f);
MPI_Comm newcomm = MPI_COMM_NULL;
Expand Down