anchor.diff:  
         real(8)               ::  updated_qhum(nlev), updated_temp(nlev), updated_pblp
         real(8)               ::  tbm, tdef, bclp, qbcl
  -      real(8)               ::  max_omega
  +      real(8)               ::  min_omega
   
   
         !-----------------------------------------------------------------------------
  
positive.code:       !-----------------------------------------------------------------------------
        !----- Calculate Maximum Omega Below PBL
        !-----------------------------------------------------------------------------
        call max_over_layer( omega, updated_pblp, pressure, nlev, missing, max_omega )
  
        !-----------------------------------------------------------------------------
        !----- Check for CI
        !-----------------------------------------------------------------------------
        pressure_deficit  =  (updated_pblp + max_omega*dt) - bclp
        t_updated         =  updated_temp
        q_updated         =  updated_qhum
        pblp_updated      =  updated_pblp
  
negative.code:       outgoing  =  maxval(incoming, mask = incoming.ne.missing .and. pressure.ge.targetPressure)
  
  end subroutine max_over_layer
  
  
  !---------------------------------------------------------------------------------
  !
  ! function: Minimum over a certain layer
  !
  !---------------------------------------------------------------------------------
  subroutine min_over_layer (incoming, targetPressure, pressure, nlev, missing, outgoing )
  
        integer, intent(in )  ::  nlev
        real(8), intent(in )  ::  incoming(nlev), pressure(nlev)
        real(8), intent(in )  ::  targetPressure
        real(8), intent(in )  ::  missing
        real(8), intent(out)  ::  outgoing
  
        outgoing  =  missing
        outgoing  =  minval(incoming, mask = incoming.ne.missing .and. pressure.ge.targetPressure)
  
  end subroutine min_over_layer
  
  
  
  