!=================================================================
! 一次元灰色大気放射対流平衡計算プログラム; 
! 黒体輻射の計算
!
!  1999/05/27  小高正嗣
!  1999/06/07  小高正嗣
!  2000/05/16  小高正嗣
!=================================================================

      subroutine CLBBRAD
     I   ( TEMP , WNU,
     O     BBRAD, BBRAD_S,
     C     TSFC ,
     D     NX   , NXB, 
     D     NZ   , NZB  )

!-----------------------------------------------------------------      
      implicit real*8 ( a-h,o-z )
!-----------------------------------------------------------------      

      dimension
     \   TEMP ( -2:NXB, -2:NZB ), 
     \   BBRAD( -2:NXB, -2:NZB ),
     \   BBRAD_S( -2:NXB ),
     \   TSFC(-2:NXB)

      parameter( pi = 3.14159263D0 )

!-----------------------------------------------------------------      

      do ix = -2, NXB
         BBRAD_S(ix) = pi * ( 1.1911D-8 * WNU**3 ) /
     \        ( EXP( 1.439D0 * WNU / TSFC(ix) ) - 1.0D0 )
      end do

      do iz = 0, NZB
         do ix = -2, NXB
!            TEMPM = ( TEMP( ix , iz ) + TEMP( ix , iz-1 ) ) * 0.5D0
         
            BBRAD(ix,iz) = pi * ( 1.1911D-8 * WNU**3 ) /
     \           ( EXP( 1.439D0 * WNU / TEMP(ix,iz) ) - 1.0D0 )
         end do
      end do

      do ix = -2, NXB
         BBRAD( ix, -1 )    = BBRAD( ix, 0 )
         BBRAD( ix, -2 )    = BBRAD( ix, 0 )
      end do
      
      return
      end
