sentinel7
Joined: 24 May 2014 Posts: 2
|
Posted: Sat May 24, 2014 9:24 pm Post subject: Bug with optimise? |
|
|
Hi,
I think I have a bug with /optimise. The following function performs differently with compiled with and without the option. Essentially it is supposed to remove any leading spaces from a character string and append a letter 'A'.
I correctly get 'helloA' without optimise. But with it I get 'hello @'.
Note - I've found several ways to re-write the code that do let it compile correctly with /optimise, so it must be something specific about this structure. (Even adding a PRINT *,J into the inner loop fixes it.
Also note - this is a simplified example to highlight the problem - so no need to suggest ways to improve the code!
Thanks,
Mark.
character*10 :: qqq
character*10 :: a,b
a=' hello'
b=qqq(a)
print *,a
print *,b
end
character*10 function qqq(a)
implicit none
character*10 :: a
integer :: i,j
do i=1,9
if(a(i:i)/=' ') then
do j=i+1,10
if(a(j:j)==' ') then
qqq=a(i:j-1)//'A'
return
end if
end do
end if
end do
qqq='XXXXXXXXXX'
return
end |
|