      SUBROUTINE SPL1D1(N,X,F,W,IOP,IJ,A,B,C)
      implicit real*8 (a-h,o-z)
      DIMENSION IOP(2),X(N),F(2),W(2),A(2),B(2),C(2)
      K=N-1
      A(2)=-(X(2)-X(1))/6.d0
      B(2)=(X(3)-X(1))/3.d0
      W(IJ+1)=(F(2*IJ+1)-F(IJ+1))/(X(3)-X(2))-(F(IJ+1)-F(1))
     1/(X(2)-X(1))
      IF (N-3)3,4,3
    3 DO 10 I=3,K
      M=(I-1)*IJ+1
      J1=M+IJ
      J2=M-IJ
      CON=(X(I+1)-X(I-1))/3.d0
      DON=(X(I)-X(I-1))/6.d0
      B(I)=CON-(DON**2)/B(I-1)
      E=(F(J1)-F(M))/(X(I+1)-X(I))-(F(M)-F(J2))/
     1(X(I)-X(I-1))
      W(M)=E-(DON*W(J2))/B(I-1)
   10 A(I)=-(DON*A(I-1))/B(I-1)
    4 K1=(N-2)*IJ+1
      C(N-1)=-((X(N)-X(N-1))/6.d0)/B(N-1)
      W(K1)=W(K1)/B(N-1)
      A(N-1)=A(N-1)/B(N-1)
      K2=K-1
      IF (N-3)7,8,7
    7 DO 20 I=2,K2
      J=N-I
      CON=(X(J+1)-X(J))/6.d0
      A(J)=(A(J)-CON*A(J+1))/B(J)
      C(J)=-(CON*C(J+1))/B(J)
      K3=(J-1)*IJ+1
      M=K3+IJ
   20 W(K3)=(W(K3)-CON*W(M))/B(J)
    8 K4=(N-1)*IJ+1
      IF (IOP(1)-5) 201,200,201
  201 C1=W(1)
      IF (IOP(2)-5) 203,202,203
  203 C2=W(K4)
      GO TO 205
  200 IF (N-4)300,302,302
  302 A1=X(1)-X(2)
      A2=X(1)-X(3)
      A3=X(1)-X(4)
      A4=X(2)-X(3)
      A5=X(2)-X(4)
      A6=X(3)-X(4)
      W(1)=F(1)*(1.d0/A1+1.d0/A2+1.d0/A3)-A2*A3*F(IJ+1)/(A1*A4*A5)+
     1 A1*A3*F(2*IJ+1)/(A2*A4*A6 )-A1*A2*F(3*IJ+1)/(A3*A5*A6)
      GO TO 201
  202 IF (N-4)300,303,303
  303 B1=X(N)-X(N-3)
      B2=X(N)-X(N-2)
      B3=X(N)-X(N-1)
      B4=X(N-1)-X(N-3)
      B5=X(N-1)-X(N-2)
      B6=X(N-2)-X(N-3)
      L1=K4-IJ
      L2=L1-IJ
      L3=L2-IJ
      W(K4)=-B2*B3*F(L3)/(B6*B4*B1)+B1*B3*F(L2)/(B6*B5*B2)
     1 -B1*B2*F(L1)/(B4*B5*B3)+F(K4)*(1.d0/B1+1.d0/B2+1.d0/B3)
      GO TO 203
  205 continue
      I = 0
   50 continue
      I = I + 1
      if ( I .gt. K ) go to 100
      M=(I-1)*IJ+1
      GO TO 60
   70 IF (I-1)80,50,80
   80 W(1)=W(1)-BOB*W(M)
      W(K4)=W(K4)-BILL*W(M)
      A(1)=A(1)-BOB*A(I)
      A(N)=A(N)-BILL*A(I)
      C(1)=C(1)-BOB*C(I)
      C(N)=C(N)-BILL*C(I)
      go to 50
   60 MK=IOP(1)
      GO TO (62,64,66,68,66),MK
   62 IF (I-1)71,63,71
   63 A(1)=-1.d0
      C(1)=0.d0
      GO TO500
   71 BOB=0.d0
      GO TO 500
   64 IF (I-1)73,76,73
   76 A(1)=-1.d0
      C(1)=0.d0
      W(1)=0.d0
      GO TO 500
   73 IF (I-2)81,81,82
   81 BOB=-C1
      GO TO 500
   82 BOB=0.d0
      GO TO 500
   66 IF (I-1)83,84,83
   84 A(1)=-(X(2)-X(1))/3.d0
      C(1)=0.d0
      W(1)=-C1+(F(IJ+1)-F(1))/(X(2)-X(1))
      GO TO 500
   83 IF (I-2)85,85,86
   85 BOB=(X(2)-X(1))/6.d0
      GO TO 500
   86 BOB=0.d0
      GO TO 500
   68 IF (I-1)87,88,87
   88 A(1)=-1.d0
      C(1)=1.d0
      W(1)=0.d0
      GO TO 500
   87 BOB=0.d0
  500 ML=IOP(2)
      GO TO (120,130,140,150,140),ML
  120 IF (I-1)121,122,121
  122 A(N)=0.d0
      C(N)=-1.d0
      GO TO 70
  121 BILL=0.d0
      GO TO 70
  130 IF (I-1)131,132,131
  132 A(N)=0.d0
      C(N)=-1.d0
      W(K4)=0.d0
      GO TO 70
  131 IF (I-K)134,133,134
  133 BILL=-C2
      GO TO 70
  134 BILL=0.d0
      GO TO 70
  140 IF (I-1)141,142,141
  142 A(N)=0.d0
      C(N)=(X(N-1)-X(N))/3.d0
      W(K4)=C2-(F(K4)-F(K1))/(X(N)-X(N-1))
      GO TO 70
  141 IF (I-K)143,144,143
  144 BILL=(X(N)-X(N-1))/6.d0
      GO TO 70
  143 BILL=0.d0
      GO TO 70
  150 IF (I-1)151,152,151
  152 A(N)=0.d0
      C(N)=(X(N-1)+X(1)-X(N)-X(2))/3.d0
      W(K4)=(F(IJ+1)-F(1))/(X(2)-X(1))-(F(K4)-F(K1))/(X(N)-X(N-1))
      GO TO 70
  151 IF (I-2)153,154,153
  154 BILL=(X(2)-X(1))/6.d0
      GO TO 70
  153 IF (I-K)155,156,155
  156 BILL=(X(N)-X(N-1))/6.d0
      GO TO 70
  155 BILL=0.d0
      GO TO 70
  100 CON=A(1)*C(N)-C(1)*A(N)
      D1=-W(1)
      D2=-W(K4)
      W(1)=(D1*C(N)-C(1)*D2)/CON
      W(K4)=(A(1)*D2-D1*A(N))/CON
      DO 110 I=2,K
      M=(I-1)*IJ+1
  110 W(M)=W(M)+A(I)*W(1)+C(I)*W(K4)
      GO TO 305
  300 write(6,*)' SPL1D1,  N.LT.4 RESULTS INCORRECT' 
* 300 CALL ErrWrt(' SPL1D1,  N.LT.4 RESULTS INCORRECT' )
      stop
  305 RETURN
      END
