!=======================================
! 2D cumulus model - kaminari
!  - subroutine pr2pi
! 
! Author    : TAKAHASHI Koko
! Date      : 2003/11/01
! Note      : $B05NO(B<->$BL5<!8505NOJQ49(B
! 
!=======================================
!---------------------------------------
subroutine pr2pi(s, i, k,im, km, pr0, rd, cp, pr, pi)

  implicit none

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

  real(8), intent(inout) :: pr(0:im+1,0:km+1)
  real(8), intent(out) :: pi(0:im+1,0:km+1)

  real(8), intent(in) :: pr0
  real(8), intent(in) :: rd
  real(8), intent(in) :: cp

  integer, intent(in) :: i, k, s

  ! $B05NO$+$iL5<!8505NO$X$NJQ49(B
  if (s == 0) then
     pi(i,k) = (pr(i,k)/pr0)**(rd/cp)
  else if (s == 1) then
  ! $BL5<!8505NO$+$i05NO$X$NJQ49(B
     pr(i,k) = pr0*pi(i,k)**(cp/rd)
  end if

end subroutine pr2pi
