! Program Example from "Essential Fortran 90 & 95" by Loren P. Meissner
! Copyright 1996. Copying for sale requires permission from the author.
! Otherwise, distribution is permitted if these three lines are included.

! Example B.3. ! Output with substring
  program L03
    implicit none
    integer :: Loc_1
    character (len = 50), dimension(3) :: Hamlet
! start program L03
    Hamlet(1) = ""
    Hamlet(2) = "Whether 'tis nobler in the mind to suffer"
    Hamlet(3) = ""
    Loc_1 = index (Hamlet(2), "the")
    write (unit = *, fmt = "(I5, 3 A)" ) Loc_1, ": ", trim( Hamlet(2)(Loc_1: ) ), "*"
    stop
  end program L03
