(j3.2006) kind conversion for intent(in), value dummy arguments
Craig Rasmussen
crasmussen
Tue Sep 16 11:38:26 EDT 2008
On Sep 15, 2008, at 9:07 PM, Jim Xia wrote:
>
> j3-bounces at j3-fortran.org wrote on 09/15/2008 07:27:29 PM:
>
>
> > Aleksandar Donev wrote:
> > > On Monday 15 September 2008 16:17, Bill Long wrote:
> > >
> > > What Craig is taking about is the case when default integer and
> C_INT are
> > > different (e.g., -i8). Then the existing MPI interface passes
> default
> > > integers even though the underlying implementation wants C ints.
> So you
> > > either need wrappers or you need to change the interface (and
> thus codes).
> > > Aleks
> > >
> >
> > Or, the user needs to explicitly specify the kinds for the
> arguments,
> > overriding the effect of -i8. This is the usual and recommended
> > solution for this problem. Since the interface is explicit,
> failure to
> > do this will give error messages that 'remind' the user to fix the
> problem.
> >
>
> In C's calling-by-value convention, there is an implicit conversion
> on the caller site to match the explicit interface. So even the
> user uses a different kind value (say int vs long long int), the
> compiler makes sure on the caller site, the conversion happens.
> This is a quite useful feature in C that lacks in Fortran's VALUE
> attribute. We may consider to add this to Fortran C-interop TR.
>
I also think this would be a useful feature for the TR. This would
allow the compiler to issue a warning if there is a kind conversion
rather than an error. Passing by value is fundamentally different from
reference semantics. Fortran allows assignment between types with
different kind values. Passing by value seems to me to be like
assignment. However, this is not a big deal for MPI, since it looks
like we will need wrapper functions anyway, the conversion can be done
within the wrapper. I rather do the conversion that blow up the
interfaces with multiple kind parameters.
Regards,
Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://j3-fortran.org/pipermail/j3/attachments/20080916/831c1d1a/attachment.html
More information about the J3
mailing list