after_fields Function

private pure function after_fields(line, n) result(rest)

The text of line after its first n fields (separated by blanks or tabs), trimmed: a star's name ('' if none: e.g. without a color index).

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: line

a line of the star catalog

integer, intent(in) :: n

fields skipped

Return Value character(len=:), allocatable


Called by

proc~~after_fields~~CalledByGraph proc~after_fields after_fields proc~read_stars read_stars proc~read_stars->proc~after_fields proc~set_star_data SkySphere%set_star_data proc~set_star_data->proc~read_stars

Source Code

    pure function after_fields(line, n) result(rest)
        character(len=*), intent(in) :: line                !! a line of the star catalog
        integer, intent(in) :: n                            !! fields skipped
        character(len=:), allocatable :: rest
        character(len=*), parameter :: blanks = ' '//achar(9)//achar(13)
        integer :: i, j, k
        rest = ''
        i = 1
        do k = 1, n
            j = verify(line(i:), blanks)                    ! the field's start
            if (j == 0) return
            i = i + j - 1
            j = scan(line(i:), blanks)                      ! the blank after it
            if (j == 0) return
            i = i + j - 1
        end do
        j = verify(line(i:), blanks)                        ! the rest, without blanks around it
        if (j == 0) return
        i = i + j - 1
        k = verify(line, blanks, back=.true.)
        rest = line(i:k)
    end function after_fields