<HTML> <BODY BGCOLOR=#ccccdd LINK=#0000aa VLINK=#0000ff ALINK=#ff0000 ><BASE TARGET="bottom_target"><PRE>
<A NAME='DA_TOGRID_NEW'><A href='../../html_code/tools/da_togrid_new.inc.html#DA_TOGRID_NEW' TARGET='top_target'><IMG SRC="../../gif/bar_red.gif" border=0></A>

subroutine da_togrid_new (x, ib, ie, i, dx, dxm) 2,2

   !-----------------------------------------------------------------------
   ! Purpose: Transfer obs. x to grid i and calculate its
   ! distance to grid i and i+1
   !-----------------------------------------------------------------------

   implicit none

   real,    intent(in)  :: x(:,:)
   integer, intent(in)  :: ib, ie
   real,    intent(out) :: dx(:,:), dxm(:,:)
   integer, intent(out) :: i(:,:)

   if (trace_use) call da_trace_entry("da_togrid_new")

   where (x(:,:) &gt; 0.0) 
      i(:,:) = int (x(:,:))

      where(i(:,:) &lt; ib)  i(:,:) = ib
      where(i(:,:) &gt;= ie) i(:,:) = ie-1

      dx(:,:) = x(:,:) - real(i(:,:))
      dxm(:,:)= 1.0 - dx(:,:)
   elsewhere 
      i(:,:) = 0
      dx(:,:) = 0.0
      dxm(:,:) = 0.0
   end where

   if (trace_use) call da_trace_exit("da_togrid_new")

end subroutine da_togrid_new