1!
2! Copyright (C) by Argonne National Laboratory
3!     See COPYRIGHT in top-level directory
4!
5
6subroutine MPI_Barrier_f08(comm, ierror)
7    use, intrinsic :: iso_c_binding, only : c_int
8    use :: mpi_f08, only : MPI_Comm
9    use :: mpi_c_interface, only : c_Comm
10    use :: mpi_c_interface, only : MPIR_Barrier_c
11
12    implicit none
13
14    type(MPI_Comm), intent(in) :: comm
15    integer, optional, intent(out) :: ierror
16
17    integer(c_Comm) :: comm_c
18    integer(c_int) :: ierror_c
19
20    if (c_int == kind(0)) then
21        ierror_c = MPIR_Barrier_c(comm%MPI_VAL)
22    else
23        comm_c = comm%MPI_VAL
24        ierror_c = MPIR_Barrier_c(comm_c)
25    end if
26
27    if (present(ierror)) ierror = ierror_c
28
29end subroutine MPI_Barrier_f08
30