da_jo_and_grady_ssmt2.inc

References to this file elsewhere.
1 subroutine da_jo_and_grady_ssmt2(iv, re, jo, jo_grad_y)
2 
3    !-----------------------------------------------------------------------
4    ! Purpose: TBD
5    !-----------------------------------------------------------------------
6 
7    implicit none
8 
9    type (ob_type), intent(in)   :: iv          ! Innovation vector.
10    type (y_type), intent(in)    :: re          ! Residual vector.
11    type (y_type), intent(inout) :: jo_grad_y   ! Grad_y(Jo)
12    type (jo_type), intent(inout):: jo          ! Obs cost function.
13 
14    integer                      :: n, k
15 
16    jo % ssmt2_rh = 0.0
17 
18    if (iv%num_ssmt2 > 0) then
19    
20       do n=1, iv%num_ssmt2
21          do k=1, iv%ssmt2(n)%info%levels
22 
23             jo_grad_y%ssmt2(n)%rh(k) = -re%ssmt2(n)%rh(k) / &
24                                       (iv%ssmt2(n)%rh(k)%error * &
25                                         iv%ssmt2(n)%rh(k)%error)
26 
27             jo % ssmt2_rh = jo % ssmt2_rh - &
28                             re%ssmt2(n)%rh(k) * jo_grad_y%ssmt2(n)%rh(k)
29          end do
30       end do
31 
32       jo % ssmt2_rh = 0.5 * jo % ssmt2_rh
33 
34    end if
35 
36 end subroutine da_jo_and_grady_ssmt2
37 
38