program vektoren_und_matrizen
implicit none

integer :: m,n, i,j
real, dimension(:,:), allocatable:: a
real, dimension(:), allocatable:: v,w
real::x
!=======================================================================
! Eingabe einer Matrix aus Datei, Dimension steht in erster Zeile
open(100, "w09.dat", action="read")
read(100,*) m,n
write(*,*) m,n
allocate(a(1:m,1:n))

do i=1,m
   do j=1,n
      read(100,"(F7.1)", advance="no") a(i,j)
      end do
   read(100,*)
   end do
close(100)
! Kontrolle
do i=1,m
   do j=1,n
      write(*,"(F7.1)", advance="no") a(i,j)
      end do
   write(*,*)
   end do
!=======================================================================
! Eingabe eines Vectors, in Datei steht ein Element pro Zeile
open(100, "w09_1.dat", action="read")
i=0
do
   read(100,"(F)", end=101) x
   i=i+1
   end do
101 n=i
close(100)
write(*,*) n
allocate(v(1:n))
open(100, "w09_1.dat", action="read")
do i=1,n
   read(100,"(F)") v(i)
   end do
close(100)
write(*,*)v
deallocate(v)
!=======================================================================
! Eingabe eines Vectors, in Datei stehen alle Elemente in einer Zeile
open(100, "w09_2.dat", action="read")
i=0
do
   read(100,"(F5.1)",advance="no", eor=102) x
   i=i+1
   end do
102 n=i
i=0
do
   read(100,"(F5.1)",advance="no", eor=103) x
   i=i+1
   end do
103 m=i
close(100)
write(*,*) n,m
open(100, "w09_2.dat", action="read")
i=0
do
   read(100,"(F5.1)",advance="no", eor=102) x
   i=i+1
   end do
102 n=i
i=0
do
   read(100,"(F5.1)",advance="no", eor=103) x
   i=i+1
   end do
103 m=i
close(100)
write(*,*) n,m
allocate(v(1:n))
allocate(w(1:m))
open(100, "w09_2.dat", action="read")
do i=1,n
   read(100,"(F5.1)",advance="no", eor=104) v(i)
   end do
104 continue
read(100,*)
do i=1,m 
   read(100,"(F5.1)",advance="no", eor=105) w(i)
   end do
105 continue
close(100)
write(*,*)v
write(*,*)w
end program vektoren_und_matrizen
