updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / var / da / da_test / da_check_xtoy_adjoint_ships.inc
blob995391f83d71eae2712a9d940d85a9ce1a694784
1 subroutine da_check_xtoy_adjoint_ships(iv, y, adjtest_lhs, pertile_lhs)
3    !-----------------------------------------------------------------------
4    ! Purpose: TBD
5    !-----------------------------------------------------------------------
7    implicit none
9    type (iv_type), intent(in)     :: iv            ! obs. inc. vector (o-b).
10    type (y_type) , intent(inout)  :: y             ! y = h (xa)
11    real          , intent(inout)  :: adjtest_lhs, pertile_lhs   
13    integer :: n             ! Loop counter.
15    if (trace_use_dull) call da_trace_entry("da_check_xtoy_adjoint_ships")
17    do n=iv%info(ships)%n1, iv%info(ships)%n2
18       if (iv%info(ships)%zk(1,n) < 1.0 .and. sfc_assi_options == 1) then
19          y%ships(n)%u = 0.0
20          y%ships(n)%v = 0.0
21          y%ships(n)%t = 0.0
22          y%ships(n)%p = 0.0
23          y%ships(n)%q = 0.0
25          cycle
26       end if
28       if ( sfc_assi_options == 2 ) then
29           if (iv%ships(n)%u%qc < 0) y%ships(n)%u = 0.0
30           if (iv%ships(n)%v%qc < 0) y%ships(n)%v = 0.0
31           if (iv%ships(n)%t%qc < 0) y%ships(n)%t = 0.0
32           if (iv%ships(n)%p%qc < 0) y%ships(n)%p = 0.0
33           if (iv%ships(n)%q%qc < 0) y%ships(n)%q = 0.0
34       end if
36       y%ships(n)%u = y%ships(n)%u/typical_u_rms
37       y%ships(n)%v = y%ships(n)%v/typical_v_rms
38       y%ships(n)%t = y%ships(n)%t/typical_t_rms
39       y%ships(n)%p = y%ships(n)%p/typical_p_rms
40       y%ships(n)%q = y%ships(n)%q/typical_q_rms
42       if (iv%info(ships)%proc_domain(1,n)) then
43          adjtest_lhs = adjtest_lhs  &
44             + (y%ships(n)%u)**2 &
45             + (y%ships(n)%v)**2 &
46             + (y%ships(n)%t)**2 &
47             + (y%ships(n)%p)**2 &
48             + (y%ships(n)%q)**2
49       end if
51       pertile_lhs = pertile_lhs &
52          + (y%ships(n)%u)**2 &
53          + (y%ships(n)%v)**2 &
54          + (y%ships(n)%t)**2 &
55          + (y%ships(n)%p)**2 &
56          + (y%ships(n)%q)**2
58       y%ships(n)%u = y%ships(n)%u/typical_u_rms
59       y%ships(n)%v = y%ships(n)%v/typical_v_rms
60       y%ships(n)%t = y%ships(n)%t/typical_t_rms
61       y%ships(n)%p = y%ships(n)%p/typical_p_rms
62       y%ships(n)%q = y%ships(n)%q/typical_q_rms
63    end do
65    if (trace_use_dull) call da_trace_exit("da_check_xtoy_adjoint_ships")
67 end subroutine da_check_xtoy_adjoint_ships