Home > Archive > Fortran > May 2004 > runs with g77 3.2.2 but not with g77 3.3. Why?
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]
| Author |
runs with g77 3.2.2 but not with g77 3.3. Why?
|
|
|
| I have a fortran code that reads an asc file and write it in a direct
acess file. I'm running it with no problem at all in
GNU F77 version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
(i386-redhat-linux)
I tried to use the same code in
GNU F77 version 3.3 20030226 (prerelease) (SuSE Linux)
(i486-suse-linux)
and though it compiles with no problem, it didn't work and I have the
message
cdue: formatted io not allowed
apparent state: unit 18 named myfile
lately writing direct unformatted external IO
Abort
I don't have a clue about how to fix this. What's wrong?
Thx for any help
Paula
| |
| Richard Maine 2004-05-14, 6:31 pm |
| 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
| |
| Paula 2004-05-16, 10:31 am |
| Hi Richard,
I did think that 'direct' is the same as 'unformatted' and 'asc' is
the same as 'formatted' (my ignorance).
I tried to add the form='unformatted' explicitaly in my open statement
and it worked! Then I discovered in gcc site that this compiler
version in particular ommits the default 'unformatted' for direct
access, and opens the file as formatted.
Anyway, now it is working, and it was good to learn to be as specific
as possible in the code, not to depends on compiler's defaults...
Thanks,
Paula
Richard Maine <nospam@see.signature> wrote in message news:<m13c62of6z.fsf@macfortran.local>...
> pcoelho@usp.br (Paula) writes:
>
>
> 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.
>
>
> 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.
|
|
|
|
|