Print

Print


> Date:          Thu, 29 Jul 2004 13:20:49 +0100
> From:          Colin Millar <[log in to unmask]>

> Hi,
>
> When an array is passed to a subroutine or function as an assumed shape
> array, do the references for each dimension of the dummy array begin at 1.

Yes.  It can be inconvenient though.
The default can always be overridden by using an explicit lower bound
in the subroutine, or by passing the actual lower bound as an argument --

real, dimension(0:,:), intent( inout ) :: 2D_array
or:
subroutine A (2D_array, lb)
   integer, ... :: lb
   real, dimension(lb:,:), intent( inout ) :: 2D_array

> Is this a portable assumption??
>
> i.e.  in the program below, if main_array was passed to subroutine A in the
> main code, would the shape of the assumed size array in subroutine A be
> dimension(1:10,1:6) ???
>
> thanks in advance,
> Colin.
>
> program main
> implicit none
> real, dimension(-1:8, 0:5) :: main_array
> ....
> call A(main_array)
> ....
> contains
>
> subroutine A (2D_array)
> real, dimension(:,:), intent( inout ) :: 2D_array
> ....
> !  transformations carried out on 2D_array
> ....
> end subroutine A
> ....
> ....
> end program
>