Re: Program compiled on intel acting weired
From: John C. Bollinger (jobollin_at_indiana.edu)
Date: 04/20/04
- Next message: Paul Van Delst: "Re: Binary to ASCII"
- Previous message: Thomas Baruchel: "Re: [F77] storing bytes data"
- In reply to: MISHAL ALHARBI: "Re: Program compiled on intel acting weired"
- Next in thread: Richard Maine: "Re: Program compiled on intel acting weired"
- Reply: Richard Maine: "Re: Program compiled on intel acting weired"
- Reply: Haifang Li: "Re: Program compiled on intel acting weired"
- Reply: MISHAL ALHARBI: "problem fixed! - Re: Program compiled on intel acting weired"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 20 Apr 2004 09:01:49 -0500
MISHAL ALHARBI wrote:
> 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.
Perhaps the key to your problem is that you are using logical unit
number 6 for I/O to your file. Are you _trying_ to redirect I/O to the
default unit into a file? Richard seems to assume that you are, but I'm
not so sure. He did recommend that you not do that, and I'll second him
there.
Assuming, though, that redirection of console I/O is _not_ your plan,
assigning unit 6 to a user file is a bad idea, because that unit number
is the one most commonly "prewired" to standard output. (As unit 5 is
the one most commonly prewired to standard input.) Intel's would not be
the first Fortran to perform I/O redirection of the default unit (*) via
user files assigned unit 5 and/or 6, but by no means do all Fortran
implementations do so. To avoid portability problems, don't use these
particular unit numbers for user files. In fact, some, including me,
would recommend that you not assign any unit numbers less than, say, ten
to user files. I personally start at 20; that may be execessively
cautious, but there are plenty of unit numbers to go around.
It does sound like Intel Fortran is a bit buggy in this area, but that
doesn't solve your problem. Chances are that you will have to use a
different unit number. Take this opportunity to do as Richard advised
and use a variable (presumably a module variable) to hold the lun --
you'll have to change the unit numbers to _something_ else, and a
variable both gives you an easy way to change the actual number later
and documents (by way of its name) what that unit is for. This is what
I do for anything complex, but not necessarilly for quick, one-off programs.
John Bollinger
jobollin@indiana.edu
- Next message: Paul Van Delst: "Re: Binary to ASCII"
- Previous message: Thomas Baruchel: "Re: [F77] storing bytes data"
- In reply to: MISHAL ALHARBI: "Re: Program compiled on intel acting weired"
- Next in thread: Richard Maine: "Re: Program compiled on intel acting weired"
- Reply: Richard Maine: "Re: Program compiled on intel acting weired"
- Reply: Haifang Li: "Re: Program compiled on intel acting weired"
- Reply: MISHAL ALHARBI: "problem fixed! - Re: Program compiled on intel acting weired"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|