(j3.2006) ASSOCIATE and selectors
Cohen Malcolm
malcolm
Tue Feb 21 02:36:18 EST 2017
?The associate names of an ASSOCIATE construct have the scope of the block.?
This means that the association is only available after the ASSOCIATE statement. Therefore the example is incorrect. And in this example...
real :: a = 1, b = 2
associate(b=>a,a=>b)
print *,a,b
end associate
end
the values 2.0 and 1.0 should be printed, not 1.0 and 1.0.
(The ?Execution? paragraph you looked at is certainly indicative, but the scoping rules are definitive.)
Cheers,
From: Steve Lionel
Sent: Tuesday, February 21, 2017 1:19 AM
To: fortran standards email list for J3
Subject: (j3.2006) ASSOCIATE and selectors
A user presented an interesting program:
program Test
implicit none
type D
integer x
end type
type(D) array(1)
array%x = 0
associate(a => array(1), b => a%x)
b = 9
end associate
print *, array(1)%x
pause
end
Intel Fortran allows the ASSOCIATE statement, associating B with the associate name A listed earlier in the same ASSOCIATE. I think this is wrong, but wanted to check to see if my reasoning is correct.
17-007 says:
11.1.3.2 Execution of the ASSOCIATE construct
Execution of an ASSOCIATE construct causes evaluation of every expression within every selector that is a variable designator and evaluation of every other selector, followed by execution of its block. During execution of that block each associate name identifies an entity which is associated (19.5.1.6) with the corresponding selector.
Note the sequence of events here. First, all of the selectors are evaluated, and only once the block begins executing does the construct association occur. If my interpretation is correct, it is wrong to treat an associate name listed earlier in the same ASSOCIATE as a variable that can be used in a selector.
Is my reasoning valid?
Steve
________________________________________________________________________
This e-mail has been scanned for all viruses by Star.
________________________________________________________________________
--------------------------------------------------------------------------------
_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3
--
.............Malcolm Cohen, NAG Oxford/Tokyo.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20170221/bc529b49/attachment.html
More information about the J3
mailing list