1!
2! Copyright (C) by Argonne National Laboratory
3!     See COPYRIGHT in top-level directory
4!
5
6subroutine MPI_Type_vector_f08(count, blocklength, stride, oldtype, newtype, ierror)
7    use, intrinsic :: iso_c_binding, only : c_int
8    use :: mpi_f08, only : MPI_Datatype
9    use :: mpi_c_interface, only : c_Datatype
10    use :: mpi_c_interface, only : MPIR_Type_vector_c
11
12    implicit none
13
14    integer, intent(in) :: count
15    integer, intent(in) :: blocklength
16    integer, intent(in) :: stride
17    type(MPI_Datatype), intent(in) :: oldtype
18    type(MPI_Datatype), intent(out) :: newtype
19    integer, optional, intent(out) :: ierror
20
21    integer(c_int) :: count_c
22    integer(c_int) :: blocklength_c
23    integer(c_int) :: stride_c
24    integer(c_Datatype) :: oldtype_c
25    integer(c_Datatype) :: newtype_c
26    integer(c_int) :: ierror_c
27
28    if (c_int == kind(0)) then
29        ierror_c = MPIR_Type_vector_c(count, blocklength, stride, oldtype%MPI_VAL, newtype%MPI_VAL)
30    else
31        count_c = count
32        blocklength_c = blocklength
33        stride_c = stride
34        oldtype_c = oldtype%MPI_VAL
35        ierror_c = MPIR_Type_vector_c(count_c, blocklength_c, stride_c, oldtype_c, newtype_c)
36        newtype%MPI_VAL = newtype_c
37    end if
38
39    if (present(ierror)) ierror = ierror_c
40
41end subroutine MPI_Type_vector_f08
42