Print

Print


On May 3, 2004, at 7:21 PM, Ted Stern wrote:

> On 3 May 2004 at 09:35 PDT, Drew McCormack wrote:
>>
>> Is the following legal fortran 90?
>>
>>
>> module A
>> contains
>> subroutine sub( array )
>>    real :: array(10)
>> end subroutine
>> end module
>>
>>
>> program main
>> use A
>> real :: a, b(10), c(10,10)
>> call sub(a)
>> call sub(b)
>> call sub(c)
>> end program
>>
>
> No.  Sorry I can't cite chapter and verse for you.
>
> There are ways to get around this for specific compilers (e.g. Cray
> pointers)
> but they should be used with *extreme* caution.  In your example, you
> could
> easily step out of bounds with the "call sub(a)" call.
I can see that if I set a(10) in sub, that I will have an out of bounds
problem, but if I tried to set array(1), would the compiler be entitled
to cause problems (according to the standard)? Is the compiler obligued
to make array(1) correspond to a in main, or is it just an error to
pass a scalar for an array with an explicit interface?
(If so, why isn't my compiler flagging this as an error?  I know... I
should buy the cray compiler ;-)   )

Drew

>
> Ted
> --
>  Ted Stern                                 Applications Group
>  Cray Inc.                               office: 206-701-2182
>  411 First Avenue South, Suite 600         cell: 206-383-1049
>  Seattle, WA 98104-2860                     FAX: 206-701-2500
>
>  Frango ut patefaciam -- I break that I may reveal
>  (The Paleontological Society motto, equally apropos for debugging)
>