
      SUBROUTINE DET3(H,Y,Z,NDIM,IER)
      DIMENSION Y(*),Z(*)
C      TEST OF DIMENSION
      IF(NDIM-3)4,1,1
C      TEST OF STEPSI'E
    1 IF(H)2,5,2
C       PREPARE THE DIFFERENTIATION LOOP
    2 HH=.5/H
      YY=Y(NDIM-2)
      B=Y(2)+Y(2)
      B=HH*(B+B-Y(3)-Y(1)-Y(1)-Y(1))
C       START DIFFERENTIATION LOOP
      DO 3 I=3,NDIM
      A=B
      B=HH*(Y(I)-Y(I-2))
    3 Z(I-2)=A
C       END OF DIFFERENTIATION LOOP
C       NORMAL EXIT
      IER=0
      A=Y(NDIM-1)+Y(NDIM-1)
      Z(NDIM)=HH*(Y(NDIM)+Y(NDIM)+Y(NDIM)-A-A+YY)
      Z(NDIM-1)=B
      RETURN
C      ERROR EXIT IN CASE NDIM IS LESS THAN 3
    4 IER=-1
      RETURN
C       ERROR EXIT IN CASE OF ZERO STEPSIZE
    5 IER=1
      RETURN
      END
