!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer, 
!                     version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms 
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer 
!version 3 or (at your option) any later version that should be found at: 
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html 
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software; 
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec), 
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
***s/r bmf_perturb - performs bit flip data perturbation
*

      subroutine bmf_perturb (varname,f,fni,fnj,fnk)
      implicit none
*
      character*4 varname
      integer fni,fnj,fnk
      integer f(fni,fnj,fnk)
*
*author   Michel Desgagne -- summer 2003
*
*revision
* v3_11 - M. Desgagne       - initial version
*
*implicits
#include "e_anal.cdk"      
*
      integer i,j,k
*
* ---------------------------------------------------------------------
*
      if (anal_perturb) then
      if (     (varname.eq.'HU').or.(varname.eq.'ES')
     $     .or.(varname.eq.'VT').or.(varname.eq.'TT')
     $     .or.(varname.eq.'UU').or.(varname.eq.'VV')) then
         print*, 'Bit flip perturbation on ',varname
*
      do k=1,fnk
      do j=1,fnj,10
      do i=1,fni,10
         f(i,j,k) = xor(f(i,j,k),1)
      end do
      end do
      end do
*
      endif
      endif
*
* ---------------------------------------------------------------------
*
      return
      end
*