da_jo_and_grady_airsr.inc
References to this file elsewhere.
1 subroutine da_jo_and_grady_airsr(iv, re, jo, jo_grad_y)
2
3 !-------------------------------------------------------------------------
4 ! Purpose: Calculates cost function and its gradient at all AIRS
5 ! retrieval locations
6 !-------------------------------------------------------------------------
7
8 implicit none
9
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.
14
15 integer :: n, k
16
17 if (trace_use_dull) call da_trace_entry("da_jo_and_grady_airsr")
18
19 jo % airsr_t = 0.0
20 jo % airsr_q = 0.0
21
22 do n=1, iv%info(airsr)%nlocal
23 do k=1, iv%info(airsr)%levels(n)
24 jo_grad_y%airsr(n)%t(k) = -re%airsr(n)%t(k) / (iv%airsr(n)%t(k)%error * iv%airsr(n)%t(k)%error)
25 jo_grad_y%airsr(n)%q(k) = -re%airsr(n)%q(k) / (iv%airsr(n)%q(k)%error * iv%airsr(n)%q(k)%error)
26 end do
27
28 if (iv%info(airsr)%proc_domain(1,n)) then
29 do k=1, iv%info(airsr)%levels(n)
30 jo % airsr_t = jo % airsr_t - re%airsr(n)%t(k) * jo_grad_y%airsr(n)%t(k)
31 jo % airsr_q = jo % airsr_q - re%airsr(n)%q(k) * jo_grad_y%airsr(n)%q(k)
32 end do
33 end if
34 end do
35
36 jo % airsr_t = 0.5 * jo % airsr_t
37 jo % airsr_q = 0.5 * jo % airsr_q
38
39 if (trace_use_dull) call da_trace_exit("da_jo_and_grady_airsr")
40
41 end subroutine da_jo_and_grady_airsr
42
43