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

Home » Public Forums » archive » Reading data with structures
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
Reading data with structures [message #3062] Mon, 07 November 1994 16:10 Go to next message
tonym is currently offline  tonym
Messages: 14
Registered: May 1994
Junior Member
I am having problems reading FORTRAN unformatted data
with idl arrays.
For example, the following works fine:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
data = replicate ( structure_template, nrecords )

for i=0L,long (nrecords-1) do begin
readu,unit,structure_template
data (i) = structure_template
endfor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
But the following doesn't:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
readu,unit,data
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

In this case, I get an "End of file encountered" error.

What gives?

-Tony Mannucci
tonym@lurleen.jpl.nasa.gov
Tony Mannucci Jet Propulsion Laboratory
tonym@lurleen.jpl.nasa.gov 4800 Oak Grove Drive
M/S 238-600
Voice: (818)354-1699 Fax: (818)393-4965 Pasadena, CA 91109
Re: Reading data with structures [message #3136 is a reply to message #3062] Fri, 11 November 1994 02:04 Go to previous message
sjt is currently offline  sjt
Messages: 72
Registered: November 1993
Member
Tony Mannucci (tonym@lurleen.jpl.nasa.gov) wrote:
: I am having problems reading FORTRAN unformatted data
: with idl arrays.
: For example, the following works fine:
: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
: data = replicate ( structure_template, nrecords )

: for i=0L,long (nrecords-1) do begin
: readu,unit,structure_template
: data (i) = structure_template
: endfor
: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
: But the following doesn't:
: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
: readu,unit,data
: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

: In this case, I get an "End of file encountered" error.

: What gives?

: -Tony Mannucci
: tonym@lurleen.jpl.nasa.gov
: Tony Mannucci Jet Propulsion Laboratory
: tonym@lurleen.jpl.nasa.gov 4800 Oak Grove Drive
: M/S 238-600
: Voice: (818)354-1699 Fax: (818)393-4965 Pasadena, CA 91109

The clue is in the explanation at the top: Fortran Unformatted Data

Because fortran is an ancient language, (1957 or thereabouts) it assumes
all i/o is record oriented, even on stream-type devices. In order to
impose this pseudo-record structure on a Unix box, a number of extra
bytes are written indicating the length of record in a fortran
unformatted write. IDL handles this transparently when the file is opened
with the F77_UNFORMATTED key, but it can only read one pseudo-record at
at time and if you try to read more than the record length it will get
confused. (I would expect similar behaviour from the real records of a
VMS spanned file).

--
+------------------------+---------------------------------- --+---------+
| James Tappin, | School of Physics & Space Research | O__ |
| sjt@xun8.sr.bham.ac.uk | University of Birmingham | -- \/` |
| "If all else fails--read the instructions!" | |
+----------------------------------------------------------- --+---------+
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: PostScript Dump
Next Topic: Shaded fills with POLYFILL on PostScript

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

Current Time: Wed Oct 08 19:41:58 PDT 2025

Total time taken to generate the page: 0.00454 seconds