pr28923

Dominique Dhumieres dominiq@lps.ens.fr
Fri Sep 1 09:11:00 GMT 2006


I just filles pr28923:

The following program:

real, dimension(3,3), parameter :: a=reshape ((/(i, i = 1,9)/),(/3,3/))
real, dimension(2,3) :: b=a(:2:-1,:)
real, dimension(2,3) :: c=a(3:2:-1,:)
print *, b
print *, c
end

compiles with gfortran and gives:

   3.000000       2.000000       6.000000       5.000000       9.000000      
8.000000    
   3.000000       2.000000       6.000000       5.000000       9.000000      
8.000000    

i.e., b=a(:2:-1,:) is interpreted as c=a(3:2:-1,:) instead of giving:

real, dimension(2,3) :: b=a(:2:-1,:)
                          1
Error: Array assignment at (1) has different sizes (6/0)

as required by the following first and last paragraphs (draft f2003):

> 6.2.2.3.1 Subscript triplet
> > A subscript triplet designates a regular sequence of subscripts
> consisting of zero or more subscript values.  The third expression in the
> subscript triplet is the increment between the subscript values and is
> called the stride.  The subscripts and stride of a subscript triplet are
> optional.  An omitted first subscript in a subscript triplet is
> equivalent to a subscript whose value is the lower bound for the array
> and an omitted second subscript is equivalent to the upper bound.  An
> omitted stride is equivalent to a stride of 1.
> > The stride shall not be zero.
> > When the stride is positive, the subscripts specified by a triplet form a
> regularly spaced sequence of integers beginning with the first subscript
> and proceeding in increments of the stride to the largest such integer
> not greater than the second subscript; the sequence is empty if the first
> subscript is greater than the second.  
> > ...
> > When the stride is negative, the sequence begins with the first subscript
> and proceeds in increments of the stride down to the smallest such
> integer equal to or greater than the second subscript; the sequence is
> empty if the second subscript is greater than the first.

Note that:

real, dimension(3,3) :: a
real, dimension(2,3) :: b
a=1
b=a(:2:-1,:)
print *, b
end

gives correctly:

b=a(:2:-1,:)
1
Error: different shape for Array assignment at (1) on dimension 1 (2/0)

Dominique



More information about the Fortran mailing list