       SUBROUTINE RDCHKH(RADNCS,CHAN,NSPOT,LWRLIM,UPRLIM,NINSTR,
     1                   SETRAD,SPTCNF,CHNAVL,FACTOR,NUMLIN)
       IMPLICIT NONE
C***********************************************************************
C
C  NAME- RDCHKH
C
C  LANGUAGE- FORTRAN 77       TYPE- SUBROUTINE   COMPUTER- CRAY  
C
C  VERSION- 1.0    DATE- 3/22/93    PROGRAMMER- DAWN JACKSON, SMSRC
C  VERSION- 2.0    DATE- 9/29/94    PROGRAMMER- SURYA JANDHYALA, SMSRC
C     XATOV-56:  REPLACED MSU AND SSU INSTRUMENTS WITH AMSU-A AND AMSU-B
C                INSTRUMENTS.  ADDED INCLUDE FILE INSPARM.
C  VERSION- 2.1    DATE- 6/2/95     PROGRAMMER- ALEX POZDNYAK, SMSRC
C    ATOVS-122:  ARGUMENT FACTOR WAS ADDED. IF THE RADIANCE VALUE IS
C                OUTSIDE THE LIMIT, THE SPOT CONFIDENCE IS DECREASE
C                BY FACTOR RATHER THAN SET TO ZERO. A CHECK WAS ADDED
C                TO BE SURE THE SPOT CONFIDENCE DOES NOT GO LESS THAN
C                ZERO. THE CHANNEL AVAILABILITY BIT FOR THE CHANNEL IS
C                SET TO ZERO, RATHER THAN THE ENTIRE WORD.
C  VERSION- 3.0    DATE- 5/10/96    PROGRAMMER- ALEX POZDNYAK, FDC 
C     FOR REHOSTING TO THE CRAY, CHANGED ALL I*4 DECLARATIONS TO
C     INTEGER AND ALL R*4 DECLARATIONS TO REAL.
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    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    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
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'HIRSTAT'
      INCLUDE'FRMINF'
      INCLUDE'SPVAL'
C
      REAL RADNCS(NSPOT), SPTCNF(NSPOT), LWRLIM, UPRLIM, FACTOR
      REAL SETRAD(20)
      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
C
C  RADIANCE FALLS OUTSIDE OF LIMITS - ADJUST SPOT CONFIDENCE.
C
CCMPF     SPTCNF(SPOT) = SPTCNF(SPOT) - FACTOR
CCMPF     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
CCMPF     BIT = 32 - CHAN
CCMPF     CHNAVL(SPOT) = IBCLR(CHNAVL(SPOT),BIT)
          RADNCS(SPOT) = SETRAD(CHAN)
          BADHIR(SPOT,NUMLIN,CHAN) = 1
          BADRET(SPOT,NUMLIN) = .TRUE.
C
C  DEPENDING ON THE INSTRUMENT, INCREMENT THE BAD RADIANCE COUNTER.
C
          IF (NINSTR .EQ. 1) THEN
CCMPF       NBRHIR(FRAMNO,CHAN) = NBRHIR(FRAMNO,CHAN) + 1
          ELSE
            IF (NINSTR .EQ. 2) THEN
              NBRAMA(FRAMNO,CHAN) = NBRAMA(FRAMNO,CHAN) + 1
            ELSE
                NBRAMB(FRAMNO,CHAN) = NBRAMB(FRAMNO,CHAN) + 1
            ENDIF
          ENDIF
        ENDIF
C
   10 CONTINUE
C
      RETURN
      END
