Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Trouble reading unformatted f77 (unix) integers?
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.. ? ?
Re: Trouble reading unformatted f77 (unix) integers?
thanks to davidf@alpha.pr1.k12.co.us (David Fanning) for replying. it was another easy problem: The problem here is that IDL integers (x=0) are two byte integers and your Fortran integers are four byte integers. Initialize your variables like this: x=0L & y=0L & z=0L and it worked!
In article <3oqmh1$nb6@post.gsfc.nasa.gov>, thompson@orpheus.nascom.nasa.gov (William Thompson) wrote: > 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. Having run into a number of gotchas with short integers (including this one), I do wish there was a way to make LONG the default integer type in IDL. Ken Bowman -- Dr. Kenneth P. Bowman 409-862-4060 Associate Professor 409-862-4132 fax Department of Meteorology bowman@csrp.tamu.edu Texas A&M University PP-Glider College Station, TX 77843-3150
I have experienced similar problems, in particular when I try to read integers. My guess has been that it is confused about reading short vs. long integers, but I would love to hear something more definitive. -Elaine Chapin http://www.cen.uiuc.edu/~ec10576/ e-chapin@uiuc.edu