J3/05-276 Date: 24 October 2005 To: J3 From: Bill Long Subject: Specification, syntax, and edits for intent(scratch) attribute References: Feature j3-044, 05-147r2 ----------------------------------------------------------------------- Summary: -------- Add a new intent for dummy arguments: INTENT(SCRATCH) specifies that the dummy argument is undefined on entry and return. The argument may be used for scratch work space only. Compilers may be able to optimize this argument aggressively. This is feature J3-044. Specification and Syntax: ------------------------- A new INTENT(SCRATCH) attribute is added. A dummy argument with the INTENT(SCRATCH) attribute shall not have the ALLOCATABLE or POINTER attributes. The entity associated with a dummy argument with the INTENT(SCRATCH) attribute shall be definable. If it is finalizable it shall be finalized on entry to the procedure. The dummy argument is undefined upon entry to the procedure, except for any default-initialized subcomponents. The entity associated with the dummy argument is finalized if it is finalizable and becomes undefined upon exit from the procedure, except for any default-initialized subcomponents. Allocated allocatable subcompoments of the dummy argument are deallocated on exit. Edits: ------ Note: < and > are used to delimit italic font. << and >> are used to delimit bold font. All page and line numbers refer to j3/04-007. ..................................................................... [xiii] Introduction, the list of new Fortran 2008 features should include Performance enhancements: INTENT(SCRATCH) attribute. ..................................................................... In section 1.6 Compatibility, there are no changes needed. ..................................................................... [58:14] Replace the last sentence of constraint C473 with The dummy argument shall not be INTENT(OUT) or INTENT(SCRATCH). ..................................................................... [59:21] In the 2nd paragraph of of section 4.5.5.2 When finalization occurs, replace the beginning of the sentence "A nonpointer, nonallocatable object" with An actual argument associated with a dummy argument with the INTENT(SCRATCH) attribute, or a nonpointer, nonallocatable object ..................................................................... [59:32] In the 6th paragraph of section 4.5.5.2 When finialization occurs, replace "INTENT(OUT)" with INTENT(OUT) or INTENT(SCRATCH) ..................................................................... [72:35+] Add a new constraint: C515a (R501) If the INTENT(SCRATCH) attribute is specified, the ALLOCATABLE or POINTER attributes shall not be specified. ..................................................................... [73:20] In constraint C527, replace "or INTENT(OUT)" with: INTENT(OUT), or INTENT(SCRATCH) .................................................................... [80:9] In constraint C544, change "INTENT(OUT)" to INTENT(OUT) or INTENT(SCRATCH) ..................................................................... [81:5+] Add to the end of R517 for : or SCRATCH ..................................................................... [81:13] In item (4) of the list in constraint C546, change "INTENT(OUT) or" to INTENT(OUT), INTENT(SCRATCH), or ..................................................................... [81:33+] Add a new paragraph to section 5.1.2.7: The INTENT(SCRATCH) attribute for a dummy argument specifies that it is intended neither to receive data from nor to return data to the invoking scoping unit. A dummy argument with the INTENT(SCRATCH) attribute shall be defined before a reference to the dummy argument is made within the procedure and any entity that becomes argument associated with such a dummy argument shall be definable. On invocation of the procedure, such a dummy argument becomes undefined except for components of an object of derived type for which default initialization has been specified. On exit from the procedure, the entity associated with the dummy argument becomes undefined, except for components of an object of a derived type for which default initialization has been specified. ................................................................... [82:1-] In the first paragraph of Note 5.14, replace the three instances of "INTENT(OUT)" with INTENT(OUT) or INTENT(SCRATCH) INTENT(OUT), INTENT(SCRATCH), INTENT(OUT) or INTENT(SCRATCH) After the second paragraph of Note 5.14, add a new paragraph: The INTENT(SCRATCH) attribute enables potential code optimizations for a dummy argument that is used only for local scratch space in a procedure. Such dummy arguments are common in legacy codes. The final value of such a dummy argument does not need to be stored. Indeed, the processor may be able to represent the dummy argument in processor registers and never load from, or store to, the memory of the entity associated with the dummy argument. ..................................................................... [116:11] In the 3rd paragraph following Note 6.24, replace the second instance of "INTENT(OUT)" with INTENT(OUT) or INTENT(SCRATCH) ..................................................................... [125:15] In item (2) of the list for restricted expressions, replace "OPTIONAL nor the INTENT(OUT)" with OPTIONAL, INTENT(OUT), nor the INTENT(SCRATCH) ..................................................................... [264:27+] In the section 12.3.2.3 description of the Procedure declaration statement, add this constraint: C1214a (R1213) If INTENT is specified, shall not be SCRATCH. ..................................................................... In section 12.4.1.2 Actual arguments associated with dummy data entities, make these changes: [270:38] Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" [270:39] Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" [271:4] Change "INTENT(OUT)" to "INTENT(OUT), INTENT(SCRATCH)" ..................................................................... [276:18] In section 12.4.3 Subroutine reference, Change "INTENT(OUT) or" to INTENT(OUT), INTENT(SCRATCH), or ..................................................................... [286:34] In section 12.6 Pure procedures, Change "INTENT(OUT) or" to INTENT(OUT), INTENT(SCRATCH), or ..................................................................... [287:8-] In the last line of Note 12.45, change "INTENT(INOUT)" to INTENT(INOUT), INTENT(SCRATCH) ..................................................................... [289:4-6] In section 12.7.3 change two instances of "INTENT(OUT)" to INTENT(OUT), INTENT(SCRATCH), ..................................................................... In section 16.4.2.1.2 Events that cause pointers to become disassociated, make these changes: [414:27] Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" [414:29] Remove "or" [414:30] Change "." to ",or" [414:30+] Add: (d) a RETURN of END statement is executed in a procedure with this object as an actual argument corresponding to a nonpointer nonallocatable dummy argument with INTENT(SCRATCH). ..................................................................... In section 16.4.2.1.3 Events that cause the association status of pointers to become undefined, modify the end of item (6): [415:20] Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" ..................................................................... In section 16.5.5 Events that casue variables to become defined, change items (6) and (23) as follows: [420:24] Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" [420:27] Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" [421:35] Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" ..................................................................... [422:17+] In item (3) of the list in subsection 16.5.6, Events that cause variables to become undefined, at the end of subitem (c), remove the final "and"; at the end of subitem (d), replace the final "." with ", and"; and add a new subitem: (e) an actual argument associated with a dummy argument with the INTENT(SCRATCH) attribute becomes undefined, except for any nonpointer default-initialized subcomponents. ..................................................................... In section 16.5.6 Events that cause variables to become undefined, change items 13(b), 13(c), and 13(d) as follows: [423:7] Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" [423:9] Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" [423:12] Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" ..................................................................... [424:2] In item 11 of subsection 16.5.7 of Variable definition context, change the end of the second line from "INTENT(OUT) or INTENT(INOUT) attribute, or" to: INTENT(OUT), INTENT(INOUT), or INTENT(SCRATCH) attribute, or ..................................................................... [431:2] In the Annex A entry for <>, change the end of the sentence from "or both" to both, or neither .....................................................................