<HTML> <BODY BGCOLOR=#ccccdd LINK=#0000aa VLINK=#0000ff ALINK=#ff0000 ><BASE TARGET="bottom_target"><PRE>
<A NAME='DA_TO_ZK'><A href='../../html_code/interpolation/da_to_zk.inc.html#DA_TO_ZK' TARGET='top_target'><IMG SRC="../../gif/bar_red.gif" border=0></A>
subroutine da_to_zk(obs_v, mdl_v, v_interp_optn, zk) 45,4
!-----------------------------------------------------------------------
! Purpose: TBD
!-----------------------------------------------------------------------
implicit none
integer, intent(in) :: v_interp_optn
real, intent(in) :: obs_v
real, dimension(kms:kme), intent(in) :: mdl_v
real, intent(out) :: zk
integer :: k
if (trace_use_dull) call da_trace_entry
("da_to_zk")
zk = missing_r
if (v_interp_optn == v_interp_p) then
if (obs_v > mdl_v(kts) .or. obs_v < mdl_v(kte)) then
if (anal_type_verify) then
! Guo (02/06/2006), for VERifY, allow the extrapolation to obtain the zk:
if (obs_v > mdl_v(kts)) then
! below the lowest level:
zk = real(kts+1) - &
(obs_v-mdl_v(kts+1))/(mdl_v(kts)-mdl_v(kts+1))
else if (obs_v < mdl_v(kte)) then
! above the highest level:
zk = real(kte-1) + &
(obs_v-mdl_v(kte-1))/(mdl_v(kte)-mdl_v(kte-1))
end if
else
if (trace_use_dull) call da_trace_exit
("da_to_zk")
return
end if
else
do k = kts,kte-1
if(obs_v <= mdl_v(k) .and. obs_v >= mdl_v(k+1)) then
zk = real(k) + (mdl_v(k) - obs_v)/(mdl_v(k) - mdl_v(k+1))
exit
end if
end do
end if
else if(v_interp_optn == v_interp_h) then
if (obs_v < mdl_v(kts) .or. obs_v > mdl_v(kte)) then
if (anal_type_verify) then
! Guo (02/06/2006), for VERifY, allow the extrapolation to obtain the zk:
if (obs_v < mdl_v(kts)) then
! below the lowest level:
zk = real(kts+1) - &
(obs_v-mdl_v(kts+1))/(mdl_v(kts)-mdl_v(kts+1))
else if (obs_v > mdl_v(kte)) then
! above the highest level:
zk = real(kte-1) + &
(obs_v-mdl_v(kte-1))/(mdl_v(kte)-mdl_v(kte-1))
end if
else
if (trace_use_dull) call da_trace_exit
("da_to_zk")
return
end if
else
do k = kts,kte-1
if(obs_v >= mdl_v(k) .and. obs_v <= mdl_v(k+1)) then
zk = real(k) + (mdl_v(k) - obs_v)/(mdl_v(k) - mdl_v(k+1))
exit
end if
end do
end if
end if
if (trace_use_dull) call da_trace_exit
("da_to_zk")
end subroutine da_to_zk