      SUBROUTINE SIMCRAD(TEMP,TAUHRS,SURTMP,LGND,KCHAN,RADSIM)
      IMPLICIT NONE
C
C**********************************************************************
C
C   NAME- SIMCRAD   
C
C   LANGUAGE- FORTRAN     TYPE- MAIN
C
C   VERSION- 1.0    DATE- 07/27/06   PROGRAMMER- FRANK TILLEY (IMSG)
C
C   FUNCTION- THIS ROUTINE CALCULATES SIMULATED CHANNEL RADIANCES
C        FOR CALCULATION OF ATTENUATION OBOVE A GIVEN PRESSURE LEVEL,
C        USUALLY THE CLOUD TOP
C
C        THIS ROUTINE WAS ADAPTED FROM ROUTINE 'SIMCBT'
C
C   PARAMETERS-
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      RADSIM                  REAL  O   SIMULATED RADIANCE FOR CHANNEL
C                                        KCHAN
C
C   COMMON AREAS- RETPARM
C
C
C**********************************************************************
C
C
      INCLUDE 'RETPARM'

      REAL   TAUHRS(PRFTLV,11),TEMP(PRFTLV),TEMPX(PRFTLV),IPLKRD,PLKRAD
      REAL   RADSIM, 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.) THEN
         RADSIM = RDN
      ELSE
         RADSIM = PLKRAD(SURTMP,KCHAN)
      END IF
      RETURN
      END
