updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / var / da / da_gpspw / da_jo_and_grady_gpspw.inc
blobfe6a51e767beaff31e2c084c4479d80c1d573706
1 subroutine da_jo_and_grady_gpspw(iv, re, jo, jo_grad_y)
3    !-----------------------------------------------------------------------
4    ! Purpose: TBD
5    !-----------------------------------------------------------------------
7    implicit none
9    type (iv_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.
14    integer                      :: n
16    if (trace_use_dull) call da_trace_entry("da_jo_and_grady_gpspw")
18    jo % gpspw_tpw = 0.0
20    if (iv%info(gpspw)%nlocal > 0) then
21       do n=1, iv%info(gpspw)%nlocal
22          jo_grad_y%gpspw(n)%tpw = -re%gpspw(n)%tpw / (iv%gpspw(n)%tpw%error * iv%gpspw(n)%tpw%error)
24          if (iv%info(gpspw)%proc_domain(1,n)) then
25             jo % gpspw_tpw = jo % gpspw_tpw - re%gpspw(n)%tpw * jo_grad_y%gpspw(n)%tpw
26          end if
27       end do
29       jo % gpspw_tpw = 0.5 * jo % gpspw_tpw
30    end if
32    if (trace_use_dull) call da_trace_exit("da_jo_and_grady_gpspw")
34 end subroutine da_jo_and_grady_gpspw