[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug? yea or nay.



Vapuser wrote:
> 
> I greatly simplified the structure in question to elucidate the point.
> 
> IDL> print,!version
> { mipseb IRIX unix 5.3 Nov 11 1999}
> 
> IDL> r={a:0.d, c:0L} & print,n_tags(r,/length),totsize(r)
> 16          12
> 

<snip>

> What say you? Bug or not?

>From the IDL online manual (I know you already know this, Vapuser. It's here for
completeness):

NTAGS
  KEYWORDS
    LENGTH

    Set this keyword to return the length of the structure, in bytes.

    Note - The length of a structure is machine dependent. The length
    of a given structure will vary depending upon the host machine.
    IDL pads and aligns structures in a manner consistent with the host
    machine's C compiler.

This sounds like a similar scenario I have encountered with COMMON blocks in F77 and
structures in F90 (to use or not to use the SEQUENCE statement? :o). If I want to read in
a series of numbers of different types, although my data structure consists of variables
adding up to N bytes, the actual amount of memory used _could_ be more depending on what
system I was on. I always presumed this was done because various OS's were "optimised" to
deal with data (i.e. store, retrieve) lined up on either 8-byte or 4-byte boundaries in
actual memory. The user shouldn't have to worry about the number of bytes (with padding)
in memory (unless you have *humungous* data structures).

I wouldn't consider it a bug, but it does seem rather, uh, lazy to return the _actual_
memory used rather than the sum size of the components when the latter is what is required
to define record sizes to read data - producing side effects such as you have found. I
though the one of the strengths of IDL was its system independence?

Maybe you can sell Kodak/RSI TOTSIZE() for IDL 5.4.1? :o)

BTW, on my linux box with IDL 5.4, print,n_tags(r,/length) = 12

paulv

-- 
Paul van Delst           A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP        Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274  There shallow draughts intoxicate the brain,
Fax:(301)763-8545        And drinking largely sobers us again.
pvandelst@ncep.noaa.gov                   Alexander Pope.