1
1

As noted by Paul Hargrove, older PGI compilers support ''some'' of

BIND(C), but not ''all'' of it.  So expand our configure checks to
look for multiple different forms of BIND(C):

 * ISO_C_BINDING
 * SUBROUTINE ... BIND(C)
 * TYPE, BIND(C)
 * TYPE(foo), BIND(C, name="bar")

If the compiler supports all of these, then declare that we support
BIND(C), and the rest of the mpi_f08 checks can continue.  If we miss
any one of those, don't bother continuing -- we won't build the
mpi_f08 module.

Also push the results of all of these tests down to ompi_info so that
they can be reported easily (e.g., "Hey, why doesn't my OMPI
installation have the mpi_f08 module?").

cmr=v1.7.4:reviewer=jsquyres:subject=Expand Fortran BIND(C) configure checks

This commit was SVN r30247.
Этот коммит содержится в:
Jeff Squyres 2014-01-10 23:44:55 +00:00
родитель 18cc164a3b
Коммит b0ffdb3ae5
3 изменённых файлов: 161 добавлений и 15 удалений

Просмотреть файл

@ -20,24 +20,97 @@ dnl
# Check whether or not the Fortran compiler supports BIND(C) or not
# OMPI_FORTRAN_CHECK_BIND_C([action if found], [action if not found])
# OMPI_FORTRAN_CHECK_ISO_C_BINDING([action if found], [action if not found])
# ----------------------------------------------------
AC_DEFUN([OMPI_FORTRAN_CHECK_BIND_C],[
AS_VAR_PUSHDEF([bind_c_var], [ompi_cv_fortran_have_bind_c])
AC_DEFUN([OMPI_FORTRAN_CHECK_ISO_C_BINDING],[
AS_VAR_PUSHDEF([iso_c_binding_var], [ompi_cv_fortran_have_iso_c_binding])
AC_CACHE_CHECK([if Fortran compiler supports BIND(C)], bind_c_var,
AC_CACHE_CHECK([if Fortran compiler supports ISO_C_BINDING], iso_c_binding_var,
[AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[program check_for_bind_c
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[program check_for_iso_c_binding
use, intrinsic :: iso_c_binding
type CType
integer(C_INT) :: i
end type
end program]])],
[AS_VAR_SET(bind_c_var, yes)],
[AS_VAR_SET(bind_c_var, no)])
[AS_VAR_SET(iso_c_binding_var, yes)],
[AS_VAR_SET(iso_c_binding_var, no)])
AC_LANG_POP([Fortran])
])
AS_VAR_IF(bind_c_var, [yes], [$1], [$2])
AS_VAR_POPDEF([bind_c_var])dnl
AS_VAR_IF(iso_c_binding_var, [yes], [$1], [$2])
AS_VAR_POPDEF([iso_c_binding_var])
])
# Check for SUBROUTINE ... BIND(C)
# OMPI_FORTRAN_CHECK_BIND_C_SUB([action if found], [action if not found])
# ----------------------------------------------------
AC_DEFUN([OMPI_FORTRAN_CHECK_BIND_C_SUB],[
AS_VAR_PUSHDEF([bind_c_sub_var], [ompi_cv_fortran_have_bind_c_sub])
AC_CACHE_CHECK([for Fortran SUBROUTINE BIND(C)], bind_c_sub_var,
[AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[program check_for_bind_c_sub
use, intrinsic :: iso_c_binding
interface
subroutine foo(i) bind(c)
integer :: i
end subroutine foo
end interface
end program]])],
[AS_VAR_SET(bind_c_sub_var, yes)],
[AS_VAR_SET(bind_c_sub_var, no)])
AC_LANG_POP([Fortran])
])
AS_VAR_IF(bind_c_sub_var, [yes], [$1], [$2])
AS_VAR_POPDEF([bind_c_sub_var])
])
# Check for TYPE, BIND(C) :: derived_type
# OMPI_FORTRAN_CHECK_BIND_C_TYPE([action if found], [action if not found])
# ----------------------------------------------------
AC_DEFUN([OMPI_FORTRAN_CHECK_BIND_C_TYPE],[
AS_VAR_PUSHDEF([bind_c_type_var], [ompi_cv_fortran_have_bind_c_type])
AC_CACHE_CHECK([for Fortran TYPE, BIND(C)], bind_c_type_var,
[AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[module bindc_test
use, intrinsic :: iso_c_binding
type, bind(c) :: foo
integer :: value
end type foo
end module]])],
[AS_VAR_SET(bind_c_type_var, yes)],
[AS_VAR_SET(bind_c_type_var, no)])
AC_LANG_POP([Fortran])
])
AS_VAR_IF(bind_c_type_var, [yes], [$1], [$2])
AS_VAR_POPDEF([bind_c_type_var])dnl
])
# Check for TYPE(type), BIND(C, name="name")
# OMPI_FORTRAN_CHECK_BIND_C_TYPE_NAME([action if found], [action if not found])
# ----------------------------------------------------
AC_DEFUN([OMPI_FORTRAN_CHECK_BIND_C_TYPE_NAME],[
AS_VAR_PUSHDEF([bind_c_type_name_var], [ompi_cv_fortran_have_bind_c_type_name])
AC_CACHE_CHECK([for Fortran TYPE(type), BIND(C, NAME="name")], bind_c_type_name_var,
[AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[module bindc_test
use, intrinsic :: iso_c_binding
type, bind(c) :: foo
integer :: value
end type foo
type(foo), bind(c, name="c_name") :: bar
end module]])],
[AS_VAR_SET(bind_c_type_name_var, yes)],
[AS_VAR_SET(bind_c_type_name_var, no)])
AC_LANG_POP([Fortran])
])
AS_VAR_IF(bind_c_type_name_var, [yes], [$1], [$2])
AS_VAR_POPDEF([bind_c_type_name_var])dnl
])

Просмотреть файл

@ -37,6 +37,10 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
OMPI_FORTRAN_HAVE_IGNORE_TKR=0
OMPI_FORTRAN_HAVE_OPTIONAL_ARGS=0
OMPI_FORTRAN_HAVE_BIND_C=0
OMPI_FORTRAN_HAVE_ISO_C_BINDING=0
OMPI_FORTRAN_HAVE_BIND_C_SUB=0
OMPI_FORTRAN_HAVE_BIND_C_TYPE=0
OMPI_FORTRAN_HAVE_BIND_C_TYPE_NAME=0
OMPI_FORTRAN_HAVE_F08_ASSUMED_RANK=0
OMPI_FORTRAN_HAVE_PRIVATE=0
@ -335,13 +339,48 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
# If we got all the stuff from above, then also look for the new
# F08 syntax that we can use for the use_mpif08 module.
# The overall "_BIND_C" variable will be set to 1 if we have all
# the necessary forms of BIND(C)
OMPI_FORTRAN_HAVE_BIND_C=0
OMPI_FORTRAN_HAVE_ISO_C_BINDING=0
AS_IF([test $OMPI_WANT_FORTRAN_USEMPIF08_BINDINGS -eq 1 -a \
$OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS -eq 1],
[ # If we don't have BIND(C), we won't build mpi_f08 at all
OMPI_FORTRAN_CHECK_BIND_C(
[OMPI_FORTRAN_HAVE_BIND_C=1],
[OMPI_FORTRAN_HAVE_BIND_C=0
[ # If we don't have ISO C bindings, we won't build mpi_f08 at all
OMPI_FORTRAN_CHECK_ISO_C_BINDING(
[OMPI_FORTRAN_HAVE_ISO_C_BINDING=1],
[OMPI_FORTRAN_HAVE_ISO_C_BINDING=0
OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS=0])])
OMPI_FORTRAN_HAVE_BIND_C_SUB=0
AS_IF([test $OMPI_WANT_FORTRAN_USEMPIF08_BINDINGS -eq 1 -a \
$OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS -eq 1],
[ # If we don't have SUBROUTINE BIND(C), we won't build mpi_f08 at all
OMPI_FORTRAN_CHECK_BIND_C_SUB(
[OMPI_FORTRAN_HAVE_BIND_C_SUB=1],
[OMPI_FORTRAN_HAVE_BIND_C_SUB=0
OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS=0])])
OMPI_FORTRAN_HAVE_BIND_C_TYPE=0
AS_IF([test $OMPI_WANT_FORTRAN_USEMPIF08_BINDINGS -eq 1 -a \
$OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS -eq 1],
[ # If we don't have TYPE, BIND(C), we won't build mpi_f08 at all
OMPI_FORTRAN_CHECK_BIND_C_SUB(
[OMPI_FORTRAN_HAVE_BIND_C_TYPE=1],
[OMPI_FORTRAN_HAVE_BIND_C_TYPE=0
OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS=0])])
OMPI_FORTRAN_HAVE_BIND_C_TYPE_NAME=0
AS_IF([test $OMPI_WANT_FORTRAN_USEMPIF08_BINDINGS -eq 1 -a \
$OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS -eq 1],
[ # If we don't have TYPE, BIND(C, name="foo"), we won't build mpi_f08 at all
OMPI_FORTRAN_CHECK_BIND_C_SUB(
[ # If we got here, we have all the required forms of
# BIND(C), so set the top-level _BIND_C variable to 1.
OMPI_FORTRAN_HAVE_BIND_C=1
OMPI_FORTRAN_HAVE_BIND_C_TYPE_NAME=1],
[OMPI_FORTRAN_HAVE_BIND_C_TYPE_NAME=0
OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS=0])])
OMPI_FORTRAN_HAVE_OPTIONAL_ARGS=0
@ -596,7 +635,19 @@ end type test_mpi_handle],
[For ompi_info: Whether the Fortran compiler supports the Fortran 2008 "assumed rank" syntax or not])
AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_BIND_C,
[$OMPI_FORTRAN_HAVE_BIND_C],
[For ompi_info: Whether we want to use BIND(C) in the mpi_f08 module or not (based on "good" or "bad" compiler determination, i.e., whether we are using fortran wrapper functions for choice buffers or not)])
[For ompi_info: Whether the compiler supports all forms of BIND(C) that we need])
AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_ISO_C_BINDING,
[$OMPI_FORTRAN_HAVE_ISO_C_BINDING],
[For ompi_info: Whether the compiler supports ISO_C_BINDING or not])
AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_BIND_C_SUB,
[$OMPI_FORTRAN_HAVE_BIND_C_SUB],
[For ompi_info: Whether the compiler supports SUBROUTINE ... BIND(C) or not])
AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_BIND_C_TYPE,
[$OMPI_FORTRAN_HAVE_BIND_C_TYPE],
[For ompi_info: Whether the compiler supports TYPE, BIND(C) or not])
AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_BIND_C_TYPE_NAME,
[$OMPI_FORTRAN_HAVE_BIND_C_TYPE_NAME],
[For ompi_info: Whether the compiler supports TYPE, BIND(C, NAME="name") or not])
AC_DEFINE_UNQUOTED([OMPI_FORTRAN_HAVE_OPTIONAL_ARGS],
[$OMPI_FORTRAN_HAVE_OPTIONAL_ARGS],
[For ompi_info: whether the Fortran compiler supports optional arguments or not])

Просмотреть файл

@ -88,6 +88,10 @@ void ompi_info_do_config(bool want_all)
char *fortran_build_f08_subarrays;
char *fortran_have_optional_args;
char *fortran_have_bind_c;
char *fortran_have_iso_c_binding;
char *fortran_have_bind_c_sub;
char *fortran_have_bind_c_type;
char *fortran_have_bind_c_type_name;
char *fortran_have_private;
char *fortran_have_abstract;
char *fortran_have_asynchronous;
@ -162,6 +166,12 @@ void ompi_info_do_config(bool want_all)
fortran_have_optional_args = OMPI_FORTRAN_HAVE_OPTIONAL_ARGS ?
"yes" : "no";
fortran_have_bind_c = OMPI_FORTRAN_HAVE_BIND_C ? "yes" : "no";
fortran_have_iso_c_binding = OMPI_FORTRAN_HAVE_ISO_C_BINDING ?
"yes" : "no";
fortran_have_bind_c_sub = OMPI_FORTRAN_HAVE_BIND_C_SUB ? "yes" : "no";
fortran_have_bind_c_type = OMPI_FORTRAN_HAVE_BIND_C_TYPE ? "yes" : "no";
fortran_have_bind_c_type_name = OMPI_FORTRAN_HAVE_BIND_C_TYPE_NAME ?
"yes" : "no";
fortran_have_private = OMPI_FORTRAN_HAVE_PRIVATE ? "yes" : "no";
fortran_have_abstract = OMPI_FORTRAN_HAVE_ABSTRACT ? "yes" : "no";
fortran_have_asynchronous = OMPI_FORTRAN_HAVE_ASYNCHRONOUS ? "yes" : "no";
@ -362,9 +372,21 @@ void ompi_info_do_config(bool want_all)
opal_info_out("Fort optional args",
"compiler:fortran:optional_arguments",
fortran_have_optional_args);
opal_info_out("Fort BIND(C)",
opal_info_out("Fort BIND(C) (all)",
"compiler:fortran:bind_c",
fortran_have_bind_c);
opal_info_out("Fort ISO_C_BINDING",
"compiler:fortran:iso_c_binding",
fortran_have_iso_c_binding);
opal_info_out("Fort SUBROUTINE BIND(C)",
"compiler:fortran:subroutine_bind_c",
fortran_have_bind_c_sub);
opal_info_out("Fort TYPE,BIND(C)",
"compiler:fortran:type_bind_c",
fortran_have_bind_c_type);
opal_info_out("Fort T,BIND(C,name=\"a\")",
"compiler:fortran:type_name_bind_c",
fortran_have_bind_c_type_name);
opal_info_out("Fort PRIVATE",
"compiler:fortran:private",
fortran_have_private);