1 subroutine da_jo_and_grady_sonde_sfc( iv, re, jo, jo_grad_y)
3 !-----------------------------------------------------------------------
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.
15 ! the following "global" objects are used only when testing
16 type(iv_type) :: iv_glob ! Global Innovation vector(O-B).
17 type(y_type) :: re_glob ! Global Residual vector(O-A).
18 type(y_type) :: jo_grad_y_glob ! Global Grad_y(Jo)
20 if (trace_use_dull) call da_trace_entry("da_jo_and_grady_sonde_sfc")
22 jo % sonde_sfc_u = 0.0
23 jo % sonde_sfc_v = 0.0
24 jo % sonde_sfc_t = 0.0
25 jo % sonde_sfc_p = 0.0
26 jo % sonde_sfc_q = 0.0
28 if (test_dm_exact) then
29 if (iv%info(sound)%ntotal == 0) then
30 if (trace_use_dull) call da_trace_exit("da_jo_and_grady_sonde_sfc")
34 if (iv%info(sound)%nlocal < 1) then
35 if (trace_use_dull) call da_trace_exit("da_jo_and_grady_sonde_sfc")
40 do n=1, iv%info(sound)%nlocal
41 jo_grad_y%sonde_sfc(n)%u = -re%sonde_sfc(n)%u / (iv%sonde_sfc(n)%u%error * iv%sonde_sfc(n)%u%error)
42 jo_grad_y%sonde_sfc(n)%v = -re%sonde_sfc(n)%v / (iv%sonde_sfc(n)%v%error * iv%sonde_sfc(n)%v%error)
43 jo_grad_y%sonde_sfc(n)%t = -re%sonde_sfc(n)%t / (iv%sonde_sfc(n)%t%error * iv%sonde_sfc(n)%t%error)
44 jo_grad_y%sonde_sfc(n)%p = -re%sonde_sfc(n)%p / (iv%sonde_sfc(n)%p%error * iv%sonde_sfc(n)%p%error)
45 jo_grad_y%sonde_sfc(n)%q = -re%sonde_sfc(n)%q / (iv%sonde_sfc(n)%q%error * iv%sonde_sfc(n)%q%error)
48 ! Bitwise-exact reduction preserves operation order of serial code for
49 ! testing, at the cost of much-increased run-time. Turn it off when not
50 ! testing. This will always be .false. for a serial run.
51 if (test_dm_exact) then
52 ! collect all obs in serial order and allocate global objects
53 call da_to_global_sonde_sfc( iv, re, jo_grad_y, iv_glob, re_glob, jo_grad_y_glob)
54 ! perform remaining computations
55 call da_jo_sonde_sfc_uvtq( iv_glob, re_glob, jo_grad_y_glob, jo)
57 call da_deallocate_global_sonde_sfc( iv_glob, re_glob, jo_grad_y_glob)
59 ! perform remaining computations
60 call da_jo_sonde_sfc_uvtq( iv, re, jo_grad_y, jo)
63 jo % sonde_sfc_u = 0.5 * jo % sonde_sfc_u
64 jo % sonde_sfc_v = 0.5 * jo % sonde_sfc_v
65 jo % sonde_sfc_t = 0.5 * jo % sonde_sfc_t
66 jo % sonde_sfc_p = 0.5 * jo % sonde_sfc_p
67 jo % sonde_sfc_q = 0.5 * jo % sonde_sfc_q
69 if (trace_use_dull) call da_trace_exit("da_jo_and_grady_sonde_sfc")
71 end subroutine da_jo_and_grady_sonde_sfc