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