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

Home » Public Forums » archive » Re: reading f77_unformatted and writing it as ascii file
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
Re: reading f77_unformatted and writing it as ascii file [message #42140] Tue, 21 December 2004 15:13
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <cqa9h7$3np$1@news.tamu.edu>, "Jaehyung Yu" <jaeyu@tamu.edu>
wrote:

> Dear all,
>
> I downloaded f77_unformatted data file and tried to extract the information
> to ascii format.
>
> However, the output file I extracted has only one value of "0".
>
> The dataset is 1400x1400 float array. I used the following lines. Can
> somebody help me what I did wrong?
>
> Thank you in advance.
>
> IDL> file = 'bal_flux.bas_smooth35'
> IDL> openr, lun, file, /f77_unformatted, /get_lun
> IDL> nx = 0L & ny = 0L
> IDL> readu, lun, nx, ny
> IDL> print, nx, ny
> 1400 1400
> IDL> bal_flux = fltarr(nx, ny)

IDL> READU, lun, bal_flux

> IDL> help, bal_flux
> BAL_FLUX FLOAT = Array[1400, 1400]
> IDL> free_lun, lun
> IDL> outfile = 'outfile.txt'
> IDL> openw, lun_out, outfile, /get_lun
> IDL> printf, lun_out, bal_flux
> IDL> free_lun, lun_out
>
> Your help is very important and urgent to me.
>
> Sincerely,
>
>

You forgot to read bal_flux. This assumes the F77 file was written with
two WRITES. It should have ((1400 x 1400) + 2 + 4) x 4 bytes.

Ken Bowman
Re: reading f77_unformatted and writing it as ascii file [message #42141 is a reply to message #42140] Tue, 21 December 2004 15:13 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jaehyung Yu writes:

> I downloaded f77_unformatted data file and tried to extract the information
> to ascii format.
>
> However, the output file I extracted has only one value of "0".
>
> The dataset is 1400x1400 float array. I used the following lines. Can
> somebody help me what I did wrong?
>
> Thank you in advance.
>
> IDL> file = 'bal_flux.bas_smooth35'
> IDL> openr, lun, file, /f77_unformatted, /get_lun
> IDL> nx = 0L & ny = 0L
> IDL> readu, lun, nx, ny
> IDL> print, nx, ny
> 1400 1400
> IDL> bal_flux = fltarr(nx, ny)
> IDL> help, bal_flux
> BAL_FLUX FLOAT = Array[1400, 1400]
> IDL> free_lun, lun
> IDL> outfile = 'outfile.txt'
> IDL> openw, lun_out, outfile, /get_lun
> IDL> printf, lun_out, bal_flux
> IDL> free_lun, lun_out
>
> Your help is very important and urgent to me.

Uh, I think you forgot to read the data into
your bal_flux array. You have made it the right
size (and you have filled it with zeros), but
you didn't read the data out of the file.
You probably need another READU in there
somewhere. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: reading f77_unformatted and writing it as ascii file
Next Topic: questionable display of an IDLgrPolygon Object with some transparency

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

Current Time: Sat Oct 11 06:07:59 PDT 2025

Total time taken to generate the page: 1.15738 seconds