Reputation: 11
Problem: Reading data file with multiple entries on a single line
~~~~~~~~~~~~
Problems with that solution:
~~~~~~~~~~~~
Is there any other way of doing this?
Upvotes: 1
Views: 119
Reputation: 21441
Using deferred length character and non-advancing reads avoids the problems you mention in your question.
Continuing to parse of the resulting line using internal IO with explicit formats then avoids the potential for user "surprise" associated with the more obscure features of list directed formatting and allows far more scope and control over input error detection and reporting.
Upvotes: 2
Reputation: 29401
You can directly read multiple items from a one or multiple lines. For example:
read (5, *) a, b, c, d
will read four values from one to many lines.
Upvotes: 2