Re: help for reading a binary file
"phywho" <phywho@gmail.com> wrote in message
news:1150811893.096266.323250@i40g2000cwc.googlegr oups.com...
> Hi,everybody here!
>
> I'm using a Fortran code based on the 386|DOS-Extender, a 32-bit
> protected mode development tool developped by Phar Lap Software, Inc.
>
> It will generate a binary data file after running. Now I need to read
> out the data. The manual mentioned the format of this as follows:
> ================================================== ==============
> The file has two records. In the 1st record, there are three variables
> (the first one is a 4-byte integer and the other two are 8-byte double
> precision real variables). The second record contains 6*1000 8-byte
> double precision real variables (array(I,J),I=1,6),J=1,1000).
> ================================================== ==============
>
> I edited a code using lf95 as follows:
> ================================================== ==============
> program test
> double precision bb,cc,array(6000)
> integer*4 aa
> character*32 testinputfile
> testinputfile = 1.dat'
Missing apostrophe.
> open(22,file=testinputfile ,status='old',form='unformatted')
> read(22,*)aa,bb,cc,(array(i),i=1,6000)
> write(5,*)aa,bb,cc,(array(i),i=1,6000)
> end
> ================================================== ==============
>
> Running my code, I got a file, fort.5. Though the total number of the
> gotten data is right as my expection, but the values look very strange.
> For example, the gotten aa is 858980352 which should be 1000. Other
> values like 3.498815625006737E-310 or -2.280122331273626E+16, their
> orders are very large.
>
> Could anyone helps me out? Many thanks in advance!
Won't you need two READs?
One for aa, bb, cc, and the other for array.
The above READ will read only one record.
|