!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2005. All rights reserved.
!---------------------------------------------------------------------
                                                                 !=begin
!= Subroutine 
!
!   * Developer: SUGIYAMA Ko-ichiro
!   * Version: $Id: $
!   * Tag Name: $Name:  $
!   * Change History: 
!
!== Overview
!
!$BCH$+$$1+$N%P%k%/K!(B
! 
!== Error Handling
!
!== Bugs
!
!== Note
!
!  *$BDj<02=$NET9g>e(B, $B?e>x5$!&1@?e!&1+?e$N:.9gHf$O4pK\>l$H>qMp$NCM$NOB$H$7$F$"$k(B
!  *$B:.9gHf$NCM$K4pK\>l$NCM$r:9$79~$`$N$O(B, $B%a%$%s%W%m%0%i%`(B init.f90 $B$G9T$&(B. 
!
!== Future Plans
!
!
                                                                 !=end
subroutine WarmRainPrm( &
     & DelTime, &
     & fs_VelX_nl, sf_VelZ_nl, ss_Exner_nl, &
     & ss_PotTemp_nl, ss_PotTemp_bl, &
     & ss_MixRtV_nl, ss_MixRtV_bl, &
     & ss_MixRtC_nl, ss_MixRtC_bl, &
     & ss_MixRtR_nl,  ss_MixRtR_bl, &
     & ss_Kh_bl, &
     & ss_PotTemp_al, &
     & ss_MixRtV_al, &
     & ss_MixRtC_al, &
     & ss_MixRtR_al, &
     & ss_EVrv_nl, & 
     & ss_CNcr_nl,&
     & ss_CLcr_nl,& 
     & ss_VelZRain_nl,& 
     & ss_PRr_nl, &
     & ss_MixRtSat_nl    )
                                                                 !=end
                                                                 !=begin
  !== Dependency
  use dc_trace, only: BeginSub, EndSub
  use gridset,  only: DimXMin, DimXMax, DimZMin, DimZMax, RegXMin, RegZMin
  use bcset,    only: ss_BC
  use average,  only: ss_avr_fs, ss_avr_sf, fs_avr_ss, sf_avr_ss
  use basicset, only: ss_ExnerBasicZ, &
       &              ss_DensBasicZ,  &
       &              ss_CpBasicZ,    &
       &              ss_PotTempBasicZ
  use physset,  only: PressSfc, CpDry, GasRDry, LatentHeat, epsilon
  use arareset, only: Min
  use differentiate_center4, only: fs_dx_ss, ss_dx_fs, sf_dz_ss, ss_dz_sf
                                                                 !=end
  !--- $B0EL[$N7?@k8@6X;_(B
  implicit none
                                                                 !=begin  
  !== Input
  real(8), intent(in) :: DelTime !$B@QJ,;~4V(B
  real(8), intent(in) :: ss_Exner_nl(DimXMin:DimXMax, DimZMin:DimZMax) !$B%(%/%9%J!<4X?t(B
  real(8), intent(in) :: ss_PotTemp_nl(DimXMin:DimXMax, DimZMin:DimZMax) !$B290L(B
  real(8), intent(in) :: ss_PotTemp_bl(DimXMin:DimXMax, DimZMin:DimZMax) !$B290L(B
  real(8), intent(in) :: ss_MixRtV_nl(DimXMin:DimXMax, DimZMin:DimZMax) !$B?e>x5$NL(B
  real(8), intent(in) :: ss_MixRtV_bl(DimXMin:DimXMax, DimZMin:DimZMax) !$B?e>x5$NL(B
  real(8), intent(in) :: ss_MixRtC_nl(DimXMin:DimXMax, DimZMin:DimZMax) !$B1@N3:.9gHf(B
  real(8), intent(in) :: ss_MixRtC_bl(DimXMin:DimXMax, DimZMin:DimZMax) !$B1@N3:.9gHf(B
  real(8), intent(in) :: ss_MixRtR_nl(DimXMin:DimXMax, DimZMin:DimZMax)  !$B1+N3:.9gHf(B
  real(8), intent(in) :: ss_MixRtR_bl(DimXMin:DimXMax, DimZMin:DimZMax)  !$B1+N3:.9gHf(B
  real(8), intent(in) :: fs_VelX_nl(DimXMin:DimXMax, DimZMin:DimZMax)   !$BB.EY(B u
  real(8), intent(in) :: sf_VelZ_nl(DimXMin:DimXMax, DimZMin:DimZMax)   !$BB.EY(B w
  real(8), intent(in) :: ss_Kh_bl(DimXMin:DimXMax, DimZMin:DimZMax) !$B12G4@-78?t(B
                                                                 !=end
                                                                 !=begin
  !== Out
  real(8), intent(Out)  :: ss_PotTemp_al(DimXMin:DimXMax, DimZMin:DimZMax) !$B290L(B
  real(8), intent(Out)  :: ss_MixRtV_al(DimXMin:DimXMax, DimZMin:DimZMax) !$B?e>x5$:.9gHf(B
  real(8), intent(Out)  :: ss_MixRtC_al(DimXMin:DimXMax, DimZMin:DimZMax)!$B1@N3:.9gHf(B
  real(8), intent(Out)  :: ss_MixRtR_al(DimXMin:DimXMax, DimZMin:DimZMax) !$B1+N3:.9gHf(B
  real(8), intent(Out)  :: ss_EVrv_nl(DimXMin:DimXMax, DimZMin:DimZMax) !$B>xH/$K$h$k1+?e$+$i?e>x5$$X$NJQ49(B
  real(8), intent(Out)  :: ss_CNcr_nl(DimXMin:DimXMax, DimZMin:DimZMax) !$BJ;9g@.D9$K$h$k1@?e$+$i1+?e$X$NJQ49(B
  real(8), intent(Out)  :: ss_CLcr_nl(DimXMin:DimXMax, DimZMin:DimZMax) !$B6E7k$K$h$k?e>x5$$+$i1@?e$X$NJQ49(B
  real(8), intent(Out)  :: ss_VelZRain_nl(DimXMin:DimXMax, DimZMin:DimZMax) !$B1+N3=*C<B.EY(B
  real(8), intent(Out)  :: ss_PRr_nl(DimXMin:DimXMax, DimZMin:DimZMax) !$B6E7k$K$h$k?e>x5$$+$i1@?e$X$NJQ49(B. 
  real(8), intent(Out)  :: ss_MixRtSat_nl(DimXMin:DimXMax, DimZMin:DimZMax) !$BK0OB>x5$05(B
                                                                 !=end 

  !== Work       
  real(8)  :: ss_Gamma(DimXMin:DimXMax, DimZMin:DimZMax) ! $B@xG.(B / ( $BHfG.(B * $B%(%/%9%J!<4X?t(B ) 
  real(8) :: ss_PressAll_nl(DimXMin:DimXMax, DimZMin:DimZMax) ! $BA405(B
  real(8) :: ss_TempAll_nl(DimXMin:DimXMax, DimZMin:DimZMax)  ! $BA429EY(B
  real(8) :: TempAll_now
  real(8) :: MixRtSat_now
  real(8) :: DeltaMixRtC_now
  real(8) :: ErrMixRtC_now
  real(8) :: PotTemp_now
  real(8) :: MixRtV_now
  real(8) :: MixRtC_now
  real(8) :: PotTemp_next
  real(8) :: MixRtV_next
  real(8) :: MixRtC_next
  real(8) :: DensGround         ! $BCOI=LLL)EY(B
  integer :: i, k, num          ! $BE:$(;z(B  
  real(8), parameter :: K1 = 1.0d-3  !$B%1%9%i!<$N78?t(B
  real(8), parameter :: K2 = 2.2d0   !$B%1%9%i!<$N78?t(B
  real(8), parameter :: A  = 1.0d-3  !$B1@?eNL$NogCM(B
  ! H2O(g,l) $B$NCM(B
  real(8), parameter :: AA = 7.9186968d0  !Antoine $B$N78?t(B A
  real(8), parameter :: AB = 1636.909d0   !Antoine $B$N78?t(B B
  real(8), parameter :: AC = 224.92d0     !Antoine $B$N78?t(B C
  
  
  !=== $B%5%V%k!<%A%s$N=i4|2=(B
  call BeginSub("Scalar", &
       &        fmt="%c",              &
       &        c1="Time integration of scalar component.")
  
  !=== $BJQ?t$N=i4|2=(B
  ss_PressAll_nl = &
       & PressSfc * (( ss_ExnerBasicZ + ss_Exner_nl ) ** ( CpDry / GasRDry ))
  ss_Gamma   = LatentHeat / ( ss_ExnerBasicZ * ss_CpBasicZ ) 
  DensGround = ss_DensBasicZ(RegXMin, RegZMin)   ! X $B:BI8$O$I$3$G$bF1$8(B

  !=== $BJQ?t$KNm$rBeF~(B
  call warmrainprm_init

!!!
!!! $B7W;;$KI,MW$H$J$k(B, $B?e>x5$(B--$B1@N3(B--$B1+N34V$NJQ4978?t$r5a$a$k(B
!!!
  !--- $BK0OB>x5$05$N7W;;(B
  ss_TempAll_nl = &
       & ( ss_Exner_nl + ss_ExnerBasicZ )*( ss_PotTemp_nl + ss_PotTempBasicZ )
  
!  ss_MixRtSat_nl = &
!       &   epsilon * 610.78d0 &
!       & * dexp( 17.269d0 * ( ss_TempAll_nl - 273.16d0 )   &
!       &                  / ( ss_TempAll_nl - 35.86d0  ) ) &
!       & /  ss_PressAll_nl &
  ss_MixRtSat_nl = &
       & epsilon    &
       & * dexp( ( AA - ( AB / ( AC + ss_TempAll_nl - 273.15d0 ) ) ) &
       &      * dlog( 10.0d0 ) + dlog( 133.322d0 ) )    &
       & / ss_PressAll_nl 
  
  !--- $B>xH/$K$h$k1+?e$+$i?e>x5$$X$NJQ49(B
  where (       ss_MixRtV_nl / ss_MixRtSat_nl < 1.0d0  & 
       &  .AND. ss_MixRtR_nl > Min )
     ss_EVrv_nl = &
          & (  &
          &     ( 1.0d0 - ss_MixRtV_nl / ss_MixRtSat_nl ) &
          &   * ( 1.6d0 + 124.9d0 * ( ss_DensBasicZ * ss_MixRtR_nl )&
          &      **( 0.2046d0 ) ) &
          &   * (ss_DensBasicZ * ss_MixRtR_nl )** ( 0.525d0 ) &
          &  ) &
          & /   &
          & ( &
          &     ss_DensBasicZ &
          &   * ( 5.4d5 &
          &        + 2.55d6 / ( ss_PressAll_nl * ss_MixRtSat_nl ) ) &
          &  )
  end where

  !--- $BJ;9g@.D9$K$h$k1@?e$+$i1+?e$X$NJQ49(B
  where ( ss_MixRtC_nl > A )
     ss_CNcr_nl = K1 * ( ss_MixRtC_nl - A )
  end where

  !--- $B6E7k$K$h$k?e>x5$$+$i1@?e$X$NJQ49(B
  where ( ss_MixRtC_nl > Min .AND. ss_MixRtR_nl > Min )
     ss_CLcr_nl = &
          & K2 * ss_MixRtC_nl * ( ss_MixRtR_nl )**( 0.875d0 )
  end where

  !--- $B6E7k$K$h$k?e>x5$$+$i1@?e$X$NJQ49(B. $B=*C<B.EY$r7W;;$7$F$+$iI>2A(B.
  !---- $B1+N3=*C<B.EY(B
  where ( ss_MixRtR_nl > Min )
     ss_VelZRain_nl = &
          &   36.34d0 * ( ss_DensBasicZ * ss_MixRtR_nl )**( 0.1346d0 ) &
          &           * ( ( DensGround / ss_DensBasicZ ) ** ( - 5.0d-1 ) )
  end where

  !---- $B6E7k$K$h$k?e>x5$$+$i1@?e$X$NJQ49(B. 
  !------ Dens $B$N(B avr $B$r<h$C$F$+$i3d$k$H(B, $B%<%m3d$,@8$8$k$N$GCm0U(B
  where ( ss_MixRtR_nl > Min )
     ss_PRr_nl &
          & = ss_avr_sf(  &
          &    sf_dz_ss( ss_DensBasicZ * ss_VelZRain_nl * ss_MixRtR_nl )&
          &   ) /  ss_DensBasicZ 
  end where
  
  
!!!
!!!$BAjJQ2=$rI=8=$9$kItJ,$r=|$$$F290L(B, $B:.9gHf$N<0$r2r$/(B
!!!
  !=== $B;~4V@QJ,(B. $B;~4VJ}8~$K%j!<%W%U%m%C%0(B, $B6u4VJ}8~$KCf?4:9J,(B
  !---- $B290L(B
  ss_PotTemp_al =                                                         &
       &   ss_PotTemp_bl                                                  &
       & + 2.0d0 * DelTime                                                &
       &   * (                                                            &
       &       - ss_Adv_ss(  ss_PotTemp_nl + ss_PotTempBasicZ,            &
       &                     fs_VelX_nl, sf_VelZ_nl )                     &
       &       + ss_Turb_ss( ss_PotTemp_bl + ss_PotTempBasicZ, ss_Kh_bl ) &
       &       + ss_NumDiff_ss( ss_PotTemp_bl )                           &
       &       - ss_Gamma * ss_EVrv_nl                                    &
       &     )

  !---- $B?e>x5$:.9gHf(B
  ss_MixRtV_al =                                                     &
       &   ss_MixRtV_bl                                              &  
       & + 2.0d0 * DelTime                                           &
       &   * (                                                       &
       &       - ss_Adv_ss(  ss_MixRtV_nl, fs_VelX_nl, sf_VelZ_nl )  &
       &       + ss_Turb_ss( ss_MixRtV_bl, ss_Kh_bl )                & 
       &       + ss_NumDiff_ss( ss_MixRtV_bl )                       &
       &       + ss_EVrv_nl                                          &
       &     )

  !---- $B1@N3:.9gHf(B
  ss_MixRtC_al =                                                     & 
       &   ss_MixRtC_bl                                              &
       & + 2.0d0 * DelTime                                           &
       &   * (                                                       &
       &       - ss_Adv_ss(  ss_MixRtC_nl, fs_VelX_nl, sf_VelZ_nl )  & 
       &       + ss_Turb_ss( ss_MixRtC_bl, ss_Kh_bl )                &
       &       + ss_NumDiff_ss( ss_MixRtC_bl )                       &
       &       - ss_CNcr_nl - ss_CLcr_nl                             &
       &     )

  !---- $B1+N3:.9gHf(B
  ss_MixRtR_al  =                                                    &
       &   ss_MixRtR_bl                                              &
       & + 2.0d0 * DelTime                                           &
       &   * (                                                       &
       &      - ss_Adv_ss(  ss_MixRtR_nl, fs_VelX_nl, sf_VelZ_nl )   &
       &      + ss_Turb_ss( ss_MixRtR_bl, ss_Kh_bl )                 &
       &      + ss_NumDiff_ss( ss_MixRtR_bl )                        &
       &      + ss_CNcr_nl + ss_CLcr_nl - ss_EVrv_nl + ss_PRr_nl     &
       &     )
  
  
  !=== $BCM$,Ii$K$J$C$?$H$-$N=hM}(B
  call FillNegative( ss_MixRtV_al  )
  call FillNegative( ss_MixRtC_al )
  call FillNegative( ss_MixRtR_al  )

  !----- $B<~0O$,(B 0 $B$G0l%+=j$@$17j$,6u$$$F$7$^$C$?$H$-$N=hM}(B
  !----- $B1+?e$N$h$&$K?t%]%$%s%H$@$1CM$r;}$D>l9g$KH/@8$9$k$3$H$,$"$k(B
  where ( ss_MixRtR_al < 0.0d0 ) 
     ss_MixRtR_al  = 0.0d0 
  end where


!!!
!!! $B<>=aK0OBD4@aK!$rMQ$$$??e>x5$(B--$B1@N34V$NJQ49(B
!!!
  MoistAjastX: do i = DimXMin, DimXMax
     MoistAjastZ: do k = DimZMin, DimZMax

        !=== $B:#$^$G$KF@$i$l$?JQ?t$r;CDjNL$H$_$J$9(B. $BE:$(;z$rJQ99(B
        MixRtV_now  = ss_MixRtV_al(i,k)
        MixRtC_now  = ss_MixRtC_al(i,k)
        PotTemp_now = ss_PotTemp_al(i,k)
        
        !=== $B%k!<%W2s?t$N=i4|2=(B
        num = 0

        Ajasting: do 
           !---- $BK0OB>x5$05$N7W;;(B
           TempAll_now  = ( PotTemp_now + ss_PotTempBasicZ(i,k) ) &
                &       * ( ss_Exner_nl(i,k) + ss_ExnerBasicZ(i,k) )
!           MixRtSat_now &
!                & =   epsilon * 610.78d0 &
!                &   * dexp( 17.269d0 * ( TempAll_now - 273.16d0 ) &
!                &           / ( TempAll_now - 35.86d0 ) ) &
!                &   / ss_PressAll_nl(i,k)
           MixRtSat_now = &
                & epsilon    &
                & * dexp( ( AA - ( AB / ( AC + TempAll_now - 273.15d0 ) ) ) &
                &      * dlog( 10.0d0 ) + dlog( 133.322d0 ) )    &
                & / ss_PressAll_nl(i,k)

!           write(*,*) i, k, ";  Temp:             ", TempAll_now
!           write(*,*) i, k, ";  MixRtSat: ", MixRtSat_now
     
           !---- $B2aK0OB$N%A%'%C%/(B.
           !---- $B8m:9$r5vMF@dBP8m:9(B Min $B$H5vMFAjBP8m:9(B Min $B$G2!$5$($k(B
           DeltaMixRtC_now =  MixRtV_now - MixRtSat_now 
!           write(*,*) i, k, ";  DeltaMixRtC: ", DeltaMixRtC_now
!           write(*,*) i, k, ";  MixRtC_now:  ", MixRtC_now
                      

           !---- $B2aK0OB$b$7$/$O;CDjE*$J1@N3:.9gHf$,%<%m0J>e$J$i(B, $BCM$rJd@5(B
           if (        DeltaMixRtC_now > Min    &
                & .OR. MixRtC_now      > 1.0d-16  ) then 
!              write(*,*) i, k, ";  Temp:             ", TempAll_now
!              write(*,*) i, k, "; DeltaMixRtC: ", DeltaMixRtC_now
!              write(*,*) i, k, "; MixRtC:      ", MixRtC_now
              
!              PotTemp_next = &
!                   &   PotTemp_now  &
!                   & + ss_Gamma(i,k) * DeltaMixRtC_now  &
!                   &    / (   1.0d0 + ss_Gamma(i,k) * MixRtSat_now &
!                   &        * 4097.93d0 * ss_ExnerBasicZ(i,k) &
!                   &        / ( TempAll_now - 35.86d0) ** 2.0d0 )
              PotTemp_next = &
                   &   PotTemp_now  &
                   & + ss_Gamma(i,k) * DeltaMixRtC_now  &
                   &    / (   1.0d0 + ss_Gamma(i,k)      &
                   &       * epsilon &
                   &       * dexp( AB * dlog( 10.0d0 )                    &
                   &            * ( PotTemp_now + ss_PotTempBasicZ(i,k))  &
                   &            / (( AC + TempAll_now - 273.15d0 )**2.0d0 ) )&
                   &       / ss_PressAll_nl(i,k) )
              
              MixRtV_next = &
                   &   MixRtV_now &
                   & + ( PotTemp_now - PotTemp_next ) / ss_Gamma(i,k)
              
              MixRtC_next = &
                   &   MixRtV_now &
                   & + MixRtC_now &
                   & - MixRtV_next
              
              !---- $B1@N3L)EY:.9gHf$NAjBP8m:9$N%A%'%C%/(B
              ErrMixRtC_now &
                   & = abs( ( MixRtC_next - MixRtC_now ) &
                   &        / MixRtC_next )

              !--- $B1@N3:.9gHf$,<}B+$7$F$$$?$i7+$jJV$7$rCf;_$9$k(B
              if (        ErrMixRtC_now <= 1.0d-10 &
                   & .OR. MixRtC_now    <= 1.0d-16 ) then 
                 ss_PotTemp_al(i,k) = PotTemp_next                 
                 ss_MixRtV_al(i,k) = MixRtV_next
                 ss_MixRtC_al(i,k) = MixRtC_next
                 exit Ajasting
              end if

              !--- $B%k!<%W2s?t$,2s$j$9$.$?$i%(%i!<$rEG$$$FB3$1$k(B
              if ( num > 20 ) then 
!                 write(*,*) "Looping is too much, num > 20"
!                 write(*,*) "ErrMixRtC_now =     ", ErrMixRtC_now 
!                 write(*,*) "ss_PotTemp_al(i,k) =     ", PotTemp_next
!                 write(*,*) "ss_MixRtV_al(i,k) = ", MixRtV_next
!                 write(*,*) "ss_MixRtC_al(i,k) = ", MixRtC_next
                 ss_PotTemp_al(i,k) = PotTemp_next                 
                 ss_MixRtV_al(i,k) = MixRtV_next
                 ss_MixRtC_al(i,k) = MixRtC_next
                 exit Ajasting
              end if
              
           else
              ss_PotTemp_al(i,k) = &
                   & PotTemp_now - ss_Gamma(i,k) * MixRtC_now
              
              ss_MixRtV_al(i,k) = &
                   & MixRtV_now + MixRtC_now
              
              ss_MixRtC_al(i,k) = 0.0d0
              
              !--- $B<}B+$7$?$HH=Dj$7$F7+$jJV$7$rCf;_$9$k(B
              exit Ajasting
           end if
           
           !---- $B7+$jJV$7$N$?$a$NJQ?tDj5A(B
           PotTemp_now       = PotTemp_next
           MixRtV_now = MixRtV_next
           MixRtC_now = MixRtC_next
           num             = num + 1
           
        end do Ajasting

     end do MoistAjastZ
  end do MoistAjastX

  !=== $B6-3&>r7o(B
  call boundary(ss_BC, ss_PotTemp_al     )
  call boundary(ss_BC, ss_MixRtV_al )
  call boundary(ss_BC, ss_MixRtC_al )
  call boundary(ss_BC, ss_MixRtR_al  )  

  call EndSub("Scalar")



  
contains
                                                                 !=begin
  function ss_Adv_ss( ss_Scalar, fs_VelX, sf_VelZ )
    use gridset, only: DimXMin, DimXMax, DimZMin, DimZMax
    use average,  only: ss_avr_fs, ss_avr_sf
    use differentiate_center4, only: fs_dx_ss, sf_dz_ss
    implicit none

    real(8), intent(in) :: fs_VelX(DimXMin:DimXMax, DimZMin:DimZMax)
    real(8), intent(in) :: sf_VelZ(DimXMin:DimXMax, DimZMin:DimZMax)
    real(8), intent(in) :: ss_Scalar(DimXMin:DimXMax, DimZMin:DimZMax)
    real(8)             :: ss_Adv_ss(DimXMin:DimXMax, DimZMin:DimZMax)

    ss_Adv_ss = 0.0d0  !$B=i4|2=(B
    ss_Adv_ss = &
         &   ss_avr_fs( fs_VelX * fs_dx_ss( ss_Scalar ) ) &
         & + ss_avr_sf( sf_VelZ * sf_dz_ss( ss_Scalar ) )

  end function ss_Adv_ss


  function ss_Turb_ss( ss_Scalar, ss_Kh )
    use gridset, only: DimXMin, DimXMax, DimZMin, DimZMax
    use average,  only: fs_avr_ss, sf_avr_ss
    use differentiate_center4, only: ss_dx_fs, fs_dx_ss, ss_dz_sf, sf_dz_ss
    implicit none

    real(8), intent(in) :: ss_Kh(DimXMin:DimXMax, DimZMin:DimZMax)
    real(8), intent(in) :: ss_Scalar(DimXMin:DimXMax, DimZMin:DimZMax)
    real(8)             :: ss_Turb_ss(DimXMin:DimXMax, DimZMin:DimZMax)

    ss_Turb_ss = 0.0d0  !$B=i4|2=(B
    ss_Turb_ss = &
         &   ss_dx_fs( fs_avr_ss( ss_Kh ) * fs_dx_ss( ss_Scalar ) ) &
         & + ss_dz_sf( sf_avr_ss( ss_Kh ) * sf_dz_ss( ss_Scalar ) )

  end function ss_Turb_ss


  function ss_NumDiff_ss( ss_Scalar )
    use gridset, only: DimXMin, DimXMax, DimZMin, DimZMax
    use differentiate_center4, only: ss_dx_fs, fs_dx_ss, ss_dz_sf, sf_dz_ss
    use arareset, only: NuH, NuV
    implicit none

    real(8), intent(in) :: ss_Scalar(DimXMin:DimXMax, DimZMin:DimZMax)
    real(8)             :: ss_NumDiff_ss(DimXMin:DimXMax, DimZMin:DimZMax)
    
    ss_NumDiff_ss = 0.0d0  !$B=i4|2=(B
    ss_NumDiff_ss = &
         &   NuH * ( ss_dx_fs( fs_dx_ss( ss_Scalar ) ) ) &
         & + NuV * ( ss_dz_sf( sf_dz_ss( ss_Scalar ) ) ) 
    
  end function ss_NumDiff_ss

    
  subroutine warmrainprm_init
    !---- $B=PNOJQ?t(B
    ss_PotTemp_al       = 0.0d0 
    ss_MixRtV_al = 0.0d0 
    ss_MixRtC_al = 0.0d0 
    ss_MixRtR_al  = 0.0d0 
    
    !---- $BFbItJQ?t(B
    ss_MixRtSat_nl  = 0.0d0 
    ss_EVrv_nl = 0.0d0 
    ss_CNcr_nl = 0.0d0 
    ss_CLcr_nl = 0.0d0 
    ss_VelZRain_nl = 0.0d0 
    ss_PRr_nl = 0.0d0 
    
    ss_TempAll_nl = 0.0d0
    MixRtSat_now = 0.0d0 
    DeltaMixRtC_now = 0.0d0 
    PotTemp_now = 0.0d0 
    MixRtV_now = 0.0d0 
    MixRtC_now = 0.0d0 
    PotTemp_next = 0.0d0 
    MixRtV_next = 0.0d0 
    MixRtC_next = 0.0d0 

  end subroutine warmrainprm_init
  

end subroutine WarmRainPrm
