Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/stdlib_io.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ contains

integer :: ios, skiprows_, i
character :: c
character(len=:), allocatable :: line
logical :: lastblank

skiprows_ = optval(skiprows, 0)
Expand All @@ -261,12 +262,15 @@ contains
do i = 1, skiprows_
read(s, *)
end do

number_of_columns = 0

! Read first non-skipped line as a whole
call getline(s, line, ios)
if (ios/=0 .or. .not.allocated(line)) return

lastblank = .true.
do
read(s, '(a)', advance='no', iostat=ios) c
if (ios /= 0) exit
do i = 1,len(line)
c = line(i:i)
if (lastblank .and. .not. is_blank(c)) number_of_columns = number_of_columns + 1
lastblank = is_blank(c)
end do
Expand Down
Loading