      SUBROUTINE NSTERP(TM,WM,XM,M,TN,WN,XN,N,KERNEL,RHFCN,RHS,KMN,
     *   NHALF,NUP)
C
C   USE THE VALUES OF XN(I), I=1,...,N, TO CALCULATE THE NYSTROM
C   INTERPOLATES XM(I), I=1,...,M.
C
      REAL KERNEL,KMN
      DIMENSION TM(M),WM(M),XM(M),TN(N),WN(N),XN(N),RHS(M),
     *   KMN(NUP,NHALF)
      EXTERNAL KERNEL,RHFCN
C
      IF(M .GT. NUP) GO TO 4
C   SINCE M .LE. NUPPER, SAVE K(TM(I),TN(J))=KMN(I,J) AND
C   RHS(I)=RHFCN(TM(I)) FOR LATER USE IN ITERT.
      DO 1 I=1,M
      DO 1 J=1,N
1     KMN(I,J)=WN(J)*KERNEL(TM(I),TN(J))
      DO 2 I=1,M
      RHS(I)=RHFCN(TM(I))
2     XM(I)=RHS(I)
C   CALCULATE NYSTROM INTERPOLATING FORMULA.
      DO 3 I=1,M
      DO 3 J=1,N
3     XM(I)=XM(I)+KMN(I,J)*XN(J)
      RETURN
C   M .GT. NUPPER, SO SAVE JUST RHS(I) FOR LATER USE IN ITERT.
C   CALCULATE NYSTROM INTERPOLATING FORMULA.
4     DO 5 I=1,M
      RHS(I)=RHFCN(TM(I))
      XM(I)=RHS(I)
      DO 5 J=1,N
5     XM(I)=XM(I)+WN(J)*KERNEL(TM(I),TN(J))*XN(J)
      RETURN
      END
