Commit cc0bdf7b authored by rtoy's avatar rtoy

val/open.f:

o Test program for open, rewind, close, and read.

val/fort.10:
o Input file for open.f.
parent 96410642
1
42
1729
6
program tstopn
c Some random tests for opening and reading from files
integer i, istat
integer a(4)
open(unit = 1, file = 'fort.10', iostat = istat, status = 'old')
if (istat .eq. 0) then
print *, 'Unexpectedly opened fort.10!'
else
print *, 'As expected, fort.10 could not be opened'
endif
open(1, file = 'fort.10', err = 10, status = 'old')
print *, 'Err option did not work!'
goto 20
10 continue
print *, 'Err option worked because open failed.'
20 continue
open(unit = 2, file = 'output', iostat = istat)
if (istat .ne. 0) then
print *, 'Could not open output!'
else
open(unit = 1, file = 'fort.1', iostat = istat)
if (istat .ne. 0) then
print *, 'Could not open fort.1!'
else
rewind 1
read(1, *) (a(i), i = 1,4)
print *, (a(i), i = 1,4)
write(2, *) (a(i), i = 1,4)
close(1)
close(unit = 2)
endif
endif
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment