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

openr,/xdr & readu,structure problems



Greetings,
I'd appreciate a hint or two is someone has
ran into a problem similar  to the one that I have.
(A deja.com search hasn't helped me.)

I have received a new "xdr" data file that I'm trying
to read in using idl5.2.1 on winnt.
(also tried on idl5.3beta, same problem)

The problem is that when I read in to a defined structure,
it sometimes (rarely) reads in a huge chunk. To be specific,
the structure read is only 92 bytes, but the READU command
seems to send the filepointer to the end of the file or
something like that). The structure will now contain
junk information.

I suspect that this is because of my platform,
since this code works fine on an SGI, but not on WinNT.
Anyone know why this is happening, and how to handle
it properly?


-------- more detail -----------------

I define a structure containing floats, integers and
arrays of integers, and arrays of floats (no strings, no bytes).
The size of the structure is 15 tags, size = 92 bytes.
This corresponds to a 104 byte chunk in the xdr-file.

Here is the (edited) code for the structure:
  int = 0				; integer type (2-byte integer)
  time_arr = intarr(6)			; time array
  time_ind = 0L				; unix time index
  snr_pow_arr = fltarr(no_channels > 1)	; snr and power array
  flt = 0.
last_analysis =   {$
TIME		:	time_arr, $	; record time - real
UNIX_TIME	:	time_ind, $	; record time - unix
RANGE		:	flt,$		; record range
ERROR		:	int,$		; error code
APP_VEL		:	fltarr(2),$	; apparent velocity
VELOCITY	:	fltarr(2),$	; true velocity
VERT_VEL	:	flt,$		; vertical velocity
FAD_TIME	:	flt,$		; fading time
CORR_FAD_TIME	:	flt,$		; corrected fading time
PATT_SCALE	:	flt,$		; pattern scale
AXIAL_RATIO	:	flt,$		; axial ratio
AXIAL_ROT	:	flt,$		; axial rotation
PTD		:	int,$		; percentage time discrepancy
SNR		:	snr_pow_arr,$	; signal to noise ratio
POWER		:	snr_pow_arr $	; signal power
}

print, last_analysis
{       0       0       0       0       0       0
           0     0.000000       0
     0.000000     0.000000
     0.000000     0.000000
     0.000000     0.000000     0.000000     0.000000     0.000000
0.000000       0
     0.000000     0.000000     0.000000
     0.000000     0.000000     0.000000
}


Here are the commands to open and read in the data:
    openr,readlun,filename,xdr=1,/get_lun    ; Input file
    fileinfo_before = fstat(readlun)
    readu,readlun,last_analysis
    fileinfo_after = fstat(readlun)


----------------------------------
----------------------------------
---FILE INFO---
-----------------BEFORE READ-----------------
** Structure FSTAT, 12 tags, length=36:
   UNIT            LONG               100
   NAME            STRING    'd:\fca\19990926_fca.fca'
   OPEN            BYTE         1
   ISATTY          BYTE         0
   ISAGUI          BYTE         0
   INTERACTIVE     BYTE         0
   READ            BYTE         1
   WRITE           BYTE         0
   TRANSFER_COUNT  LONG                 0
   CUR_PTR         LONG                 0
   SIZE            LONG           1241760
   REC_LEN         LONG                 0
-----------------after READ-----------------
** Structure FSTAT, 12 tags, length=36:
   UNIT            LONG               100
   NAME            STRING    'd:\fca\19990926_fca.fca'
   OPEN            BYTE         1
   ISATTY          BYTE         0
   ISAGUI          BYTE         0
   INTERACTIVE     BYTE         0
   READ            BYTE         1
   WRITE           BYTE         0
   TRANSFER_COUNT  LONG                 0
   CUR_PTR         LONG             32857
   SIZE            LONG           1241760
   REC_LEN         LONG                 0


The point I am making is that the "after" file pointer
is at 32857, when it really should be 104
>   CUR_PTR         LONG             32857

So what is going on?
Thanks a lot,
cheers,
bob

--
¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`
R.G. Stockwell
stockwell at co-ra.com
Colorado Research Associates
3380 Mitchell Lane


Sent via Deja.com http://www.deja.com/
Before you buy.