      PROGRAM MATRIXV
c     MULTIPLICATION OF MATRIX A(N,M) BY VECTOR V(M), RESULT Y.
c     Y=AV

c     PROGRAM MAIN
c     DECLARATIONS
      integer N,M,p
      
c     INPUT DATA
    1 write(*,*)'PROGRAM MATRIXV'
      write(*,*)'GIVE N AND M PLEASE'
c     N - NUMBER OF LINES
c     M - NUMBER OF COLUMNS
      read (*,*) N,M

c     CALLING SUBROUTINE SUBMV(N,M)
      call SUBMV(N,M)

c     WHAT TO DO AFTER EXECUTION OF MV?
      write(*,*) ' 0 - END'
      write(*,*) ' 1 - REPEAT'
      read (*,*) p

      if(p.eq.0)then
      goto 100
      else
      goto 1
      endif
  100 stop 100
      end


c     SUBROUTINE SUBMV
      subroutine SUBMV(N,M)

c     DECLARATIONS
      integer N,M,j,k
      real*8 A,V,Y,O
      dimension A(N,M),V(M),Y(N)

      O=real(0)
c     INPUT DATA: A
      write(*,*)'PLEASE MATRIX A LINE BY LINE: N LINES'
      do j=1,N,1
      do k=1,M,1
      read (*,*) A(j,k)
c     CONTROL OUTPUT
      write(*,*)'j=',j,' k=',k,' A=',A(j,k)
      enddo
      enddo
      
c     INPUT V

      write(*,*)'PLEASE VECTOR V: DIMENSION=M'
      do k=1,M,1
      read (*,*) V(k)
c     CONTROL OUTPUT
      write(*,*)'k=',k,' V=',V(k)
      enddo
      
      
c     DOUBLE LOUP OF MULTIPLICATION AV=Y
      do j=1,N,1
      Y(j)=O
      do k=1,M,1
      Y(j)=Y(j)+A(j,k)*V(k)
      enddo
      enddo
      
c     OUTPUT: Y
      write(*,*)'RESULT:'
      do j=1,N,1
      write(*,*)' j=',j,' Y=',Y(j)
      enddo
      write(*,*)'<ENTER TO CONTINUE>'
      read (*,*)
      
c     BACK TO THE MAIN PROGRAM
      return
      end