       SUBROUTINE RDCHKB(RADNCS,CHAN,NSPOT,LWRLIM,UPRLIM,NINSTR,
     1                   SETRAD,SPTCNF,CHNAVL,FACTOR,NUMLIN)
C***********************************************************************
C
C  NAME- RDCHKB
C
C  LANGUAGE- FORTRAN 77       TYPE- SUBROUTINE   COMPUTER- IBM SP
C
C  VERSION- 1.0    DATE- 1/15/04    PROGRAMMER- FRANK TILLEY (RAYTHEON)
C
C  FUNCTION-  THIS SUBROUTINE PERFORMS A GROSS LIMITS CHECK ON
C             RADIANCES FOR ALL THE SPOTS OF A GIVEN CHANNEL.  IF A
C             RADIANCE FOR ANY SPOT FAILS THE LIMITS CHECK:
C              -THE SPOT CONFIDENCE IS DECREASED BY "FACTOR".
C              -THE BIT CHANNEL IN CHANNEL AVAILABILITY FLAG IS SET
C               TO 0.
C              -THE SPOT FOR THE RADIANCE IS SET TO A MISSING VALUE.
C              -DEPENDING ON THE INSTRUMENT, ITS BAD RADIANCE COUNTER IS
C               INCREMENTED BY 1.
C
C  CALLING SEQUENCE PARAMETERS-
C    VARIABLE   TYPE  I/O   DESCRIPTION
C    --------   ----  ---   -----------
C    RADNCS     REAL  I/O   RADIANCES VECTOR (DIMENSIONED NSPOT).
C    CHAN       INT    I    CHANNEL OF INSTRUMENT BEING CHECKED.
C    NSPOT      INT    I    NUMBER OF SPOTS IN A SCAN FOR THE
C                           INSTRUMENT.
C    NUMLIN     INT    I    THE LINE NUMBER OF THE SPOT BEING PROCESSED
C                           WITH RESPECT TO THE HIRS EXTENDED FRAME.
C    LWRLIM     REAL   I    LOWER LIMIT ON RADIANCES FOR THE INSTRUMENT
C                           CHANNEL (FROM CDB).
C    UPRLIM     REAL   I    UPPER LIMIT ON RADIANCES FOR THE INSTRUMENT
C                           CHANNEL (FROM CDB).
C    NINSTR     INT    I    NUMBER OF INSTRUMENT.
C                           1 = HIRS, 2 = AMSU-A, 3 = AMSU-B.
C    SPTCNF     REAL  I/O   SPOT CONFIDENCE VECTOR (DIMENSIONED NSPOT)
C                           VALUES ARE FROM 0 - 100.
C    SETRAD     REAL   I    DUMMY RADIANCE VALUES USED AS SUBSTITUTES FOR
C                           CHANNEL RADIANCES WHICH HAVE FAILED THE GROSS
C                           LIMITS CHECKS, SET TO ALLOW PROCESSING TO CON-
C                           TINUE.  SUCH SPOTS ARE MARKED AS HAVING BAD
C                           HIRS DATA AND A NON-HIRS RETRIEVAL IS PROCESSED.
C                           SETRAD CONTAINS RADIANCES FOR EACH OF THE 20 
C                           HIRS CHANNELS WHICH WILL PASS THE GROSS LIMITS
C                           CHECKS.
C    CHNAVL     INT   I/O   CHANNEL AVAILABILITY (DIMENSIONED NSPOT).
C    FACTOR     REAL  I     AMOUNT BY WHICH TO LOWER SPOT CONFIDENCE
C                           IF BRIGHTNESS TEMPERATURE LIMITS FOR
C                           CHANNEL ARE NOT MET (FROM CDB).
C
C   COMMON AREA PARAMETERS- MONSTA, FRMINF, INSPARM, SPVAL, HIRSTAT
C
C  LOCAL VARIABLES-
C    VARIABLE     TYPE    DESCRIPTION
C    --------     ----    -----------
C    BIT          INT     BIT TO SET IN CHANNEL AVAILABILITY.
C    SPOT         INT     DO LOOP COUNTER FOR SPOTS IN SCAN LINE.
C
C  FUNCTIONS USED- NONE.
C
C  EXIT STATES-NONE.
C
C  COMMENTS- THIS SUBROUTINE IS ONLY CALLED FOR DATA WHICH HAS BEEN
C            CHECKED AND IS CONSIDERED USABLE (THUS NO VALUES SHOULD
C            BE MISSING).
C
C            IT IS ASSUMED THAT THE INSTRUMENT NUMBER WILL ONLY BE
C            A 1, 2 OR 3.
C
C***********************************************************************
C
      INCLUDE'MONSTA'
      INCLUDE'INSPARM'
      INCLUDE'AMASTAT'
      INCLUDE'FRMINF'
      INCLUDE'SPVAL'
C
      REAL RADNCS(NSPOT), SPTCNF(NSPOT), LWRLIM, UPRLIM, FACTOR
      REAL SETRAD(5)
      INTEGER CHAN, NSPOT, NINSTR, SPOT
      INTEGER CHNAVL(NSPOT), NUMLIN
C
      INTEGER BIT
C
      DO 10 SPOT = 1, NSPOT
        IF ((RADNCS(SPOT).GT.UPRLIM).OR.(RADNCS(SPOT).LT.LWRLIM)) THEN
ccft       IF(AMBOFF(CHAN))THEN
ccft          RADNCS(SPOT) = SETRAD(CHAN)
ccft          BADAMB(SPOT,NUMLIN,CHAN) = 1
ccft          BADBRET(SPOT,NUMLIN) = .TRUE.
ccft       ELSE
C
C  RADIANCE FALLS OUTSIDE OF LIMITS - ADJUST SPOT CONFIDENCE.
C
              SPTCNF(SPOT) = SPTCNF(SPOT) - FACTOR
              IF (SPTCNF(SPOT) .LT. 0.0) SPTCNF(SPOT) = 0.0
C
C  SET BIT CHANNEL IN CHANNEL AVAILABILITY TO ZERO.
C  SET RADIANCE EQUAL TO A REAL MISSING VALUE.
C
              BIT = 32 - CHAN
              CHNAVL(SPOT) = IBCLR(CHNAVL(SPOT),BIT)
C
C  DEPENDING ON THE INSTRUMENT, INCREMENT THE BAD RADIANCE COUNTER.
C
              IF (NINSTR .EQ. 1) THEN
                 NBRHIR(FRAMNO,CHAN) = NBRHIR(FRAMNO,CHAN) + 1
              END IF
              IF (NINSTR .EQ. 2) THEN
                 NBRAMA(FRAMNO,CHAN) = NBRAMA(FRAMNO,CHAN) + 1
              END IF
              IF (NINSTR .EQ. 3) THEN
                 NBRAMB(FRAMNO,CHAN) = NBRAMB(FRAMNO,CHAN) + 1
              ENDIF
ccft       ENDIF
        ENDIF
C
   10 CONTINUE
C
      RETURN
      END
