      SUBROUTINE CHNBCOL(IVAL,NVAL,IDEB,ITABLE)
      SAVE N,NBCOL
      INTEGER NBCOL(-5:240),TAB(256)
C
      IF (IDEB.EQ.0) THEN
        N = -5
        NNN = NBMAXGRA()
        DO I=1,240
          IF (N.NE.0) THEN
            CALL TABLE(TAB,N,NB,1,0)
            IF (NB.GT.NNN) GOTO 100
            NBCOL(N) = NB
          ENDIF
          N=N+1
        ENDDO
100     N=N-1
      ENDIF
C
      NVAL = 0
      NEC = 9999
      DO I=-5,N
        IF (I.NE.0) THEN
          IF (ABS(NBCOL(I)-IVAL).LT.NEC) THEN
            NEC = ABS(NBCOL(I)-IVAL)
            NVAL = I
          ENDIF
        ENDIF
      ENDDO
      IF (ITABLE.GT.2) NVAL = NBCOL(NVAL)
      END
