13-235r1
To: J3
From: Malcolm Cohen
Subject: Interp F08/0086 on implied shape
Date: 2013 February 13
1. Introduction
Below is a revised F08/0086; the main ANSWER and EDITS basically
answer the question the same way (but the mistakes have been
removed). The alternative answer provides the extension suggested
by Bob Corbett.
2. The revised interp
----------------------------------------------------------------------
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,c
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 declaration of B as an implied-shape array is erroneous.
Is this program-unit intended to be standard-conforming?
ANSWER:
A1. Yes, the program was intended to conform to the Fortran standard.
An edit is provided to modify the requirement for prior
specification so as to allow this case.
A2. Yes, the program is intended to conform to the Fortran standard.
An edit is provided to add syntax to permit this unambiguously.
EDITS to 10-007r1:
[94:10] 5.3.8.1, R515,
Change "" to "".
{This will be the unambiguous implied-shape syntax.}
[94:10+] Insert new production
"<> ".
{This will be the otherwise-ambiguous syntax.}
[95:32] 5.3.8.5p1
Replace sentence
"An assumed-size array is declared with an ."
with
"A dummy argument is declared to be an assumed-size array by an
or an ."
{Now two ways of declaring assumed size.}
[95:33] After "<>" insert ",".
{The unambiguous case starts with an .}
[95:37+] Insert new BNF rule and constraint
"R521a <> [ :
] *
C534a An object whose array bounds are specified by an
shall be a dummy data
object or a named constant."
{The otherwise-ambiguous case. Note careful wording.}
[96:24-25] 5.3.8.6p1
Replace sentence
"An implied-shape array ... ."
with
"A named constant is declared to be an implied-shape array by an
or an ."
{Now two ways of declaring implied shape.}
[96:26] R522, append ", [ [ : ] * ]...".
{This is now the unambiguously implied-shape spec.}
[107:11] 5.4.11p1 "shape" -> "rank".
{In the PARAMETER statement, only require the rank to be specified in
a prior specification statement.}
NOTES ON THE ALTERNATIVE EDITS:
(1) Since "[ : ] *" now appears 4 times, it might make
sense to define a BNF term for it, e.g. , and use
that term in those places instead.
(2) The current wording of C533 is slightly defective, as it does not
clearly prohibit "REAL,DIMENSION(*) :: dummy,nondummy", seeing as
how that does indeed declare "the array bounds of a dummy data
object". C533 should probably be reworded similarly to C534a.
SUBMITTED BY: Bill Long
HISTORY: 12-191 m199 F08/0086 submitted - revised by Malcolm Cohen -
passed by J3 meeting
13-237 m200 Failed letter ballot
13-235 m200 Revised with straw votes
----------------------------------------------------------------------