1! -*- f90 -*-
2!
3! Copyright (c) 2009-2014 Cisco Systems, Inc.  All rights reserved.
4! Copyright (c) 2009-2012 Los Alamos National Security, LLC.
5!               All Rights reserved.
6! Copyright (c) 2018      Research Organization for Information Science
7!                         and Technology (RIST).  All rights reserved.
8! $COPYRIGHT$
9
10#include "ompi/mpi/fortran/configure-fortran-output.h"
11
12subroutine MPI_Register_datarep_f08(datarep,read_conversion_fn,write_conversion_fn, &
13                                    dtype_file_extent_fn,extra_state,ierror)
14   use, intrinsic :: iso_c_binding, only: c_funptr, c_funloc
15   use :: mpi_f08_types, only : MPI_ADDRESS_KIND
16   use :: mpi_f08_interfaces_callbacks, only : MPI_Datarep_conversion_function
17   use :: mpi_f08_interfaces_callbacks, only : MPI_Datarep_extent_function
18   use :: ompi_mpifh_bindings, only : ompi_register_datarep_f
19   implicit none
20   PROCEDURE(MPI_Datarep_conversion_function) :: read_conversion_fn
21   PROCEDURE(MPI_Datarep_conversion_function) :: write_conversion_fn
22   PROCEDURE(MPI_Datarep_extent_function) :: dtype_file_extent_fn
23   CHARACTER(LEN=*), INTENT(IN) :: datarep
24   INTEGER(MPI_ADDRESS_KIND), INTENT(IN) :: extra_state
25   INTEGER, OPTIONAL, INTENT(OUT) :: ierror
26   integer :: c_ierror
27   type(c_funptr) :: fread_fn, fwrite_fn, fdtype_fn
28
29   fread_fn = c_funloc(read_conversion_fn)
30   fwrite_fn = c_funloc(write_conversion_fn)
31   fdtype_fn = c_funloc(dtype_file_extent_fn)
32   call ompi_register_datarep_f(datarep,fread_fn,fwrite_fn, &
33                                fdtype_fn,extra_state,c_ierror,len(datarep))
34   if (present(ierror)) ierror = c_ierror
35
36end subroutine MPI_Register_datarep_f08
37