logical function onedvar_passive_ok( kfail)

!**** 1D-Var in clouds/precipitation for SSM/I radiances

! Checks a 1DVar failure code bitfield to see if it corresponds
! to an observation which is OK, or else is to be passively monitored 
! (clear sky or passive monitoring bits set) but is otherwise OK 
! (no other bits set).

! 19-Mar-2007  A Geer  First implementation

use parkind1, only: jpim, jprb
use yomhook, only: lhook, dr_hook
use yomonedvar, only: ifail_passive, ifail_clear

implicit none                         

integer (kind=jpim), intent (in) :: kfail   

real (kind=jprb) :: zhook_handle

if (lhook) call dr_hook ('onedvar_passive_ok',0,zhook_handle)
      
onedvar_passive_ok = &
 & (kfail == 0) .or. &  ! Cloudy, OK
 & (kfail == ibset(0,ifail_clear)) .or. & ! Clear, OK otherwise
 & (kfail == ibset(0,ifail_passive)) .or. & ! Passive, cloudy, OK otherwise
 & (kfail == ibset(ibset(0,ifail_passive),ifail_clear)) ! Passive, clear, OK otherwise 
 
if (lhook) call dr_hook('onedvar_passive_ok',1,zhook_handle)

end function onedvar_passive_ok
