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