1dnl -*- shell-script -*-
2dnl
3dnl Copyright (c) 2014      Research Organization for Information Science
4dnl                         and Technology (RIST). All rights reserved.
5dnl Copyright (c) 2014 Cisco Systems, Inc.  All rights reserved.
6dnl $COPYRIGHT$
7dnl
8dnl Additional copyrights may follow
9dnl
10dnl $HEADER$
11dnl
12
13# Check whether or not the Fortran compiler implements
14# TS 29113 subclause 8.1:
15# Removed restrictions on ISO_C_BINDING module procedures.
16
17# OMPI_FORTRAN_CHECK_C_FUNLOC([action if found],
18#                             [action if not found])
19# ----------------------------------------------------
20AC_DEFUN([OMPI_FORTRAN_CHECK_C_FUNLOC],[
21    AS_VAR_PUSHDEF([c_funloc], [ompi_cv_fortran_c_funloc])
22
23    AC_CACHE_CHECK([if Fortran compiler supports C_FUNLOC/TS 29113], c_funloc,
24       [AC_LANG_PUSH([Fortran])
25        AC_COMPILE_IFELSE([AC_LANG_SOURCE([[program main
26abstract interface
27  subroutine MPI_Comm_errhandler_function(comm, error_code)
28    implicit none
29    integer :: comm, error_code
30  end subroutine
31end interface
32
33contains
34
35subroutine  mysub(fn)
36    use, intrinsic :: iso_c_binding, only : c_funloc, c_funptr
37    procedure(MPI_Comm_errhandler_function) :: comm_errhandler_fn
38    type(c_funptr) :: comm_errhandler_fn_c
39    comm_errhandler_fn_c = c_funloc(comm_errhandler_fn)
40end subroutine mysub
41end program]])],
42             [AS_VAR_SET(c_funloc, yes)],
43             [AS_VAR_SET(c_funloc, no)])
44        AC_LANG_POP([Fortran])
45       ])
46
47    AS_VAR_IF(c_funloc, [yes], [$1], [$2])
48    AS_VAR_POPDEF([c_funloc])dnl
49])
50