get_current_line_from_file_stream Subroutine

private subroutine get_current_line_from_file_stream(iunit, line)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: iunit

file unit number

character(kind=CK,len=:), intent(out), allocatable:: line

current line

Description

Rewind the file to the beginning of the current line, and return this line. The file is assumed to be opened. This is the STREAM version (see also get_current_line_from_file_sequential).

Called By

proc~~get_current_line_from_file_stream~~CalledByGraph proc~get_current_line_from_file_stream get_current_line_from_file_stream proc~annotate_invalid_json annotate_invalid_json proc~annotate_invalid_json->proc~get_current_line_from_file_stream proc~json_parse_file json_parse_file proc~json_parse_file->proc~annotate_invalid_json proc~json_parse_string json_parse_string proc~json_parse_string->proc~annotate_invalid_json interface~json_parse json_parse interface~json_parse->proc~json_parse_file interface~json_parse->proc~json_parse_string proc~test_14 test_14 proc~test_14->interface~json_parse proc~test_8 test_8 proc~test_8->interface~json_parse proc~json_file_load json_file_load proc~json_file_load->interface~json_parse proc~json_file_load_from_string json_file_load_from_string proc~json_file_load_from_string->interface~json_parse program~jf_test_14 jf_test_14 program~jf_test_14->proc~test_14 program~jf_test_8 jf_test_8 program~jf_test_8->proc~test_8 proc~wrap_json_file_load_from_string wrap_json_file_load_from_string proc~wrap_json_file_load_from_string->proc~json_file_load_from_string proc~wrap_json_parse_string wrap_json_parse_string proc~wrap_json_parse_string->proc~json_parse_string
Help

Variables

TypeVisibility AttributesNameInitial
integer(kind=IK), public :: istart
integer(kind=IK), public :: iend
integer(kind=IK), public :: ios
character(kind=CK,len=1), public :: c

Source Code

    subroutine get_current_line_from_file_stream(iunit,line)

    implicit none

    integer(IK),intent(in)                           :: iunit  !! file unit number
    character(kind=CK,len=:),allocatable,intent(out) :: line   !! current line

    integer(IK) :: istart,iend,ios
    character(kind=CK,len=1) :: c

    !updated for the new STREAM version:

    istart = ipos
    do
        if (istart<=1) then
            istart = 1
            exit
        end if
        read(iunit,pos=istart,iostat=ios) c
        if (c==newline .or. ios/=0) then
            if (istart/=1) istart = istart - 1
            exit
        end if
        istart = istart-1  !rewind until the beginning of the line
    end do
    iend = ipos
    do
        read(iunit,pos=iend,iostat=ios) c
        if (c==newline .or. ios/=0) exit
        iend=iend+1
    end do
    allocate( character(kind=CK,len=iend-istart+1) :: line )
    read(iunit,pos=istart,iostat=ios) line

    end subroutine get_current_line_from_file_stream