(j3.2006) TYPE(*) and scalars
Wed Mar 21 19:21:52 EDT 2012
On 3/21/12 5:40 PM, Rasmussen, Craig E wrote:
> The problem is that the "well know name" is that it must be implementable in Fortran with a standard subroutine. So generics don't really work unless MPI publishes both interfaces. In your example, the published routine names would have to be both bar1 and bar2.
In a real implementation I would assume that foo would be spelled cbar.
(as in both being MPI_send, or some such.) That's the actual name of
the C function in the MPI library, which is the only actual routine.
> In case anyone really cares, this is because of the PMPI interfaces which allows tool writers to intercept the MPI calls.
The tools can't intercept the C functions by their actual names? C
programmers can't use the tools? Timing the C function (where all the
work happens) would seem like what you want.
> On Mar 21, 2012, at 12:11 PM, Bill Long wrote:
>> On 3/21/12 11:42 AM, Rasmussen, Craig E wrote:
>>> The MPI-3 Fortran subcommittee has been having a discussion with Tobias regarding the use of TYPE(*). There is a potential problem for the MPI-3 standard, in the interim, until compilers implement assumed rank. The issue regards needing two generic interfaces (one for scalars and one for arrays) if TYPE(*) is used WITHOUT assumed rank (for example, Tobias has already added TYPE(*) to gfortran but assumed rank will obviously take more time). Other compilers use some sort of IGNORE_TKR directive that allows scalar actual arguments. However, Tobias doesn't think TYPE(*) alone should allow this behavior.
>>> So I'm not putting words in Tobias' mouth, here is his comments from earlier emails:
>>>> However, without "dimension(*)" you may not pass an array (or array section) and with "dimension(*)" you may not pass a scalar as argument. (* with exceptions for strings and array elements.)
>>>> See Fortran 2008 standard:
>>>> "If the actual argument is a noncoindexed scalar, the corresponding dummy argument shall be scalar unless the actual argument is default character, of type character with the C character kind (15.2.2), or is an element or substring of an element of an array that is not an assumed-shape, pointer, or polymorphic array." (188.8.131.52p13)
>>>> "A scalar dummy argument of a nonelemental procedure shall correspond only to a scalar actual argument." (184.108.40.206p16)
>>>> I don't think that TS 29113 changes this - except for assumed-rank dummies ("dimension(..)").
>>> This is actually critical to the MPI-3 Fortran standard as we really can't pollute the FORTRAN namespace with two generic interfaces as we have to publish the "well known name" of the interface implementation so that it really can't be generic.
>>> Advice would be appreciated.
>> It should be possible to work around this. If the "known interface name" is foo, then
>> interface foo
>> subroutine bar1 (x) bind(C, name="cbar")
>> type(*) :: x
>> end subroutine bar1
>> subroutine bar2 (x) bind(C, name="cbar")
>> type(*),dimension(*) :: x
>> end subroutine bar2
>> end interface
>> will work. The specifics are distinguishable because of the rank distinction, independent of the types. Since you can map both of them to the same C routine, there is no need to have extra C wrappers. On the C side, the corresponding formal parameter is (void *), which is valid for either specific.
>>> FYI. We have released a tarball for the Open MPI implementation of the new MPI-3 Fortran standard. In case there are any vendors who wish to try this beta please let Jeff Squyres know. Several vendors have already tried this beta release and have fixed bugs in their compilers.
>>> J3 mailing list
>>> J3 at j3-fortran.org
>> Bill Long longb at cray.com
>> Fortran Technical Support& voice: 651-605-9024
>> Bioinformatics Software Development fax: 651-605-9142
>> Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
>> J3 mailing list
>> J3 at j3-fortran.org
> J3 mailing list
> J3 at j3-fortran.org
Bill Long longb at cray.com
Fortran Technical Support & 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 J3