binary i/o problem
Roger Davis
rbd at lamont.UUCP
Wed May 8 05:39:26 AEST 1985
Does anyone know how to get a Fortran program to read
a binary file through standard input? (Or why it's not
possible, if such is the case?) The following test
program, and an infinite number of variations thereon,
will not work, while a similar program that reads formatted
input through standard input works fine.
% cat rdbinary.f
c program rdbinary
c
c read binary input from stdin
c
integer number
c
close(5)
open(5, status='old', form='unformatted', err=80)
write(6, '("stdin opened")')
c
read(5, err=90) number
write(6, '("number = ", i5)') number
goto 100
c
c error messages
80 write(6, '("open error")')
goto 100
90 write(6, '("read error")')
goto 100
c
100 stop
end
This program produces the following output
when supplied with a binary input:
% rdbinary <binaryfile
stdin opened
read sue: [-1] end of file
logical unit 5, named 'fort.5'
lately: reading sequential unformatted external IO
IOT trap (core dumped)
Roger Davis
lamont!rbd
UUCP: {decvax, ihnp4, cmc12} philabs!lamont!rbd
More information about the Comp.unix.wizards
mailing list