Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems reading binary file

Status
Not open for further replies.

marcelosousa1

Technical User
Sep 3, 2008
1
CA
I am having problems reading a binary file in FORTRAN. I know that the file was generated by the code below:

open(7,file='hctd1_kxx.dat',form='unformatted')
...
write(7) iscl
write(7) inode,npoints
write(7) (kxm(i)*(10**(prop(i))),i=1,npoints)
close(7)

iscl, inode, npoints are integer*4 and kxm(), prop() are real*4

I am trying to read the file using the code below (variables have consistent data types and sizes):

open(11,file='hctd1_kxx.dat',status='old', form='unformatted', ACTION='READ')
...
read(7) iscl
read(7) inode,npoints
read(7) (single(i),i=1,npoints)

The program reads OK until it reaches the line above, where it always crashes after performing 256 iterations (it should go to npoints=406924).

I tried different input files and opening the file using different options for the CONVERT specifier and it keeps crashing after the first 256 entries.

The error message I get is the following: “forrtl: severe (67): input statement requires too much data”.

Does anyone have any suggestions?

Thanks a lot for your attention!

Marcelo
P.S.: my compiler is Compaq Visual Fortran 6.5
 
10 is not real*4. 10**prop(i) probably generates real*8. Try 10_1 or 10_4. Some compilers take _1 for real*4, others take _4 for real*4.

If that still fails, take the whole thing out of the impiled loop and do the calculation outside.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top