Merge remote-tracking branch 'origin/release-v4.5.2'
[WRF.git] / var / da / da_ssmi / da_transform_xtotb.inc
blobbbab09ce7756c0985925e7b5a7a5c3f1ddaaea23
1 subroutine da_transform_xtotb(grid)
3    !----------------------------------------------------------------------
4    ! Purpose: TBD
5    !----------------------------------------------------------------------
7    implicit none
9    type (domain), intent(inout)   :: grid
11    integer            :: i,j,k
13    real               :: psfc,ta,gamma,sst,htpw,speed,alw,zcld,tpw,dum1,zrhom
15    if (trace_use) call da_trace_entry("da_transform_xtotb")
17    do j=jts,jte
18       do i=its,ite
19          ! surface pressure (mb) (940 -1030)
21          psfc          = 0.01*grid%xb%psfc(i,j)
23          ! sea surface temperature (k) (273 - 303) (doesnot change) 
25          sst           = grid%xb%tgrn(i,j)
27          ! effective surface air temperature (263 - 303)
29          ta          = grid%xb%tgrn(i,j) + &
30                        (grid%xb%t(i,j,kts)-grid%xb%tgrn(i,j))*log(2.0/0.0001)/ &
31                        log((grid%xb%h(i,j,kts) - grid%xb%terr(i,j))/0.0001)
33          ! gamma is an emperical formula and zcld is given for now
35          gamma   = (ta-270)*0.023 + 5.03  ! effective lapse rate(km) (4.0-6.5)
37          zcld    = 1                           ! effective cloud height (km)
38                                                ! = 1 if no cloud infomation
39          ! total precipitable water in cm
40          ! total precipitable water in (kg/m**2) (0 - 70)
42          tpw          = grid%xb%tpw(i,j)*10.0
43          speed        = grid%xb%speed(i,j)
45          ! Column liquid water (kg/m**2)  (0-0.5) (no data now. So do it later)
47          alw          = 0.0
49          ! Column height weighted moisture density on the grid locally 
51          zrhom = 0.0
52          do k=kts,kte
53             zrhom=zrhom+(grid%xb%hf(i,j,k+1)-grid%xb%hf(i,j,k))*grid%xb%h(i,j,k)*grid%xb%q(i,j,k)* &
54                grid%xb%rho(i,j,k)
55          end do
57          ! Column moisture density on the grid locally
59          htpw          = zrhom/tpw/1000.0
61          call tb(1,53.0,psfc,ta,gamma,sst,tpw,htpw, &
62             speed,alw,zcld,grid%xb%tb19v(i,j),grid%xb%tb19h(i,j))
63          call tb(2,53.0,psfc,ta,gamma,sst,tpw,htpw, &
64             speed,alw,zcld,grid%xb%tb22v(i,j),dum1)
65          call tb(3,53.0,psfc,ta,gamma,sst,tpw,htpw, &
66             speed,alw,zcld,grid%xb%tb37v(i,j),grid%xb%tb37h(i,j))
67          call tb(4,53.0,psfc,ta,gamma,sst,tpw,htpw, &
68             speed,alw,zcld,grid%xb%tb85v(i,j),grid%xb%tb85h(i,j))
69       end do
70    end do
72    if (trace_use) call da_trace_exit("da_transform_xtotb")
74 end subroutine da_transform_xtotb