      SUBROUTINE SIMCBT(TEMP,TAUHRS,SURTMP,LGND,KCHAN,BTSIMU)
      IMPLICIT NONE
C
C**********************************************************************
C
C   NAME- SIMCBT
C
C   LANGUAGE- FORTRAN     TYPE- MAIN
C
C   VERSION- 1.0    DATE- 02/06/91   PROGRAMMER- ZHOU SISONG
C   VERSION- 1.1    DATE- 12/14/95   PROGRAMMER- T. GARDNER  (HSTX)
C   VERSION- 1.2    DATE- 06/04/96   PROGRAMMER- LEAH CASEY  (HSTX)
C   VERSION- 3.0    DATE- 11/13/97   PROGRAMMER- BRIAN BARIL (HSTX)
C   VERSION- 3.1    DATE- 10/05/98   PROGRAMMER- BRIAN BARIL (ITSS)
C   VERSION- 3.2    DATE- 04/04/01   PROGRAMMER- A. ALLEGRINO (ITSS)
C   VERSION- 3.3    DATE- 07/18/03   PROGRAMMER- F. TILLEY (RAYTHEON)
C
C   FUNCTION-*$TGARDN* PROGRAM CALCULATES SIMULATED BRIGHTNESS
C        TEMPERATURES FOR CALCULATION OF ATTENUATION ABOVE A GIVEN
C        PRESSURE LEVEL, USUALLY THE CLOUD TOP
C
C   VERSION- 1.2 CHANGE FUNCTION BRIGHT TO FUNCTION IPLKRD FOR RTOVS
C         ATTENUATION ABOVE THE CLOUDS.
C
C   VERSION- 3.0 MODIFICATIONS FOR INCLUSION INTO ATOVS.
C   VERSION- 3.1 CORRECTED AN INACCURACY IN THE ALGORITHM.  RDN WAS 
C                INITIALIZED BY DEL TAU.  IT WAS CHANGED TO DEL TAU
C                TIMES B1, ASSUMING ISOTHERMAL CONDITIONS AT L1.
C   VERSION- 3.2 CORRECTED TO PROPERLY USE LEVEL 41 DATA WHEN USING THE
C                SURFACE TEMPERATURE ESTIMATE. (WR#150)
C   VERSION- 3.3 EXPLICITLY DECLARED VARIABLES.
C
C   CALLING ARGUMENTS-
C      VARIABLE                TYPE I/O FUNCTION
C      --------                ---- --- --------
C      TEMP                    REAL  I   THE ATMOSPHERIC TEMPERATURE
C                                        PROFILE.
C      TAUHRS                  REAL  I   TRANSMITTANCE PROFILES FOR  
C                                        HIRS CHANNELS 1-11.
C      SURTMP                  REAL  I   TEMPERATURE AT THE SURFACE  
C                                        (OR CLOUD TOP).
C      LGND                    REAL  I   THE BOTTOM MOST LEVEL OF THE
C                                        LAYER FOR WHICH TO COMPUTE THE
C                                        B. TEMPERATURE CONTRIBUTION.
C      KCHAN                   REAL  I   THE CHANNEL TO SIMULATE THE
C                                        BRIGHTNESS TEMP. FOR.
C      BTSIMU                  REAL  O   SIMULATED BRIGHTNESS TEMP.
C                                        CONTRIBUTION FOR CHANNEL KCHAN.
C
C   COMMON AREAS- RETPARM
C
C   LOCAL VARIABLES-
C      NAME              TYPE     DESCRIPTION
C      ----              ----     -----------
C      B1                REAL     CHANNEL RADIANCE FROM THE UPPER LEVEL
C      B2                REAL     CHANNEL RADIANCE FROM THE LOWER LEVEL
C      BS                REAL     CHANNEL RADIANCE FOR THE "SURFACE" LEVEL
C      RDN               REAL     CUMMULATIVE RADIANCE VALUE
C      TAU1              REAL     TRANSMITTANCE FOR THE UPPER LEVEL
C      TAU2              REAL     TRANSMITTANCE FOR THE LOWER LEVEL
C
C
C
C**********************************************************************
C
C
      INCLUDE 'RETPARM'

      REAL   TAUHRS(PRFTLV,11),TEMP(PRFTLV),TEMPX(PRFTLV),IPLKRD,PLKRAD
      REAL   BTSIMU, SURTMP, SKINTK, TAU1, TAU2, B1, B2, BS, RDN 
      INTEGER LGND, LBTM, I, L, KCHAN 
C
C  USE RETRIEVED TEMPERATURES FROM 0.1 MB TO THE LEVEL ABOVE THE BOTTOM
C  LEVEL SPECIFIED IN THE CALLING ARGUMENTS.
C
      LBTM = LGND - 1
      DO 50 L=1,LBTM
        TEMPX(L) = TEMP(L)
  50  CONTINUE
C
C  SET SURFACE AND SKIN TEMPERATURE TO THE TEMPERATURE PROVIDED IN THE
C  CALLING ARGUMENTS.
C
      TEMPX(LGND) = SURTMP
      SKINTK      = SURTMP
C
C  SIMULATE RADIANCE FROM THE TOP OF THE ATMOSPHERE DOWN TO THE LEVEL
C  CORRESPONDING TO THE TEMPERATURE PROVIDED IN THE CALLING ARGUMENTS.
C

      B1=PLKRAD(TEMPX(1),KCHAN)
      TAU1=TAUHRS(1,KCHAN)
      RDN=B1*(1.0-TAU1)
C
C  ADD CONTRIBUTIONS ONLY TO THE LEVEL SPECIFIED IN THE CALLING ARGUMENTS.
C
      DO 120 I=2,LGND
        B2=PLKRAD(TEMPX(I),KCHAN)
        TAU2=TAUHRS(I,KCHAN)
        RDN=RDN+.5*(B1+B2)*(TAU1-TAU2)
        B1=B2
        TAU1=TAU2
  120 CONTINUE
C
      BS=PLKRAD(SKINTK,KCHAN)
      RDN=RDN+BS*TAUHRS(LGND,KCHAN)
C
C  CONVERT RADIANCE VALUE TO BRIGHTNESS TEMPERATURE
C
      IF(RDN.GT.0.) BTSIMU = IPLKRD(RDN,KCHAN)
      RETURN
      END
