Matmul problem

Hi,
I’ve discovered what I think is a fault in the pgf90 compiler, version 4.0-2, involving the MATMUL command. The following code should multiply the vector v=(1,2,3,4,5,6,7,8) by an array segment a(:,5) (equal to v), but for some unknown reason seems to multiply v by a(:,1) instead.
Pgf90 gives the answer -204 (incorrect)
Ifc gives the answer 204 (correct)

Is it a bug, or a problem with my code?

Phil

PS Code enclosed here - consists of one module and one program.

MODULE GLOBAL
  REAL( KIND = 8), ALLOCATABLE, PUBLIC :: ARRAY(:,:)
  
  CONTAINS
  
  SUBROUTINE INIT
  IMPLICIT NONE
  ALLOCATE(ARRAY(1:8,1:6) )
  ARRAY = 0.0D0
  
  ARRAY(1:8,1) = (/-1,-2,-3,-4,-5,-6,-7,-8/)
  ARRAY(1:8,5) = (/1,2,3,4,5,6,7,8/)
  
  
  RETURN
  END SUBROUTINE INIT
  
  END MODULE GLOBAL

 program simple
  USE GLOBAL
  IMPLICIT NONE
  REAL( KIND = 8) :: TEMP(8)
  TEMP = (/1,2,3,4,5,6,7,8/)
  CALL INIT
  
   
  PRINT*, MATMUL( TEMP(1:8), ARRAY(1:8,5:5) )
  PRINT*, SUM( TEMP(1:8) * ARRAY(1:8,5) ) !should be the same
  STOP
  END

Thanks for the great example. It really helps in determining the problem.

I can confirm that this was a bug that crept into the 4.0-2 release. Fortunately, it was fixed shortly after so downloading the latest 4.0 compilers should correct the problem. You can find the 4.0-3 compilers in the download archives at http://www.pgroup.com/support/download_archive.php

  • Mat