Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

EOF stopping me!

Richard_Conn_H_
Beginner
472 Views

I started writing fortran in 1959, ie, right at the beginning.  I just tried writing a program to read in a big file, and ran into trouble.  The file is 31,215 numbers, and is in blocks of 200 with, it seems, an EOF at the end of each block.  My program balks at that.  I need to get all 31,215 numbers. How do I get past the EOF?

 

 

0 Kudos
6 Replies
Richard_Conn_H_
Beginner
472 Views

Oh, yes, I'm 78 now.  Still LOVE fortran!  If you can solve my problem, I hope you might email me the solution:  henry@jhu.edu   thanks you!

0 Kudos
jimdempseyatthecove
Honored Contributor III
472 Views

There is no EOF character in the character set.

What is likely happening is your program may be reading the first number of each 200 number block.

Is this file formatted (text) or binary?

If formatted, attach the first two blocks of data.

Also show the OPEN statement and READ statements for your readin code.

Jim Dempsey

0 Kudos
Richard_Conn_H_
Beginner
472 Views

Thanks Jim!  I have some years ago successfully read in these same data from the same files using identical code, and it worked then, and it doesn't work now.  There are six blocks of data (a catalog of ultraviolet stars) and the first block is just the serial number, which goes from 1 to 31,215.  That's what I'm trying to read.  What I get is attached.  At least I think I attached it.  Anyway it is just the numbers from 1 to 200 and what it does NOT do is go on to 201, 202, ... and 31,200   (as I say, these are just the id, the other files are the actual data I need)

0 Kudos
Richard_Conn_H_
Beginner
472 Views

Here is the full program:  

    dimension number(31215)
    open(66,file='TD1.DATnumber')     

!read(66,24)(number(i),i=1,31215)

do k=1,3
read(66,24)(number(i),i=1,200)
24    format(200i6)

rewind 66  ! if you omit this, it stops:  forrtl: severe (24): end-of-file during read, unit 66, file /Users/dickhenry/f/TD1.DATnumber

write(6,*)(number(i),i=1,200)

end do

stop
end

 

0 Kudos
Eugene_E_Intel
Employee
472 Views

Hi Richard,

Are you trying to read this catalog's data?  http://vizier.cfa.harvard.edu/vizier/ftp/cats/II/59B/catalog.dat.gz (as linked from http://vizier.cfa.harvard.edu/viz-bin/Cat?cat=II%2F59B&target=http&) ?

This catalog is a text file that has 31215 rows, each row starting with an integer.  This particular file doesn't seem to have any EOF markers in the middle, only printable text.

Thank you,

Eugene

0 Kudos
jimdempseyatthecove
Honored Contributor III
472 Views

If the file you are reading is what Eugene posted, or like that file, that file does not conform to:]

24    format(200i6)

IOW it quite differently formatted data:

    1      3 0BD+44 4550  2151  6.5 A0  0.011276  0.784542  5.01 0.14  6.00 0.38  7.91 0.57  4.94 0.34 -12
    2     14 0BD+68 1426  5083  7.0 B9  0.011846  1.197401  6.07 3.22  8.4613.98 17.6626.85 10.76 0.51 -12
    3     17 0BD+34 5061  1473  6.9 A2  0.011524  0.615986  3.17 0.11  3.12 0.32  3.81 0.49  0.83 0.26 -12

That file is not 200i6 fields. Note, your file may differ. I suggest you use the {...} code button, the Plain Text format, to paste in the first two lines of the data file.

Jim Dempsey

0 Kudos
Reply