Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

CSHIFT problem in sub-arrays

electricb
Beginner
2,112 Views
Hello, I am having trouble using CSHIFT with a sub-array. Maybe an example would explain this better:
*** START PROGRAM ****
INTEGER,ALLOCATABLE,DIMENSION(:)::indice
INTEGER::i

ALLOCATE(indice(0:10))

DO i=0,10
indice(i) = i
END DO

WRITE(*,*) indice
indice(3:10) = CSHIFT(indice(3:10), 1)
WRITE(*,*) indice
DEALLOCATE(indice)
**** END PROGRAM ****
I want to cshift the end of the vector so that 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 becames 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 3. But I am getting the following output:
**** BEGIN OUTPUT ****
0 1 2 3 4 5 6 7 8 9 10
0 1 2 9 9 9 9 9 9 9 9
*** END OUTPUT ***
I am using Intel Fortran Compiler for Linux (i32) 9.0
0 Kudos
2 Replies
Micah_Elliott
Beginner
2,112 Views
Looks like a bug in early 9.0 compilers. I can see that it works properly on ifort-9.0.024 and newer compilers, including any 9.1.
0 Kudos
electricb
Beginner
2,112 Views
madmdelliot, thanks for the tip. I updated to the latest 9.1 compiler and the problem is gone. Now that was a strange one.

0 Kudos
Reply