Re: type/rank mismatch error
- From: "Jugoslav Dujic" <jdujic@xxxxxxxxx>
- Date: Fri, 29 Jun 2007 11:59:53 +0200
Richard Maine wrote:
| Jugoslav Dujic <jdujic@xxxxxxxxx> wrote:
|
|| estevino@xxxxxxxxx wrote:
| ...[module calulate, which defines some_op]
||| MODULE various
||| USE calculate
||| CONTAINS
||| SUBROUTINE number1(x,y,some_op)
||| ...
||| END SUBROUTINE number1
||| SUBROUTINE number2(x,y,some_op)
||| ...
||| END SUBROUTINE number2
||| END MODULE various
|
|| I must say I'm confused as to the intent of the code. The code, as shown,
|| violates the simple rule that
||
|| *Any formal (dummy) argument of a routine must be declared locally
|| in the routine, not elsewhere*
|
| Um. I'm confused by that "rule". I think I know what you mean, but the
| expression of it confuses me. You can, of course, define things of that
| same name elsewhere all you want.That just doesn't constitute defining
| the dummy argument.
|
|| in other words, if you defined some_op in the module "calculate", you
|| must not redefine some_op elsewhere (at least, not in a scope which
|| USEs the module "calculate")
|
| True, but the code shown doesn't do that. It defines some_op in module
| procedures that are *NOT* in the same scope as the USE statement. It
| makes a huge difference. See host association. The use of those names as
| dummy arguments blocks the host association of the name imported by the
| USE.
I overlooked the fact that, in case of host association, the local
declaration overrides the host-associated declaration. Thus, one
may have two different entities of the same name "accessible" (for
want of a better word) in the same scope, but only the one from the
inner scope will be visible and usable.
The OP didn't show us enough code to confirm the meaning of some_op
as the dummy argument of number1. From the naming and explanation,
I judged that the intent was "use declaration as from module calculate"
rather than "use the local declaration, overriding the one from
host-association".
Still, I don't see what's wrong with the rule as written: the *entity*
referred to by formal argument must be declared in the routine itself
(let's put the issue of implicit typing aside); it is local to the
routine ab definitio. Other same-named entities may or may not exist
in the host scope, but they won't be accessible anyway.
In any case, avoiding re-using the same name for different entities
in inner and outer scope is a good rule of thumb (I overlooked the
overriding thingo as I use that rule of thumb myself, so tend to
forget that it's allowable).
[Please, pardon my loose usage of standardese above; while I'm familiar
with it, I'm not always able to find the exact precise wording on my own.
I hope that the message does get through though.]
--
Jugoslav
___________
www.xeffort.com
Please reply to the newsgroup.
You can find my real e-mail on my home page above.
.
- Follow-Ups:
- Re: type/rank mismatch error
- From: estevino
- Re: type/rank mismatch error
- References:
- type/rank mismatch error
- From: estevino
- Re: type/rank mismatch error
- From: Jugoslav Dujic
- Re: type/rank mismatch error
- From: Richard Maine
- type/rank mismatch error
- Prev by Date: Re: Need Help: compiling old Fortran program
- Next by Date: Re: Need Help: compiling old Fortran program
- Previous by thread: Re: type/rank mismatch error
- Next by thread: Re: type/rank mismatch error
- Index(es):
Relevant Pages
|