program writetest
implicit none
integer, parameter ::  n=100, m=200
integer :: i, j
real(4)    ::  x(n,m)

! set values
do i=1, n
 do j=1, m
  x(i, j) = 100 * i + j
 end do
end do

! write data

 open(unit=12, file='testdata2.bin', form='unformatted', &
	 access='direct', recl=4*m)
 do i=1, n
   write(unit=12, rec=i) ( x(i,j), j=1,m)
 end do

 close(12)


! read data

 open(unit=12, file='testdata2.bin', form='unformatted', &
	 access='direct', recl=4*m)

 i = 30
!  do i=1, n
   read(unit=12, rec=i) ( x(i,j), j=1,m)
   write(*,*) ( x(i,j), j=1,m )
! end do

 close(12)



stop
end
