On May 3, 2004, at 10:01 PM, Aleksandar Donev wrote:
> Hello,
>
> This is a FAQ. Note that there is a major Fortran committee meeting
> now,
> and thus the lack of replies (from Richard :-).
>
>> If so, why isn't my compiler flagging this as an error?
> The compiler is not required to flag this--it is not a constraint but
> rather a requirement on your program. A scalar actual can only be
> associated with a scalar dummy---this is an explicit rule in the
> standard. So NAG will tell you:
>
> Error: explicit.f90, line 12: Scalar supplied for array argument ARRAY
> (no. 1) of SUB
>
> Note that there is a specific exception for this in F2003 for character
> strings---this makes it easier to mix strings with character arrays and
> has been long on my list of wishes. But it is not in F95.
>
> For explicit-shape arrays, the standard only requires that an actual
> array argument is at least as big as the dummy array. There is no
> requirement in terms of ranks. So if you had a(1) as the actual, NAG
> would tell you:
>
> Error: explicit.f90, line 12: Array supplied for dummy ARRAY (no. 1) of
> SUB too small
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.
Thanks for the explanation anyway.
Drew
>
> Only for assumed-shape arrays is there a requirement for rank-matching.
> For those who want to read the rules, download the F2003 draft standard
> (still free!) and look at section 12.4.1.2.
>
> Best,
> Aleksandar
>
|