! pr 15472
|
! pr 15472
|
! sequential access files
|
! sequential access files
|
!
|
!
|
! this test verifies the most basic sequential unformatted I/O
|
! this test verifies the most basic sequential unformatted I/O
|
! write 3 records of various sizes
|
! write 3 records of various sizes
|
! then read them back
|
! then read them back
|
! and compare with what was written
|
! and compare with what was written
|
!
|
!
|
implicit none
|
implicit none
|
integer size
|
integer size
|
parameter(size=100)
|
parameter(size=100)
|
logical debug
|
logical debug
|
data debug /.FALSE./
|
data debug /.FALSE./
|
! set debug to true for help in debugging failures.
|
! set debug to true for help in debugging failures.
|
integer m(2)
|
integer m(2)
|
integer n
|
integer n
|
real*4 r(size)
|
real*4 r(size)
|
integer i
|
integer i
|
m(1) = Z'11111111'
|
m(1) = Z'11111111'
|
m(2) = Z'22222222'
|
m(2) = Z'22222222'
|
n = Z'33333333'
|
n = Z'33333333'
|
do i = 1,size
|
do i = 1,size
|
r(i) = i
|
r(i) = i
|
end do
|
end do
|
write(9)m ! an array of 2
|
write(9)m ! an array of 2
|
write(9)n ! an integer
|
write(9)n ! an integer
|
write(9)r ! an array of reals
|
write(9)r ! an array of reals
|
! zero all the results so we can compare after they are read back
|
! zero all the results so we can compare after they are read back
|
do i = 1,size
|
do i = 1,size
|
r(i) = 0
|
r(i) = 0
|
end do
|
end do
|
m(1) = 0
|
m(1) = 0
|
m(2) = 0
|
m(2) = 0
|
n = 0
|
n = 0
|
|
|
rewind(9)
|
rewind(9)
|
read(9)m
|
read(9)m
|
read(9)n
|
read(9)n
|
read(9)r
|
read(9)r
|
!
|
!
|
! check results
|
! check results
|
if (m(1).ne.Z'11111111') then
|
if (m(1).ne.Z'11111111') then
|
if (debug) then
|
if (debug) then
|
print '(A,Z8)','m(1) incorrect. m(1) = ',m(1)
|
print '(A,Z8)','m(1) incorrect. m(1) = ',m(1)
|
else
|
else
|
call abort
|
call abort
|
endif
|
endif
|
endif
|
endif
|
|
|
if (m(2).ne.Z'22222222') then
|
if (m(2).ne.Z'22222222') then
|
if (debug) then
|
if (debug) then
|
print '(A,Z8)','m(2) incorrect. m(2) = ',m(2)
|
print '(A,Z8)','m(2) incorrect. m(2) = ',m(2)
|
else
|
else
|
call abort
|
call abort
|
endif
|
endif
|
endif
|
endif
|
|
|
if (n.ne.Z'33333333') then
|
if (n.ne.Z'33333333') then
|
if (debug) then
|
if (debug) then
|
print '(A,Z8)','n incorrect. n = ',n
|
print '(A,Z8)','n incorrect. n = ',n
|
else
|
else
|
call abort
|
call abort
|
endif
|
endif
|
endif
|
endif
|
|
|
do i = 1,size
|
do i = 1,size
|
if (int(r(i)).ne.i) then
|
if (int(r(i)).ne.i) then
|
if (debug) then
|
if (debug) then
|
print*,'element ',i,' was ',r(i),' should be ',i
|
print*,'element ',i,' was ',r(i),' should be ',i
|
else
|
else
|
call abort
|
call abort
|
endif
|
endif
|
endif
|
endif
|
end do
|
end do
|
! use hexdump to look at the file "fort.9"
|
! use hexdump to look at the file "fort.9"
|
if (debug) then
|
if (debug) then
|
close(9)
|
close(9)
|
else
|
else
|
close(9,status='DELETE')
|
close(9,status='DELETE')
|
endif
|
endif
|
end
|
end
|
|
|