C======================================================================
C         V E C T O R    H A N D L I N G  (grid-oriented operations)
C======================================================================
C----------------------------------------------------------------------
C VVCOPI: J(.) <--  I(.) ;
C----------------------------------------------------------------------
      SUBROUTINE VVCOPI(J, I, N)
      IMPLICIT none
      INTEGER*4 I,J,L,N
      DIMENSION I(N), J(N)
C
      DO 10 L=1,N
 10   J(L) = I(L)
C
      RETURN
      END
C----------------------------------------------------------------------
C VVCOPY: V(.) <--  W(.) ;
C----------------------------------------------------------------------
      SUBROUTINE VVCOPY(V, W, N)
      IMPLICIT none
      DOUBLE PRECISION    V, W
      INTEGER*4 I, N
      DIMENSION V(N), W(N)
C
      DO 10 I=1,N
 10   V(I) = W(I)
C
      RETURN
      END
C----------------------------------------------------------------------
C VVADD1:  V1(.) <--  V1(.) + V2(.) ;
C----------------------------------------------------------------------
      SUBROUTINE VVADD1(V1, V2, N)
      IMPLICIT none
      DOUBLE PRECISION V1,V2
      INTEGER*4 I,N
      DIMENSION V1(N), V2(N)
C
      DO 10 I=1,N
 10   V1(I) = V1(I) + V2(I)
C
      RETURN
      END
C----------------------------------------------------------------------
C VVADD:   V1(.) <--  V2(.) + V3(.) ;
C----------------------------------------------------------------------
      SUBROUTINE VVADD(V1, V2, V3, N)
      IMPLICIT none
      DOUBLE PRECISION V1,V2,V3
      INTEGER*4 I,N
      DIMENSION V1(N), V2(N), V3(N)
C
      DO 10 I=1,N
 10   V1(I) = V2(I) + V3(I)
C
      RETURN
      END
C-----------------------------------------------------------------------
C VECUP1:       V(.) = V1(.) - X2(.) - X3(.)
C-----------------------------------------------------------------------
      SUBROUTINE VECUP1(V, V1, V2, V3, N)
      IMPLICIT none
      DOUBLE PRECISION V,V1,V2,V3
      INTEGER*4 I,N
      DIMENSION V(N), V1(N), V2(N), V3(N)
C
      DO 10 I=1, N
 10   V(I) = V1(I) - V2(I) - V3(I)
C
      RETURN
      END
C-----------------------------------------------------------------------
C VECUP:        V(.) = V1(.) - a * X2(.) - b * X3(.)
C-----------------------------------------------------------------------
      SUBROUTINE VECUP(V, V1, V2, V3, a, b, N)
      IMPLICIT none
      DOUBLE PRECISION V,V1,V2,V3,a,b
      INTEGER*4 I,N
      DIMENSION V(N), V1(N), V2(N), V3(N)
C
      DO 10 I=1, N
 10   V(I) = V1(I) - a * V2(I) - b * V3(I)
C
      RETURN
      END
C-----------------------------------------------------------------------
C VVCHEB:        Y(.) = a*X(.) + (1-a)*Y(.) * Z(.)
C-----------------------------------------------------------------------
      SUBROUTINE VVCHEB(X, Y, Z, a, N)
      IMPLICIT none
      DOUBLE PRECISION X,Y,Z,a
      INTEGER*4 I,N
      DIMENSION X(N), Y(N), Z(N)
C
      DO 10 I=1, N
 10   Y(I) = a*X(I) + (1.0d0 - a)*Y(I) + Z(I)
C
      RETURN
      END
C-----------------------------------------------------------------------
C DINPRD:     INNER PRODUCT REAL FUNCTION
C-----------------------------------------------------------------------
      FUNCTION DINPRD(V, W, N)
      IMPLICIT none
      DOUBLE PRECISION DINPRD,V,W
      INTEGER*4 I,N
      DIMENSION V(N), W(N)
      DINPRD = 0.0d0
      DO 10 I=1,N
 10   DINPRD = DINPRD + V(I)*W(I)
C
      RETURN
      END
C----------------------------------------------------------------------
C B11MUL: X <- MATRIX B11 TIMES VECTOR Y
C              B11 IS A DIAGONAL MATRIX SAVED AS A VECTOR
C----------------------------------------------------------------------
      SUBROUTINE B11MUL(X, B11, Y, N)
      IMPLICIT none
      DOUBLE PRECISION B11,X,Y
      INTEGER*4 I,N
      DIMENSION X(N), Y(N),
     >          B11(N)
C
      DO 10 I=1,N
         X(I) = B11(I) * Y(I)
 10   CONTINUE
C
      RETURN
      END
C----------------------------------------------------------------------
C FRMB11: B11 <--- SPV / B11
C----------------------------------------------------------------------
      SUBROUTINE FRMB11(B11, SPV, N)
      IMPLICIT none
      DOUBLE PRECISION B11,SPV
      INTEGER*4 I,N
      DIMENSION B11(N), SPV(N)
      DO 10 I=1,N
         B11(I) = SPV(I) / B11(I)
 10   CONTINUE

      RETURN
      END
C-----------------------------------------------------------------------
C VPLSTV:        V(.) = V(.) + Y(.) - S * W(.)
C-----------------------------------------------------------------------
      SUBROUTINE VPLSTV(V, Y, S, W, N)
      IMPLICIT none
      DOUBLE PRECISION V,Y,W,S
      INTEGER*4 I,N
      DIMENSION V(N), Y(N), W(N)
C
      DO 10 I=1, N
 10   V(I) = V(I) + Y(I) - S * W(I)
C
      RETURN
      END
C-----------------------------------------------------------------------
C VMSSV:        V(.) =  - S * V(.)
C-----------------------------------------------------------------------
      SUBROUTINE VMSSV(V, S, N)
      IMPLICIT none
      DOUBLE PRECISION V,S
      INTEGER*4 I,N
      DIMENSION V(N)
C
      DO 10 I=1, N
 10   V(I) =  - S * V(I)
C
      RETURN
      end
C----------------------------------------------------------------------
C VVDEL: V1 <--- V3 / V2
C----------------------------------------------------------------------
      SUBROUTINE VVDEL(V1, V2, V3, N)
      IMPLICIT none
      DOUBLE PRECISION V1,V2,V3
      INTEGER*4 I,N
      DIMENSION V1(N), V2(N), V3(N)
      DO 10 I=1,N
         V1(I) = V3(I) / V2(I)
 10   CONTINUE
      RETURN
      END
C"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "
C PRTVEC:
C"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "
      SUBROUTINE PRTVEC(I, X, N)
      IMPLICIT none
      DOUBLE PRECISION X
      INTEGER*4 I, L, N
      DIMENSION I(N), X(N)
C
            WRITE(*,*) ' *** ',N
            DO 10 L=1,N
            WRITE(*,*) ' ** ',L,I(L),X(L)
 10   CONTINUE
      RETURN
      END
C"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "
C PRTVI:
C"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "
      SUBROUTINE PRTVI(I, N)
      IMPLICIT none
      INTEGER*4 I, L, N
      DIMENSION I(N)
C
            WRITE(*,*) ' *** ',N
            DO 10 L=1,N
            WRITE(*,*) ' ** ',L,I(L)
 10   CONTINUE
      RETURN
      END
C"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "
C PRTVE:
C"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "
      SUBROUTINE PRTVE(X, N)
      IMPLICIT none
      DOUBLE PRECISION X
      INTEGER*4 I, L, N
      DIMENSION X(N)
C
            WRITE(*,*) ' *** ',N
            DO 10 L=1,N
            WRITE(*,*) ' ** ',L,X(L)
 10   CONTINUE
      RETURN
      END

