subroutine comm_irecv_real_sp_array_2d(comm, data, source, tag, request)
!! Non-blocking receive of a 2D allocatable single-precision real array
type(comm_t), intent(in) :: comm
real(sp), intent(inout), allocatable :: data(:, :)
integer(int32), intent(in) :: source
integer(int32), intent(in) :: tag
type(request_t), intent(out) :: request
integer(int32) :: ierr, dim1, dim2
! Receive dimensions first (blocking - needed to allocate)
call MPI_Recv(dim1, 1, MPI_INTEGER, source, tag, comm%m_comm, MPI_STATUS_IGNORE, ierr)
call MPI_Recv(dim2, 1, MPI_INTEGER, source, tag, comm%m_comm, MPI_STATUS_IGNORE, ierr)
! Allocate array with received dimensions
if (.not. allocated(data)) then
allocate (data(dim1, dim2))
end if
! Receive data (non-blocking)
call MPI_Irecv(data, dim1*dim2, MPI_REAL, source, tag, comm%m_comm, request%m_request, ierr)
request%is_valid = .true.
end subroutine comm_irecv_real_sp_array_2d