@@ -96,6 +96,11 @@ module mpi
96
96
module procedure MPI_Waitall_proc
97
97
end interface
98
98
99
+ interface MPI_Allgatherv
100
+ module procedure MPI_Allgatherv_int
101
+ module procedure MPI_Allgatherv_real
102
+ end interface MPI_Allgatherv
103
+
99
104
interface MPI_Ssend
100
105
module procedure MPI_Ssend_proc
101
106
end interface
@@ -799,6 +804,89 @@ subroutine MPI_Waitall_proc(count, array_of_requests, array_of_statuses, ierror)
799
804
800
805
end subroutine MPI_Waitall_proc
801
806
807
+ subroutine MPI_Allgatherv_int (sendbuf , sendcount , sendtype , recvbuf , recvcounts , &
808
+ displs , recvtype , comm , ierror )
809
+ use iso_c_binding, only: c_int, c_ptr, c_loc
810
+ use mpi_c_bindings, only: c_mpi_allgatherv, c_mpi_in_place
811
+ integer , dimension (:), intent (in ), target :: sendbuf
812
+ integer , intent (in ) :: sendcount
813
+ integer , intent (in ) :: sendtype
814
+ integer , dimension (:), intent (out ), target :: recvbuf
815
+ integer , dimension (:), intent (in ) :: recvcounts
816
+ integer , dimension (:), intent (in ) :: displs
817
+ integer , intent (in ) :: recvtype
818
+ integer , intent (in ) :: comm
819
+ integer , optional , intent (out ) :: ierror
820
+ integer (kind= MPI_HANDLE_KIND) :: c_sendtype, c_recvtype, c_comm
821
+ type (c_ptr) :: c_sendbuf, c_recvbuf
822
+ integer (c_int) :: local_ierr
823
+
824
+ ! Handle sendbuf (support MPI_IN_PLACE)
825
+ if (sendbuf(1 ) == MPI_IN_PLACE) then
826
+ c_sendbuf = c_MPI_IN_PLACE
827
+ else
828
+ c_sendbuf = c_loc(sendbuf)
829
+ end if
830
+ c_recvbuf = c_loc(recvbuf)
831
+ c_sendtype = handle_mpi_datatype_f2c(sendtype)
832
+ c_recvtype = handle_mpi_datatype_f2c(recvtype)
833
+ c_comm = handle_mpi_comm_f2c(comm)
834
+
835
+ ! Call C MPI_Allgatherv
836
+ local_ierr = c_mpi_allgatherv(c_sendbuf, sendcount, c_sendtype, &
837
+ c_recvbuf, recvcounts, displs, c_recvtype, &
838
+ c_comm)
839
+
840
+ ! Handle error
841
+ if (present (ierror)) then
842
+ ierror = local_ierr
843
+ else if (local_ierr /= MPI_SUCCESS) then
844
+ print * , " MPI_Allgatherv failed with error code: " , local_ierr
845
+ end if
846
+
847
+ end subroutine MPI_Allgatherv_int
848
+
849
+ subroutine MPI_Allgatherv_real (sendbuf , sendcount , sendtype , recvbuf , recvcounts , &
850
+ displs , recvtype , comm , ierror )
851
+ use iso_c_binding, only: c_int, c_ptr, c_loc
852
+ use mpi_c_bindings, only: c_mpi_allgatherv, c_mpi_in_place
853
+ real (8 ), dimension (:), intent (in ), target :: sendbuf
854
+ integer , intent (in ) :: sendcount
855
+ integer , intent (in ) :: sendtype
856
+ real (8 ), dimension (:), intent (out ), target :: recvbuf
857
+ integer , dimension (:), intent (in ) :: recvcounts
858
+ integer , dimension (:), intent (in ) :: displs
859
+ integer , intent (in ) :: recvtype
860
+ integer , intent (in ) :: comm
861
+ integer , optional , intent (out ) :: ierror
862
+ integer (kind= MPI_HANDLE_KIND) :: c_sendtype, c_recvtype, c_comm
863
+ type (c_ptr) :: c_sendbuf, c_recvbuf
864
+ integer (c_int) :: local_ierr
865
+
866
+ if (sendbuf(1 ) == MPI_IN_PLACE) then
867
+ c_sendbuf = c_MPI_IN_PLACE
868
+ else
869
+ c_sendbuf = c_loc(sendbuf)
870
+ end if
871
+
872
+ c_recvbuf = c_loc(recvbuf)
873
+ c_sendtype = handle_mpi_datatype_f2c(sendtype)
874
+ c_recvtype = handle_mpi_datatype_f2c(recvtype)
875
+ c_comm = handle_mpi_comm_f2c(comm)
876
+
877
+ ! Call C MPI_Allgatherv
878
+ local_ierr = c_mpi_allgatherv(c_sendbuf, sendcount, c_sendtype, &
879
+ c_recvbuf, recvcounts, displs, c_recvtype, &
880
+ c_comm)
881
+
882
+ if (present (ierror)) then
883
+ ierror = local_ierr
884
+ else if (local_ierr /= MPI_SUCCESS) then
885
+ print * , " MPI_Allgatherv failed with error code: " , local_ierr
886
+ end if
887
+
888
+ end subroutine MPI_Allgatherv_real
889
+
802
890
subroutine MPI_Ssend_proc (buf , count , datatype , dest , tag , comm , ierror )
803
891
use iso_c_binding, only: c_int, c_ptr
804
892
use mpi_c_bindings, only: c_mpi_ssend
0 commit comments