1 subroutine da_jo_and_grady_gpsref( iv, re, jo, jo_grad_y)
3 !-----------------------------------------------------------------------
5 !-----------------------------------------------------------------------
7 !----------------------------------------------------------------------
8 ! Called by da_minimisation/da_jo_and_grady.inc
9 !----------------------------------------------------------------------
13 type(iv_type), intent(in) :: iv ! Innovation vector.
14 type(y_type), intent(in) :: re ! Residual vector.
15 type(y_type), intent(inout) :: jo_grad_y ! Grad_y(Jo)
16 type(jo_type), intent(inout) :: jo ! Obs cost function.
20 if (trace_use_dull) call da_trace_entry("da_jo_and_grady_gpsref")
24 do n=1, iv%info(gpsref)%nlocal
25 do k=1, iv%info(gpsref)%levels(n)
26 jo_grad_y%gpsref(n)%ref(k) = -re%gpsref(n)%ref(k) / &
27 ( iv%gpsref(n)%ref(k)%error * iv%gpsref(n)%ref(k)%error)
30 if (iv%info(gpsref)%proc_domain(1,n)) then
31 do k=1, iv%info(gpsref)%levels(n)
32 jo % gpsref_ref = jo % gpsref_ref - &
33 re%gpsref(n)%ref(k) * jo_grad_y%gpsref(n)%ref(k)
39 jo % gpsref_ref = 0.5 * jo % gpsref_ref
41 if (trace_use_dull) call da_trace_exit("da_jo_and_grady_gpsref")
43 end subroutine da_jo_and_grady_gpsref