[MPIWG Fortran] BIND(C) attribute of MPI callback functions

Bill Long longb at cray.com
Wed Jul 2 07:05:02 CDT 2014


On Jul 2, 2014, at 2:11 AM, Rolf Rabenseifner <rabenseifner at hlrs.de> wrote:

> Bill,
> 
> The reason for removal of BIND(C) was simple:
> Four callbacks contain LOGICAL arguments
> and we learnt that LOGICAL and BIND(C) does not work together.
> Therefore the errata is correct.

Agreed.

> 
> I hope you find a solution for storing the callback pointer
> in a C structure and to bring it back to Fortran.
> I expect that calling the Fortran callbacks
> in a portable way may require Fortran code
> that calls the callback.

For compilers that support the TS, there should be no problem. As noted by Junchao, Cray and Gfortran did not have a problem.  The IBM compiler appears to have overlooked the TS  change. A bug report to IBM should resolve the issue.  The fix is trivial - just disabling an error message.

Cheers,
Bill


> 
> Best regards
> Rolf
> 
> 
> ----- Original Message -----
>> From: "Bill Long" <longb at cray.com>
>> To: "MPI-WG Fortran working group" <mpiwg-fortran at lists.mpi-forum.org>
>> Sent: Tuesday, July 1, 2014 9:06:05 PM
>> Subject: Re: [MPIWG Fortran] BIND(C) attribute of MPI callback functions
>> 
>> 
>> On Jul 1, 2014, at 2:00 PM, Junchao Zhang <jczhang at mcs.anl.gov>
>> wrote:
>> 
>>> Hello,
>>>  Errata for MPI-3.0 removed the BIND(C) attribute of MPI callback
>>>  functions. But in an implementation, to pass the Fortran
>>>  procedure to the backend C, I need to get its C function pointer
>>>  with c_funloc, as the following code shows. When I compile it
>>>  with IBM XLF 15.1, it complains with such an error "1516-203 (S)
>>>  The argument to the intrinsic procedure C_FUNLOC must be a
>>>  procedure with the BIND(C) attribute." In my experiments, gcc
>>>  and Cray ftn are fine with it.  Looking at
>>>  https://gcc.gnu.org/onlinedocs/gfortran/C_005fFUNLOC.html, I
>>>  find c_funloc indeed requires an interoperable function
>>>  argument. Any comments?
>> 
>> This requirement on the argument of C_FUNLOC was removed by TS 29113,
>> subclause 8.1 “Removed restrictions on ISO_C_BINDING module
>> procedures”.
>> 
>> Cheers,
>> Bill
>> 
>> 
>> 
>>> 
>>> subroutine MPI_Comm_create_errhandler_f08(comm_errhandler_fn,
>>> errhandler, ierror)
>>>    use, intrinsic :: iso_c_binding, only : c_funloc, c_int,
>>>    c_funptr
>>>    use :: mpi_f08, only : MPI_Errhandler,
>>>    MPI_Comm_errhandler_function
>>>    use :: mpi_c_interface, only : c_Errhandler,
>>>    MPIR_Comm_create_errhandler_c
>>> 
>>>    implicit none
>>> 
>>>    procedure(MPI_Comm_errhandler_function) :: comm_errhandler_fn
>>>    type(MPI_Errhandler), intent(out) :: errhandler
>>>    integer, optional, intent(out) :: ierror
>>> 
>>>    type(c_funptr) :: comm_errhandler_fn_c
>>> 
>>>    comm_errhandler_fn_c = c_funloc(comm_errhandler_fn) !! xlf
>>>    issues an error
>>>    ierror_c = MPIR_Comm_create_errhandler_c(comm_errhandler_fn_c,
>>>    errhandler%MPI_VAL)
>>>    ...
>>> end subroutine MPI_Comm_create_errhandler_f08
>>> 
>>> --Junchao Zhang
>>> _______________________________________________
>>> mpiwg-fortran mailing list
>>> mpiwg-fortran at lists.mpi-forum.org
>>> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpiwg-fortran
>> 
>> Bill Long
>>                                                                      longb at cray.com
>> Fortran Technical Suport  &                                  voice:
>> 651-605-9024
>> Bioinformatics Software Development                     fax:
>> 651-605-9142
>> Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
>> 
>> 
>> _______________________________________________
>> mpiwg-fortran mailing list
>> mpiwg-fortran at lists.mpi-forum.org
>> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpiwg-fortran
>> 
> 
> -- 
> Dr. Rolf Rabenseifner . . . . . . . . . .. email rabenseifner at hlrs.de
> High Performance Computing Center (HLRS) . phone ++49(0)711/685-65530
> University of Stuttgart . . . . . . . . .. fax ++49(0)711 / 685-65832
> Head of Dpmt Parallel Computing . . . www.hlrs.de/people/rabenseifner
> Nobelstr. 19, D-70550 Stuttgart, Germany . . . . (Office: Room 1.307)
> _______________________________________________
> mpiwg-fortran mailing list
> mpiwg-fortran at lists.mpi-forum.org
> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpiwg-fortran

Bill Long                                                                       longb at cray.com
Fortran Technical Suport  &                                  voice:  651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101





More information about the mpiwg-fortran mailing list