- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to read a simple text file containing variable length lines of ascii text. Each line is terminated with a carriage return character. open(unit=8, file=inFileName, status='old', action='read', iostat=status) followed by read(8,*, iostat=status) charString where charString(len=100) reads the entire file ignoring line endings. I have tried the new Access="stream_cr', etc included in 10.1.006 in the open statement, but it won't compile. Is this a bug or am I missing something in Fortran. It's been about 15 years since I used Fortran, but I can't remember this being a problem back then .
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is probably best to open an issue on Premier for this one, since when you open a problem report you can attach your input file and your source code you use to read the file.
Do you really mean that you have a Linux file with JUST a carriage return to mark line end, or is it a line feed? Or is it a CR-LF combo?
od -ax will dump the hex and ascii so you can see.
It's also not clear what you want to do - do you want to read one line at a time, or do you really want to read in the whole file at once into a large character variable?
thanks
ron
Do you really mean that you have a Linux file with JUST a carriage return to mark line end, or is it a line feed? Or is it a CR-LF combo?
od -ax
It's also not clear what you want to do - do you want to read one line at a time, or do you really want to read in the whole file at once into a large character variable?
thanks
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A note on od -ax
you want to see newline ( nl 0a ) for line endings.
you want to see newline ( nl 0a ) for line endings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! The problem was with the line endings. The original text file was created on a PC. Since I'm running ifort on a Mac, I converted the line endings to Mac (cr). Now that I have converted them to UNIX (lf) all appears to be working properly.
Sorry to have bothered you.
Sorry to have bothered you.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page