!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2004. All rights reserved.
!---------------------------------------------------------------------
                                                                 !=begin
!=Module Summation
!
!  * Developer: KITAMORI Taichi
!  * Version: $Id: summation.f90,v 1.1.2.3 2005/11/14 01:49:46 kitamo Exp $
!  * Tag: $Name: arare3m $
!  * Change History:
!
!==Overview
!
!配列変数を領域積算した値を返す. 
!
!==Error Handling
!
!==Known Bugs
!
!==Note
!
!==Future Plans
!
                                                                 !=end
module summation

  interface sumxz
     function sumxz(var)
       use gridset
       real(8), intent(in) :: var(DimXMin:DimXMax, DimZMin:DimZMax)
       real(8)             :: sumxz
     end function sumxz
  end interface

  interface sumx
     function sumx(var)
        use gridset
        real(8), intent(in) :: var(DimXMin:DimXMax)
        real(8)             :: sumx
     end function sumx
  end interface

end module summation

function sumxz(var)
  use gridset
  implicit none

  real(8), intent(in) :: var(DimXMin:DimXMax, DimZMin:DimZMax)
  real(8)             :: sumxz
  integer             :: i,k

  sumxz = 0.0d0
  do k = RegZMin, RegZMax
     do i = RegXMin, RegXMax
        sumxz = sumxz + var(i,k)
     end do
  end do

end function sumxz

function sumx(var)
  use gridset
  implicit none

  real(8), intent(in) :: var(DimXMin:DimXMax)
  real(8)             :: sumx
  integer             :: i

  sumx = 0.0d0
  do i = RegXMin, RegXMax
     sumx = sumx + var(i)
  end do

end function sumx
