@@ -21,6 +21,7 @@ module mpi
21
21
real (8 ), parameter :: MPI_IN_PLACE = - 1002
22
22
integer , parameter :: MPI_SUM = - 2300
23
23
integer , parameter :: MPI_MAX = - 2301
24
+ integer , parameter :: MPI_LOR = - 2302
24
25
integer , parameter :: MPI_INFO_NULL = - 2000
25
26
integer , parameter :: MPI_STATUS_SIZE = 5
26
27
integer :: MPI_STATUS_IGNORE = 0
@@ -99,6 +100,7 @@ module mpi
99
100
module procedure MPI_Allreduce_1D_recv_proc
100
101
module procedure MPI_Allreduce_1D_real_proc
101
102
module procedure MPI_Allreduce_1D_int_proc
103
+ module procedure MPI_Allreduce_scalar_logical_proc
102
104
end interface
103
105
104
106
interface MPI_Gatherv
@@ -172,14 +174,16 @@ module mpi
172
174
contains
173
175
174
176
integer (kind= MPI_HANDLE_KIND) function handle_mpi_op_f2c(op_f) result(c_op)
175
- use mpi_c_bindings, only: c_mpi_op_f2c, c_mpi_sum, c_mpi_max
177
+ use mpi_c_bindings, only: c_mpi_op_f2c, c_mpi_sum, c_mpi_max, c_mpi_lor
176
178
integer , intent (in ) :: op_f
177
179
if (op_f == MPI_SUM) then
178
180
c_op = c_mpi_sum
179
181
else if (op_f == MPI_MAX) then
180
182
c_op = c_MPI_MAX
183
+ else if (op_f == MPI_LOR) then
184
+ c_op = c_mpi_lor
181
185
else
182
- c_op = c_mpi_op_f2c(op_f)
186
+ c_op = c_mpi_op_f2c(op_f) ! For other operations, use the C binding
183
187
end if
184
188
end function
185
189
@@ -841,6 +845,35 @@ subroutine MPI_Allreduce_1D_int_proc(sendbuf, recvbuf, count, datatype, op, comm
841
845
end if
842
846
end subroutine MPI_Allreduce_1D_int_proc
843
847
848
+ subroutine MPI_Allreduce_scalar_logical_proc (sendbuf , recvbuf , count , datatype , op , comm , ierror )
849
+ use iso_c_binding, only: c_int, c_ptr, c_loc
850
+ use mpi_c_bindings, only: c_mpi_allreduce, c_mpi_comm_f2c
851
+ logical , intent (in ), target :: sendbuf
852
+ logical , intent (out ), target :: recvbuf
853
+ integer , intent (in ) :: count, datatype, op, comm
854
+ integer , intent (out ), optional :: ierror
855
+ type (c_ptr) :: sendbuf_ptr, recvbuf_ptr
856
+ integer (kind= MPI_HANDLE_KIND) :: c_datatype, c_op, c_comm
857
+ integer (c_int) :: local_ierr
858
+
859
+ sendbuf_ptr = c_loc(sendbuf)
860
+ recvbuf_ptr = c_loc(recvbuf)
861
+ c_datatype = handle_mpi_datatype_f2c(datatype)
862
+ c_op = handle_mpi_op_f2c(op)
863
+
864
+ c_comm = handle_mpi_comm_f2c(comm)
865
+
866
+ local_ierr = c_mpi_allreduce(sendbuf_ptr, recvbuf_ptr, count, c_datatype, c_op, c_comm)
867
+
868
+ if (present (ierror)) then
869
+ ierror = local_ierr
870
+ else
871
+ if (local_ierr /= MPI_SUCCESS) then
872
+ print * , " MPI_Allreduce_1D_recv_proc failed with error code: " , local_ierr
873
+ end if
874
+ end if
875
+ end subroutine MPI_Allreduce_scalar_logical_proc
876
+
844
877
function MPI_Wtime_proc () result(time)
845
878
use mpi_c_bindings, only: c_mpi_wtime
846
879
real (8 ) :: time
0 commit comments