Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

warning #5581: Shape mismatch

David_Billinghurst
New Contributor II
502 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 II
395 Views

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

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

4 Replies
David_Billinghurst
New Contributor II
467 Views

Support request number is 05190993

David_Billinghurst
New Contributor II
396 Views

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

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. "

 

David_Billinghurst
New Contributor II
316 Views

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

David_Billinghurst
New Contributor II
73 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

 

Reply