Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
공지
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29286 토론

Bogus array bounds violation with ifx 2025

Jellby1
새로운 기여자 I
1,182 조회수

I'm getting a "wrong" failure with -check all that doesn't agree with the code I compile:

$ cat a.f90
module Lebedev_quadrature
 implicit none
 private
 public :: ld0014
 contains
 subroutine ld0014(x,y,z,w)
   real, intent(out) :: x(14), y(14), z(14), w(14)
   real, parameter :: v1 = 1.0/15.0, v2 = 3.0/40.0
   integer :: m
   m = 1
   call gen_oh(1,m,v1,x(m:),y(m:),z(m:),w(m:))
   call gen_oh(2,m,v2,x(m:),y(m:),z(m:),w(m:))
 end subroutine ld0014
 subroutine gen_oh(code,num,v,x,y,z,w)
   integer, intent(in) :: code
   integer, intent(inout) :: num
   real, intent(in) :: v
   real, intent(out) :: x(*), y(*), z(*), w(*)
   real :: a
   integer :: n

   select case (code)
     case (1)
       a = 1.0
       x(1:6) = [  a, -a,0.0,0.0,0.0,0.0]
       y(1:6) = [0.0,0.0,  a, -a,0.0,0.0]
       z(1:6) = [0.0,0.0,0.0,0.0,  a, -a]
       w(1:6) = v
       n = 6
     case (2)
       a = sqrt(1.0/3.0)
       x(1:8) = [ a,-a, a,-a, a,-a, a,-a]
       y(1:8) = [ a, a,-a,-a, a, a,-a,-a]
       z(1:8) = [ a, a, a, a,-a,-a,-a,-a]
       w(1:8) = v
       n = 8
   end select
   num = num+n
 end subroutine gen_oh
end module Lebedev_quadrature

program main
 use Lebedev_quadrature, only: ld0014
 implicit none
 integer :: i, j
 real :: TempR(14,3), TempW(14)
 call ld0014(TempR(:,1),TempR(:,2),TempR(:,3),TempW)
 do i=1,14
   print *, (TempR(i,j),j=1,3),TempW(i)
 end do
end program main

$ ifx -check all a.f90 && ./a.out
forrtl: severe (408): fort: (3): Subscript #1 of the array X has value 0 which is less than the lower bound of 1

Image              PC                Routine            Line        Source              
a.out              0000000000405FAC  Unknown               Unknown  Unknown
a.out              00000000004058E6  Unknown               Unknown  Unknown
a.out              0000000000406391  Unknown               Unknown  Unknown
a.out              000000000040516D  Unknown               Unknown  Unknown
libc.so.6          00007F13823F4D90  Unknown               Unknown  Unknown
libc.so.6          00007F13823F4E40  __libc_start_main     Unknown  Unknown
a.out              0000000000405085  Unknown               Unknown  Unknown

$ ifx --version
ifx (IFX) 2025.0.4 20241205
Copyright (C) 1985-2024 Intel Corporation. All rights reserved

I'm using explicit subscripts (1:6) and (1:8), so there's no way there could be a 0 subscript. I believe this happens because the inline arrays are using a variable.

1 솔루션
taehunkim
직원
976 조회수

I tested it in the next version under development and it will be solved.

원본 게시물의 솔루션 보기

6 응답
Andrew_Smith
소중한 기여자 I
1,167 조회수

The code works OK using the IFORT compiler, or if you change the array declarations to use assumed shape ,i.e.

real, intent(out) :: x(:), y(:), z(:), w(:)

Jellby1
새로운 기여자 I
1,084 조회수

Thanks for testing. Unfortunately, both x(:) and x(*) are inappropriate. If I'm using intent(out), I should not rely on the size passed by the caller. The original code had something like:

integer, parameter :: points(2) = [6,8]
real, intent(out) :: x(points(code))
x(:) = [...]

so that the size is dependent on the value of the code argument. It still failed in the same way.

0 포인트
jimdempseyatthecove
명예로운 기여자 III
1,022 조회수

jimdempseyatthecove_0-1741195241407.png

So you can use assumed shape.

But note that the passed arrays have origine at index 1 and with size passed in.

Jim Dempsey

0 포인트
Jellby1
새로운 기여자 I
940 조회수

Yes, but then the calling program needs to know the size. In my case, only the subroutine being called knows the size. I could of course re-structure the code, move the "points" parameter to a module-wide definition, and so on...

0 포인트
taehunkim
직원
977 조회수

I tested it in the next version under development and it will be solved.

jimdempseyatthecove
명예로운 기여자 III
903 조회수

>>but then the calling program needs to know the size

in my example, at the call: size(array(23:45)) would be the size of what will be passed.

Or in your example: size(x(m:))

Jim Dempsey

 

0 포인트
응답