Aleksandar Donev writes:
> INTERFACE
> SUBROUTINE Test(x,y)
> REAL, DIMENSION(:) :: x
> REAL, DIMENSION(SIZE(x)) :: y
> END SUBROUTINE Test
> END INTERFACE
>
> Is the Fortran 95 compiler obliged to check whether x and y have actual
> matching sizes during compile time?
No. In fact, they don't have to have the same sizes. The size of y
has to be at least as big as that of x, but it doesn't have to be
equal. (It is legal to pass an actual argument that is larger than
the dummy when the dummy has an explicitly declared shape).
> Say I call:
> CALL Test(x(1:5),y(1:1))
> Should this be a compile error?
Well, it would be most unusual for it to be caught at compile time as
a compilation error. Possible, but unusual, and certainly not
required. In general, shapes need not be known until run-time. You
might have a run-time error if your compiler supports detection of
such things, but I'd be surprised at a compilation error.
In general *NO* detection of run-time errors is required by the
standard. Many compilers provide options for various run-time
checks, but such are not required by the standard.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|