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

warning #5581: Shape mismatch

David_Billinghurst
New Contributor III
1,912 Views

I am getting a warning #5581: Shape mismatch with the code below.  I think it is a false positive but I have been wrong before.

OS: Windows 10
Visual Studio: 2019 Professional 16.4.20
Compiler: IFORT 2021.3.0.306

The reduced test case is

program shape_warning
  implicit none
  integer, parameter :: L = 8, M = 12, N = 6
  real r
  real, dimension(2,M,L,L,N) ::  a=1.0
  r = calc()
  write(*,*) r
contains
  real function calc result (maxs)
    implicit none
    real :: s(L,L)
    s = sum(a(1,:,:,:,1),dim=1)
    maxs = maxval(s)
  end
end program shape_warning

 

With the compiler options

/nologo /debug:full /Od /warn:all /module:"x64\Debug\\" /object:"x64\Debug\\" /Fd"x64\Debug\vc160.pdb" /traceback /check:all /libs:dll /threads /dbglibs /c

I get the warning

Compiling with Intel® Fortran Compiler Classic 2021.3.0 [Intel(R) 64]...
shape_warning.f90
C:\Users\david\source\repos\shape_warning\shape_warning\shape_warning.f90(12): warning #5581: Shape mismatch: The extent of dimension 1 of array S is 8 and the corresponding extent of array A is 12

The code runs correctly, returning r=12.0.   If I examine s in the debugger it is an 8x8 array with all values 12.0, as expected.  More complicated test cases also behave as expected.

The warning is triggered by the /check:shape compiler option.  I am hoping it is just a false warning (or an error on my part) and not a code generation issue.

0 Kudos
1 Solution
David_Billinghurst
New Contributor III
1,805 Views

See https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-check-shape-ifort-2021-2-0/m-p/1290092

Response there is "The fix is in review. The fix missed the code cutoff for 2021.4.0, but look for it in 2022.1 later this year. "

 

View solution in original post

0 Kudos
6 Replies
David_Billinghurst
New Contributor III
1,877 Views

Support request number is 05190993

0 Kudos
David_Billinghurst
New Contributor III
1,806 Views

See https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-check-shape-ifort-2021-2-0/m-p/1290092

Response there is "The fix is in review. The fix missed the code cutoff for 2021.4.0, but look for it in 2022.1 later this year. "

 

0 Kudos
David_Billinghurst
New Contributor III
1,726 Views

Intel support confirmed this is only a diagnostic issue.  The generated code is correct. 

0 Kudos
David_Billinghurst
New Contributor III
1,483 Views

I can confirm that the problem above is fixed in ifort version 2021.6.0, which is part of the oneAPI HPC Toolkit 2022.2. 

However the following slightly modified example, with a mask for the sum, still generates a warning.

program main
  implicit none
  integer, parameter :: L = 8, M = 12, N = 6
  real r
  real, dimension(2,M,L,L,N) ::  a=1.0
  logical, dimension(M,L,L) :: mask = .true. ! mask
  r = calc()
  write(*,*) r
contains
  real function calc result (maxs)
    implicit none
    real :: s(L,L)
    s = sum(a(1,:,:,:,1),mask=mask,dim=1) !
    maxs = maxval(s)
  end
end

 

Compiling with Intel® Fortran Compiler Classic 2021.6.0 [Intel(R) 64]...
calc.f90
C:\Users\david\source\repos\shape_mismatch2\shape_mismatch\calc.f90(13): warning #5581: Shape mismatch: The extent of dimension 2 of array A is 12 and the corresponding extent of array MASK is 8

 

0 Kudos
David_Billinghurst
New Contributor III
1,374 Views

I can confirm this is fixed in oneAPI 2022.3 / ifort 2021.7.0

0 Kudos
JohnNichols
Valued Contributor III
1,359 Views

Half the fun in life is waking up in the morning, and then reading this forum.  There are always neat little problems. 

Occasionally, I read the Fortran discourse chat, although that tends to give me the shudders, they lack the humour of this august group.  Although, the FD's recent discussion on the new Intel OneAPI compiler was worth noting for the comment to read the Intel Forum.  Brings to mind Jim's comment of RTFM. 

I enjoyed your one sided conversation, I mean if you sit in a bar and talk to yourself, in the 13th century, you could expect to see a burning at the stake, (note to self, one of my relatives appears to have been famously burnt at the stake in the 15th century in Wales.), in the 20th century the men in the white coats would arrive, aka one flew over the cuckoos nest, (note to self, I lived in a Missouri Mental Institution grounds in the 1970's - as mum said, you should always see a TRACHEOTOMY performed with a butter knife,  (no sharp knives) on a guy who was choking on a bone, my father performed the operation.)  Now people know you are on your phone and you are safe, well except for the guy who tries to sell your car bumper bar insurance.  

Stay well.  PS The bra kets as Pure math professors called them in the 70's are my humble dig at LISP.  

Intel should develop a LISP or Scheme compiler.

 

0 Kudos
Reply