(j3.2006) TYPE(*) and scalars

Van Snyder Van.Snyder
Wed Mar 21 14:42:52 EDT 2012


On Wed, 2012-03-21 at 11:11 -0700, 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." (12.5.2.4p13)
> >>
> >> "A scalar dummy argument of a nonelemental procedure shall correspond only to a scalar actual argument." (12.5.2.4p16)
> >>
> >>
> >> 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.

The problem with generics is that they can't be pointer targets or
actual arguments.  That's why I proposed a method to resolve generics to
specifics without invoking them.  Is it contemplated that one would want
to use MPI-3 routines in this way?  If not, this solution probably
works.  Otherwise, a problem remains.

> Cheers,
> Bill
> 
> > 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.
> >
> > -craig
> >
> >
> >
> >
> > _______________________________________________
> > J3 mailing list
> > J3 at j3-fortran.org
> > http://j3-fortran.org/mailman/listinfo/j3
> 




More information about the J3 mailing list