[MPI3 Fortran] Proposing changes to Fortran 2008

Lionel, Steve steve.lionel at intel.com
Fri Mar 14 15:47:12 CDT 2008


Aleksandar Donev wrote:
 
> A possible solution is something like:
> 
> interface
> subroutine mpi_send(buffer...) bind(c)
>     type(c_void), dimension(*) :: buffer
> end subroutine
> end interface
> 
> or
> 
> interface
> subroutine mpi_send(buffer,N,...) bind(c)
>     integer :: N
>     type(c_void), dimension(N) :: buffer
> end subroutine
> end interface
> 
> The important thing here, which will be objected to in J3, is that
such
> a type(c_void) argument can only appear in bind(c) interfaces for an
> assumed-size or explicit-shape array (we can discuss extensions to
> assumed-shape arrays later...we are working on a TR for that). One
> cannot write an actual Fortran routine that has a dummy with no type
> since it is ill-defined what that means in Fortran. 

My opinion on this is that "type(c_void)" is not consistent with the
Fortran language.  I'd propose instead that a new VOID attribute be
allowed in declarations of dummy arguments.  The argument could be
declared as having any type (INTEGER would do) - but a dummy with the
VOID attribute would match any actual argument TKR (Type, Kind, Rank).
Indeed, many commercial compilers already implement this concept, though
each spells it differently (with some sort of comment-looking directive,
such as Intel's !DEC$ ATTRIBUTES NO_ARG_CHECK).

I feel that a VOID attribute is more natural to Fortran in that it does
not require a special case for a specially named derived type (note that
one ought to be able to write the module ISO_C_BINDING in Fortran
(perhaps with some extensions), and we in fact do so.)  I think this
would also be easy for programmers to understand the correspondence with
C's void (un)type.

So with my proposal, the interface above would be written:

interface
 subroutine mpi_send(buffer...) bind(c)
     integer, dimension(*), void :: buffer
 end subroutine
end interface

In this case, the dimension(*) is really there for the reader - the
compiler ignores it.

When used in a generic procedure declaration, VOID arguments match any
TKR.


Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH 






More information about the mpiwg-fortran mailing list