Re: Program compiled on intel acting weired

From: MISHAL ALHARBI (mishal_at_verizon.net)
Date: 04/20/04


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



Relevant Pages

  • Re: Need Help deleting record from text file
    ... Who said you need to read an entire array into memory just to access a small portion of it? ... If you write the data in a suitable format you can later open the data file by reading just a relatively small header chunk and then read in the elements or the portion of data you require. ... How is using a database going to speed up that operation! ...
    (microsoft.public.vb.general.discussion)
  • Re: C++ programming: keeping count of data items read from file
    ... In a C++ program I am reading a data file for later processing and ... The data file is just a text file with N lines with C doubles in each ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: C++ programming: keeping count of data items read from file
    ... In a C++ program I am reading a data file for later processing and computations. ... The data file is just a text file with N lines with C doubles in each line. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". ...
    (Debian-User)
  • Re: C++ programming: keeping count of data items read from file
    ... While reading that data file, I want to keep track of data ... The data file is just a text file with N lines with C doubles in each ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: hex represenation from string in perl
    ... I tried reading the FAQ, ... > It is out of frustration and wanting to learn. ... What was wrong with the suggestion John gave you? ...
    (comp.lang.perl.misc)