IDL/FORTRAN File Reading [message #66690] |
Thu, 04 June 2009 10:04  |
robparker23
Messages: 10 Registered: March 2009
|
Junior Member |
|
|
This might be a bit of a strange request but I'm hoping we have some
multi-skilled people here who might be able to help.
I have a file written by some fortran code as a "f77_unformatted"
file.
I've managed to figure out how to read this in in IDL and I've done as
follows:
header = strarr(80,1)
openr,unit,filename, /f77_unf,/get_lun
i=0
while ~ eof(unit) do begin
readu,unit,header
b = 0.0d0
c = 0.0d0
e = 0.0d0
f = 0L
g = 0.0
readu,unit,b,c,e,f,nlo
if f EQ -99 then break
a=dblarr(f,1)
readu,unit,a
case i of
0: BEGIN
data=a
END
data=[data, a]
END
endcase
i=1
endwhile
close, unit
free_lun, unit
This reads in b,c,d,e,f and then f is used to determine how big a is
and then that chunk of data is read in. It then repeats with a new
value of f being read in which defines a new chunk of a and so on
until the EOF.
That's probably a lot simpler than I described it.
Anyway my problem is that whilst I can do this in IDL, ironically I
can't figure out how to do it in FORTRAN. As i'm just about at the
"hello world" stage that's not surprising but I thought it would
simply be a case of defining my variables as the correct type and then
just using the fortran READ command but that spits out the wrong
values. I was hoping that someone capable in both IDL and FORTRAN
might be able to "translate" between the two for me.
|
|
|