(j3.2006) [MPI3 Fortran] Feedback from Fortran J3 meeting
Jim Xia
jimxia
Wed May 28 15:46:33 EDT 2008
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.
Cheers
Jim Xia
RL Fortran Compiler Test
IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7
Phone (905) 413-3444 Tie-line 313-3444
email: jimxia at ca.ibm.com
D2/YF7/8200 /MKM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://j3-fortran.org/pipermail/j3/attachments/20080528/f38b2a7b/attachment.html
More information about the J3
mailing list