12-191 To: J3 From: Malcolm Cohen/Bill Long Subject: Implied-shape and separate PARAMETER statement Date: 2012/10/16 ---------------------------------------------------------------------- NUMBER: F08/0086 TITLE: Implied-shape and separate PARAMETER statement KEYWORDS: Implied-shape, PARAMETER DEFECT TYPE: Clarification or Erratum STATUS: J3 consideration in progress QUESTION: Q1. Consider Program test1 Character(*) a,b(*) Dimension c(*) Parameter (a='123', b=['1','2','3']) Character(*),Parameter :: c = [ '44','55','66' ] Print *,a,b,c End The definition of the assumed-length character named constant A conforms to Fortran 77 to Fortran 2008. However, the definition of the implied-shape named constant B appears not to conform to Fortran 2008, as the standard says in 5.4.11p2 "A named array constant defined by a PARAMETER statement shall have its shape specified in a prior specification statement." On the other hand, the named constant C does not have such a requirement, so its definition would appear to be conforming. This apparent requirement on the named constant B would thus appear to be inconsistent with those on the named constant C, as well as inconsistent with the way that assumed length works, and with the general principle of allowing attributes to be specified either in a single type declaration statement or with separate specification statements. Is the program intended to conform to the Fortran standard? Q2. Consider Subroutine test2(a) Real,Dimension(*) :: a,b,c Integer,Parameter :: b = 123 Parameter (c = 45.6) a(b) = c End Subroutine The in the type declaration statement is ambiguous; if it is an then the declaration of A as an assumed-size array is erroneous, but if it is an then the declarations of B and C as implied-shape arrays is erroneous. Is this program-unit intended to be standard-conforming? ANSWER: A1. No, the program is not intended to conform to the Fortran standard. A clarifying edit is supplied to make it clear that an implied-shape array specification is only permitted for a named constant whose value is given in the same statement. This makes it clear that the declarations of both B and C are non-conforming. A2. No, the program is not intended to conform to the Fortran standard. This is clarified by the same edit that clarifies the answer to question 1. ALTERNATIVE ANSWER: A1. Yes, the program is intended to conform to the Fortran standard. An edit is supplied to remove the inadvertant requirement in 5.4.11. A2. Yes, this was intended to conform to the Fortran standard. Edits are left as an exercise for the reader. EDIT to 10-007r1: [97:27+] In 5.3.8.6, insert new constraint "C535a An shall appear only in a type declaration statement in which the PARAMETER keyword appears." ALTERNATIVE EDIT to 10-007r1: [107:11] In 5.4.11p2, change "shape" to "rank". SUBMITTED BY: Bill Long HISTORY: 12-191 m199 Submitted as revised by Malcolm Cohen. ----------------------------------------------------------------------