Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29271 Discussions

Trouble recognizing line endings reading text with 10.1.006

grroot
Beginner
779 Views
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 .
0 Kudos
3 Replies
Ron_Green
Moderator
779 Views
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
0 Kudos
Ron_Green
Moderator
779 Views
A note on od -ax

you want to see newline ( nl 0a ) for line endings.
0 Kudos
grroot
Beginner
779 Views
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.
0 Kudos
Reply