1 subroutine da_jo_and_grady_geoamv( iv, re, jo, jo_grad_y)
3 !-------------------------------------------------------------------------
4 ! Purpose: Calculates Cost function and Gradient for Geo. CVMs
5 !-------------------------------------------------------------------------
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.
16 if (trace_use_dull) call da_trace_entry("da_jo_and_grady_geoamv")
21 if (iv%info(geoamv)%nlocal > 0) then
22 do n=1, iv%info(geoamv)%nlocal
23 do k=1, iv%info(geoamv)%levels(n)
24 jo_grad_y%geoamv(n)%u(k) = -re%geoamv(n)%u(k) / ( iv%geoamv(n)%u(k)%error * iv%geoamv(n)%u(k)%error)
25 jo_grad_y%geoamv(n)%v(k) = -re%geoamv(n)%v(k) / ( iv%geoamv(n)%v(k)%error * iv%geoamv(n)%v(k)%error)
28 do k=1, iv%info(geoamv)%levels(n)
29 if (iv%info(geoamv)%proc_domain(1,n)) then
30 jo % geoamv_u = jo % geoamv_u - re%geoamv(n)%u(k) * jo_grad_y%geoamv(n)%u(k)
31 jo % geoamv_v = jo % geoamv_v - re%geoamv(n)%v(k) * jo_grad_y%geoamv(n)%v(k)
36 jo % geoamv_u = 0.5 * jo % geoamv_u
37 jo % geoamv_v = 0.5 * jo % geoamv_v
40 if (trace_use_dull) call da_trace_exit("da_jo_and_grady_geoamv")
42 end subroutine da_jo_and_grady_geoamv