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

issue with unreported array shape mismatch

Andreas_Z_
New Contributor I
1,199 Views

Hi, I've noticed that an array bounds/shape mismatch is currently not reported (ifort version 2021.6.0) when the array bounds are not listed in an expression. The following simple example illustrates the problem (case 4). Also, commented out are cases (1)--(3) that do get reported as expected:

 

program TestArrayShapeMismatch

implicit none
integer,parameter   :: n = 4
integer             :: i, m
real                :: p
real,dimension(n)   :: ra, rb 
real,dimension(n-1) :: rc
real,dimension(:),allocatable :: qqc

m = n-1
allocate(qqc(n-1))
ra = [(i*1.0, i = 1,n)]
rc = [(  1.0, i = 1,m)]
qqc = rc
p = 2.0

!rb = ra * p * rc               !(1) useful: compiler reports "error #6366: The shapes of the array expressions do not conform."
!rb = ra(1:n) * p * qqc(1:m)    !(2) useful: error/warning issued during compilation nor at run time
!rb = ra(:) * p * qqc(:)        !(3) useful: error reported during run time: "forrtl: severe (408): fort: (10): Subscript #1 of the array QQC has value 4 which is greater than the upper bound of 3"
rb = ra * p * qqc               !(4) problem; no error/warning about array bounds/shape mismatch reported during compilation or run time

write(*,*) "rb =", rb

end program TestArrayShapeMismatch 
    
!command lines (on windows):
!ifort /o a.exe /Od /warn:all /check:all .\TestArrayShapeMismatch.f90
!gfortran -o b.exe -O0 -Wall -fcheck=all ./TestArrayShapeMismatch.f90

 

The command line I used for tests (on windows):
ifort /o a.exe /Od /warn:all /check:all .\TestArrayShapeMismatch.f90

Note that case (3), which I consider to contain the same amount of information, leads to a run-time error being reported. Also, gfortran (with -fcheck:all option) reports the issue.

11 Replies
Ron_Green
Moderator
1,141 Views

This is fixed in the latest release - oneAPI 2022.3 with compiler 2021.7.0.  At least on Linux, I haven't tried Windows.

 

 

ifort  -g -traceback -warn all -check all -o repro -what -V repro.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

 Intel(R) Fortran 2021.7.0-1776
GNU ld version 2.37-27.fc36

$ ./repro
forrtl: severe (408): fort: (2): Subscript #1 of the array QQC has value 4 which is greater than the upper bound of 3

Image              PC                Routine            Line        Source             
repro              0000000000404B11  MAIN__                     20  repro.f90
repro              000000000040419D  Unknown               Unknown  Unknown
libc.so.6          00007FCCFF278590  Unknown               Unknown  Unknown
libc.so.6          00007FCCFF278649  __libc_start_main     Unknown  Unknown
repro              00000000004040B5  Unknown               Unknown  Unknown

 

 

 

0 Kudos
Andreas_Z_
New Contributor I
977 Views

Hi Ron, 
Thanks for checking on this. I've now updated to the latest oneAPI release (for Windows) with Fortran compiler 2021.7.0, but I still get the same behaviour on Windows. Am I missing something or is it possible that the same version and build on Linux and Windows produce different behavior in such cases?

PS > ifort /o a.exe /Od /Zi /warn:all /check:all /traceback /what TestArrayShapeMismatch.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

 Intel(R) Fortran 2021.7.0-1776
Microsoft (R) Incremental Linker Version 14.29.30146.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:a.exe
-debug
-pdb:a.pdb
-subsystem:console
-incremental:no
TestArrayShapeMismatch.obj
PS > .\a.exe
 rb =   2.000000       4.000000       6.000000      0.0000000E+00

No error is issued. 

0 Kudos
Andreas_Z_
New Contributor I
977 Views

Hi Ron,

I've updated my oneAPI to the latest version, including Fortran compiler 2021.7.0 and the same build as yours (but on Windows). I still see the same behavior as reported originally. Did you run your check for case (3) instead of (4) indicated in the source code? It seems the run-time error reported in your output is form line 20.

This is what I get on Windows:

PS > ifort /o a.exe /Od /warn:all /check:all /what /Zi TestArrayShapeMismatch.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

 Intel(R) Fortran 2021.7.0-1776
Microsoft (R) Incremental Linker Version 14.29.30146.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:a.exe
-debug
-pdb:a.pdb
-subsystem:console
TestArrayShapeMismatch.obj
PS > .\a.exe
 rb =   2.000000       4.000000       6.000000      0.0000000E+00
0 Kudos
Andreas_Z_
New Contributor I
977 Views

This is what I get with the latest Fortran compiler on Windows (no run-time error for case 4 from the test program):

PS C:\Users ... > ifort /o a.exe /Od /warn:all /check:all /Zi /what .\TestArrayShapeMismatch.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation. All rights reserved.

Intel(R) Fortran 2021.7.0-1776
Microsoft (R) Incremental Linker Version 14.29.30146.0
Copyright (C) Microsoft Corporation. All rights reserved.

-out:a.exe
-debug
-pdb:a.pdb
-subsystem:console
TestArrayShapeMismatch.obj
PS C:\Users ... > .\a.exe
rb = 2.000000 4.000000 6.000000 5.5836710E-38

0 Kudos
Andreas_Z_
New Contributor I
1,112 Views

Hi, 
somehow my replies that include command terminal output are not being posted. Anyways, I've updated my oneAPI to the latest version with Intel Fortran compiler 2021.7.0 on Windows (same build number as Ron's on Linux). I still see the issue for case (4) on Windows. 

Ron, could it be that your output with the reported run time error is for case (3) of test program? It seems that the issue is reported for line 20, which is case (3) unless you had changed the code a bit.

0 Kudos
Andreas_Z_
New Contributor I
977 Views

This is what I get: 

PS > ifort /o a.exe /Od /warn:all /check:all /what /Zi TestArrayShapeMismatch.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

 Intel(R) Fortran 2021.7.0-1776
Microsoft (R) Incremental Linker Version 14.29.30146.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:a.exe
-debug
-pdb:a.pdb
-subsystem:console
TestArrayShapeMismatch.obj
PS > .\a.exe
 rb =   2.000000       4.000000       6.000000      0.0000000E+00
0 Kudos
Andreas_Z_
New Contributor I
977 Views

output I get on Windows with latest oneAPI Fortran:

PS C:\Users ... > ifort /o a.exe /Od /warn:all /check:all /Zi /what .\TestArrayShapeMismatch.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation. All rights reserved.

Intel(R) Fortran 2021.7.0-1776
Microsoft (R) Incremental Linker Version 14.29.30146.0
Copyright (C) Microsoft Corporation. All rights reserved.

-out:a.exe
-debug
-pdb:a.pdb
-subsystem:console
TestArrayShapeMismatch.obj
PS C:\Users ... > .\a.exe
rb = 2.000000 4.000000 6.000000 5.5836710E-38
0 Kudos
Ron_Green
Moderator
1,072 Views

you are right - my mistake.  I uncommented case 3 during test and forgot to comment it out again.

Neither IFORT nor IFX are catching case 4.  I'll start a bug report on this.  Sorry for the confusion.  But the 2021.7.0 compiler has a lot of fixes over 2021.6.0 so I'm glad you are up to date. 

 

 

 

 

 

0 Kudos
Andreas_Z_
New Contributor I
977 Views

The following is what I get on Windows with the latest compiler version (no run-time error for case 4 of test program):

PS C:\Users ... > ifort /o a.exe /Od /warn:all /check:all /Zi /what .\TestArrayShapeMismatch.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation. All rights reserved.

Intel(R) Fortran 2021.7.0-1776
Microsoft (R) Incremental Linker Version 14.29.30146.0
Copyright (C) Microsoft Corporation. All rights reserved.

-out:a.exe
-debug
-pdb:a.pdb
-subsystem:console
TestArrayShapeMismatch.obj
PS C:\Users ... > .\a.exe
rb = 2.000000 4.000000 6.000000 5.5836710E-38

0 Kudos
Barbara_P_Intel
Moderator
1,054 Views

I filed a bug, CMPLRLLVM-41164, to catch that Case 4. I'll let you know when a fix is available.



0 Kudos
Barbara_P_Intel
Moderator
731 Views

I now get an error message that states there is a shape mismatch! I used the latest compiler, ifort version 2021.9.0. It was made available last week as part of oneAPI HPC Toolkit 2023.1.

Please try it out!

+ ifort -g -warn all -check all shape.f90
+ a.out
forrtl: warning (406): fort: (33): Shape mismatch: The extent of dimension 1 of array RB is 4 and the corresponding extent of array QQC is 3
Image              PC                Routine            Line        Source      
a.out              00000000004049DA  Unknown               Unknown  Unknown
a.out              00000000004041BD  Unknown               Unknown  Unknown
libc.so.6          00007FF36CE29510  Unknown               Unknown  Unknown
libc.so.6          00007FF36CE295C9  __libc_start_main     Unknown  Unknown
a.out              00000000004040D5  Unknown               Unknown  Unknown
 rb =   2.000000       4.000000       6.000000      0.0000000E+00

+ rm a.out
+ ifx -g -warn all -check all shape.f90
ifx: remark #10440: Note that use of a debug option without any optimization-level option will turnoff most compiler optimizations similar to use of '-O0'
+ a.out
forrtl: warning (406): fort: (33): Shape mismatch: The extent of dimension 1 of array RB is 4 and the corresponding extent of array QQC is 3
Image              PC                Routine            Line        Source      
a.out              0000000000405815  Unknown               Unknown  Unknown
a.out              00000000004051BD  Unknown               Unknown  Unknown
libc.so.6          00007FF520429510  Unknown               Unknown  Unknown
libc.so.6          00007FF5204295C9  __libc_start_main     Unknown  Unknown
a.out              00000000004050D5  Unknown               Unknown  Unknown
 rb =   2.000000       4.000000       6.000000      0.0000000E+00
 

 

0 Kudos
Reply