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

Home » Public Forums » archive » Trouble reading unformatted f77 (unix) integers?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Trouble reading unformatted f77 (unix) integers? [message #4158] Wed, 10 May 1995 00:00
Brett Hennig is currently offline  Brett Hennig
Messages: 3
Registered: May 1995
Junior Member
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? [message #4246 is a reply to message #4158] Wed, 10 May 1995 00:00 Go to previous message
Brett Hennig is currently offline  Brett Hennig
Messages: 3
Registered: May 1995
Junior Member
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!
Re: Trouble reading unformatted f77 (unix) integers? [message #4248 is a reply to message #4158] Wed, 10 May 1995 00:00 Go to previous message
bowman is currently offline  bowman
Messages: 121
Registered: September 1991
Senior Member
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
Re: Trouble reading unformatted f77 (unix) integers? [message #4249 is a reply to message #4158] Wed, 10 May 1995 00:00 Go to previous message
ec10576 is currently offline  ec10576
Messages: 2
Registered: March 1995
Junior Member
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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Trouble reading unformatted f77 (unix) integers?
Next Topic: Re: Zeiger in IDL

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

Current Time: Wed Oct 08 13:44:08 PDT 2025

Total time taken to generate the page: 0.00872 seconds