From fa9108d4b343082b9c580dc8cb7c0bb8614edcbc Mon Sep 17 00:00:00 2001 From: Aditya Trivedi Date: Mon, 31 Mar 2025 13:39:35 +0530 Subject: [PATCH 1/2] Fix: use correct helper function --- src/mpi_wrapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mpi_wrapper.c b/src/mpi_wrapper.c index eb78d02..87e7c5e 100644 --- a/src/mpi_wrapper.c +++ b/src/mpi_wrapper.c @@ -200,7 +200,7 @@ void mpi_waitall_wrapper(int *count, int *array_of_requests_f, void mpi_ssend_wrapper(double *buf, int *count, int *datatype_f, int *dest, int *tag, int *comm_f, int *ierror) { - MPI_Datatype datatype = get_c_comm_from_fortran(*datatype_f); + MPI_Datatype datatype = get_c_datatype_from_fortran(*datatype_f); MPI_Comm comm = get_c_comm_from_fortran(*comm_f); *ierror = MPI_Ssend(buf, *count, datatype, *dest, *tag, comm); From 3d1d7bbb67f693af682bbabac638dfb7f4f1d3cc Mon Sep 17 00:00:00 2001 From: Aditya Trivedi Date: Mon, 31 Mar 2025 14:40:50 +0530 Subject: [PATCH 2/2] Add MPI_Ssend test --- tests/ssend_1.f90 | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/ssend_1.f90 diff --git a/tests/ssend_1.f90 b/tests/ssend_1.f90 new file mode 100644 index 0000000..6a2afd0 --- /dev/null +++ b/tests/ssend_1.f90 @@ -0,0 +1,59 @@ +program ssend_example + use mpi + implicit none + + integer, parameter :: ARRAY_SIZE = 10 + integer :: rank, size, ierr, i + real(8) :: buffer(10) + integer :: tag = 100 + + ! allocate(buffer(10)) + ! Initialize MPI environment + call MPI_Init(ierr) + + ! Get rank (process ID) and size (total number of processes) + call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr) + call MPI_Comm_size(MPI_COMM_WORLD, size, ierr) + + if (size < 2) then + if (rank == 0) then + print *, "This example requires at least 2 MPI processes" + end if + call MPI_Finalize(ierr) + stop + end if + + ! Process 0 sends data to process 1 + if (rank == 0) then + ! Initialize the buffer with some values + do i = 1, 10 + buffer(i) = i * 10 + end do + + print *, "Process 0: Sending data using MPI_Ssend..." + + ! Using MPI_Ssend (synchronous send) + ! This will block until process 1 starts receiving + call MPI_Ssend(buffer, 10, MPI_REAL8, 1, tag, MPI_COMM_WORLD, ierr) + + print *, "Process 0: Send completed successfully" + + ! Process 1 receives data from process 0 + else if (rank == 1) then + + print *, "Process 1: Receiving data..." + + ! Clear the buffer + buffer = 0 + + ! Receive the message + call MPI_Recv(buffer, 10, MPI_REAL8, 0, tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE, ierr) + + print *, "Process 1: Received data:" + ! write(*, '(10I5)') buffer + print *, buffer + end if + + ! Finalize MPI environment + call MPI_Finalize(ierr) +end program ssend_example \ No newline at end of file