-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add getline to read whole line from formatted unit #597
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks! I left a few comments and questions.
@urbanjost Does this look good to merge to you? |
If IOSTAT is optional on the call and the user leaves it off, how do you tell you hit end-of-file? The only other thing I see is a matter of taste. If LINE comes before UNIT then UNIT could be optional also and default to stdin. I think that is preferable to encouraging users to put in a 5; although if they put in INPUT_UNIT it is not bad, but requires a USE statement and using a long variable name. There really should be a note somewhere the input file requires PAD mode to be on or it will confuse someone sooner or later. Could have sworn something similar was in stdlib allready but apparently not; I find a procedure like this very handy, especially for prototyping. I have a version that ignored trailing ctrl_J and ctrl_M characters because of a problem with MSWindows and Linux, especially when reading files from the other platform but it looks like that has settled down, as I tried it with three compilers and did not see anything wrong at least with formatted sequential files. I think it would still be a problem with stream I/O but this would seem to (almost?) always be used with formatted sequential so I do not consider that a problem. |
This should work in analogy with a usual
I added another version of
I'm checking the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
My only concern is the lenght of the buffer. 512 characters would be often too small for some of my cases.
I created a test with different bufferlengths for reading 3600 lines, with the longest lines having 120000 chars, short lines having 1200 chars. Timings in seconds.
Larger buffersizes indeed give a sizable speedup, as the time consuming step is the read of each chunk from the unit. Also, it is good to see that short lines are read fast regardless of the buffersize. |
Co-authored-by: Milan Curcic <[email protected]>
Co-authored-by: Milan Curcic <[email protected]>
Alternative implementation by John @urbanjost in M_io