Bounds Checking Problem with F90 6.1 -- 5.2 Works

I have an F90 code that won’t run with the 6.1 bounds checking turned on. The code runs OK with pgf90 v5.2 with and without bounds checking. It also runs OK with the 6.1 compiler without bounds checking. With bounds checking turned on and the v6.1 compiler, I get a run-time error message:

0: Subscript out of range for array x (arraytest.f: 61)
subscript=25, lower bound=0, upper bound=24, dimension=1

The code is

45: REAL, POINTER :: x(:,:)

60: do i = 1, size(x,1)
61: write(6,*)'Element ', i, ‘:’, x(i,1)
62: end do

The output using 5.2 and 6.1 without bounds checking is identical. The platform is Linux and I’m using the 64-bit compiler.

Thanks,

Bill

Hi Bill,

I suspect you have the lower bound of x specified as 0. If this is the case, then you’ll need to adjust your do loops indices to match your array’s upper and lower bounds. If this isn’t it, can you post more of the code, including how x is allocated, or send a copy to trs@progup.com?

Thanks,
Mat

I get the following error when I compile with bounds checking (pgf90 -Mbounds -o demo arraytest.f)

0: Subscript out of range for array x (arraytest.f: 48)
subscript=25, lower bound=0, upper bound=24, dimension=1

It works without bounds checking (pgf90 -o demo arraytest.f)

Here’s the code:

PROGRAM arraytest

IMPLICIT none

INTEGER i, j, k, ms, mm, mg
PARAMETER (ms = 31 , mm = 25, mg = 8)

INTERFACE
SUBROUTINE arraywrite(zx)
REAL, INTENT(INOUT) :: zx(:,:)
END SUBROUTINE
ENDINTERFACE

REAL zx(mm, ms, mg)
SAVE zx

DO i = 1, mm
DO j = 1, ms
DO k = 1, mg
zx(i,j,k) = k
END DO
END DO
END DO

DO k = 1, mg
CALL arraywrite(zx(:,:,k))
END DO

END PROGRAM

C--------------------------------------------------------------------

SUBROUTINE arraywrite(t_zx)

IMPLICIT none

REAL, POINTER :: x(:,:)
COMMON /pntrs/x
SAVE /pntrs/
INTEGER i
REAL, TARGET :: t_zx(:,:)

x => t_zx

WRITE(6,*)'Size of Array ', size(x,1), 'x ', size(x,2)

DO i = 1, size(x,1)
WRITE(6,*)'Element ', i, ‘:’, x(i,1)
END DO

END SUBROUTINE

Hi Bill,

Thank you for the example code. I’m showing that the code fails with the 6.0 to 6.1-4 releases but works with the 6.1-5 and 6.1-6 releases. However, I don’t see a bug fix that specifically address is problem so have asked our compiler team to investigate what the original problems was and how it was fixed.

Note you can download the latest release HERE

Thank for your report,
Mat