Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.
27551 Discussions

Shape mismatch bug with vector subscript


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 and

0 Kudos
1 Reply
Black Belt Retired Employee

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.