pgfortran 14.3-0 internal compiler error at -O2 or above


rMBP~/pgi/bugs$ cat astats.f90
!!!
subroutine RealArrayStats(name,list,m,array,n,mask,stats)
implicit real(8) (a-h,o-z)
dimension array(m,n),stats(m,-1:2)
character(),parameter :: FMT=‘g13.7’
intent(in) name,list,m,array,n,mask; intent(out) stats
character(
) name,list; logical(1) mask(n)
!
! return min,ave,max,rms,p-v stats for each array component
!
parameter (KON=6,ltab=1); character(2),parameter :: TAB=’ ‘//char(9)
dimension a(m),mloc(m,-1:1)
character(4) frc(-1:2)
! logical(1) msk(m,n) !automatic (on stack)
logical(1),allocatable :: msk(:,:) !on heap
character(10) str
logical mess,same; logical,parameter :: FP=FMT(:1)/=‘i’
dimension l(100)
stats=0; if (ltab<1) return
s=count(mask); if (s==0) return
mess=name/=’ ’
if (mess) then
i=Num2Char(s,str); call InitializeMeter(‘calculating ‘//str(:i)//’ ‘//trim(name)//’ statistics’)
endif
allocate(msk(m,n)); !msk=spread(mask,1,m) !for large n will overflow stack
do i=1,m; msk(i,:)=mask; enddo !i
mloc(:,0)=0; mloc(:,-1)=minloc(array,2,msk); forall (i=1:m) stats(i,-1)=array(i,mloc(i,-1)); if (mess) call ProgressMeter(25)
a=sum(array,2,msk)/s
if (FP) then; stats(:,0)=a
else; stats(:,0)=nint(a); endif
if (mess) call ProgressMeter(50)
mloc(:,1)=maxloc(array,2,msk); forall (i=1:m) stats(i,1)=array(i,mloc(i,1)); if (mess) call ProgressMeter(75)
forall (i=1:m) a(i)=sqrt(sum((array(i,:)-a(i))**2,msk(i,:))/s) !smaller temporary
if (FP) then; stats(:,2)=a
else; stats(:,2)=nint(a); endif
if (mess) call ProgressMeter(100)
if (list==’ ‘) return
k=ListParse(list,’,’,l); j=len_trim(list); if (m>1) j=(j-1)/m
if (k==1.and.m>1) then
j=1; l=(/(i,i=0,99)/)
endif
if (FP) then; same=all(real(stats(:,-1))==real(stats(:,1)))
else; same=all(stats(:,-1)==stats(:,1)); endif
if (mess.and…not.same) &
write(KON,’(a,a,5(3x,a7,4x))’) TAB(:ltab),repeat(’ ‘,j),‘Minimum’,‘Average’,‘Maximum’,’ RMSvar’,‘Max-Min’
do i=1,m
if (real(stats(i,-1))==real(stats(i,1))) then
write(KON,’(a,a,1x,’//FMT//’)’) TAB(:ltab),list(l(i)+1:l(i)+j),stats(i,-1)
else
if (FP) then
write(KON,’(a,a,5(1x,’//FMT//’))’) TAB(:ltab),list(l(i)+1:l(i)+j),stats(i,:),stats(i,1)-stats(i,-1)
else
frc=’ ’
do k=-1,1
write(frc(k),’(f4.3)’) count(mask.and.array(i,:)==stats(i,k))/s; if (frc(k)==’****’) frc(k)=’ ’
enddo !k
write(KON,’(a,a,5(1x,’//FMT//’))’) TAB(:ltab),list(l(i)+1:l(i)+j),(stats(i,k),frc(k),k=-1,2),stats(i,1)-stats(i,-1)
endif
if (ltab>1) write(KON,’(a,a,3(i10.0,4x))’) TAB(:ltab),repeat(’ ',j),mloc(i,:)
endif
enddo !i
return
end

rMBP~/pgi/bugs$ pgfortran -V -c -O1 astats.f90

pgfortran 14.3-0 64-bit target on Apple OS/X developer
The Portland Group - PGI Compilers and Tools
Copyright © 2014, NVIDIA CORPORATION. All rights reserved.
PGF90/x86-64 OSX 14.3-0
Copyright © 2014, NVIDIA CORPORATION. All rights reserved.
PGF90/x86-64 OSX 14.3-0
Copyright © 2014, NVIDIA CORPORATION. All rights reserved.
rMBP~/pgi/bugs$ pgfortran -V -c -O2 astats.f90

pgfortran 14.3-0 64-bit target on Apple OS/X developer
The Portland Group - PGI Compilers and Tools
Copyright © 2014, NVIDIA CORPORATION. All rights reserved.
PGF90/x86-64 OSX 14.3-0
Copyright © 2014, NVIDIA CORPORATION. All rights reserved.
PGF90/x86-64 OSX 14.3-0
Copyright © 2014, NVIDIA CORPORATION. All rights reserved.
PGF90-S-0000-Internal compiler error. compute_initial_aryaddr: addr not found 1761 (astats.f90: 33)
PGF90-S-0000-Internal compiler error. compute_initial_aryaddr: addr not found 1761 (astats.f90: 33)
0 inform, 0 warnings, 2 severes, 0 fatal for realarraystats

Hi,

I have reproduced your problem here at PGI, and I have filed a report with our developers. I will let you know as soon as this issue has been resolved. Thanks for the report.

Best regards,

+chris

This problem has been corrected in the current 14.4 release.

Thanks again for reporting the problem.

regards,
dave