Fortran Reading files in pre-f77 - handling end of file

  • Thread starter Thread starter synch
  • Start date Start date
AI Thread Summary
The discussion focuses on reading files with an arbitrary number of records in Fortran 66, specifically using DO loops and READ statements. It highlights the use of the END parameter in READ statements to handle end-of-file conditions, though there is uncertainty about its presence in Fortran 66, suggesting it may be a vendor extension specific to the Burroughs 6700. Participants note that earlier versions of Fortran required programmers to manage EOF markers and procedures themselves, as the language did not inherently support this functionality.The conversation also touches on the control variable within DO loops, emphasizing that its state is undefined upon a normal exit from the loop. The need for a conditional EXIT statement to handle EOF scenarios is acknowledged, with references to documentation for Burroughs FORTRAN compilers and their extensions. The discussion concludes with a personal reflection on the evolution of programming understanding and the importance of historical documentation for legacy systems.
synch
Messages
84
Reaction score
11
[ Historical program question - I am not asking advice about current versions ]

About reading a file with an arbitrary number of records in say Fortran 66 :
Typically a DO loop was used to repeat a READ statement.
There was an option in a READ statement eg END = nnn, with nnn being the statement ID
to branch to when the end of the file was reached. I think there was also an
EXIT statement which would wind up the current DO loop, so I guess that would be
the typical statement to branch to, in that situation.

The question is, if the loop finishes and terminates naturally before the end of the file is reached,
presumably the EXIT statement would still be present and so cause problems unless it was bypassed.
Was it possible to conditionally EXIT only if there was a current end-of-file condition ?

[ I know f77 and later had better methods eg "while" constructs and so on, the question is not about those.]
 
Technology news on Phys.org
You will need to get the F66 or FORTRAN IV, programming manual for the machine that the original code was written for. What make and model was that original target machine?

What is the data in the record, numeric or text? There are subtle differences in the way ASCII or EBCDIC characters were packed in single and double precision FP variables. Different machines had different word sizes, so different numbers of characters. That also controlled the maximum variable name length used.
 
  • Like
Likes Astronuc, .Scott and Klystron
synch said:
I think there was also an
EXIT statement which would wind up the current DO loop

Don't think there was. Any evidence ?
 
I think it was Fortran 66 on a Burroughs 6700 but I don't have a reference mentioning exit at this stage, it may be a vendor extension.

Generic references include it in f77 and later.
Eg an EOF(n) function that would check for an end of file condition reached on unit n.
So that was checked as part of the loop, and used to exit the loop accordingly.

Eg Ref : Intel Fortran Developers guide.
 
synch said:
I think it was Fortran 66 on a Burroughs 6700 but I don't have a reference mentioning exit at this stage, it may be a vendor extension.
If I remember correctly, the FORTRAN compiler for the B6700/B6800 was an in-house special, written in Algol 60, that exceeded the FORTRAN IV specs. I used it from 1974 and should have a copy of the manual somewhere, since I later scrapped a B6800 😭, in the 1980s, and kept most books, and half the core memory.
 
There is documentation for a couple of early Burroughs FORTRAN compilers here. They evolved, but did not change much during that period.
http://bitsavers.org/pdf/burroughs/LargeSystems/

Circa 1967-1968
http://bitsavers.org/pdf/burroughs/LargeSystems/B5000_5500_5700/1032083_B5500_FortranRef_196804.pdf

"
The control variable i is available for use by all statements within the DO loop, including the terminal statement, and may be modified as desired. The control variable i is available for computation when exiting from a DO loop by transferring outside the loop and not making a normal exit. When a normal exit is made from the DO loop, the control variable is undefined.
"
 
  • Like
Likes Astronuc and synch
synch said:
About reading a file with an arbitrary number of records in say Fortran 66 :
Typically a DO loop was used to repeat a READ statement.
There was an option in a READ statement eg END = nnn, with nnn being the statement ID
to branch to when the end of the file was reached. I think there was also an
EXIT statement which would wind up the current DO loop, so I guess that would be
the typical statement to branch to, in that situation.

Let's start with your "say Fortran 66".
I just read through that pdf file, and there is no mention of an "END" parameter to the read statement.
This makes sense. Generally, you were reading a deck of cards or a tape and just because your card reader ran out of cards or your tape drive ran into the EOT marker, didn't mean that this was significant to the read statement. And if you were reading from disk (they had some in those days), the file system was whatever you or the manufacturer had arranged. In general, the programmer was responsible for including EOF markers and/or procedures.
Which gets us to your next statement:
synch said:
I think it was Fortran 66 on a Burroughs 6700 but I don't have a reference mentioning exit at this stage, it may be a vendor extension.
Yes, it would have been a vendor extension. In those days there were dozens of versions of Fortran extant.
And this means that whatever was available would have been specified in the Boroughs Fortran manual. The 6700 began shipping in 1969 and since Burroughs was known for supporting higher level languages in preference over machine/assembler. They would have published a manual similar to this one, but for their "Large Systems" (ex, 6700) detailing what language extensions had been provided for disc file access.
 
Baluncore said:
There is documentation for a couple of early Burroughs FORTRAN compilers here. They evolved, but did not change much during that period.
http://bitsavers.org/pdf/burroughs/LargeSystems/

Circa 1967-1968
http://bitsavers.org/pdf/burroughs/LargeSystems/B5000_5500_5700/1032083_B5500_FortranRef_196804.pdf

"
The control variable i is available for use by all statements within the DO loop, including the terminal statement, and may be modified as desired. The control variable i is available for computation when exiting from a DO loop by transferring outside the loop and not making a normal exit. When a normal exit is made from the DO loop, the control variable is undefined.
"


Brilliant ! Thanks, exactly on the spot.

I see the READ has a transfer of control option, for EOF or errors.

My initial programs were on a 6700, I enjoyed it. As a pastime decades later I have written an interpreter, which has forced me to understand programming languages in quite more depth. It struck me that my early programs (er, quite some time ago) were a bit hazy about exiting loops - hence my question .
I think an "END = ..." read option and a following conditional EXIT works OK so I will include that.

Many thanks.

BTW I think I have some later CANDE advisory documents, if the silverfish haven't eaten them, I'll try to find them
 
Last edited:
There was a document for the B5500, form number 1031325, that I cannot find.
FORTRAN II — FORTRAN IV Translator Reference Manual.

Meanwhile, the basis for those beautiful Big Machines, stack-based and totally secure, is described in this book, available from the same archive. It is essential reading for designers of structured systems.
http://bitsavers.org/pdf/burroughs/..._Organization_The_B5700_B6700_Series_1973.pdf
The elegance of the stack-based instruction set is described here.
http://bitsavers.org/pdf/burroughs/LargeSystems/B6500_6700/1058633_B6700_RefMan_May72.pdf
 

Similar threads

Replies
4
Views
2K
Replies
5
Views
5K
Replies
1
Views
3K
Replies
33
Views
5K
Replies
20
Views
6K
Replies
2
Views
2K
Replies
19
Views
6K
Replies
5
Views
6K
Replies
1
Views
5K
Replies
2
Views
9K
Back
Top