da_jo_and_grady_synop.inc
References to this file elsewhere.
1 subroutine da_jo_and_grady_synop(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
15 ! the following "global" objects are used only when testing
16 type (ob_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)
19
20 jo % synop_u = 0.0
21 jo % synop_v = 0.0
22 jo % synop_t = 0.0
23 jo % synop_p = 0.0
24 jo % synop_q = 0.0
25
26 if (testing_dm_exact) then
27 if (iv%num_synop_glo == 0) return
28 else
29 if (iv%num_synop < 1) return
30 end if
31
32 do n=1, iv%num_synop
33
34 jo_grad_y%synop(n)%u = -re%synop(n)%u / &
35 (iv%synop(n)%u%error * iv%synop(n)%u%error)
36 jo_grad_y%synop(n)%v = -re%synop(n)%v / &
37 (iv%synop(n)%v%error * iv%synop(n)%v%error)
38 jo_grad_y%synop(n)%t = -re%synop(n)%t / &
39 (iv%synop(n)%t%error * iv%synop(n)%t%error)
40 jo_grad_y%synop(n)%p = -re%synop(n)%p / &
41 (iv%synop(n)%p%error * iv%synop(n)%p%error)
42 jo_grad_y%synop(n)%q = -re%synop(n)%q / &
43 (iv%synop(n)%q%error * iv%synop(n)%q%error)
44 end do
45
46 ! Bitwise-exact reduction preserves operation order of serial code for
47 ! testing, at the cost of much-increased run-time. Turn it off when not
48 ! testing. This will always be .false. for a serial run.
49 if (testing_dm_exact) then
50 ! collect all obs in serial order and allocate global objects
51 call da_to_global_synop(iv, re, jo_grad_y, &
52 iv_glob, re_glob, jo_grad_y_glob)
53 ! perform remaining computations
54 call da_jo_synop_uvtq(iv_glob, re_glob, jo_grad_y_glob, jo)
55 ! free global objects
56 call da_deallocate_global_synop(iv_glob, re_glob, jo_grad_y_glob)
57 else
58 ! perform remaining computations
59 call da_jo_synop_uvtq(iv, re, jo_grad_y, jo)
60 end if
61
62 jo % synop_u = 0.5 * jo % synop_u
63 jo % synop_v = 0.5 * jo % synop_v
64 jo % synop_t = 0.5 * jo % synop_t
65 jo % synop_p = 0.5 * jo % synop_p
66 jo % synop_q = 0.5 * jo % synop_q
67
68 end subroutine da_jo_and_grady_synop
69
70