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

Home » Public Forums » archive » Re: Associated reads on Unix/f77 binaries
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: Associated reads on Unix/f77 binaries [message #5603] Mon, 22 January 1996 00:00
hahn is currently offline  hahn
Messages: 108
Registered: November 1993
Senior Member
franz@bikini.gsfc.nasa.gov (Bryan A. Franz) wrote:

> Has anybody managed to do associated reads on files generated by f77 under
> Unix ?

> I have RTFM, which states that you can't do associated reads on files
> generated from FORTRAN 77 under Unix. Apparently, f77 sticks a longword
> containing the number of bytes before and after each logical record. IDL's
> readu accounts for the extra bytes, but assoc does not. It seems to me that I
> should still be able to do the associated reads, if I just added a dummy
> longword on either side of my datastructure, but it does not seem to work.
On Sun, 21 Jan 1996 22:38:33, you wrote:

> Has anybody managed to do associated reads on files generated by f77 under
> Unix ?

> I have RTFM, which states that you can't do associated reads on files
> generated from FORTRAN 77 under Unix. Apparently, f77 sticks a longword
> containing the number of bytes before and after each logical record. IDL's
> readu accounts for the extra bytes, but assoc does not. It seems to me that I
> should still be able to do the associated reads, if I just added a dummy
> longword on either side of my datastructure, but it does not seem to work.

Fortran allows to write binary data without adding the record
length long word: The output file must be opened as direct access
file which implies constant record length. And this is what is
actually expected by IDL when ASSOC a piece of data to a varible.

Hope this help
Norbert Hahn
Re: Associated reads on Unix/f77 binaries [message #5606 is a reply to message #5603] Mon, 22 January 1996 00:00 Go to previous message
nhbkmich is currently offline  nhbkmich
Messages: 8
Registered: January 1996
Junior Member
Bryan A. Franz (franz@bikini.gsfc.nasa.gov) wrote:
: Has anybody managed to do associated reads on files generated by f77 under
: Unix ?

: I have RTFM, which states that you can't do associated reads on files
: generated from FORTRAN 77 under Unix. Apparently, f77 sticks a longword
: containing the number of bytes before and after each logical record. IDL's
: readu accounts for the extra bytes, but assoc does not. It seems to me that I
: should still be able to do the associated reads, if I just added a dummy
: longword on either side of my datastructure, but it does not seem to work.

There are two kinds of unformatted files in Fortran: access='sequential' and
access='direct'. The latter one is equivalent to IDL's associated IO, all
records must have the same size and are reached by index. Under UNIX these files
don't contain recordlength information and reading them using ASSOC works fine.

Files written by Fortran with access='sequential' (the default!) may contain
records of different sizes, thus reading by ASSOC might fail.

But the follwing example for reading a sequentially written file with records
of equal sizes works (at least on HP-UX):

Fortran writing square numbers of 1 to 10 into 'unfo.dat':

program unfo
implicit none
integer i
open(1, file='unfo.dat', form='unformatted', access='sequential')
do i=1,10
write(1) i**2
end do
close(1)
end


IDL reading 'unfo.dat' by ASSOC:

pro unfo
openr,unit,'unfo.dat',/get_lun
buf={dummy1:0L, value:0L, dummy2:0L}
unf=assoc(unit,buf)
for i=0,9 do begin
buf=unf(i)
print,buf.value
endfor
free_lun,unit
end
Re: Associated reads on Unix/f77 binaries [message #5609 is a reply to message #5603] Mon, 22 January 1996 00:00 Go to previous message
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
In article <franz.8.0016A52E@bikini.gsfc.nasa.gov>, franz@bikini.gsfc.nasa.gov (
Bryan A. Franz) writes:
||>
|> Has anybody managed to do associated reads on files generated by f77 under
|> Unix ?
|>
|> I have RTFM, which states that you can't do associated reads on files
|> generated from FORTRAN 77 under Unix. Apparently, f77 sticks a longword
|> containing the number of bytes before and after each logical record. IDL's
|> readu accounts for the extra bytes, but assoc does not. It seems to me that
I
|> should still be able to do the associated reads, if I just added a dummy
|> longword on either side of my datastructure, but it does not seem to work.
|>

I think this should work. f77's idea of a logical record need not be
the same as your idea of a logical record, though! If you write one
(of your) record(s) with multiple WRITE statements, I think f77
decides that there's one record for each WRITE statement. You should
really take a look at the format of the file itself to make sure.
Use e.g., od (octal dump -- use "-h" to get hex, which I prefer) too look
at it. Once you get the number (and placement) of extra longwords
correct, it should work.

Stein Vidar
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: READU problems in IDL 4.0.1 for Windows
Next Topic: Digitize-Board

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

Current Time: Fri Oct 10 10:26:11 PDT 2025

Total time taken to generate the page: 0.79752 seconds