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

Home » Public Forums » archive » reading unformatted fortran
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
reading unformatted fortran [message #18202] Mon, 13 December 1999 00:00 Go to previous message
Morwenna Grifiths is currently offline  Morwenna Grifiths
Messages: 2
Registered: December 1999
Junior Member
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
[Message index]
 
Read Message
Read Message
Previous Topic: Messy output in profiler
Next Topic: Re: Wt/Motif Interface (was: Real Number on PV-WAVE)

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

Current Time: Fri Oct 10 09:58:40 PDT 2025

Total time taken to generate the page: 0.15788 seconds