Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How did the fortran standard of unit numbers came to be?

Tags:

fortran

In fortran stderr is unit 0. Stdin is unit 5 and stdout is unit 6. This appears to be a cray decision as far as Google seems to indicate, but it is not clear why they chose so. Why not 1 and 2? What was the use of 1-4 on old fortran compilers that shifted stdin and out to 5 and 6?

like image 788
Stefano Borini Avatar asked Oct 30 '22 03:10

Stefano Borini


1 Answers

According to this page (the "Professional Programmer's Guide to Fortran77" by Clive G. Page), units 5 and 6 are assigned to stdin and stdout, respectively, for backwards compatibility and that card-readers were typically connected to "unit 5" and line printers to "unit 6", quote:

In order to retain compatibility with Fortran66, many systems provide other pre-connected files. It used to be customary to have unit 5 connected to the card-reader, and unit 6 to the line printer. Other units were usually connected to disc files with appropriate names: thus unit 39 might be connected to a file called FTN039.DAT or even TAPE39.

Not that this gives any logic to why numbers 5 and 6 were chosen, but only some historical context. Still leaves open what was connected to unit numbers 1-4 on historic machines. The following old books/handbooks might shed some light:

According to D.D. Fisher et al. An Introduction to Fortran Programming, page 90, not all FORTRAN compilers used units 5 and 6 for card-reader input and line printer output:
Waterloo FORTRAN IV and IBM System/360 FORTRAN IV did use units 5 and 6 for that purpose, on the IBM 1130, however, units 2 and 1 were used for card-reader input and line printer output.

And finally according to the FORTRAN-10/20 and VAX FORTRAN Compatibility Manual, page 3-6, in case of FORTRAN-10/20 "unit 1 is disk, unit 2 is the card reader, unit 3 is line printer, unit 5 is the terminal". With VAX FORTRAN, unit 5 is good for both I and O with the terminal.
Maybe this final part indicates that because some machines started to have terminals for I/O in addition to card-reader input and line printer output, and the preferred/default devices might have become terminals for both input and output, that the higher terminal-related units have become I/O defaults.

like image 92
v-joe Avatar answered Nov 09 '22 10:11

v-joe