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

subroutine da_residual_synop(iv, y, re, np_missing, np_bad_data, np_obs_used, np_available) 1,7

   !-----------------------------------------------------------------------
   ! Purpose: Calculate residuals for synop obs
   !-----------------------------------------------------------------------

   implicit none

   type (iv_type), intent(in)    :: iv     ! Innovation vector (O-B).
   type (y_type) , intent(in)    :: y      ! y = H (xa)
   type (y_type) , intent(inout) :: re     ! Residual vector (O-A).

   integer       , intent(inout) :: np_available
   integer       , intent(inout) :: np_obs_used
   integer       , intent(inout) :: np_missing
   integer       , intent(inout) :: np_bad_data

   type (bad_data_type)              :: n_obs_bad
   integer                           :: n

   if (trace_use_dull) call da_trace_entry("da_residual_synop")

   n_obs_bad % u % num = number_type(0, 0, 0)
   n_obs_bad % v % num = number_type(0, 0, 0)
   n_obs_bad % t % num = number_type(0, 0, 0)
   n_obs_bad % p % num = number_type(0, 0, 0)
   n_obs_bad % q % num = number_type(0, 0, 0)

   do n=1, iv%info(synop)%nlocal
      np_available = np_available + 5

      re%synop(n)%u = da_residual(n, 0, y%synop(n)%u, iv%synop(n)%u, n_obs_bad % u)
      re%synop(n)%v = da_residual(n, 0, y%synop(n)%v, iv%synop(n)%v, n_obs_bad % v)
      re%synop(n)%t = da_residual(n, 0, y%synop(n)%t, iv%synop(n)%t, n_obs_bad % t)
      re%synop(n)%p = da_residual(n, 0, y%synop(n)%p, iv%synop(n)%p, n_obs_bad % p)
      re%synop(n)%q = da_residual(n, 0, y%synop(n)%q, iv%synop(n)%q, n_obs_bad % q)
   end do

   np_missing = np_missing + n_obs_bad % u % num % miss + &amp;
      n_obs_bad % v % num % miss + n_obs_bad % t % num % miss + &amp;
      n_obs_bad % p % num % miss + n_obs_bad % q % num % miss
   np_bad_data = np_bad_data + n_obs_bad % u % num % bad + &amp;
      n_obs_bad % v % num % bad + n_obs_bad % t % num % bad + &amp;
      n_obs_bad % p % num % bad + n_obs_bad % q % num % bad
   np_obs_used = np_obs_used + n_obs_bad % u % num % use + &amp;
      n_obs_bad % v % num % use + n_obs_bad % t % num % use + &amp;
      n_obs_bad % p % num % use + n_obs_bad % q % num % use

   if (trace_use_dull) call da_trace_exit("da_residual_synop")

end subroutine da_residual_synop