Drew McCormack writes:
> I find it all pretty confusing. If I pass a, which is a scalar, it is
> illegal because I am expected to pass an array. But if I pass a scalar
> which is an element in an array (eg a(1) ), that is OK, as long as the
> array dummy is no bigger than the scalar.
> If that interpretation is correct, I find it pretty cryptic.
I agree it is cryptic. This is not, however, new to f90.
This comes from at least f77, probably earlier. In f77, array
elements were very special things; they were *NOT* scalars, or
indeed variables at all. They were array elements, their own
special thing. In f77, there are a lot of places where you'll
find phrases like "variable or array element".
In f90, an array element is an ordinary scalar variable (well,
if the array is a variable) and mostly acts like one. What
you are seeing here is a strange special-case exception that
is there because f77 allowed it, so f90 has to also allow it
for compatibility with f77.
I recommend against using the practice in new codes. If you
use it, and find it confusing, all I'll say is that you failed
to follow my advice. Also, if you use it and then find that it
doesn't generalize "reasonably", I'll say the same thing.
(For example, you'll find that it no longer works if you try to
play such tricks with a generic). The exception is really
pretty naarrowly tailored to allow what f77 allowed, but not
more.
Of course, you'll find plenty of existing codes using the
practice, there not having been much in the way of good alternatives
in f77.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|