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 (ob_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 jo % airsr_t = 0.0
18 jo % airsr_q = 0.0
19
20 if (iv%num_airsr < 0) return
21
22 do n=1, iv%num_airsr
23 do k=1, iv%airsr(n)%info%levels
24 jo_grad_y%airsr(n)%t(k) = -re%airsr(n)%t(k) / &
25 (iv%airsr(n)%t(k)%error * &
26 iv%airsr(n)%t(k)%error)
27 jo_grad_y%airsr(n)%q(k) = -re%airsr(n)%q(k) / &
28 (iv%airsr(n)%q(k)%error * &
29 iv%airsr(n)%q(k)%error)
30 end do
31
32 if (iv%airsr(n)%loc%proc_domain) then
33 do k=1, iv%airsr(n)%info%levels
34 jo % airsr_t = jo % airsr_t - &
35 re%airsr(n)%t(k) * jo_grad_y%airsr(n)%t(k)
36 jo % airsr_q = jo % airsr_q - &
37 re%airsr(n)%q(k) * jo_grad_y%airsr(n)%q(k)
38 end do
39 end if
40 end do
41
42 jo % airsr_t = 0.5 * jo % airsr_t
43 jo % airsr_q = 0.5 * jo % airsr_q
44
45 end subroutine da_jo_and_grady_airsr
46
47