vector expression question.

Tobias Burnus burnus@net-b.de
Thu Nov 17 19:48:00 GMT 2011


Mike Kumbera wrote:
> I would like to start out with I'm not sure if this is a bug or not... The program bellow computes xser and x and I expected them to have the same answer. They didn't.
> The results with 4.6.1 were xser(:) = 2 and x(:)=1.

It's a bug - but not in the compiler(s) but in your program.

The code in question is:
    integer :: x
    x = 0
    x ([1,2,3,4,5,5,4,3,2,1]) = x ([1,2,3,4,5,5,4,3,2,1]) + 1

A simpler example would be:
   x ( [1, 1] ) = [ 1, 2 ]
Should this assign "1" or "2" to X(1)? Well, the standard takes a simple 
way out be declaring:

"If a vector subscript has two or more elements with the same value, an 
array section with that vector subscript shall not appear in a variable 
definition context (16.6.7)." [Fortran 2008, 6.5.3.3.2 Vector subscript]

Tobias



More information about the Fortran mailing list