       SUBROUTINE BTCHKA(BRTTMP,CHAN,NSPOT,LWRLIM,UPRLIM,FACTOR,
     .                   SPTCNF,CHNAVL,NUMLIN)
       IMPLICIT NONE
C***********************************************************************
C
C  NAME- BTCHKH
C
C  LANGUAGE- FORTRAN 77       TYPE- SUBROUTINE   COMPUTER- CRAY   
C
C  VERSION- 1.0        DATE- 4/09/91    PROGRAMMER- CARLA NEIGH (SMSRC)
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  VERSION- 3.1        DATE-12/05/00   PROGRAMMER- M.P. FERGUSON (RITSS)
C     PROGRAM MODIFIED TO SUSPEND REDUCTION OF SPOT CONFIDENCE DUE TO 
C     BRIGHTNESS TEMPERATURES FAILING GROSS LIMITS CHECKS FOR THOSE 
C     CHANNELS THAT ARE INDICATED BY FLAG AMAOFF AS BEING UNNECESSARY
C     EITHER BECAUSE THEY ARE NOT IN THE FIRST GUESS OR RETRIEVAL CHA-
C     NEL COMBINATIONS.  INSTEAD, DUMMY VALUES THAT FALL WITHIN THE BOUNDS
C     OF THE CDB-RESIDENT THRESHOLDS ARE USED BY THIS METHOD:  THEY ARE 
C     INSERTED IN THEIR PLACE AND THE AMSU-A SPOTS ARE MARKED AS BAD TO
C     ALLOW PROCESSING TO CONTINUE FOR THE SPOT IN QUESTION, ONLY THE
C     AMSU-A DATA IN QUESTION WILL BE REPLACED BY MISSING VALUES WHEN ITS 
C     VALUES ARE WRITTEN TO RRODF AND RHODF.  THIS SUBROUTINE IS
C     NEW BUT ESSENTIALLY THE AMSU-A VERSION OF BTCHEK, WITH MODIFICA-
C     TIONS SPECIFIC TO AMSU-A BRIGHTNESS TEMPERATURE CHECKING (PR # 28). 
C
C  FUNCTION-  THIS SUBROUTINE PERFORMS A GROSS LIMITS CHECK ON
C             BRIGHTNESS TEMPERATURES FOR ALL THE SPOTS OF A GIVEN
C             CHANNEL.  IF A BRIGHTNESS TEMPERATURE FOR ANY SPOT FAILS
C             THE LIMITS CHECK, THE SPOT CONFIDENCE FOR THAT SPOT IS
C             DECREASED BY THE AMOUNT GIVEN IN FACTOR, AND THE CHANNEL
C
C  CALLING SEQUENCE PARAMETERS-
C    VARIABLE   TYPE  I/O   DESCRIPTION
C    --------   ----  ---   -----------
C    BRTTMP     REAL   I    BRIGHTNESS TEMPERATURE VECTOR (DIM NSPOT)
C    CHAN       INT    I    CHANNEL OF INSTRUMENT BEING CHECKED
C    NSPOT      INT    I    NUMBER OF SPOTS IN A SCAN FOR THE INSTRUMENT
C    LWRLIM     REAL   I    LOWER LIMIT ON BRIGHTNESS TEMPERATURE FOR
C                           THE INSTRUMENT CHANNEL (FROM CDB)
C    UPRLIM     REAL   I    UPPER LIMIT ON BRIGHTNESS TEMPERATURE FOR
C                           THE INSTRUMENT CHANNEL (FROM CDB)
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    SPTCNF     REAL  I/O   SPOT CONFIDENCE VECTOR (DIMENSION NSPOT)
C                           VALUES ARE FROM 0 - 100
C    CHNAVL     INT   I/O   CHANNEL AVAILABILITY (DIMENSION NSPOT)
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- IBCLR
C
C  COMMON BLOCKS USED- HIRSTAT
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***********************************************************************
C
      INCLUDE'AMASTAT'
      INTEGER   NSPOT, SPOT, BIT, CHAN
      INTEGER   CHNAVL(NSPOT),NUMLIN
      REAL   BRTTMP(NSPOT), SPTCNF(NSPOT), LWRLIM, UPRLIM, FACTOR
C
      DO 10 SPOT = 1, NSPOT
        IF ((BRTTMP(SPOT).GT.UPRLIM).OR.(BRTTMP(SPOT).LT.LWRLIM)) THEN
         IF(AMAOFF(CHAN))THEN
          BADAMA(SPOT,NUMLIN,CHAN) = 1
          BADARET(SPOT,NUMLIN) = .TRUE.
          BRTTMP(SPOT) = (UPRLIM + LWRLIM) / 2
         ELSE
C
C  BRIGHTNESS TEMP FALLS OUTSIDE OF LIMITS - ADJUST SPOT CONFIDENCE
C
          SPTCNF(SPOT) = SPTCNF(SPOT) - FACTOR
C
C  FORCE VALUE TO ZERO IF LESS THAN ZERO
C
          IF (SPTCNF(SPOT).LT.0.0) SPTCNF(SPOT) = 0.0
C
C  SET BIT FOR CHANNEL IN CHANNEL AVAILABILITY TO ZERO
C
          BIT = 32 - CHAN
          CHNAVL(SPOT) = IBCLR(CHNAVL(SPOT), BIT)
         PRINT *,'AMSU-A BT ',BRTTMP(SPOT),' IS OUT OF RANGE'
         PRINT *,'LWRLIM ',LWRLIM,' UPRLIM ',UPRLIM
         PRINT *,' '
         ENDIF
C
        ENDIF
C
   10 CONTINUE
C
      RETURN
      END
