Re: Program compiled on intel acting weired
From: MISHAL ALHARBI (mishal_at_verizon.net)
Date: 04/20/04
- Next message: Roman: "Re: character array initialization"
- Previous message: Michael Metcalf: "Fortran Resources (April, 2004)"
- In reply to: Richard Maine: "Re: Program compiled on intel acting weired"
- Next in thread: John C. Bollinger: "Re: Program compiled on intel acting weired"
- Reply: John C. Bollinger: "Re: Program compiled on intel acting weired"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 20 Apr 2004 10:21:34 GMT
Thanx Richard for the quick reply,
The data file is open for read but then it gets overwritten by what
WRITE(*,*) is doing. When the READ statment tries to access the file, I get
the error message "read after write". I understand the reason for the error
but I don't understand why things got "short circuited" between the data
file and the screet output. In other words, why did WRITE(*,*) points to
the file that was opened for READ. The program runs with no problems when
compiled with CVF which overrules any bugs in the code. This is my first
attempt to use Intel Fortan 7 and I am not sure if there are cmpiler
specific issues that cause this.
Mishal
"Richard Maine" <nospam@see.signature> wrote in message
news:m165bvmv1c.fsf@macfortran.local...
> "MISHAL ALHARBI" <mishal@verizon.net> writes:
>
> > 3- program then will give the error " read after write" and exit
> >
> > I have to say that I ran out of ideas to debug it,
>
> Well, are you in fact ever reading from this file? If so,
> that is likely to be a problem. Reading from the standard
> output file is problematic at best. I'd first trace down
> what statement is causing the error. (I'm not enough of
> a CVF or Intel Fortran expert to give you any specialized
> advise on how to do that other than the obvious generic
> approaches.) If that is a READ statement and it is
> indeed reading from the output file, then you'll need to
> do some digging to figure out what it is really trying to
> do.
>
> The problem that the message refers to is that if the last
> thing you did to a file was write to it, you will be at the
> end of the file, so reading will never make sense. You'd
> need to rewind or backspace first in order to have any chance
> of being useful. But in your case, if this file is the
> standard output file, that adds extra complications.
>
> > anyone have any idea why
> > a program would even direct a terminal write into a file ?
>
> There are *LOTS* of possible reasons for that. So many that I find it
> hard to name just one or two. Since pretty much every current shell
> has special syntax to achieve things like that, its a pretty good
> guess that someone somewhere might have had a reason to want it. :-)
>
> Start with
>
> 1. Wanting a permament record of something.
>
> 2. Having an output to large for a single screen.
>
> 3. Wanting to process the output with some other program.
>
> 4. Etc, etc.
>
> And yes, these all apply to output that might, in some other
> situation, go directly to a terminal screen.
>
> In my own production code I avoid writing to unit * particularly
> because that makes it so compiler-dependent how to deal with
> redirecting it. I find it a lot easier to do redirection by
> using a variable for the unit number. Then, I can open a
> different unit and set the variable to that new unit number;
> that is far more portable than figuring out how to make
> unit 6 (or whatever, but usually 6) refer to some other file.
>
> --
> Richard Maine | Good judgment comes from
experience;
> email: my first.last at org.domain | experience comes from bad judgment.
> org: nasa, domain: gov | -- Mark Twain
- Next message: Roman: "Re: character array initialization"
- Previous message: Michael Metcalf: "Fortran Resources (April, 2004)"
- In reply to: Richard Maine: "Re: Program compiled on intel acting weired"
- Next in thread: John C. Bollinger: "Re: Program compiled on intel acting weired"
- Reply: John C. Bollinger: "Re: Program compiled on intel acting weired"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|