subroutine Hchange( Ha, Hj, Hk, N, Nk, k, v, jv, hops )
integer(ip), intent(in) :: N, Nk, k, jv
real(rp), intent(in) :: v
integer(ip), intent(inout) :: Hj(N), Hk(Nk)
real(rp), intent(inout) :: Ha(N)
integer(ip), intent(out) :: hops
!==================================================================
! Hchange changes Ha(k) to v in heap of length N.
!
! 01 May 2002: Need Nk for length of Hk.
! 07 May 2002: Protect input parameters N, Nk, k.
! 07 May 2002: Current version of Hchange.
! 12 Dec 2011: First f90 version.
!==================================================================
integer(ip) :: kx, Nx, Nkx
real(rp) :: v1
Nx = N
Nkx = Nk
kx = k
v1 = Ha(k)
Ha(k) = v
Hj(k) = jv
Hk(jv) = k
if (v1 < v) then
call Hup ( Ha, Hj, Hk, Nx, Nkx, kx, hops )
else
call Hdown ( Ha, Hj, Hk, Nx, Nkx, kx, hops )
end if
end subroutine Hchange