pgf90 v6.0 array problem

I’m seeing a difference in Fortran 90 array sections and/or pointers from version 5.2. The following scaled down code snippet demonstrates:

PROGRAM main
   PARAMETER (n=5)
   REAL t(n)

   INTERFACE
     SUBROUTINE sub(n, t)
       INTEGER :: n
       REAL :: t(:)
     END SUBROUTINE
   END INTERFACE

   DO i = 1,n
      t(i) = FLOAT(i)
      WRITE(*,"('MAIN T(',i1,') = ',F4.1)") i,t(i)
   ENDDO

   CALL sub(n, t(:))
END

SUBROUTINE sub(n, p_t)
   REAL, POINTER :: t(:)
   REAL, TARGET :: p_t(:)
   t => p_t

   DO i = 1,n
     WRITE(*,"('SUB T(',i1,') = ',F4.1)") i,t(i)
   ENDDO
END

5.2 output:

MAIN T(1) = 1.0
MAIN T(2) = 2.0
MAIN T(3) = 3.0
MAIN T(4) = 4.0
MAIN T(5) = 5.0
SUB T(1) = 1.0
SUB T(2) = 2.0
SUB T(3) = 3.0
SUB T(4) = 4.0
SUB T(5) = 5.0

6.0 output:

MAIN T(1) = 1.0
MAIN T(2) = 2.0
MAIN T(3) = 3.0
MAIN T(4) = 4.0
MAIN T(5) = 5.0
SUB T(1) = 2.0
SUB T(2) = 3.0
SUB T(3) = 4.0
SUB T(4) = 5.0
SUB T(5) = 0.0

The 6.0 output is shifted by one. It seems to be assuming zero-based array indexing on the pointer.

Calling the subroutine without specifying an array section works. Example:

CALL sub(n, t)

My real code is passing a 2d array section extracted from a 3d array to a subroutine using pointers, so this isn’t an option.

Suggestions?

Thanks,
Josh

Hi John,


Thank you for the report. The problem appears to be on how we’re setting up the call using the section. I’ve filled TPR #3618 and have ask our compiler team to investigate further. I’ve also listed you as the contact.

The work arround as you have already determined is to remove the array section from the actual argument list or use the 5.2 compiler.

Thanks again,
Mat