C
      SUBROUTINE NEWTNN(A,B,N,FW,FU,XX,DNS,VP,VS,THK,ML,IER
     *                 ,L1,DEP1,L2,DEP2,ISO)
C
      IMPLICIT REAL*8(A-H,O-Z)
      COMPLEX*16 VP(ML),VS(ML),FW,FU,WY,UY,WF,UF,WQ,UQ
      DIMENSION DNS(ML),THK(ML)
C
      IF(N.LT.1)THEN
        IER=1000
        FW=(0.D0,0.D0)
        FU=(0.D0,0.D0)
        GO TO 9999
      END IF
      IF(A.EQ.B)THEN
        IER=2000
        FW=(0.D0,0.D0)
        FU=(0.D0,0.D0)
        GO TO 9999
      END IF
C
      H=(B-A)/N
      CALL FNCRN(A,WY,UY,XX,DNS,VP,VS,THK,ML,L1,DEP1,L2,DEP2,ISO)
      WQ=(0.D0,0.D0)
      UQ=(0.D0,0.D0)
C
      DO  100 I=1,N
      X=A+H*I
      CALL FNCRN(X,WF,UF,XX,DNS,VP,VS,THK,ML,L1,DEP1,L2,DEP2,ISO)
      WQ  = WQ+H*(WY+WF)/2.D0
      UQ  = UQ+H*(UY+UF)/2.D0
      WY  = WF
      UY  = UF
  100 CONTINUE
C
      FW = WQ
      FU = UQ
      IER=0
C
 9999 RETURN
C
      END
