(j3.2006) [MPI3 Fortran] Feedback from Fortran J3 meeting
Craig Rasmussen
crasmussen
Wed May 28 18:05:15 EDT 2008
On May 28, 2008, at 1:46 PM, Jim Xia wrote:
>
> j3-bounces at j3-fortran.org wrote on 05/28/2008 03:24:28 PM:
>
> > On Wednesday 28 May 2008 12:18, Jim Xia wrote:
> >
> > > But don't expect TARGET in interface block along will do the
> trick. In
> > > this case, TARGET is simply ignored.
> > Let me give an example:
> >
> > use iso_c_binding
> > real(c_float), dimension(10), target :: x
> >
> > call c_routine_1(c_loc(x))
> > ....
> >
> > call c_routine_2()
> > x=...
> >
> > The compiler better not move the "x=" assignment before the
> procedure
> > call---would yours?
> >
> > Example 2:
> > ------
> >
> > use iso_c_binding
> > real(c_float), dimension(10), target :: x
> >
> > interface
> > subroutine c_routine_1(x)
> > real(c_float), dimension(10), target :: x
> > end subroutine
> > end interface
> >
> > call c_routine_1(x)
> > ....
> >
> > call c_routine_2()
> > x=... ! Don't move it
> >
> > The same as example 1---the call to routine 1 can save a pointer
> to x and
> > modify x during the execution of routine 2. This all seems to me
> to be legal
> > and specified by the standard (Fortran + C).
>
>
> In both cases, x= is not moved because x are declared with TARGET in
> the main for both. But if you drop TARGET from those declarations
> in the main, then there is no guarantee. That's consistent with
> what I said: if you do see a target on x in the main program and
> then the code motion within this unit is disabled.
>
How would your compiler treat x if it had the ASYNCHRONOUS attribute
rather than TARGET?
Regards,
Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://j3-fortran.org/pipermail/j3/attachments/20080528/3a0b3e16/attachment.html
More information about the J3
mailing list