I'm having difficulty reading unformatted fortran in IDL. I think I am
doing just what the manual tells me to, but I assume I'm not! Here's a
sample program.
The fortran code to write the unformatted data:
program write_out
integer bb
real aa
write(6,*) 'in write_out now'
open(unit=15,file='t1',form='unformatted',status='unknown')
bb = 23
write(15) bb
close(unit=15)
open(unit=16,file='t2',form='unformatted',status='unknown')
aa=47.0
write(16) aa
close(unit=16)
stop
end
The IDL code that doesn't work:
a=1 & b=1 & c=1 & d=1 & e=1 & f=1 & aa=1.0
openr,1,'t1',/f77_unformatted
readu,1,a
close,1
print,'should be',a ; gives an answer of 0
openr,1,'t1',f77_unformatted
readu,1,a,b,c,d,e,f
print,'but it is: ',a,b,c,d,e,f ; gives answers of 0 4 0 23 0 4, so the
4th number is correct
close,1
openr,2,'t2',f77_unformatted
readu,2,aa
print,'real number ',aa ; gives an answer of 5.60519e-45, no idea why!
close,/all
So it seems that IDL is reading some extra characters before and after
the integer, and I have no idea what's happening with the real data.
I'm running both the fortran and IDL on the same machine (a silicon
graphics).
Can anyone help me, please?
Morwenna
|