comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Trouble reading unformatted f77 (unix) integers?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Trouble reading unformatted f77 (unix) integers? [message #4155] Wed, 10 May 1995 00:00 Go to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
Brett Hennig <bretth@lovelace.maths.monash.edu.au> writes:

> Here's the problem:
> The F77 code:
> open(unit=51,name='test1.dat',status='unknown',form='unforma tted')
> write(51)1,2,3
> close(51)
> end

> The idl code(that doesn't work):

> openr,n,'test1.dat',/get_lun,/f77_unformatted
> x=0 & y=0 & z=0
> readu,n,x,y,z
> print,x,y,z -----> 1 0 2
> free_lun,n
> end

> Code that does:
> openr,n,'test1.dat',/get_lun,/f77_unformatted
> x=0 & y=0 & z=0 & dum1=0 & dum2=0
> readu,n,x,dum1,y,dum2,z
> print,x,dum1,y,dum2,z -----> 1 0 2 0 3
> free_lun,n
> end

> is idl not interpreting the input correctly? or.. ? ?

Your problem is very simple. The default integer data type in FORTRAN takes up
four bytes (INTEGER*4). In IDL parlance, this is known as a long integer. The
default IDL integer type is a short integer which only takes up two bytes.

The following code should work correctly.

openr,n,'test1.dat',/get_lun,/f77_unformatted
x=0L & y=0L & z=0L
readu,n,x,y,z
print,x,y,z
free_lun,n
end

As should this.

openr,n,'test1.dat',/get_lun,/f77_unformatted
xyz=lonarr(3)
readu,n,xyz
print,xyz
free_lun,n
end

Bill Thompson
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Maker Interchange Format device driver
Next Topic: Trouble reading unformatted f77 (unix) integers?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 12:49:54 PDT 2025

Total time taken to generate the page: 0.16027 seconds