I have compiled code with gfortran and AOCC flang compiler, but it fails for both, is there anything wrong I am doing?
program find_sub_indx
implicit none
!decl
character(len =30) :: main_string, sub_string
integer :: index_1 , index_2
logical :: back
!defn
main_string = "this is the main string"
sub_string = "a"
back = .false.
index_1 = INDEX(main_string, sub_string, back) !why does this not work
index_2 = INDEX("this is the main string","a", .false.) !this works why?
print *, "index_1 is " , index_1, index_2
end program find_sub_indx
Result expected:
index_1 is 14 14
Actual result:
index_1 is 0 14
Is there some standard reference for learning fortran, as I couldn't find the proper definition of intrinsic function used above.