1 subroutine da_jo_and_grady_lightning(iv, re, jo, jo_grad_y)
3 !-----------------------------------------------------------------------
5 ! Authors: Z Chen (zchen@fjnu.edu.cn), Jenny Sun (NCAR), X Qie (IAP)
6 !-----------------------------------------------------------------------
10 type (iv_type), intent(in) :: iv ! Innovation vector.
11 type (y_type), intent(in) :: re ! Residual vector.
12 type (y_type), intent(inout) :: jo_grad_y ! Grad_y(Jo)
13 type (jo_type), intent(inout) :: jo ! Obs cost function.
16 if (trace_use_dull) call da_trace_entry("da_jo_and_grady_lightning")
18 ! defined in da_define_structure.f90
19 jo % lightning_w = 0.0
20 jo % lightning_div = 0.0
21 jo % lightning_qv = 0.0
23 do n = 1, iv%info(lightning)%nlocal
24 do k = 2, iv%info(lightning)%levels(n)
25 if(use_lightning_w) then
26 jo_grad_y%lightning(n)%w(k) = -re%lightning(n)%w(k)/(iv%lightning(n)%w(k)%error * iv%lightning(n)%w(k)%error)
29 if(use_lightning_div) then
30 jo_grad_y%lightning(n)%div(k) = -re%lightning(n)%div(k)/(iv%lightning(n)%div(k)%error * iv%lightning(n)%div(k)%error)
33 if(use_lightning_qv) then
34 jo_grad_y%lightning(n)%qv(k) = -re%lightning(n)%qv(k)/(iv%lightning(n)%qv(k)%error * iv%lightning(n)%qv(k)%error)
38 if(iv%info(lightning)%proc_domain(1,n)) then
39 do k = 2, iv%info(lightning)%levels(n)
41 if(use_lightning_w) then
42 jo%lightning_w = jo%lightning_w-re%lightning(n)%w(k)*jo_grad_y%lightning(n)%w(k)
45 if(use_lightning_div) then
46 jo%lightning_div = jo%lightning_div-re%lightning(n)%div(k) * jo_grad_y%lightning(n)%div(k)
49 if(use_lightning_qv) then
50 jo%lightning_qv = jo%lightning_qv-re%lightning(n)%qv(k)*jo_grad_y%lightning(n)%qv(k)
58 jo%lightning_w = 0.5 * jo % lightning_w
59 jo%lightning_div = 0.5 * jo % lightning_div
60 jo%lightning_qv = 0.5 * jo % lightning_qv
62 if (trace_use_dull) call da_trace_exit("da_jo_and_grady_lightning")
64 end subroutine da_jo_and_grady_lightning