Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compaq Visual Fortran 6.6 to read UNIX unformatted file

23 views
Skip to first unread message

Chien-hui Liu

unread,
Sep 16, 2002, 9:53:47 PM9/16/02
to
Hi,

1. I ran the following file on IBM AIX.

program xxx

real*4 a(13)

.......processing

do j=1,20
write(10)(a(i),i=1,13)
end do

stop
end

2. Then I transfer back to Windows 2000. Try to use Compaq Visual
Fortran 6.6 to read it with the following file:

program xxx

real*4 a(13)

open(11,file='fort.10',status='old',form='unformatted')
do j=1,20
write(10)(a(i),i=1,13)
end do

stop
end

Then error message shows "illegal structure for unformatted".
I've noticed the file size is 1200bytes on IBM AIX.
If I ran the same program in Windows 2000 by Compaq VF6.6, then the
output file size is 1082bytes. If there's no extra data, it should be
4*13*20=1040bytes.
How come there's difference between the outputs of UNIX and Windows
2000?

How to read the unformatted file ran by UNIX by using visual fortran?
Could someone do me a favor?
Thank you very much.

Chien-hui Liu

Jan C. Vorbrüggen

unread,
Sep 17, 2002, 3:49:36 AM9/17/02
to
- How did you transfer the file?
- I know Wintel is little-endian, I suspect the AIX machine is big-endian.

Jan

Rob James

unread,
Sep 17, 2002, 7:26:50 AM9/17/02
to
Jan C. Vorbrüggen wrote:
> - I know Wintel is little-endian, I suspect the AIX machine is big-endian.

Yes, they have opposite endianness, alright. Most of us who have dealt
with both have run into that realization at some point. And don't
expect those record markers to be the same between CVF and XLF for
unformatted record files, either (not that I know for sure that they are
different). That would account for the file size discrepancy, and the
error message about the structure of the file not being valid for CVF.

--
Rob James


James Van Buskirk

unread,
Sep 17, 2002, 2:57:58 PM9/17/02
to

"Chien-hui Liu" <ch...@tit.edu.tw> wrote in message
news:5e084a37.02091...@posting.google.com...

> Then error message shows "illegal structure for unformatted".
> I've noticed the file size is 1200bytes on IBM AIX.
> If I ran the same program in Windows 2000 by Compaq VF6.6, then the
> output file size is 1082bytes. If there's no extra data, it should be
> 4*13*20=1040bytes.
> How come there's difference between the outputs of UNIX and Windows
> 2000?

It is most certainly possible to read the file in CVF, but
it will likely take some effort to do so. The court of last
appeal would be to open the file with FORM='BINARY' and
CONVERT='BIG_ENDIAN' in CVF which would allow you to read
the file if you can figure out what the extra data does so
that you could throw it out as it is read. You might find
things to be easier if you could change the kind of file you
write in AIX. If possible, I would look at the documentation
for the OPEN statement on both compilers to see if I could
find some extensions that make the two more compatible. As
alluded to above, the CONVERT and FORM specifiers are what
I would look at on the CVF side; hopefully you can find
something that makes sense on the AIX side. Would be nice
if both sides read and wrote IEEE-754 floating point...

0 new messages