!=================================================================
!  CO2 大気放射計算プログラム: 近赤外放射の計算
!
!  2000/09/22  小高正嗣; 
!  2000/10/31  小高正嗣; 2D モデルへ
!=================================================================

      subroutine CLSRAD
     I   ( TAUN  , S0    , COSZ  ,
     O     SXRADU, SXRADD, SXRADN, SQRAD,
     B     TPOT0 , TEMP0 , PRES0 , DENS0 , FDZ  ,
     C     WNU_SR, 
     C     CPDRY , TSOL  , DX    , SIGMA, 
     C     DELNU , GRAV  , PI    ,
     W     SXRADU_NU, SXRADD_NU,
     D     NX ,  NXB,  NZ,  NZB,  NBNDSR )

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

      dimension
     \   TPOT0 ( -2:NZB ), TEMP0( -2:NZB ), 
     \   PRES0 ( -2:NZB ), DENS0( -2:NZB ), FDZ  ( -2:NZB ) 

      dimension
     \   WNU_SR(NBNDSR)

      dimension
     \   SXRADU(-2:NXB,-2:NZB), SXRADD(-2:NXB,-2:NZB), 
     \   SXRADN(-2:NXB,-2:NZB), SQRAD (-2:NXB,-2:NZB)

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

      dimension
     \   SXRADU_NU(-2:NXB,-2:NZB,NBNDSR), 
     \   SXRADD_NU(-2:NXB,-2:NZB,NBNDSR)

!-----------------------------------------------------------------      
! 初期化

      do iz = -2, NZB      
      do ix = -2, NXB
         SXRADU(ix,iz) = 0.0D0
         SXRADD(ix,iz) = 0.0D0
         SXRADN(ix,iz) = 0.0D0
         SQRAD (ix,iz) = 0.0D0
      end do
      end do

      do inb = 1, NBNDSR
      do iz = -2, NZB
      do ix = -2, NXB 
            SXRADU_NU(ix,iz,inb) = 0.0D0
            SXRADD_NU(ix,iz,inb) = 0.0D0
      end do
      end do
      end do

!-----------------------------------------------------------------      
! バンドごとの寄与を計算

      do inb = 1, NBNDSR
         do ix = -2, NXB

         SXRADD_NU(IX, NZ+1,inb) = PI * ( 1.1911D-8 * WNU_SR(inb)**3 ) /
     \        ( EXP( 1.439D0 * WNU_SR(inb) / TSOL ) - 1.0D0 ) * 
     \        ( S0 / ( SIGMA * TSOL ** 4.0 ) ) * COSZ

         do iz = 0, NZ
            SXRADD_NU(ix, iz,inb) = 
     \           SXRADD_NU(ix, NZ+1,inb) * TAUN(iz,NZ+1,inb)
         end do

         end do

      end do

!-----------------------------------------------------------------      
! 波長積分; バンドの両端から和をとる

      do iz = -2, NZB
      do ix = -2, NXB
         do inb = 1, NBNDSR/2
            SXRADD(ix,iz) = SXRADD(ix,iz) + DELNU * 
     \           ( SXRADD_NU(ix,iz,inb) + 
     \             SXRADD_NU(ix,iz,NBNDSR+1-inb) ) 
         end do
      end do
      end do

      call CLFXRDN
     I   ( SXRADU, SXRADD,
     O     SXRADN,
     D     NX    , NXB   , 
     D     NZ    , NZB     )

      call CLQRAD
     I   ( SXRADN, DENS0, TEMP0 , TPOT0,  PRES0 , 
     I     FDZ  , 
     O     SQRAD ,
     C     CPDRY , DX   , GRAV  ,
     D     NX    , NXB  , NZ   , NZB          )

!-----------------------------------------------------------------      
      return
      end


