Re: Reading string data from binary f77 files? [message #1637 is a reply to message #1636] |
Thu, 06 January 1994 15:18  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
scott@abyss.ATMOS.ColoState.Edu (Scott Denning) writes:
> I have binary files of model output that are set up with a bunch of header
> info, including a list of the names of the fields contained in the file.
> The files are written in IEEE binary by fortran 77 programs. I can read
> everything just fine into IDL by opening the file code like
> ..
> ARRAY1 = FLTARR(im,jm,lm)
> OPENR, 1, 'model.output', /F77_UNFORMATTED
> READU, 1, ARRAY1
> ..
> etc.
> The only trouble seems to be in reading the strings which are supposed to
> be the names of the fields (titles for the plots I make with IDL). I have
> been trying variations on
> title = StrArr(100)
> readu, 1, title
> All I get is an array of 100 nulls.
> Even reading a single character string like this:
> name = '123'
> readu, 1, header
> doesn't work.
> Any ideas?
The way to do this is to create a byte array with the correct number of
characters, read this into IDL, and then convert it to string. Assuming that
you're trying to read a title string with 100 characters in your example above,
this should do the trick:
title = bytarr(100)
readu, 1, title
title = string(title)
Bill Thompson
|
|
|