Fortran Wiki


Returns the position of the start of the first occurrence of string substring as a substring in string, counting from one. If substring is not present in string, zero is returned. If the back argument is present and true, the return value is the start of the last occurrence rather than the first.


FORTRAN 77 and later, with kind argument Fortran 2003 and later


Elemental function


result = index(string, substring [, back [, kind]])


  • string - Shall be a scalar character, with intent(in)
  • substring - Shall be a scalar character, with intent(in)
  • back - (Optional) Shall be a scalar logical, with intent(in)
  • kind - (Optional) An integer initialization expression indicating the kind parameter of the result.

Return Value

The return value is of type integer and of kind kind. If kind is absent, the return value is of default integer kind.

See Also

scan, verify

category: intrinsics