The following code extract from CASTEP is miscompiled by every version of pgf90
I have access to up to and including 8.0.1.
program stringtest
integer,parameter :: num_ff_dump=1
integer :: indx2, indx1
character(len=256) :: ff_dump
character(len=256) :: cjunk
ff_dump = 'print : 2'
indx1 = index(ff_dump,':')
indx2=index(ff_dump,':')
if(indx2.gt.0) then
cjunk = ff_dump(1:indx2-1)
ff_dump=trim(cjunk)//repeat(' ',indx1-indx2+1)//': '&
//trim(adjustl(ff_dump(indx2+1:)))//'#'
end if
write(*,*) trim(ff_dump)
end program stringtest
The string constructed in “ff_dump” contains junk. The output produced when compiling with Intel Fortran, Pathscale Fortran, Sun Express, gfortran, g95 and NAG Fortran is
print : 2#
while PGI Fortran (7-1.x, 7.2.x, 8.01) produce
print 1 xc`xc2 :
Is thi the correct place to submit a bug report?
Keith Refson
Hi Kieth,
Thank you for the report. There appears to be a problem with the size of the temporary array used to hold the string returned by the ‘repeat’ intrinsic. I’m able to work around the problem by adding a ‘trim’ around the repeat. Note this problem first began with the 7.1 compiler and does occur with the most current version (8.0-3).
I went ahead and added a technical problem report (TPR#15518) and have sent it to engineering.
Is this the correct place to submit a bug report?
Typically we ask users to submit issues to Customer Service directly by sending email to trs@pgroup.com. However, I don’t mind adding TPRs as well. The difference is that I don’t have direct access to your email address, so you wont get an email notification when the problem has been resolved. We typically have patch releases on the first or second Thursday of each month, so you can either check back periodically to see if the problem has been fixed, or send a note to trs@pgroup.com asking customer service to send you notification.
Work around is to add a trim around the repeat:
% cat string.F90
program stringtest
integer,parameter :: num_ff_dump=1
integer :: indx2, indx1
character(len=256) :: ff_dump
character(len=256) :: cjunk
ff_dump = 'print : 2'
indx1 = index(ff_dump,':')
indx2=index(ff_dump,':')
if(indx2.gt.0) then
cjunk = ff_dump(1:indx2-1)
ff_dump=trim(cjunk)//trim(repeat(' ',indx1-indx2+1))//': '//&
trim(adjustl(ff_dump(indx2+1:)))//'#'
end if
write(*,*) trim(ff_dump)
end program stringtest
% pgf90 -O0 string.F90 -V8.0-3
% a.out
print: 2#
Hi Kieth,
TPR#15518 has been fixed as of the 8.0-4 release.