da_get_innov_vector_sound.inc

References to this file elsewhere.
1 subroutine da_get_innov_vector_sound( it, xb, xp, ob, iv)
2 
3    !-----------------------------------------------------------------------
4    ! Purpose: TBD
5    ! Update :
6    !     01/24/2007    Syed RH Rizvi
7    !     Updated for "VERIFY"       
8    !-----------------------------------------------------------------------
9 
10    implicit none
11 
12    integer,           intent(in)    :: it       ! External iteration.
13    type(xb_type),    intent(in)    :: xb       ! first guess state.
14    type(xpose_type), intent(in)    :: xp       ! Domain decomposition vars.
15    type(y_type),     intent(inout) :: ob       ! Observation structure.
16    type(ob_type),    intent(inout) :: iv       ! O-B structure.
17 
18    integer                        :: n        ! Loop counter.
19    integer                        :: i, j, k  ! Index dimension.
20    integer                        :: num_levs ! Number of obs levels.
21    real                           :: dx, dxm  ! Interpolation weights.
22    real                           :: dy, dym  ! Interpolation weights.
23 
24    real, dimension(1:max_ob_levels) :: model_u  ! Model value u at ob location.
25    real, dimension(1:max_ob_levels) :: model_v  ! Model value v at ob location.
26    real, dimension(1:max_ob_levels) :: model_t  ! Model value t at ob location.
27    real, dimension(1:max_ob_levels) :: model_q  ! Model value q at ob location.
28    ! real, dimension(1:max_ob_levels) :: model_h  ! Model value h at ob location.
29 
30    real, dimension(xp%kms:xp%kme)   :: v_h      ! Model value h at ob hor. location.
31    real, dimension(xp%kms:xp%kme)   :: v_p      ! Model value p at ob hor. location.
32 
33    integer           :: itu,ituf,itvv,itvvf,itt,ittf,itqv,itqvf
34 
35 
36 
37    if (iv%num_sound < 1) return
38 
39    itu   = 0; itvv    = 0;  itt  = 0; itqv  = 0;
40    ituf  = 0; itvvf   = 0;  ittf = 0; itqvf = 0;
41 
42    do n=iv%ob_numb(iv%current_ob_time-1)%sound + 1, &
43       iv%ob_numb(iv%current_ob_time)%sound
44       num_levs = iv%sound(n)%info%levels
45 
46       if (num_levs < 1) cycle
47 
48       model_u(:) = 0.0
49       model_v(:) = 0.0
50       model_t(:) = 0.0
51       model_q(:) = 0.0
52       ! model_h(:) = 0.0
53 
54       ! [1.1] Get horizontal interpolation weights:
55 
56       i = iv%sound(n)%loc%i
57       j = iv%sound(n)%loc%j
58       dx = iv%sound(n)%loc%dx
59       dy = iv%sound(n)%loc%dy
60       dxm = iv%sound(n)%loc%dxm
61       dym = iv%sound(n)%loc%dym
62 
63       do k=xp%kts,xp%kte
64          v_h(k) = dym*(dxm*xb%h(i,j  ,k) + dx*xb%h(i+1,j  ,k)) &
65                 + dy *(dxm*xb%h(i,j+1,k) + dx*xb%h(i+1,j+1,k))
66          v_p(k) = dym*(dxm*xb%p(i,j  ,k) + dx*xb%p(i+1,j  ,k)) &
67                 + dy *(dxm*xb%p(i,j+1,k) + dx*xb%p(i+1,j+1,k))
68       end do
69 
70       do k=1, num_levs
71          iv%sound(n)%zk(k)=missing_r
72 
73          if (iv%sound(n)%p(k) > 1.0) then
74             call da_to_zk(iv%sound(n)%p(k), v_p, xp, v_interp_p, &
75                iv%sound(n)%zk(k))
76          else if (iv%sound(n)%h(k) > 0.0) then
77             call da_to_zk(iv%sound(n)%h(k), v_h, xp, v_interp_h, &
78                iv%sound(n)%zk(k))
79          end if
80 
81          if (iv%sound(n)%zk(k) < 0.0 .and.  .not.anal_type_verify) then
82             iv%sound(n)%u(k)%qc = missing
83             iv%sound(n)%v(k)%qc = missing
84             iv%sound(n)%t(k)%qc = missing
85             iv%sound(n)%q(k)%qc = missing
86          end if
87       end do
88 
89       ! [1.2] Interpolate horizontally to ob:
90 
91       call da_interp_lin_3d( xb%u, xp, i, j, dx, dy, dxm, dym, &
92                            model_u, max_ob_levels, iv%sound(n)%zk, num_levs)
93       call da_interp_lin_3d( xb%v, xp, i, j, dx, dy, dxm, dym, &
94                            model_v, max_ob_levels, iv%sound(n)%zk, num_levs)
95       call da_interp_lin_3d( xb%t, xp, i, j, dx, dy, dxm, dym, &
96                            model_t, max_ob_levels, iv%sound(n)%zk, num_levs)
97       call da_interp_lin_3d( xb%q, xp, i, j, dx, dy, dxm, dym, &
98                            model_q, max_ob_levels, iv%sound(n)%zk, num_levs)
99 
100       ! call da_interp_lin_3d( xb%h, xp, i, j, dx, dy, dxm, dym, &
101       !   model_h, max_ob_levels, iv%sound(n)%zk, num_levs)
102 
103       !----------------------------------------------------------------------
104       ! [2.0] Initialise components of innovation vector:
105       !----------------------------------------------------------------------
106 
107       do k = 1, iv%sound(n)%info%levels
108          iv%sound(n)%u(k)%inv = 0.0
109          iv%sound(n)%v(k)%inv = 0.0
110          iv%sound(n)%t(k)%inv = 0.0
111          iv%sound(n)%q(k)%inv = 0.0
112 
113          !-------------------------------------------------------------------
114          ! [3.0] Interpolation:
115          !-------------------------------------------------------------------
116 
117          if (ob%sound(n)%u(k) > missing_r .AND. &
118               iv%sound(n)%u(k)%qc >= obs_qc_pointer) then
119             iv%sound(n)%u(k)%inv = ob%sound(n)%u(k) - model_u(k)
120          end if
121 
122          if (ob%sound(n)%v(k) > missing_r .AND. &
123               iv%sound(n)%v(k)%qc >= obs_qc_pointer) then
124             iv%sound(n)%v(k)%inv = ob%sound(n)%v(k) - model_v(k)
125          end if
126 
127 
128          if (ob%sound(n)%t(k) > missing_r .AND. &
129               iv%sound(n)%t(k)%qc >= obs_qc_pointer) then
130             iv%sound(n)%t(k)%inv = ob%sound(n)%t(k) - model_t(k)
131          end if
132 
133          if (ob%sound(n)%q(k) > missing_r .AND. &
134               iv%sound(n)%q(k)%qc >= obs_qc_pointer) then
135             iv%sound(n)%q(k)%inv = ob%sound(n)%q(k) - model_q(k)
136          end if
137       end do
138 
139       !----------------------------------------------------------------------
140       ! [5.0] Perform optional maximum error check:
141       !----------------------------------------------------------------------
142 
143       if (check_max_iv) then
144          call da_check_max_iv_sound(it, iv % sound(n), &
145            itu,ituf,itvv,itvvf,itt,ittf,itqv,itqvf)
146       end if
147    end do
148 
149    if (rootproc .and. check_max_iv_print) then
150       write(unit = check_max_iv_unit, fmt ='(A,i5,A)')'For outer iteration ',it, &
151          ', Total Rejections for Sound follows:'
152 
153       write(unit = check_max_iv_unit, fmt = '(/,10(2(A,I6),/))') &
154          'Number of failed u-wind observations:     ',ituf, ' on ',itu,   &
155          'Number of failed v-wind observations:     ',itvvf,' on ',itvv,   &
156          'Number of failed temperature observations:',ittf, ' on ',itt,   &
157          'Number of failed mixing ratio observations:',itqvf,' on ',itqv, &
158          'Finally Total Sound rejections: ',ituf+itvvf+ittf+itqvf,' on ',&
159                                             itu +itvv+itt +itqv
160    end if
161 
162 end subroutine da_get_innov_vector_sound
163 
164