@@ -8,6 +8,8 @@ module mpi
8
8
integer , parameter :: MPI_DOUBLE_PRECISION = - 10004
9
9
integer , parameter :: MPI_REAL4 = - 10013
10
10
integer , parameter :: MPI_REAL8 = - 10014
11
+ integer , parameter :: MPI_CHARACTER = - 10003
12
+ integer , parameter :: MPI_LOGICAL = - 10005
11
13
12
14
integer , parameter :: MPI_COMM_TYPE_SHARED = 1
13
15
integer , parameter :: MPI_PROC_NULL = - 1
@@ -75,6 +77,7 @@ module mpi
75
77
interface MPI_Gatherv
76
78
module procedure MPI_Gatherv_int
77
79
module procedure MPI_Gatherv_real
80
+ module procedure MPI_Gatherv_character
78
81
end interface MPI_Gatherv
79
82
80
83
interface MPI_Wtime
@@ -170,14 +173,18 @@ integer(kind=MPI_HANDLE_KIND) function handle_mpi_info_f2c(info_f) result(c_info
170
173
end function handle_mpi_info_f2c
171
174
172
175
integer (kind= MPI_HANDLE_KIND) function handle_mpi_datatype_f2c(datatype_f) result(c_datatype)
173
- use mpi_c_bindings, only: c_mpi_float, c_mpi_double, c_mpi_int
176
+ use mpi_c_bindings, only: c_mpi_float, c_mpi_double, c_mpi_int, c_mpi_logical, c_mpi_character
174
177
integer , intent (in ) :: datatype_f
175
178
if (datatype_f == MPI_REAL4) then
176
179
c_datatype = c_mpi_float
177
180
else if (datatype_f == MPI_REAL8 .OR. datatype_f == MPI_DOUBLE_PRECISION) then
178
181
c_datatype = c_mpi_double
179
182
else if (datatype_f == MPI_INTEGER) then
180
183
c_datatype = c_mpi_int
184
+ else if (datatype_f == MPI_CHARACTER) then
185
+ c_datatype = c_mpi_character
186
+ else if (datatype_f == MPI_LOGICAL) then
187
+ c_datatype = c_mpi_logical
181
188
end if
182
189
end function
183
190
@@ -852,6 +859,42 @@ subroutine MPI_Gatherv_real(sendbuf, sendcount, sendtype, recvbuf, recvcounts, &
852
859
end if
853
860
end subroutine MPI_Gatherv_real
854
861
862
+ subroutine MPI_Gatherv_character (sendbuf , sendcount , sendtype , recvbuf , recvcounts , &
863
+ displs , recvtype , root , comm , ierror )
864
+ use iso_c_binding, only: c_int, c_ptr, c_loc
865
+ use mpi_c_bindings, only: c_mpi_gatherv
866
+ character (len=* ), intent (in ), target :: sendbuf(* )
867
+ integer , intent (in ) :: sendcount
868
+ integer , intent (in ) :: sendtype
869
+ character (len=* ), intent (out ), target :: recvbuf(* )
870
+ integer , dimension (:), intent (in ) :: recvcounts
871
+ integer , dimension (:), intent (in ) :: displs
872
+ integer , intent (in ) :: recvtype
873
+ integer , intent (in ) :: root
874
+ integer , intent (in ) :: comm
875
+ integer , optional , intent (out ) :: ierror
876
+ integer (kind= MPI_HANDLE_KIND) :: c_sendtype, c_recvtype, c_comm
877
+ type (c_ptr) :: c_sendbuf, c_recvbuf
878
+ integer (c_int) :: local_ierr
879
+
880
+ c_sendbuf = c_loc(sendbuf)
881
+ c_recvbuf = c_loc(recvbuf)
882
+ c_sendtype = handle_mpi_datatype_f2c(sendtype)
883
+ c_recvtype = handle_mpi_datatype_f2c(recvtype)
884
+ c_comm = handle_mpi_comm_f2c(comm)
885
+
886
+ ! Call C MPI_Gatherv
887
+ local_ierr = c_mpi_gatherv(c_sendbuf, sendcount, c_sendtype, &
888
+ c_recvbuf, recvcounts, displs, c_recvtype, &
889
+ root, c_comm)
890
+
891
+ if (present (ierror)) then
892
+ ierror = local_ierr
893
+ else if (local_ierr /= MPI_SUCCESS) then
894
+ print * , " MPI_Gatherv failed with error code: " , local_ierr
895
+ end if
896
+ end subroutine MPI_Gatherv_character
897
+
855
898
subroutine MPI_Waitall_proc (count , array_of_requests , array_of_statuses , ierror )
856
899
use iso_c_binding, only: c_int, c_ptr
857
900
use mpi_c_bindings, only: c_mpi_waitall, c_mpi_request_f2c, c_mpi_request_c2f, c_mpi_status_c2f, c_mpi_statuses_ignore
0 commit comments