da_to_zk.inc
References to this file elsewhere.
1 subroutine da_to_zk(obs_v, mdl_v, xp, v_interp_optn, zk)
2
3 !-----------------------------------------------------------------------
4 ! Purpose: TBD
5 !-----------------------------------------------------------------------
6
7 implicit none
8
9 integer, intent(in) :: v_interp_optn
10 type(xpose_type), intent(in) :: xp!Domain decomposition vars.
11 real, intent(in) :: obs_v
12 real, dimension(xp%kms:xp%kme), intent(in) :: mdl_v
13 real, intent(out) :: zk
14
15 integer :: k
16
17 if (trace_use_frequent) call da_trace_entry("da_to_zk")
18
19 zk = missing_r
20
21 if (v_interp_optn == v_interp_p) then
22 if (obs_v > mdl_v(xp%kts) .or. obs_v < mdl_v(xp%kte)) then
23 if (anal_type_verify) then
24 ! Guo (02/06/2006), for VERifY, allow the extrapolation to obtain the zk:
25 if (obs_v > mdl_v(xp%kts)) then
26 ! below the lowest level:
27 zk = real(xp%kts+1) - &
28 (obs_v-mdl_v(xp%kts+1))/(mdl_v(xp%kts)-mdl_v(xp%kts+1))
29 else if (obs_v < mdl_v(xp%kte)) then
30 ! above the highest level:
31 zk = real(xp%kte-1) + &
32 (obs_v-mdl_v(xp%kte-1))/(mdl_v(xp%kte)-mdl_v(xp%kte-1))
33 end if
34 else
35 if (trace_use_frequent) call da_trace_exit("da_to_zk")
36 return
37 end if
38 else
39 do k = xp%kts,xp%kte-1
40 if(obs_v <= mdl_v(k) .and. obs_v >= mdl_v(k+1)) then
41 zk = real(k) + (mdl_v(k) - obs_v)/(mdl_v(k) - mdl_v(k+1))
42 exit
43 end if
44 end do
45 end if
46 else if(v_interp_optn == v_interp_h) then
47 if (obs_v < mdl_v(xp%kts) .or. obs_v > mdl_v(xp%kte)) then
48 if (anal_type_verify) then
49 ! Guo (02/06/2006), for VERifY, allow the extrapolation to obtain the zk:
50 if (obs_v < mdl_v(xp%kts)) then
51 ! below the lowest level:
52 zk = real(xp%kts+1) - &
53 (obs_v-mdl_v(xp%kts+1))/(mdl_v(xp%kts)-mdl_v(xp%kts+1))
54 else if (obs_v > mdl_v(xp%kte)) then
55 ! above the highest level:
56 zk = real(xp%kte-1) + &
57 (obs_v-mdl_v(xp%kte-1))/(mdl_v(xp%kte)-mdl_v(xp%kte-1))
58 end if
59 else
60 if (trace_use_frequent) call da_trace_exit("da_to_zk")
61 return
62 end if
63 else
64 do k = xp%kts,xp%kte-1
65 if(obs_v >= mdl_v(k) .and. obs_v <= mdl_v(k+1)) then
66 zk = real(k) + (mdl_v(k) - obs_v)/(mdl_v(k) - mdl_v(k+1))
67 exit
68 end if
69 end do
70 end if
71 end if
72
73 if (trace_use_frequent) call da_trace_exit("da_to_zk")
74
75 end subroutine da_to_zk
76
77