(j3.2006) Should Local Variables of Impure Elemental Procedures Have the SAVE Attribute?
Craig Dedo
craig
Wed Oct 5 16:46:07 EDT 2011
Everyone:
It appears that there is another oversight in the definition of IMPURE
ELEMENTAL procedures. Should impure elemental procedures be allowed to have local
variables with the SAVE attribute? If so, what should happen if such procedures are
called with array-valued arguments?
In thinking this over, it appears that this is another situation where a
constraint of PURE procedures should also apply to impure elemental procedures. Are there
any possible advantages to allowing impure elemental procedures to have local variables
with the SAVE attribute? If they are allowed, what complications could result from such
procedures being called with array-valued arguments?
This afternoon I wrote up a proposed interpretation. What do others think of
this approach? If there are flaws in my approach, what alternatives would you prefer and
why?
[Begin proposed interpretation request]
NUMBER: F08/????
TITLE: Local Variables of Impure Elemental Procedures
KEYWORDS: IMPURE, ELEMENTAL, SAVE
DEFECT TYPE: Erratum ???
STATUS: Submitted with proposed answer
QUESTIONS:
Consider the following impure elemental subroutine:
Impure Elemental Subroutine Swap_DP ( R1, R2 )
Use, Intrinsic :: ISO_Fortran_Env
Implicit None ! Force explicit declaration of all data objects.
! Declare subroutine arguments.
Real (Kind=Real64), Intent (InOut) :: R1, R2
! Declare local variables.
Real (Kind=Real64), Save :: Temp
! Execution starts here.
Temp = R1
R1 = R2
R2 = Temp
End Subroutine Swap_DP
Q1. Was it intended to be standard-conforming to allow impure elemental
procedures to have local variables with the SAVE attribute?
Q2. If it is standard-conforming, what should happen if an impure elemental
procedure is called with array-valued arguments with the same shape and the
impure elemental procedure has local variables with the SAVE attribute?
ANSWERS:
A1.
This was not intended to be standard-conforming. Omission of the
requirement for non-saved local variables in impure elemental procedures
was inadvertent. An edit is supplied to correct this oversight.
A2.
There could be serious complications if the SAVE attribute is allowed for
local variables of impure elemental procedures. Therefore, local variables
in such procedures should not have the SAVE attribute.
EDITS to 11-007r1:
[314:7] Insert new constraint at the end of 12.8.1
"C1290b A local variable of an elemental subprogram, or of a BLOCK construct
within an elemental subprogram, shall not have the SAVE attribute."
SUBMITTED BY:
Craig T. Dedo
17130 Burleigh Place
PO Box 423
Brookfield, WI 53008-0423
USA
HISTORY: 11-??? m196 F08/???? submitted with proposed answer
[End of proposed interpretation request]
Sincerely,
Craig T. Dedo
17130 W. Burleigh Place
P. O. Box 423 Mobile Phone: (414) 412-5869
Brookfield, WI 53008-0423 E-mail: < <mailto:craig at ctdedo.com> craig at ctdedo.com>
USA
Linked-In: <http://www.linkedin.com/in/craigdedo> http://www.linkedin.com/in/craigdedo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://j3-fortran.org/pipermail/j3/attachments/20111005/4de2cc8f/attachment-0001.html>
More information about the J3
mailing list