ASSOC and structures - structure size problem [message #8807] |
Mon, 28 April 1997 00:00  |
sdpp
Messages: 2 Registered: January 1997
|
Junior Member |
|
|
I'm trying to use ASSOC to link a structure with a large file.
The structure consists of lonarr(48) followed by intarr(14423). This pattern
being repeated 16036 times in the file.
I ASSOC the structure with the file (including 16252 byte offset for a file
header)
The structure size should be 29038 bytes , but HELP,/STRUCT gives it as 29040.
I would accept the 2 byte difference as a structure ID or something. But the
data values I'm getting are all wrong - suggesting that ASSOC is not mapping
the structure onto the file correctly, or it's using the wrong structure size
?
Can anyone explain this anomaly.
I'm using DEC Unix 3.2 on an Alpha.
Thanks
Steve
Anite Systems
Bristol UK
|
|
|
Re: ASSOC and structures - structure size problem [message #8868 is a reply to message #8807] |
Fri, 02 May 1997 00:00  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
sdpp@anitesystems.co.uk (Steve Phillips) writes:
> I'm trying to use ASSOC to link a structure with a large file.
> The structure consists of lonarr(48) followed by intarr(14423). This pattern
> being repeated 16036 times in the file.
> I ASSOC the structure with the file (including 16252 byte offset for a file
> header)
> The structure size should be 29038 bytes , but HELP,/STRUCT gives it as 29040.
> I would accept the 2 byte difference as a structure ID or something. But the
> data values I'm getting are all wrong - suggesting that ASSOC is not mapping
> the structure onto the file correctly, or it's using the wrong structure size
> ?
> Can anyone explain this anomaly.
> I'm using DEC Unix 3.2 on an Alpha.
I suspect that what is happening is that the structure is being padded to end
on a word boundary. You should be able to read in the first instance of your
structure correctly, but the alignment will be wrong for any others, so you'll
read in garbage data.
An alternative way to read the file would be to use the commands POINT_LUN to
move to a specific byte in the file, and READU to read in the data. For
example, if you wanted to read in the third structure, you'd enter the commands
IDL> POINT_LUN, UNIT, 16252 + 2*29038
IDL> READU, UNIT, MY_STRUCT
Bill Thompson
|
|
|
Re: ASSOC and structures - structure size problem [message #8898 is a reply to message #8807] |
Tue, 29 April 1997 00:00  |
Joseph M Zawodny
Messages: 24 Registered: March 1996
|
Junior Member |
|
|
Steve Phillips wrote:
>
> I'm trying to use ASSOC to link a structure with a large file.
>
> The structure consists of lonarr(48) followed by intarr(14423). This pattern
> being repeated 16036 times in the file.
>
> I ASSOC the structure with the file (including 16252 byte offset for a file
> header)
>
> The structure size should be 29038 bytes , but HELP,/STRUCT gives it as 29040.
>
> I would accept the 2 byte difference as a structure ID or something. But the
> data values I'm getting are all wrong - suggesting that ASSOC is not mapping
> the structure onto the file correctly, or it's using the wrong structure size
> ?
>
> Can anyone explain this anomaly.
Chances are that the problem is related to the odd number of 2-byte
integers in the second vector of your structure. Make a test file
with an even number (like 14424) of elements and I bet it will work.
Sorry, I do not have a fix for this though.
Good Luck.
JMZ
|
|
|