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

Shape mismatch bug with vector subscript

Gibson__Angus
Beginner
544 Views

I'm trying to assign an array to an array section with a vector subscript:

program test
  integer, dimension(3) :: model, mesh
  integer, dimension(1, 3) :: permutation

  permutation(1,:) = [1, 2, 2]
  mesh(:) = model(permutation(1,:))
end program test

 

Compiling with -check, I get:

test.f90(6): error #5581: Shape mismatch: The extent of dimension 1 of array MESH is 3 and the corresponding extent of array MODEL is 1
  mesh = model(permutation(1,:))
---------^
compilation aborted for test.f90 (code 1)

 

My suspicion is that in this context, the array section I've selected from permutation is incorrectly rank 2. If, however, I force it to rank 1 with reshape(permutation(1,:), [3]), no error is raised.

 

I've tried ifort versions 19.1.0.166 and 19.0.3.199

0 Kudos
1 Reply
Steve_Lionel
Honored Contributor III
544 Views

It has nothing to do with rank. The compiler's new shape checking feature is getting confused, thinking that the extent of model(permutation(1,:)) is 1 instead of 3. Please report this bug using the Intel Online Service Center.

For now you can disable shape checking, a new feature in compiler 19.1.

0 Kudos
Reply