1
1
openmpi/ompi/mpi/fortran/use-mpi-tkr/mpi-f90-cptr-interfaces.F90
Jeff Squyres 0089ac20af Fortran: put type(c_ptr) interfaces in a separate file in the TKR mpi module
Older gfortran compilers (e.g., the gfortran that ships in RHEL5) do
not support ISO_C_BINDING, and therefore do not support the
TYPE(C_PTR) type.  As such, they cannot support the overloaded
interfaces for MPI_WIN_ALLOCATE_SHARED and MPI_SHARED_QUERY that are
mandated in MPI-3.

So we separate those interfaces out into a separate .F90 file that is
#include'd in the tkr mpi.F90 file.  In this separate .F90 file, we
use an #if to determine whether the compiler supports ISO_C_BINDING or
not.

Also re-jiggered the order of testing in ompi_setup_mpi_fortran.m4: we
now need to test whether the compiler supports ISO_C_BINDING even when
we're only building the mpi module (not strictly when we're building
the mpi_f08 module).

Finally, tweaked the use-mpi-tkr/Makefile.am to:

* Add some proper dependencies for mpi.F90
* Allow the general AM compilation to be used instead of supplying a
  specific rule for compiling mpi.F90

cmr=v1.8.2:ticket=trac:4736

This commit was SVN r32204.

The following Trac tickets were found above:
  Ticket 4736 --> https://svn.open-mpi.org/trac/ompi/ticket/4736
2014-07-10 19:10:03 +00:00

78 строки
2.4 KiB
Fortran

! -*- fortran -*-
!
! Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
! $COPYRIGHT$
!
! Additional copyrights may follow
!
! $HEADER$
!
! This file contains interfaces that use the ISO_C_BINDING module and
! the TYPE(C_PTR) type, which not all Fortran compilers support (e.g.,
! gfortran on RHEL 5 does not support this module/type). So we use a
! preprocessor macro to protect the problematic declarations.
!
! This file is included via a preprocessor include directorive in
! mpi.F90, which allows us to use the preprocessor "if" directive,
! below.
!
interface MPI_Win_allocate_shared
subroutine MPI_Win_allocate_shared(size, disp_unit, info, comm, &
baseptr, win, ierror)
include 'mpif-config.h'
integer(KIND=MPI_ADDRESS_KIND), intent(in) :: size
integer, intent(in) :: disp_unit
integer, intent(in) :: info
integer, intent(in) :: comm
integer(KIND=MPI_ADDRESS_KIND), intent(out) :: baseptr
integer, intent(out) :: win
integer, intent(out) :: ierror
end subroutine MPI_Win_allocate_shared
! Only include the 2nd interface if we have ISO_C_BINDING / TYPE(C_PTR)
#if OMPI_FORTRAN_HAVE_ISO_C_BINDING
subroutine MPI_Win_allocate_shared_cptr(size, disp_unit, info, comm, &
baseptr, win, ierror)
use, intrinsic :: iso_c_binding, only : c_ptr
include 'mpif-config.h'
integer :: disp_unit, info, comm, win, ierror
integer(KIND=MPI_ADDRESS_KIND) :: size
type(C_PTR) :: baseptr
end subroutine MPI_Win_allocate_shared_cptr
#endif
end interface
interface MPI_Win_shared_query
subroutine MPI_Win_shared_query(win, rank, size, disp_unit, baseptr,&
ierror)
include 'mpif-config.h'
integer, intent(in) :: win
integer, intent(in) :: rank
integer(KIND=MPI_ADDRESS_KIND), intent(out) :: size
integer, intent(out) :: disp_unit
integer(KIND=MPI_ADDRESS_KIND), intent(out) :: baseptr
integer, intent(out) :: ierror
end subroutine MPI_Win_shared_query
! Only include the 2nd interface if we have ISO_C_BINDING / TYPE(C_PTR)
#if OMPI_FORTRAN_HAVE_ISO_C_BINDING
subroutine MPI_Win_shared_query_cptr(win, rank, size, disp_unit, baseptr,&
ierror)
use, intrinsic :: iso_c_binding, only : c_ptr
include 'mpif-config.h'
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 MPI_Win_shared_query_cptr
#endif
end interface