Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / var / da / da_tools / da_togrid_new.inc
blob20f333cd3d9b58289a62ef1d59618be2fe8792be
1 subroutine da_togrid_new (x, ib, ie, i, dx, dxm)
3    !-----------------------------------------------------------------------
4    ! Purpose: Transfer obs. x to grid i and calculate its
5    ! distance to grid i and i+1
6    !-----------------------------------------------------------------------
8    implicit none
10    real,    intent(in)  :: x(:,:)
11    integer, intent(in)  :: ib, ie
12    real,    intent(out) :: dx(:,:), dxm(:,:)
13    integer, intent(out) :: i(:,:)
15    if (trace_use) call da_trace_entry("da_togrid_new")
17    where (x(:,:) > 0.0) 
18       i(:,:) = int (x(:,:))
20       where(i(:,:) < ib)  i(:,:) = ib
21       where(i(:,:) >= ie) i(:,:) = ie-1
23       dx(:,:) = x(:,:) - real(i(:,:))
24       dxm(:,:)= 1.0 - dx(:,:)
25    elsewhere 
26       i(:,:) = 0
27       dx(:,:) = 0.0
28       dxm(:,:) = 0.0
29    end where
31    if (trace_use) call da_trace_exit("da_togrid_new")
33 end subroutine da_togrid_new