!=================================================================
!  一次元 CO2 大気放射対流平衡計算プログラム; 
!  上向き放射束密度の計算
!  (Pollack et al., 1981:J. Atmos. Sci., 38, 3--29.)
!
!  1999/05/25  小高正嗣
!  1999/06/04  小高正嗣
!=================================================================

      subroutine CLFXRDU
     I   ( BBRAD , EQWDTH, TEMP0,
     O     FXRADU,
     C     SIGMA , TSFC  ,
     D     NZ    , NZB   , NXB   )

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

      dimension
     \   BBRAD(-2:NZB), TEMP0(-2:NZB), FXRADU(-2:NZB)

      dimension EQWDTH(0:NZ,0:NZ)
      dimension TSFC(-2:NXB)

      parameter( pi = 3.14159263D0 )
      parameter( NU = 667.0D0 )

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

      BBRAD( 0) = ( 1.1911D-8 * NU**3 ) /
     \        ( EXP( 1.439D0 * NU / TSFC(0) ) - 1.0D0 )

      do iz = 0, NZ

         FXRADU( iz ) = SIGMA * TSFC(0)**4.

         do jz = 1, iz

            DELBBR = BBRAD( jz - 1 ) - BBRAD( jz ) 
c            DELBBR = BBRAD( jz  ) - BBRAD( jz - 1 ) 

            FXRADU( iz ) = FXRADU( iz ) - 
     \           2.0D0 * pi * 0.488D0 * DELBBR * EQWDTH( iz, jz-1 )
         end do
      end do

      FXRADU(-1)   = FXRADU(0) 
      FXRADU(-2)   = FXRADU(0) 
c      FXRADU(NZ-1) = FXRADU(NZ-2) 
c      FXRADU(NZ)   = FXRADU(NZ-1) 
      FXRADU(NZ+1) = FXRADU(NZ) 
      FXRADU(NZ+2) = FXRADU(NZ) 

      return

      end
