We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
number_of_columns
2 parents 52d3baa + 4708a0a commit 399f9a1Copy full SHA for 399f9a1
src/stdlib_io.fypp
@@ -252,6 +252,7 @@ contains
252
253
integer :: ios, skiprows_, i
254
character :: c
255
+ character(len=:), allocatable :: line
256
logical :: lastblank
257
258
skiprows_ = optval(skiprows, 0)
@@ -261,12 +262,15 @@ contains
261
262
do i = 1, skiprows_
263
read(s, *)
264
end do
-
265
number_of_columns = 0
266
+
267
+ ! Read first non-skipped line as a whole
268
+ call getline(s, line, ios)
269
+ if (ios/=0 .or. .not.allocated(line)) return
270
271
lastblank = .true.
- do
- read(s, '(a)', advance='no', iostat=ios) c
- if (ios /= 0) exit
272
+ do i = 1,len(line)
273
+ c = line(i:i)
274
if (lastblank .and. .not. is_blank(c)) number_of_columns = number_of_columns + 1
275
lastblank = is_blank(c)
276
0 commit comments