!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! $BI=Bj(B: $BJQ?t$rB-$7B3$1$k(B(SNP $B$H(B AVE $B$N0c$$$KCm0U(B)
! 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine monit_add_2(var_name, data, dtime)
  
  use prm      , only : imax, jmax
  use com_monit, only : mxptr_2, mxptr_nouse_2, sum_2, name_2, name_nouse_2 &
       &                ,tflg_2
  use com_step,  only : monit2D_flg 


  implicit none
  
  real(8),           intent(IN) :: data(1:IMAX, 1:JMAX)  ! $B2C$($kJQ?t(B
  character(LEN=10), intent(IN) :: var_name              ! $BJQ?tL>(B
  real(8)          , intent(IN) :: dtime                 ! $B2C$($k;~$N&$(BT
  integer                       :: iptr   ! $B%]%$%s%?$N0LCV(B
  
  integer                       :: i 
  write(6, *)'mxptr_2' , mxptr_2
  
  iptr = -999
  do i = 1, mxptr_2
     if(var_name == name_2(i))then
        iptr = i  
        exit 
     end if
  end do
  if(iptr == -999)then
     do i = 1, mxptr_nouse_2
        if(var_name == name_nouse_2(i))then
           return
        end if
     end do
     write(6, *) 'ERROR, cannot find the keyword data', &
          & var_name ,': monit_add_2'
     stop
  end if

  ! $B=V4VCM$J$i=PNO$9$k;~0J30$O2C$($J$$(B.
  if(tflg_2(iptr) == 'SNP' .and. monit2D_flg /= 1)then
     return
  end if

  sum_2(:, :, iptr) =  sum_2(:, :, iptr) + data(:, :)*dtime
  


end subroutine monit_add_2


subroutine monit_add_3(var_name, data, dtime)
  
  use prm      , only : imax, jmax, kmax
  use com_monit, only : mxptr_3, mxptr_nouse_3, sum_3, name_3, name_nouse_3 &
       &                ,tflg_3
  use com_step,  only : monit3D_flg 


  implicit none
  
  real(8),           intent(IN) :: data(1:IMAX, 1:JMAX, 1:KMAX)  ! $B2C$($kJQ?t(B
  character(LEN=10), intent(IN) :: var_name              ! $BJQ?tL>(B
  real(8)          , intent(IN) :: dtime                 ! $B2C$($k;~$N&$(BT
  integer                       :: iptr   ! $B%]%$%s%?$N0LCV(B
  
  integer                       :: i 
  write(6, *)'mxptr_3' , mxptr_3
  
  iptr = -999
  do i = 1, mxptr_3
     if(var_name == name_3(i))then
        iptr = i  
        exit 
     end if
  end do
  if(iptr == -999)then
     do i = 1, mxptr_nouse_3
        if(var_name == name_nouse_3(i))then
           return
        end if
     end do
     write(6, *) 'ERROR, cannot find the keyword data', &
          & var_name ,': monit_add_3'
     stop
  end if

  ! $B=V4VCM$J$i=PNO$9$k;~0J30$O2C$($J$$(B.
  if(tflg_3(iptr) == 'SNP' .and. monit3D_flg /= 1)then
     return
  end if

  sum_3(:, :, :, iptr) =  sum_3(:, :, :, iptr) + data(:, :, :)*dtime
  


end subroutine monit_add_3
