The intrinsic function INDEX scans a string for the position of the first occurrence of a substring.
Here I am searching for the character '9' in the string '1234567890'
Running the code below shows this works fine when the option back is logical .false. - the return value is 9, if .true. i.e. scanning from the end of the sting, when I run this code the return value is 9, which is wrong - it should be 2. Or am I doing something silly here - it's very late here in the UK - well past my bedtime!
Thanks
Ken
program test
implicit none
character (len=10) w
integer i
logical back
w = '1234567890'
write(6,'(a)')w
back = .false.
i = INDEX(w,'9',back )
write(6,*) i
back = .true.
i = INDEX(w,'9',back )
write(6,*) i
i = INDEX(w,'9')
write(6,*) i
end program test