Read a file into a 2d int array. Uses the '(*(I1))' format.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | filename |
function read_file_to_int_array(filename) result(array) character(len=*),intent(in) :: filename integer,dimension(:,:),allocatable :: array integer :: i, iunit, n_lines, n_cols character(len=:),allocatable :: line open(newunit=iunit, file=filename, status='OLD') n_lines = number_of_lines_in_file(iunit) line = read_line(iunit) n_cols = len(line) rewind(iunit) allocate(array(n_lines, n_cols)) do i = 1, n_lines line = read_line(iunit) read(line,'(*(I1))') array(i,1:n_cols) end do close(iunit) end function read_file_to_int_array