1!
2! Copyright (C) by Argonne National Laboratory
3!     See COPYRIGHT in top-level directory
4!
5
6subroutine PMPIR_Test_cancelled_f08(status, flag, ierror)
7    use, intrinsic :: iso_c_binding, only : c_loc
8    use, intrinsic :: iso_c_binding, only : c_int, c_ptr
9    use :: mpi_f08, only : MPI_Status
10    use :: mpi_f08, only : assignment(=)
11    use :: mpi_c_interface, only : c_Status
12    use :: mpi_c_interface, only : MPIR_Test_cancelled_c
13
14    implicit none
15
16    type(MPI_Status), intent(in), target :: status
17    logical, intent(out) :: flag
18    integer, optional, intent(out) :: ierror
19
20    type(c_Status), target :: status_c
21    integer(c_int) :: flag_c
22    integer(c_int) :: ierror_c
23
24    ierror_c = MPIR_Test_cancelled_c(c_loc(status), flag_c)
25
26    flag = (flag_c /= 0)
27    if (present(ierror)) ierror = ierror_c
28
29end subroutine PMPIR_Test_cancelled_f08
30