Home > Archive > Fortran > April 2005 > Newline behavior
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Thomas Lang 2005-04-06, 12:21 pm |
| hi all,
reading-in a formatted file with a simple
READ(5,'(A)') BUFFER
Lahey's Fortran compiler includes the trailing newline into BUFFER,
where Intel's compiler doesn't. How to open the file or do the
read-statement to obtain the same with both compilers?
The task is to read an input file where comments and lines without a "="
(empty lines) should be skipped.
thanx in advance & br,
Tom
| |
| beliavsky@aol.com 2005-04-06, 12:21 pm |
| Thomas Lang wrote:
> hi all,
>
> reading-in a formatted file with a simple
>
> READ(5,'(A)') BUFFER
>
> Lahey's Fortran compiler includes the trailing newline into BUFFER,
> where Intel's compiler doesn't. How to open the file or do the
> read-statement to obtain the same with both compilers?
You could try fiddling with the carriage control option present in
Lahey/Fujitsu 7.1 for Windows (and perhaps other versions on other
operating systems).
-[n]concc support carriage control characters in console I/O
> The task is to read an input file where comments and lines without a
"="
> (empty lines) should be skipped.
The INDEX character function should be useful.
| |
| Richard Maine 2005-04-06, 12:21 pm |
| Thomas Lang <lang@itp.tugraz.at> writes:
> reading-in a formatted file with a simple
>
> READ(5,'(A)') BUFFER
>
> Lahey's Fortran compiler includes the trailing newline into BUFFER,
Really? I'd find that *VERY* surprising. That would violate the
Fortran standard. It would also break a huge fraction of the existing
programs (including almost all of mine).
I'd find this so surprising that I suspect that you are either misinterpreting
the symptoms you are seeing, or perhaps you didn't correctly describe what
you meant.
How is it that you know there is a newline character in there? Did you
actually look at the character codes and find a character index values of
10 and/or 13 (I'm not entirely sure which you mean)? If so, I'd like to
see a small sample or I'll have trouble believing it.
Hmm. One possibility does occur to me. Is there any chance that you are
trying to read a file thagt is not a properly formatted text file for
the OS you are using? In that case, I could believe any of several behaviors.
For example, if you are trying to read a Dos-formatted file on a Unix
system, it would not be surprising to find that the buffer included
carriage return characters; that's because the carriage return is not
part of the UNix "newline" (bugt is part of the Dos one).
--
Richard Maine
email: my last name at domain
domain: summertriangle dot net
| |
| Thomas Lang 2005-04-06, 12:21 pm |
| Richard Maine wrote:
> Really? I'd find that *VERY* surprising.
:) - you're right!
The problem was a DOS cr+lf leftover - my fault, I apologize. I cancled
the post, but you two have been faster :)
br,
Tom
|
|
|
|
|