pgfortran 13.2 compiler bug

I have found what seems to be a bug with optimization in
pgfortran 13.2.

It’s all explained in this short test code (sorry about the lack
of appropriate spacing).

PROGRAM HLINE
C
C This illustrates a bug in
C pgfortran 13.2-0 64-bit target on x86-64 Linux -tp gh
C
C If you compile as
C pgfortran -g -O1 -o hline hline.F
C and run with inputs 15 20 the output (correct) is
C JD,KD= 15 20
C Indices MS
C 2 2 2 2 2 2 2 2 2 2
C 2 2 2 2 2 2 2 2 3 4
C 5 6 7 8 9 10 11 12 13 14
C Indices ME
C 2 3 4 5 6 7 8 9 10 11
C 12 13 14 14 14 14 14 14 14 14
C 14 14 14 14 14 14 14 14 14 14
C
C If you compile as
C pgfortran -g -O2 -o hline hline.F
C and run with inputs 15 20 the output (incorrect) is
C JD,KD= 15 20
C Indices MS
C 2 2 2 2 -11 -10 -9 -8 2 2
C 2 2 -3 -2 -1 0 2 2 3 4
C 5 6 7 8 9 10 11 12 13 14
C Indices ME
C 14 14 14 14 2 3 4 -3 14 14
C 14 14 10 11 12 21 14 14 14 14
C 18 19 20 13 14 14 14 14 14 14
C
C pgfortran 12.5-0 worked OK for me
C (pgfortran 12.5-0 64-bit target on x86-64 Linux -tp sandybridge)
C
IMPLICIT NONE
INTEGER :: JD,KD
INTEGER :: JS,JE,KS,KE,N
INTEGER, DIMENSION(:), ALLOCATABLE :: MS,ME
C
C
WRITE(,“('What dimensions JD,KD? ',$)”)
READ ,JD,KD
WRITE(
,“(‘JD,KD=’,2I5)”) JD,KD
ALLOCATE( MS(JD
KD),ME(JDKD) )
C
C Integration limits, adjusted for periodicity.
C
JS = 2
JE = JD-1
KS = 2
KE = KD-1
C
C Set up indices for hyper-line.
C
CALL HYPLIN( JS,JE,KS,KE,MS,ME,JD,KD )
C
WRITE(
,“(‘Indices MS’)”)
DO N = JS+KS,JE+KE,10
WRITE(,“(10I5)”) MS(N:MIN(N+9,JE+KE))
ENDDO
WRITE(
,“(‘Indices ME’)”)
DO N = JS+KS,JE+KE,10
WRITE(,“(10I5)”) ME(N:MIN(N+9,JE+KE))
ENDDO
DEALLOCATE( MS,ME )
C
C
END
C
***************************************************************
SUBROUTINE HYPLIN( JS,JE,KS,KE,MS,ME,JD,KD )
C
C Set up indices for hyper-line.
C
IMPLICIT NONE
INTEGER, INTENT (IN) :: JS,JE,KS,KE,JD,KD
INTEGER, DIMENSION(JD*KD), INTENT (OUT) :: MS,ME
C
INTEGER :: M
C
C
DO M = JS+KS,JE+KE
MS(M) = MAX(JS,M-KE)
ME(M) = MIN(JE,M-JS)
ENDDO
C
C
RETURN
END

Hi Dennis,

Thanks for the report. I was able to reproduce the problem here and have filed a problem report (TPR#19134) with our compiler team. Note that the error appears to only occur on AMD systems when using vectorization. Hence, you can add the flag “-Mnovect” to work around the issue. Also, the error does occur in earlier versions of the compiler when “-Mvect=sse” is added. In PGI 2013, more optimization were added to -O2, including vectorization, and is why you just saw it.

Best Regards,
Mat

Dennis,

TPR 19134 has been fixed in the current 13.7 release. Thanks again for your submission.

regards,
dave