fdoc

subroutineconstruct_linespureprivate

pure subroutine construct_lines(low, starts, stops)

The lines of low that could start or end a procedure or type.

Arguments

NameTypeIntentAttributesDescription
lowcharacter(len=*)in

the file, in lowercase

startsintegeroutallocatabledimension(:)

where each line starts

stopsintegeroutallocatabledimension(:)

where each line ends

Source

Show the code
pure subroutine construct_lines(low, starts, stops)
    character(len=*), intent(in) :: low             !! the file, in lowercase
    integer, allocatable, intent(out) :: starts(:)  !! where each line starts
    integer, allocatable, intent(out) :: stops(:)   !! where each line ends
    integer :: pass, i, j, stop_at, n

    do pass = 1, 2
        n = 0
        i = 1
        do while (i <= len(low))
            j = index(low(i:), achar(10))
            stop_at = merge(len(low), i + j - 2, j == 0)
            if (index(low(i:stop_at), 'subroutine') > 0 .or. index(low(i:stop_at), 'function') > 0 .or. &
                index(low(i:stop_at), 'type') > 0) then
                n = n + 1
                if (pass == 2) then
                    starts(n) = i
                    stops(n) = stop_at
                end if
            end if
            if (j == 0) exit
            i = stop_at + 2
        end do
        if (pass == 1) allocate (starts(n), stops(n))
    end do
end subroutine construct_lines

Graphs

Called by