!=================================================================
!  CO2 大気放射計算プログラム; 
!  上向き放射束密度の計算
!  (Savijarvi, 1991:Contr. Atmos. Phys. 64, 103-112.)
!
!  2000/05/03  小高正嗣
!  2000/05/12  小高正嗣; 2D モデルへ
!=================================================================

      subroutine CLFXRDU
     I   ( BBRAD , BBRAD_S, TAUN, INB , 
     O     FXRADU,
     D     NZ   , NZB   , NX  , NXB , NBND )

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

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

      dimension 
     \   TAUN(  0:NZ+1,  0:NZ+1, NBND )

      dimension
     \   BBRAD_S( -2:NXB )

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

      do ix = -2, NXB
      do iz = 0, NZ+1

! 地表面からの寄与は波長積分を容易にするため吸収量を評価する. 

         FXRADU(ix,iz) = BBRAD_S(ix) * ( TAUN(0,iz,INB) - 1.0D0 )

         do jz = 1, iz
            DELTAU = TAUN(jz,iz,INB) - TAUN(jz-1,iz,INB)
            FXRADU(ix,iz) = FXRADU(ix,iz) + DELTAU * BBRAD(ix,jz-1)
         end do

      end do
      end do

      do ix = -2, NXB 
         FXRADU( ix, -1 )    = FXRADU( ix, 0 )  
         FXRADU( ix, -2 )    = FXRADU( ix, 0 )  
         FXRADU( ix, NZ+2 ) = FXRADU( ix, NZ+1 )  
      end do

      return

      end
