!=======================================
! 2D cumulus model - kaminari
!  - subroutine prss2pi
! 
! Author    : TAKAHASHI Koko
! Date      : 2003/11/01
! Note      : $B05NO(B<->$BL5<!8505NOJQ49(B
!             s = 0 $B$G05NO$+$iL5<!8505NO$X$NJQ49(B
!             s = 1 $B$GL5<!8505NO$+$i05NO$X$NJQ49(B
! 
!=======================================
!---------------------------------------
subroutine prss2pi(s, i, k,im, km, prss_sfc, rd, cp, prss, pi)

  implicit none

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

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

  real(8), intent(in) :: prss_sfc
  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) = (prss(i,k)/prss_sfc)**(rd/cp)
  else if (s == 1) then
  ! $BL5<!8505NO$+$i05NO$X$NJQ49(B
     prss(i,k) = prss_sfc*pi(i,k)**(cp/rd)
  end if

end subroutine prss2pi
