read_file_to_integer64_array Function

public function read_file_to_integer64_array(filename) result(iarray)

Read a file into an ip integer array (one element per line)

Arguments

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

Return Value integer(kind=ip), dimension(:), allocatable


Calls

proc~~read_file_to_integer64_array~~CallsGraph proc~read_file_to_integer64_array aoc_utilities::read_file_to_integer64_array proc~number_of_lines_in_file aoc_utilities::number_of_lines_in_file proc~read_file_to_integer64_array->proc~number_of_lines_in_file

Source Code

    function read_file_to_integer64_array(filename) result(iarray)

    character(len=*),intent(in) :: filename
    integer(ip),dimension(:),allocatable :: iarray

    integer :: i, iunit, n_lines, istat

    open(newunit=iunit, file=filename, iostat=istat)
    if (istat /= 0) error stop ' error reading file'

    n_lines = number_of_lines_in_file(iunit)
    allocate(iarray(n_lines))
    do i = 1, n_lines
        read(iunit, *) iarray(i)
    end do

    close(iunit)

    end function read_file_to_integer64_array