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!

RECL = 2147483647 1

Status
Not open for further replies.

jpbjr

Programmer
Jul 6, 2004
2
US
I am trying to read a Sequential file from a disk with one big physical record. Using INQUIRE I know it is a sequential file with a recl of 2147483647. The disk file is uploaded to an old mainframe system that apparently 'thinks' it is a tape file.

The record contains formatted 'employee-related' data consisting of 250 characters for approximately 550 employees, so 550*250 vs the recl number tells me there is lots of blank (or garbage) data at the end of the record.

I need to read the record as character*250 data(550), do some fixes in the data, and then write out the corrected version in the same 'tape-like' format to send to the mainframe.

I have tried:
100 format(a250)
read(*,fmt=100)(data(i),i=1,1)
which works EXCEPT that it does NOT read the first character of the first chunk of data, but starts at the second character....how can I get the 1st character of the 250 character sequence?

but
100 format(a250)
read(*,fmt=100)(data(i),i=1,550)
(or even reading just i=1,2) generates the following error:
"An endfile error was detected in a READ statement"

Apparently there is an endfile marker between each data chunk, eventhough the RECL is huge. I don't understand it.

If an implicit read will not work, is there something else I can try?

Thanks!
 
1) read (*...) reads from the console. How are you opening the file?
2) Is it a binary file or a text file

If it is a binary file, try opening with format='unformatted', access='direct', recl=250. Not sure about the 250, you may have to increase it to cater for padding.

Say you've opened it with file handle 20, read record r using

read (20, rec=r) employee(r)

3) Not a good idea calling an array data since data is also a keyword. Could be confusing.

4) Don't forget to close the file

Have a look at the open command and play around with the parameters until you get something that works. If you find the records drifting, you may have to change the record length.
 
xwb,

Thanks!

I did not know that eventhough an INQUIRE said the file was Sequential, I could open it as Direct!

Opening it as DIRECT with RECL 250
and then reading it as you suggested in a loop:

Do I =1 , 50
read(10,fmt=50,rec=I)line2(I)
if(line2(i)(1:3).ne."405") then
goto 100
end if
end do
100continue
50 format(a250)

works GREAT....each record starts with "405" so I know I am at the end of the data with the 'if' test.

Thanks very much for the help
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top