[J3] Question involving explicit initialization

Vipul Parekh parekhvs at gmail.com
Sat May 4 19:11:29 EDT 2019


On Sat, May 4, 2019 at 3:17 PM Robert Corbett via J3
<j3 at mailman.j3-fortran.org> wrote:
>
> Bill has it right.  Subroutines are scoping units.  The name "i" identifies  one variable in one subroutine, and a different variable in the other subroutine.
>
> If the variable "i" was declared in the scope of the module and the name "i" was not redeclared in the subroutines, the name "i" would still refer to different entities in the subroutines, but they would both be host associated with the variable "i" in the scope of the module.
> ..

Thank you all for your feedback.

My question was based on my confusion "once in a program" and if there
was any connection here with variables that have the SAVE attribute
such as 'i'.  I thought SAVE might carry the implication of a "global
entity" due to a 'static variable' status, at least with some
implementations, and I was wondering whether that had any bearing.

So now, is the sentence in the standard document sufficiently precise:
"A variable, or part of a variable, shall not be explicitly
initialized more than once in a program"?  Or would a phrase "more
than once in a *scoping unit*" more clearly capture the responsibility
of the coder at to where a variable "shall not be explicitly
initialized more than once"

Regards,
Vipul Parekh


More information about the J3 mailing list