J3/05-236r2 Date: 11 August 2005 To: J3 From: Rob James 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. On entry to a procedure, a dummy argument with the INTENT(SCRATCH) attribute (as well as the argument associated entity) will be finalized and default initialized in the same way as INTENT(OUT) arguments. On exit from such a procedure, the same operations will be performed. This is feature J3-044. Specification and Syntax: ------------------------- A new INTENT(SCRATCH) attribute is proposed. The entity associated with a dummy argument with the INTENT(SCRATCH) attribute shall be definable. The dummy argument is undefined upon entry to the procedure and the entity associated with the dummy argument becomes undefined upon exit from the procedure. 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. ..................................................................... In the Introduction section (page xiii), 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). ..................................................................... 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) ..................................................................... 74:8. In item (4) of the list in constraint C538, change "INTENT(OUT) or" to INTENT(OUT), INTENT(SCRATCH), or .................................................................... 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 and Note: 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. On exit from the procedure, the entity associated with the dummy argument becomes undefined. ................................................................... 82:Note 5.14. 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. 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. ..................................................................... 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) ..................................................................... 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. Change "INTENT(OUT) or" to INTENT(OUT), INTENT(SCRATCH), or ..................................................................... 286:43. Change "INTENT(OUT) or" to INTENT(OUT), INTENT(SCRATCH), or ..................................................................... 287:Note 12.45. 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), ..................................................................... 414:27. Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" 415:20. Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" 415:22. Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" 420:24. Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" 420:27. Change "INTENT(OUT)" to "INTENT(OUT) or INTENT(SCRATCH)" 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)" ..................................................................... 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. ..................................................................... 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 .....................................................................