      PROGRAM MATVEC
      INTEGER LDA
      PARAMETER(LDA = 30)
      REAL A, X, Y
      INTEGER N, I, J
      DIMENSION A(LDA,LDA), B(LDA), C(LDA)
      OPEN(UNIT=1,FILE='input.dat',STATUS='UNKNOWN')
      READ(1,*) N
      DO 10 I = 1,N
        READ(1,*) (A(I,J), J = 1,N)
        C(I) = 0.
   10 CONTINUE
      READ(1,*) (B(I), I = 1,N)
      CLOSE(1)
      CALL MTRVEC(LDA,N,A,B,C)
      OPEN(UNIT=2,FILE='output.dat',STATUS='UNKNOWN')
      WRITE(2,*) 'To diavusma eivai:'
      DO 20 I = 1,N
        WRITE(2,*) C(I)
   20 CONTINUE
      CLOSE(2)
      STOP
      END

      SUBROUTINE MTRVEC(LDA,NDIM,A,X,Y)
      REAL A(LDA,*), X(*), Y(*), S
      INTEGER NDIM, I, J
      DO 20 I = 1,NDIM
        S = 0.0
        DO 30 J = 1,NDIM
          S = S + A(I,J)*X(J)
   30   CONTINUE
        Y(I) = S
   20 CONTINUE
      RETURN
      END
