      SUBROUTINE CT2RDH(COUNTS,CLCOEF,NUMCHN,NUMSPT,RDIANC,BADLIN)
      IMPLICIT NONE
C
C**********************************************************************
C
C   NAME- CNT2RD
C
C   LANGUAGE- FORTRAN 77  TYPE- SUBROUTINE      COMPUTER- CRAY  
C 
C   VERSION- 1.0    DATE- 11/30/94   PROGRAMMER- SURYA JANDHYALA(SMSRC)
C   VERSION- 2.1    DATE- 03/20/95   PROGRAMMER- LI LU(SMSRC)
C     ATOVS78 :  IN CLCOEF ARRAY, FIRST COEFFICIENT IS THE ZEROTH ORDER
C                TERM, SECOND COEFFICIENT IS THE FIRST ORDER TERM, AND
C                THIRD COEFFICIENT IS THE SECOND ORDER TERM. DIMENSION
C                OF RDIANC ARRAY IS CHANGED TO (NUMSPT*NUMCHN).
C   VERSION- 3.0    DATE- 11/30/94   PROGRAMMER- ALEX POZDNYAK (FDC)   
C     FOR REHOSTING TO THE CRAY, CHANGED ALL INTEGER*4 DECLARATIONS TO
C     INTEGER, INTEGER*2 TO INTEGER, AND REAL*4 TO REAL.
C   VERSION- 3.1    DATE- 07/29/00   PROGRAMMER- M.P. FERGUSON (RITSS)
C     NEW HIRS-ONLY VERSION CREATED SO THAT CONTROL OVER COUNTS TO RADIANCE
C     CALCULATION COULD BE ASSERTED TO AVOID PLACING MISING VALUES INTO THE
C     RADIANCE BUFFERS AND THUS UNNECESSARILY SUSPENDING PROCESSING FOR THIS
C     FOV. NON-HIRS RETRIEVALS NOW PERFORMED FOR SUCH SPOTS (WR # 105).
C
C   FUNCTION- THIS ROUTINE CONVERTS THE COUNTS TO RADIANCES BY APPLYING
C             THE CALIBRATION COEFFICIENTS TO THE COUNTS.
C
C   CALLING SEQUENCE PARAMETERS-
C     VARIABLE          TYPE I/O  DESCRIPTION
C     --------          ---- ---  -----------
C     BADLIN            INT   I   AN INPUT INDICATING WHETHER THE CHANNEL
C                                 REFERENCE HAS GOOD CALIBATION COEFFI-
C                                 CIENTS.  IF ONE, THE CHANNEL DOES NOT
C                                 AND HAS ALREADY BEEN FILLED WITH DUMMY
C                                 VALUES.  THUS, IT WILL NOT BE CALCULATED
C                                 IN THIS ROUTINE.
C     COUNTS            INT   I   ARRAY OF COUNTS. DIMENSIONED NUMCHN X
C                                 NUMSPT.
C
C     CLCOEF            REAL  I   ARRAY CONTAINING CALIBRATION
C                                 COEFFICIENTS. DIMENSIONED 3 X NUMCHN.
C                                 FIRST COEFFICIENT IS THE ZEROTH ORDER
C                                 TERM, SECOND COEFFICIENT IS THE
C                                 FIRST ORDER TERM, AND THE THIRD
C                                 COEFFICIENT IS THE SECOND ORDER TERM.
C
C     NUMCHN            INT  I    THE NUMBER OF INPUT CHANNELS.
C
C     NUMSPT            INT  I    THE NUMBER OF SPOTS.
C
C     RDIANC            REAL O    ARRAY CONTAINING THE RADIANCES.
C                                 DIMENSIONED NUMSPT X NUMCHN.
C
      INTEGER    COUNTS(NUMCHN,NUMSPT)
      INTEGER    NUMCHN, NUMSPT, BADLIN(20)
      REAL       CLCOEF(3,NUMCHN),RDIANC(NUMSPT,NUMCHN)
C
C   LOCAL PARAMETERS-
C     VARIABLE          TYPE  DESCRIPTION
C     --------          ----  -----------
C     I                 INT   DO LOOP INDEX VARIABLE.
C
C     J                 INT   DO LOOP INDEX VARIABLE.
C
      INTEGER   I,J
C
C   SUBPROGRAMS CALLED- NONE
C
C   EXIT STATES- NONE
C
C   ASSUMPTIONS- NO MISSING VALUES ARE INPUT TO THIS ROUTINE.
C
C**********************************************************************
C
C  CONVERT THE COUNTS TO RADIANCES
C
      DO 20 J = 1, NUMCHN
          IF(BADLIN(J).EQ.1)GO TO 20
          DO 10 I = 1, NUMSPT
              RDIANC(I,J) = CLCOEF(1,J)
              RDIANC(I,J) = RDIANC(I,J) + CLCOEF(2,J)*COUNTS(J,I)
              RDIANC(I,J) = RDIANC(I,J) + CLCOEF(3,J)*(COUNTS(J,I)**2)
   10     CONTINUE
   20 CONTINUE
C
      RETURN
      END
