!=======================================
! 2D cumulus model - kaminari
!  - subroutine a_filter
! 
! Author    : TAKAHASHI Koko
! Date      : 2004/01/05 $B?75,:n@.(B
! Note      : Asselin $B$N;~4V%U%#%k%?(B
! 
!=======================================
subroutine a_filter(im,km,mu_a,ptemp,ptemp_old,ptemp_old2)

  implicit none

  integer(8), intent(in) :: im, km

  real(8), intent(in) :: mu_a

  real(8), intent(in) :: ptemp(-2:im+2,-2:km+2)
  real(8), intent(in) :: ptemp_old(-2:im+2,-2:km+2)

  real(8), intent(out) :: ptemp_old2(-2:im+2,-2:km+2)

  integer(8) :: i, k

  real(8) :: ptemp_f(-2:im+2,-2:km+2)

  do k = -2,km+2
     do i = -2,im+2
        ptemp_f(i,k) = ptemp_old(i,k)                       &
             &       + mu_a                                 &
             &         *(                                   &
             &           ptemp(i,k) - 2.0d0*ptemp_old(i,k)  &
             &           + ptemp_f(i,k)                     &
             &          )
        ptemp_old2(i,k) = ptemp_f(i,k)
     end do
  end do

end subroutine a_filter
