da_jo_and_grady_sonde_sfc.inc

References to this file elsewhere.
1 subroutine da_jo_and_grady_sonde_sfc( 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 % sonde_sfc_u = 0.0
21    jo % sonde_sfc_v = 0.0
22    jo % sonde_sfc_t = 0.0
23    jo % sonde_sfc_p = 0.0
24    jo % sonde_sfc_q = 0.0
25 
26    if (testing_dm_exact) then
27       if (iv%num_sound_glo == 0) return
28    else
29       if (iv%num_sound < 1) return
30    end if
31 
32    do n=1, iv%num_sound
33       jo_grad_y%sonde_sfc(n)%u = -re%sonde_sfc(n)%u / &
34         ( iv%sonde_sfc(n)%u%error * iv%sonde_sfc(n)%u%error)
35       jo_grad_y%sonde_sfc(n)%v = -re%sonde_sfc(n)%v / &
36         ( iv%sonde_sfc(n)%v%error * iv%sonde_sfc(n)%v%error)
37       jo_grad_y%sonde_sfc(n)%t = -re%sonde_sfc(n)%t / &
38         ( iv%sonde_sfc(n)%t%error * iv%sonde_sfc(n)%t%error)
39       jo_grad_y%sonde_sfc(n)%p = -re%sonde_sfc(n)%p / &
40         ( iv%sonde_sfc(n)%p%error * iv%sonde_sfc(n)%p%error)
41       jo_grad_y%sonde_sfc(n)%q = -re%sonde_sfc(n)%q / &
42         ( iv%sonde_sfc(n)%q%error * iv%sonde_sfc(n)%q%error)
43    end do
44 
45    ! Bitwise-exact reduction preserves operation order of serial code for
46    ! testing, at the cost of much-increased run-time.  Turn it off when not
47    ! testing.  This will always be .false. for a serial run.
48    if (testing_dm_exact) then
49       ! collect all obs in serial order and allocate global objects
50       call da_to_global_sonde_sfc( iv,      re,      jo_grad_y, &
51                            iv_glob, re_glob, jo_grad_y_glob)
52       ! perform remaining computations
53       call da_jo_sonde_sfc_uvtq( iv_glob, re_glob, jo_grad_y_glob, jo)
54       ! free global objects
55       call da_deallocate_global_sonde_sfc( iv_glob, re_glob, jo_grad_y_glob)
56    else
57       ! perform remaining computations
58       call da_jo_sonde_sfc_uvtq( iv, re, jo_grad_y, jo)
59    end if
60 
61    jo % sonde_sfc_u = 0.5 * jo % sonde_sfc_u
62    jo % sonde_sfc_v = 0.5 * jo % sonde_sfc_v
63    jo % sonde_sfc_t = 0.5 * jo % sonde_sfc_t
64    jo % sonde_sfc_p = 0.5 * jo % sonde_sfc_p
65    jo % sonde_sfc_q = 0.5 * jo % sonde_sfc_q
66 
67    return
68 
69 end subroutine da_jo_and_grady_sonde_sfc
70 
71