split_first_last Subroutine

public pure subroutine split_first_last(string, set, first, last)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: string
character(len=*), intent(in) :: set
integer, intent(out), allocatable :: first(:)
integer, intent(out), allocatable :: last(:)

Source Code

pure subroutine split_first_last(string, set, first, last)
    character(*), intent(in) :: string
    character(*), intent(in) :: set
    integer, allocatable, intent(out) :: first(:)
    integer, allocatable, intent(out) :: last(:)

    integer, dimension(len(string) + 1) :: istart, iend
    integer :: p, n, slen

    slen = len(string)

    n = 0
    if (slen > 0) then
        p = 0
        do while (p < slen)
            n = n + 1
            istart(n) = min(p + 1, slen)
            call split_pos(string, set, p)
            iend(n) = p - 1
        end do
    end if

    first = istart(:n)
    last = iend(:n)

end subroutine split_first_last