Re: Does the order of declarations matter?
- From: "James Van Buskirk" <not_valid@xxxxxxxxxxx>
- Date: Wed, 25 Jan 2006 12:12:18 -0700
<ejko123@xxxxxxxxx> wrote in message
news:1138214075.359667.137670@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> More precisely, is the following code fragment standard-conforming:
> subroutine sub(dum,n)
> real,intent(inout):: dum(n)
> integer,intent(in):: n
> ! rest of sub
> end subroutine
> Or must the declaration for N appear before the declaration
> of DUM?
Obviously a trick question! Looking at ISO/IEC 1539-1:1997(E),
section 7.1.6.2:
"A variable in a specification expression shall have its type
and type parameters, if any, specified by a previous declaration
in the same scoping unit, or by the implicit typing rules in
effect for the scoping unit, or by host or use association. If
a variable in a specification expression is typed by the
implicit typing rules, its appearance in any subsequent type
declaration statement shall confirm the implied type and type
parameters."
Thus the place to look to decide standard conformance is the
host procedure or module that sets the default typing rules for
subroutine sub. If implicit none is in force there, or n
has implicit type that is not integer or kind type paraemter
that is not that of a default integer, the code is not
standard conforming. If there is no host, or the host implicitly
types n as a default integer, the code is OK.
> Related question: Is there a difference between
> subroutine sub2(iarray,n)
> integer,intent(in):: iarray(n),n
> and
> integer,intent(in):: n,iarray(n)
Section 7.1.6.2 goes on to say:
"If a specification expression includes a reference to an
inquiry function for a type parameter or an array bound of
an entity specified in the same specification-part, the type
parameter or array bound shall be specified in a prior
specification of the specification-part. The prior
specification may be to the left of the inquiry function in
the same statement. If a specification expression includes a
reference to the value of an element of an array specified in
the same specification-part, the array shall be completely
specified in prior declarations."
I think this means that the first declaration above is only
OK if n is implicitly default integer, but the second is
always OK because n is not an array. Umm... the last
paragraph above is changed by Corrigendum 2:
"If a specification expression includes a reference to an
inquiry function that depends on a type parameter or an array
bound of an entity specified in the same specification-part,
the type parameter or array bound shall be specified in a prior
specification of the specification-part. The prior
specification may be to the left of the inquiry function in
the same statement, but shall not be within the same entity-
decl. If a specification expression includes a reference to
the value of an element of an array specified in the same
specification-part, the array shall be completely specified in
prior declarations."
Doesn't seem to change my interpretation, though.
--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end
.
- References:
- Does the order of declarations matter?
- From: ejko123
- Does the order of declarations matter?
- Prev by Date: Does the order of declarations matter?
- Next by Date: Re: formatted output
- Previous by thread: Does the order of declarations matter?
- Next by thread: Re: Does the order of declarations matter?
- Index(es):
Relevant Pages
|