Re: runs with g77 3.2.2 but not with g77 3.3. Why?

From: Richard Maine (nospam_at_see.signature)
Date: 05/14/04


Date: 14 May 2004 14:45:56 -0700

pcoelho@usp.br (Paula) writes:

> I have a fortran code that reads an asc file and write it in a direct
> acess file.

Possibly incomplete information here. And I suspect the
incompleteness is the source of the problem. There are two separate
concepts here - formatted vs unformatted, and sequential vs direct
access. All 4 combinations exist.

By "asc", I am guessing you mean a formatted sequential file.
You then say you are writing it to a direct access file, but you
say nothing about whether that direct access file is formatted or
unformatted.

> cdue: formatted io not allowed
> apparent state: unit 18 named myfile
> lately writing direct unformatted external IO

This suggests to me that you are trying to do a formatted
write (which would be sensible enough - actually, either
formatted or unformatted could be sensible). But the
file was opened as unformatted.

I'm doubly suspicious because unformatted is the default for
direct access files (formatted direct access being fairly rare).
I'm betting that not only did you forget to mention to us that
your direct access file was unformatted, but you also forgot
to mention it to the compiler. Add a form="formatted" to the
OPEN to fix that. Note that formatted is the default for sequential
files, which is why you may be used to omitting it.

The fact that it worked with one compiler, although some evidence
of correctness, is not conclusive. Some compilers have extensions
to the standard. Or in this case, there is at least a fair chance
that the compiler didn't so much intentionally extend the standard
as just fail to notice the error and happened to work as you
desired.

P.S. Direct access formatted is moderately rare, though it does have
some application. I'll just assume that you know what you are doing
and do actually want direct access formatted. Be aware that the
result will not have line terminators and thus will not be readable
as a "normal" text file by most applications unless you explicitly
write line terminators yourself. Or perhaps you don't need a
normal text file.

I suppose the other possibility is that you made the opposite
error and, instead of the OPEN being in error, you intended
an unformatted direct access file, but accidentally have a formatted
writ eto it.

-- 
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