On Mon, 3 May 2004, Drew McCormack wrote:
> > For example, here's what Intel Fortran says (once the error of the
> > module and variable having the same name is fixed):
> >
> > t.f90(12) : Error: If the actual argument is scalar, the corresponding
> > dummy
> > argument shall be scalar unless the actual argument is an element of an
> > array that
> > is not an assumed-shape or pointer array, or a substring of such an
> > element.
> > [ARRAY]
> > call sub(a)
>
> Hmm. Does that mean that this call would be legal?
>
> real :: arg(5)
> call sub( arg(2) )
>
> If that is legal and 'call sub(a)' is not, then I think Fortran 90 is a
> pretty subtle language.
'call sub(a)' passes a scalar to an array dummy argument which is
obviously wrong. the above 'call sub( arg(2) )' is legal to accomodate f77
style programming which didn't have array sections. passing arg(2) passes
a reference to the 2nd element of array arg .
in the subroutine sub: array(1) corresponds to arg(2), array(2) to arg(3)
and so on... (obviously in your example there is an out-of-bound array
access). compilers are not really required to check if the dummy and
actual argument sizes match when you use assumed size dummy arguments.
renchi
|