Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / var / da / da_sound / da_transform_xtoy_sound.inc
blob4c37276445c4ef10523ae47805c359c18c1767b6
1 subroutine da_transform_xtoy_sound (grid, iv, y)
3    !-----------------------------------------------------------------------
4    ! Purpose: TBD
5    !    Updated for Analysis on Arakawa-C grid
6    !    Author: Syed RH Rizvi,  MMM/ESSL/NCAR,  Date: 10/22/2008
7    !-----------------------------------------------------------------------
9    implicit none
11    type (domain),     intent(in)    :: grid
12    type (iv_type),    intent(in)    :: iv       ! Innovation vector (O-B).
13    type (y_type),     intent(inout) :: y        ! y = h (grid%xa) (linear)
15    real, allocatable :: u(:,:)
16    real, allocatable :: v(:,:)
17    real, allocatable :: t(:,:)
18    real, allocatable :: q(:,:)
20    real, allocatable :: ub(:,:)
21    real, allocatable :: vb(:,:)
23    integer :: n,k
25    if (trace_use_dull) call da_trace_entry("da_transform_xtoy_sound")
27    allocate (u(iv%info(sound)%max_lev,iv%info(sound)%n1:iv%info(sound)%n2))
28    allocate (v(iv%info(sound)%max_lev,iv%info(sound)%n1:iv%info(sound)%n2))
29    allocate (t(iv%info(sound)%max_lev,iv%info(sound)%n1:iv%info(sound)%n2))
30    allocate (q(iv%info(sound)%max_lev,iv%info(sound)%n1:iv%info(sound)%n2))
32    allocate (ub(iv%info(sound)%max_lev,iv%info(sound)%n1:iv%info(sound)%n2))
33    allocate (vb(iv%info(sound)%max_lev,iv%info(sound)%n1:iv%info(sound)%n2))
34   
35 #ifdef A2C
36    call da_interp_lin_3d (grid%xa%u, iv%info(sound), u,'u')
37    call da_interp_lin_3d (grid%xa%v, iv%info(sound), v,'v')
38 #else
39    call da_interp_lin_3d (grid%xa%u, iv%info(sound), u)
40    call da_interp_lin_3d (grid%xa%v, iv%info(sound), v)
41 #endif
42    call da_interp_lin_3d (grid%xa%t, iv%info(sound), t)
43    call da_interp_lin_3d (grid%xa%q, iv%info(sound), q)
45    call da_interp_lin_3d (grid%xb%u, iv%info(sound), ub)
46    call da_interp_lin_3d (grid%xb%v, iv%info(sound), vb)
49    do n=iv%info(sound)%n1,iv%info(sound)%n2
50       do k = 1, iv%info(sound)%levels(n)
51          if(wind_sd_sound) then
52             call da_uv_to_sd_lin(y%sound(n)%u(k),y%sound(n)%v(k),u(k,n),v(k,n),ub(k,n),vb(k,n))
53          else
54             y%sound(n)%u(k) = u(k,n)
55             y%sound(n)%v(k) = v(k,n)
56          end if
57       end do
58       y%sound(n)%t(:) = t(1:size(y%sound(n)%t),n)
59       y%sound(n)%q(:) = q(1:size(y%sound(n)%q),n)
60    end do
62    deallocate (u)
63    deallocate (v)
64    deallocate (t)
65    deallocate (q)
66    deallocate (ub)
67    deallocate (vb)
69    if (trace_use_dull) call da_trace_exit("da_transform_xtoy_sound")
71 end subroutine da_transform_xtoy_sound