1 subroutine da_get_innov_vector_lightning( it, grid, ob, iv)
2 !-----------------------------------------------------------------------
4 ! Authors: Z Chen (zchen@fjnu.edu.cn), Jenny Sun (NCAR), X Qie (IAP)
5 !-----------------------------------------------------------------------
9 integer, intent(in) :: it ! External iteration.
10 type(domain), intent(in) :: grid ! first guess state.
11 type(y_type), intent(inout) :: ob ! Observation structure.
12 type(iv_type), intent(inout) :: iv ! O-B structure.
14 integer :: n ! Loop counter.
15 integer :: i, j, k ! Index dimension.
16 real :: dx, dxm ! Interpolation weights.
17 real :: dy, dym ! Interpolation weights.
18 integer :: num_levs ! obs vertical levels
19 real :: div(kts:kte) ! Model divergence at ob loc
20 real :: w(kts:kte) ! Model vertical velocity
22 if (trace_use) call da_trace_entry("da_get_innov_vector_lightning")
25 do n = iv%info(lightning)%n1, iv%info(lightning)%n2
26 do k = 1, iv%info(lightning)%levels(n)
27 if(iv%lightning(n)% w(k)%qc == fails_error_max) iv%lightning(n)% w(k)%qc = 0
28 if(iv%lightning(n)%div(k)%qc == fails_error_max) iv%lightning(n)%div(k)%qc = 0
29 if(iv%lightning(n)% qv(k)%qc == fails_error_max) iv%lightning(n)% qv(k)%qc = 0
34 do n = iv%info(lightning)%n1, iv%info(lightning)%n2
35 num_levs = iv%info(lightning)%levels(n)
42 ! [1.0] Get cross pt. horizontal interpolation weights:
44 i = iv%info(lightning)%i(1,n)
45 dy = iv%info(lightning)%dy(1,n)
46 dym = iv%info(lightning)%dym(1,n)
47 j = iv%info(lightning)%j(1,n)
48 dx = iv%info(lightning)%dx(1,n)
49 dxm = iv%info(lightning)%dxm(1,n)
51 ! [2.0] Calculate vertical profile of divergence and qv at obs pt.
54 iv % lightning(n) % w(k) % inv = 0.0
55 iv % lightning(n) % div(k) % inv = 0.0
56 iv % lightning(n) % qv(k) % inv = 0.0
58 if(use_lightning_w) then
59 if(ob%lightning(n)%w(k) > missing_r .and. iv%lightning(n)%w(k)%qc >= obs_qc_pointer) then
60 w(k) = dym*(dxm*grid%xb%w(i,j,k)+dx*grid%xb%w(i+1,j,k))+dy*(dxm*grid%xb%w(i,j+1,k)+dx*grid%xb%w(i+1,j+1,k))
61 iv%lightning(n)%w(k)%qc = obs_qc_pointer
62 iv%lightning(n)%w(k)%inv = ob%lightning(n)%w(k) - w(k)
66 if(use_lightning_div) then
67 if(ob%lightning(n)%div(k) > missing_r .and. iv%lightning(n)%div(k)%qc >= obs_qc_pointer) then
68 iv%lightning(n)%div(k)%qc = obs_qc_pointer
69 call da_div_profile(grid, iv%info(lightning), n, k, div(k))
70 iv%lightning(n)%div(k)%inv = ob%lightning(n)%div(k) - div(k)
74 if(use_lightning_qv) then
75 if(ob%lightning(n)%qv(k) > missing_r .and. iv%lightning(n)%qv(k)%qc >= obs_qc_pointer) then
76 iv%lightning(n)%qv(k)%inv = ob%lightning(n)%qv(k) - grid%xb%q(i,j,k)
77 iv%lightning(n)%qv(k)%inv = amax1(0.0, iv%lightning(n)%qv(k)%inv)
84 ! -----------------------------------------------------------------------
85 ! [3.0] Perform optional maximum error check:
86 !-----------------------------------------------------------------------
89 call da_check_max_iv_lightning(iv, ob, it)
91 if (trace_use) call da_trace_exit("da_get_innov_vector_lightning")
93 end subroutine da_get_innov_vector_lightning