-
Notifications
You must be signed in to change notification settings - Fork 193
Open
Labels
ideaProposition of an idea and opening an issue to discuss itProposition of an idea and opening an issue to discuss ittopic: IOCommon input/output related featuresCommon input/output related features
Description
Motivation
I have met many novices who have no programming background and are mostly related to scientific computing. Fortran beginners often fail to master the reading of files well and will encounter EOF (End of File) errors.
If we can query the number of lines in the file in advance, we can slightly avoid EOF and guide the allocation of the allocatable array.
So, I see that there is already a function number_of_rows
in stdlib_io
, I think it can be overloaded:
interface count_lines
module procedure :: number_of_rows
end interface count_lines
! - - -
counts = count_lines(unit)
Prior Art
Count lines:
Read the context of the file as a string (or array)
Additional Information
counts = count_lines(filename [, iostat] )
type(string_type) :: string(:)/string = read_file(unit/filename [, iostat] )
call count_lines( unit/filename, lines [, columns, max_width, len_lines(:), iostat] )
call count_lines( unit/file, lines [, max_width, iostat] )
milancurcic, ivan-pi and LuNeder
Metadata
Metadata
Assignees
Labels
ideaProposition of an idea and opening an issue to discuss itProposition of an idea and opening an issue to discuss ittopic: IOCommon input/output related featuresCommon input/output related features