1 subroutine da_residual_lightning(iv, y, re,np_missing, np_bad_data,np_obs_used, np_available)
3 !-----------------------------------------------------------------------
4 ! Purpose: Calculate residuals for lightning obs
5 ! Authors: Z Chen (zchen@fjnu.edu.cn), Jenny Sun (NCAR), X Qie (IAP)
6 !-----------------------------------------------------------------------
10 type (iv_type), intent(in) :: iv ! Innovation vector (O-B).
11 type (y_type) , intent(in) :: y ! y = H (xa)
12 type (y_type) , intent(inout) :: re ! Residual vector (O-A).
14 integer , intent(inout) :: np_available
15 integer , intent(inout) :: np_obs_used
16 integer , intent(inout) :: np_missing
17 integer , intent(inout) :: np_bad_data
19 type (bad_data_type) :: n_obs_bad
22 if (trace_use_dull) call da_trace_entry("da_residual_lightning")
24 n_obs_bad%w%num = number_type(0, 0, 0)
25 n_obs_bad%q%num = number_type(0, 0, 0)
26 n_obs_bad%div%num = number_type(0, 0, 0)
28 do n = 1, iv%info(lightning)%nlocal
29 do k = 1, iv%info(lightning)%levels(n)
31 if(use_lightning_w) then
32 np_available = np_available + 1
33 re%lightning(n)%w(k) = da_residual(n, k, y%lightning(n)%w(k), iv%lightning(n)%w(k), n_obs_bad % w)
36 if(use_lightning_div) then
37 np_available = np_available + 1
38 re%lightning(n)%div(k) = da_residual(n, k, y%lightning(n)%div(k), iv%lightning(n)%div(k), n_obs_bad % div)
41 if(use_lightning_qv) then
42 np_available = np_available + 1
43 re%lightning(n)%qv(k) = da_residual(n, k, y%lightning(n)%qv(k), iv%lightning(n)%qv(k), n_obs_bad % q)
48 np_missing = np_missing + n_obs_bad%w%num%miss + n_obs_bad%div%num%miss + n_obs_bad%q%num%miss
49 np_bad_data = np_bad_data + n_obs_bad%w%num%bad + n_obs_bad%div%num%bad + n_obs_bad%q%num%bad
50 np_obs_used = np_obs_used + n_obs_bad%w%num%use + n_obs_bad%div%num%use + n_obs_bad%q%num%use
52 if (trace_use_dull) call da_trace_exit("da_residual_lightning")
54 end subroutine da_residual_lightning