get_current_line_from_file_sequential Subroutine

private subroutine get_current_line_from_file_sequential(iunit, line)

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

Type Bound

json_core

Arguments

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

file unit number

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

current line


Called by

proc~~get_current_line_from_file_sequential~~CalledByGraph proc~get_current_line_from_file_sequential json_core%get_current_line_from_file_sequential proc~annotate_invalid_json json_core%annotate_invalid_json proc~annotate_invalid_json->proc~get_current_line_from_file_sequential proc~json_parse_file json_core%json_parse_file proc~json_parse_file->proc~annotate_invalid_json proc~json_parse_string json_core%json_parse_string proc~json_parse_string->proc~annotate_invalid_json none~deserialize json_core%deserialize none~deserialize->proc~json_parse_string none~load json_core%load none~load->proc~json_parse_file proc~json_file_load json_file%json_file_load proc~json_file_load->none~load proc~json_file_load_from_string json_file%json_file_load_from_string proc~json_file_load_from_string->none~deserialize proc~wrap_json_parse_string wrap_json_parse_string proc~wrap_json_parse_string->none~deserialize none~deserialize~2 json_file%deserialize none~deserialize~2->proc~json_file_load_from_string proc~assign_string_to_json_file json_file%assign_string_to_json_file proc~assign_string_to_json_file->none~deserialize~2 proc~initialize_json_file_from_string initialize_json_file_from_string proc~initialize_json_file_from_string->none~deserialize~2 proc~initialize_json_file_from_string_v2 initialize_json_file_from_string_v2 proc~initialize_json_file_from_string_v2->none~deserialize~2 proc~wrap_json_file_load_from_string wrap_json_file_load_from_string proc~wrap_json_file_load_from_string->none~deserialize~2 interface~json_file json_file interface~json_file->proc~initialize_json_file_from_string interface~json_file->proc~initialize_json_file_from_string_v2 proc~wrap_assign_string_to_json_file wrap_assign_string_to_json_file proc~wrap_assign_string_to_json_file->proc~assign_string_to_json_file proc~wrap_initialize_json_file_from_string wrap_initialize_json_file_from_string proc~wrap_initialize_json_file_from_string->proc~initialize_json_file_from_string proc~wrap_initialize_json_file_from_string_v2 wrap_initialize_json_file_from_string_v2 proc~wrap_initialize_json_file_from_string_v2->proc~initialize_json_file_from_string_v2

Source Code

    subroutine get_current_line_from_file_sequential(iunit,line)

    implicit none

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

    character(kind=CK,len=seq_chunk_size) :: chunk !! for reading line in chunks
    integer(IK) :: istat  !! iostat flag
    integer(IK) :: isize  !! number of characters read in read statement

    !initialize:
    line = CK_''

    !rewind to beginning of the current record:
    backspace(iunit, iostat=istat)

    !loop to read in all the characters in the current record.
    ![the line is read in chunks until the end of the line is reached]
    if (istat==0) then
        do
            isize = 0
            read(iunit,fmt='(A)',advance='NO',size=isize,iostat=istat) chunk
            if (istat==0) then
                line = line//chunk
            else
                if (isize>0 .and. isize<=seq_chunk_size) line = line//chunk(1:isize)
                exit
            end if
        end do
    end if

    end subroutine get_current_line_from_file_sequential