1
1

fortran: fix compile issue with ABSoft compilers

ABSoft compilers cannot compile a fortran subroutine
with the BIND(C, NAME="name") modifier *and* argument(s)
with the OPTIONAL modifier

This patch detects this unsupported feature and use
adhoc wrappers if it is missing

cmr=v1.8.2:reviewer=jsquyres

This commit was SVN r32246.
Этот коммит содержится в:
Gilles Gouaillardet 2014-07-15 10:41:11 +00:00
родитель c57687d8ec
Коммит 08d2a1a48d
6 изменённых файлов: 225 добавлений и 0 удалений

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

@ -0,0 +1,101 @@
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2014 Research Organization for Information Science
dnl and Technology (RIST). All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
# Check whether or not the Fortran compiler supports subroutines with
# the BIND(C, NAME="name") parameter and optional arguments or not,
# and we (generally) don't need wrapper subroutines.
# OMPI_FORTRAN_CHECK_BIND_C_WITH_OPTIONAL_ARGS([action if found],
# [action if not found])
# ----------------------------------------------------
AC_DEFUN([OMPI_FORTRAN_CHECK_BIND_C_WITH_OPTIONAL_ARGS],[
unset happy
OPAL_VAR_SCOPE_PUSH([happy ompi_conftest_h])
AC_CACHE_CHECK(
[if Fortran compiler supports BIND(C, NAME="name") subroutine with optional arguments],
[ompi_cv_fortran_bind_c_with_optional_args],
[ompi_cv_fortran_bind_c_with_optional_args=no
cat > conftestf.f90 <<EOF
program check_for_bind_c_with_optional
use, intrinsic :: iso_c_binding
interface
subroutine check_op(i, ierror) BIND(C, name="check_op")
integer, intent(in), value :: i
integer, intent(out), optional :: ierror
end subroutine check_op
end interface
integer :: ierror
call check_op(0)
call check_op(1, ierror)
end program
EOF
# C module
if test -f conftest.h; then
ompi_conftest_h="#include \"conftest.h\""
else
ompi_conftest_h=""
fi
cat > conftest.c <<EOF
#include <stdio.h>
#include <stdlib.h>
$ompi_conftest_h
#ifdef __cplusplus
extern "C" {
#endif
void check_op(int, int *);
void check_op(int has_op, int *ierror)
{
/* Force a segv if the conditions are wrong */
char *bogus = 0;
if (0 == has_op) {
/* won't have optional argument */
if (NULL != ierror) *bogus= 13;
} else {
/* will have optional argument */
if (NULL == ierror) *bogus= 13;
*ierror = 33;
}
}
#ifdef __cplusplus
}
#endif
EOF
OPAL_LOG_COMMAND([$CC $CFLAGS -I. -c conftest.c],
[OPAL_LOG_COMMAND([$FC $FCFLAGS conftestf.f90 conftest.o -o conftest $LDFLAGS $LIBS],
[happy="yes"], [happy="no"])],
[happy="c_fail"])
AS_IF([test "$happy" = "c_fail"],
[AC_MSG_RESULT([error])
AC_MSG_ERROR([This error should not happen -- contact the Open MPI developers])
])
AS_IF([test "$cross_compiling" = "yes"],
[AC_MSG_RESULT([cross-compiling])
AC_MSG_ERROR([Cannot determine if Fortran compiler supports optional arguments when cross-compiling])],
[OPAL_LOG_COMMAND([./conftest],
[ompi_cv_fortran_bind_c_with_optional_args=yes])
])
rm -f conftest*
])dnl
AS_VAR_COPY([happy], [ompi_cv_fortran_bind_c_with_optional_args])
AS_IF([test "$happy" = "yes"], [$1], [$2])
OPAL_VAR_SCOPE_POP
])

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

@ -15,6 +15,8 @@
# Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights
# reserved.
# Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
# Copyright (c) 2014 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
@ -36,6 +38,7 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
OMPI_FORTRAN_HAVE_IGNORE_TKR=0
OMPI_FORTRAN_HAVE_OPTIONAL_ARGS=0
OMPI_FORTRAN_HAVE_BIND_C_WITH_OPTIONAL_ARGS=0
OMPI_FORTRAN_HAVE_BIND_C=0
OMPI_FORTRAN_HAVE_ISO_C_BINDING=0
OMPI_FORTRAN_HAVE_BIND_C_SUB=0
@ -385,6 +388,16 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
[OMPI_FORTRAN_HAVE_OPTIONAL_ARGS=0
OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS=0])])
OMPI_FORTRAN_HAVE_BIND_C_WITH_OPTIONAL_ARGS=0
AS_IF([test $OMPI_WANT_FORTRAN_USEMPIF08_BINDINGS -eq 1 -a \
$OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS -eq 1 -a \
$OMPI_FORTRAN_HAVE_BIND_C_TYPE_NAME -eq 1 -a \
$OMPI_FORTRAN_HAVE_OPTIONAL_ARGS -eq 1],
[ # Does the compiler have optional arguments?
OMPI_FORTRAN_CHECK_BIND_C_WITH_OPTIONAL_ARGS(
[OMPI_FORTRAN_HAVE_BIND_C_WITH_OPTIONAL_ARGS=1],
[OMPI_FORTRAN_HAVE_BIND_C_WITH_OPTIONAL_ARGS=0])])
OMPI_FORTRAN_HAVE_PRIVATE=0
AS_IF([test $OMPI_WANT_FORTRAN_USEMPIF08_BINDINGS -eq 1 -a \
$OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS -eq 1],
@ -648,6 +661,9 @@ end type test_mpi_handle],
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])
AC_DEFINE_UNQUOTED([OMPI_FORTRAN_HAVE_BIND_C_WITH_OPTIONAL_ARGS],
[$OMPI_FORTRAN_HAVE_BIND_C_WITH_OPTIONAL_ARGS],
[For ompi_info: whether the Fortran compiler supports BIND(C, NAME="name") subroutine with optional arguments or not])
# For configure-fortran-output.h, mpi-f08-types.F90 (and ompi_info)
AC_SUBST([OMPI_FORTRAN_HAVE_PRIVATE])
@ -685,6 +701,10 @@ end type test_mpi_handle],
# For configure-fortran-output.h
AC_SUBST(OMPI_FORTRAN_HAVE_BIND_C)
# For configure-fortran-output.h, various files in
# ompi/mpi/fortran/use-mpi-f08/*.F90 and *.h files (and ompi_info)
AC_SUBST(OMPI_FORTRAN_HAVE_BIND_C_WITH_OPTIONAL_ARGS)
# Somewhat redundant because ompi/Makefile.am won't traverse into
# ompi/mpi/fortran/use-mpi-f08 if it's not to be built, but we
# might as well have ompi/mpi/fortran/use-mpi-f08/Makefile.am be

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

@ -3,6 +3,8 @@
! Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
! Copyright (c) 2009-2012 Los Alamos National Security, LLC.
! All rights reserved.
! Copyright (c) 2014 Research Organization for Information Science
! and Technology (RIST). All rights reserved.
!
! $COPYRIGHT$
!
@ -41,6 +43,9 @@
! Whether we are building the MPI F08 bindings with subarray support or not
#define OMPI_FORTRAN_SUBARRAYS_SUPPORTED @OMPI_FORTRAN_SUBARRAYS_SUPPORTED@
! Whether we have BIND(C, NAME="name") subroutine with optional parameters or not
#define OMPI_FORTRAN_HAVE_BIND_C_WITH_OPTIONAL_ARGS @OMPI_FORTRAN_HAVE_BIND_C_WITH_OPTIONAL_ARGS@
! Line 1 of the ignore TKR syntax
! ...JMS not figured out yet...

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

@ -7,6 +7,8 @@
! of Tennessee Research Foundation. All rights
! reserved.
! Copyright (c) 2012 Inria. All rights reserved.
! Copyright (c) 2014 Research Organization for Information Science
! and Technology (RIST). All rights reserved.
! $COPYRIGHT$
!
! This file provides the interface specifications for the MPI Fortran
@ -2426,6 +2428,7 @@ subroutine ompi_win_post_f(group,assert,win,ierror) &
INTEGER, INTENT(OUT) :: ierror
end subroutine ompi_win_post_f
#if OMPI_FORTRAN_HAVE_BIND_C_WITH_OPTIONAL_ARGS
subroutine ompi_win_shared_query_f(win, rank, size, disp_unit, baseptr,&
ierror) BIND(C, name="ompi_win_shared_query_f")
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
@ -2437,6 +2440,20 @@ subroutine ompi_win_shared_query_f(win, rank, size, disp_unit, baseptr,&
TYPE(C_PTR), INTENT(OUT) :: baseptr
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
end subroutine ompi_win_shared_query_f
#else
subroutine ompi_win_shared_query_f(win, rank, size, disp_unit, baseptr,&
ierror)
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
use :: mpi_f08_types, only : MPI_ADDRESS_KIND
implicit none
INTEGER, INTENT(IN) :: win
INTEGER, INTENT(IN) :: rank
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(OUT) :: size
INTEGER, INTENT(OUT) :: disp_unit
TYPE(C_PTR), INTENT(OUT) :: baseptr
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
end subroutine ompi_win_shared_query_f
#endif
subroutine ompi_win_start_f(group,assert,win,ierror) &
BIND(C, name="ompi_win_start_f")

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

@ -13,6 +13,8 @@
! Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
! Copyright (c) 2009-2012 Los Alamos National Security, LLC.
! All rights reserved.
! Copyright (c) 2014 Research Organization for Information Science
! and Technology (RIST). All rights reserved.
! $COPYRIGHT$
!
! Additional copyrights may follow
@ -45,3 +47,67 @@ module mpi_f08
include "conversion-fn-null-f08-interface.h"
end module mpi_f08
#if ! OMPI_FORTRAN_HAVE_BIND_C_WITH_OPTIONAL_ARGS
subroutine ompi_win_shared_query_f_with_ierror(win, rank, size, disp_unit, baseptr,&
ierror) BIND(C, name="ompi_win_shared_query_f")
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
use :: mpi_f08_types, only : MPI_ADDRESS_KIND
INTEGER, INTENT(IN) :: win
INTEGER, INTENT(IN) :: rank
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(OUT) :: size
INTEGER, INTENT(OUT) :: disp_unit
TYPE(C_PTR), INTENT(OUT) :: baseptr
INTEGER, INTENT(OUT) :: ierror
end subroutine ompi_win_shared_query_f_with_ierror
subroutine ompi_win_shared_query_f(win, rank, size, disp_unit, baseptr,&
ierror)
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
use :: mpi_f08_types, only : MPI_ADDRESS_KIND
implicit none
INTEGER, INTENT(IN) :: win
INTEGER, INTENT(IN) :: rank
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(OUT) :: size
INTEGER, INTENT(OUT) :: disp_unit
TYPE(C_PTR), INTENT(OUT) :: baseptr
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
INTEGER :: ilerror
if (PRESENT(ierror)) then
call ompi_win_shared_query_f_with_ierror(win, rank, size, disp_unit, baseptr, ierror)
else
call ompi_win_shared_query_f_with_ierror(win, rank, size, disp_unit, baseptr, ilerror)
endif
end subroutine ompi_win_shared_query_f
subroutine pompi_win_shared_query_f_with_ierror(win, rank, size, disp_unit, baseptr,&
ierror) BIND(C, name="pompi_win_shared_query_f")
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
use :: mpi_f08_types, only : MPI_ADDRESS_KIND
INTEGER, INTENT(IN) :: win
INTEGER, INTENT(IN) :: rank
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(OUT) :: size
INTEGER, INTENT(OUT) :: disp_unit
TYPE(C_PTR), INTENT(OUT) :: baseptr
INTEGER, INTENT(OUT) :: ierror
end subroutine pompi_win_shared_query_f_with_ierror
subroutine pompi_win_shared_query_f(win, rank, size, disp_unit, baseptr,&
ierror)
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
use :: mpi_f08_types, only : MPI_ADDRESS_KIND
implicit none
INTEGER, INTENT(IN) :: win
INTEGER, INTENT(IN) :: rank
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(OUT) :: size
INTEGER, INTENT(OUT) :: disp_unit
TYPE(C_PTR), INTENT(OUT) :: baseptr
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
INTEGER :: ilerror
if (PRESENT(ierror)) then
call pompi_win_shared_query_f_with_ierror(win, rank, size, disp_unit, baseptr, ierror)
else
call pompi_win_shared_query_f_with_ierror(win, rank, size, disp_unit, baseptr, ilerror)
endif
end subroutine pompi_win_shared_query_f
#endif

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

@ -7,6 +7,8 @@
! of Tennessee Research Foundation. All rights
! reserved.
! Copyright (c) 2012 Inria. All rights reserved.
! Copyright (c) 2014 Research Organization for Information Science
! and Technology (RIST). All rights reserved.
! $COPYRIGHT$
!
! This file provides the interface specifications for the MPI Fortran
@ -2263,6 +2265,7 @@ subroutine pompi_win_post_f(group,assert,win,ierror) &
INTEGER, INTENT(OUT) :: ierror
end subroutine pompi_win_post_f
#if OMPI_FORTRAN_HAVE_BIND_C_WITH_OPTIONAL_ARGS
subroutine pompi_win_shared_query_f(win, rank, size, disp_unit, baseptr,&
ierror) BIND(C, name="ompi_win_shared_query_f")
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
@ -2274,6 +2277,19 @@ subroutine pompi_win_shared_query_f(win, rank, size, disp_unit, baseptr,&
TYPE(C_PTR), INTENT(OUT) :: baseptr
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
end subroutine pompi_win_shared_query_f
#else
subroutine pompi_win_shared_query_f(win, rank, size, disp_unit, baseptr,&
ierror)
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
use :: mpi_f08_types, only : MPI_ADDRESS_KIND
INTEGER, INTENT(IN) :: win
INTEGER, INTENT(IN) :: rank
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(OUT) :: size
INTEGER, INTENT(OUT) :: disp_unit
TYPE(C_PTR), INTENT(OUT) :: baseptr
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
end subroutine pompi_win_shared_query_f
#endif
subroutine pompi_win_start_f(group,assert,win,ierror) &
BIND(C, name="pompi_win_start_f")