help reading fortran generated binary data...
- From: "Jeff Godfrey" <jeff_godfrey@xxxxxxxxx>
- Date: Wed, 17 Aug 2005 16:36:03 GMT
Hi All,
First, for those not interested in the "long" story (below), here's my
basic problem...
I've read a value from binary file using the following code:
binary scan $binaryData @${offset}d1 theData (1 double-precision floating
point value)
The value *should* be any of 0, 90, 180, or 270.
What I get instead is 4 variations of an *extreme* (large or small) number,
such as:
5.4388530464437965e+185
So, is there some magic that needs to be performed on the above to extract
the value I'm actually after?
Details below...
--------------------------------------------------------------------------------------
I have a tcl program designed to read an old Fortran Unformatted Sequential
file format (as described in (much) earlier threads). Up until know, I
have only needed certain data from the file - which I have been able to
successfully retrieve. Up until now, I have just "read through" data that
I didn't care about. Now, I have a need to use a few pieces of data that I
used to just ignore. Ultimately, I'm having trouble pulling "sensible"
data from this section of the file and thought someone could give me a push
in the right direction...
Basically, I have some old FORTRAN code that is capable of reading the same
file - which I have used as a guide when writing my tcl version. In the
case of the data in question, the FORTRAN code reads the data into a common
block defined as follows:
INTEGER NUMEX2,EXTNUM
REAL*8 EXTORI,EXTX,EXTY,EXTZ
LOGICAL EXTMIR
INTEGER*2 EXTASM,EXTSUB,EXTPAR,EXTJOB
CHARACTER*1 EXTSTK(MAXSTK)
INTEGER EXTDUM(MAXSTK+12)
EQUIVALENCE(EXTORI,EXTDUM)
COMMON/NSTEXT/EXTORI,EXTX,EXTY,EXTZ,EXTMIR,EXTASM,EXTSUB,
* EXTPAR,EXTJOB,EXTNUM,EXTSTK,NUMEX2
The FORTRAN reads the data into the above common block by reading a known
number of INTEGER values into the EXTDUM array as defined above. The code
for the read is as follows:
IF (NUMEX2.GT.0)
* READ(FIL,ERR=900,END=900)(EXTDUM(I),I=1,NUMEX2)
Again, currently I am successfully "reading through" this data (which is
required so the read process doesn't get lost), but now I need to "keep"
some of it. What I'm currently after is the data stored in the EXTORI
variable above - which is defined as a REAL*8.
So, once I'm looking at the proper section of the file, it seems to me that
the following should return the proper data:
binary scan $binaryData @${offset}d1 theData
While this seems to read the proper "amount" of data (again, I know this
because if I don't account for the data, the read "gets lost" and the
process will hang), the resulting value is not sensible. The values stored
at this location in the file are angles, and are basically 0, 90, 180, or
270 (as returned by the original FORTRAN reader). The value stored my the
tcl "theData" variable above contains *huge* exponent values, both positive
and negative (depending upon the file being read). For example, I might
get the following back:
5.4388530464437965e+185
Interestingly, I only get 4 different values back (which again should
equate to 0, 90, 180, and 270), so I *think* I'm getting the correct data,
and likely just not interpreting it correctly.
So, is there some mathematical magic that needs to performed on the above
value to reveal the number I'm really after?
Thanks for any input, as I'm really stumped here...
Jeff
.
- Follow-Ups:
- SOLVED - help reading fortran generated binary data (LONG)
- From: Jeff Godfrey
- Re: help reading fortran generated binary data...
- From: Rob Ratcliff
- Re: help reading fortran generated binary data...
- From: Uwe Klein
- Re: help reading fortran generated binary data...
- From: Helmut Giese
- Re: help reading fortran generated binary data...
- From: James Littlefield
- SOLVED - help reading fortran generated binary data (LONG)
- Prev by Date: Re: Dust Mote Web Server
- Next by Date: Re: help reading fortran generated binary data...
- Previous by thread: Dust Mote Web Server
- Next by thread: Re: help reading fortran generated binary data...
- Index(es):
Relevant Pages
|