anchor.diff:  !----------------------------------------------------------------------------------------------
   subroutine is_there_moist_convection(temperature, height, pressure, qhum, pblp,          &
                                        sensible   , latent, omega   , dt  , nlev, missing, &
  -                                     pressure_deficit, t_updated, q_updated, pblp_updated )
  +                                     pressure_deficit, t_updated, q_updated, pblp_updated, p_updated )
   
         integer, intent(in )  ::  nlev                   !*** # of atmospheric levels
         real(8), intent(in )  ::  temperature(nlev)      !*** temperature profile [K]
  
positive.code:       real(8), intent(out)  ::  pressure_deficit       !*** a measure saturation at the top of PBL [Pa]
        real(8), intent(out)  ::  t_updated  (nlev)      !*** updated temperature profile [K]
        real(8), intent(out)  ::  q_updated  (nlev)      !*** updated specific humidity profile [kg/kg]
        real(8), intent(out)  ::  pblp_updated           !*** new pressure at the top of the boundary layer [Pa]
  
        real(8)               ::  updated_qhum(nlev), updated_temp(nlev), updated_pblp
        real(8)               ::  tbm, tdef, bclp, qbcl
        real(8)               ::  min_omega
  
  
        !-----------------------------------------------------------------------------
        !----- Updated the profiles of temperature and humidity after injecting
        !----- the surface senisble and latent heat fluxes
        !-----------------------------------------------------------------------------
        call add_surface_fluxes (temperature, height, pressure, qhum, pblp, sensible, latent, dt, nlev, missing, &
                                 updated_temp, updated_qhum, updated_pblp )
  
        !-----------------------------------------------------------------------------
        !----- Calculate HCF variables in new system
        !-----------------------------------------------------------------------------
        call hcfcalc ( nlev, missing, updated_temp, pressure, updated_qhum, height, pblp, tbm, tdef, bclp, qbcl )
  
        !-----------------------------------------------------------------------------
        !----- Calculate Maximum Omega Below PBL
        !-----------------------------------------------------------------------------
        call min_over_layer( omega, updated_pblp, pressure, nlev, missing, min_omega )
  
        !-----------------------------------------------------------------------------
        !----- Check for CI
        !-----------------------------------------------------------------------------
        pressure_deficit  =  (updated_pblp + min_omega*dt) - bclp
        t_updated         =  updated_temp
        q_updated         =  updated_qhum
        pblp_updated      =  updated_pblp
  
  
  end subroutine is_there_moist_convection
  
  
negative.code:       end if
  
  end subroutine add_sensible_heat_energy
  
  
  
  
  !----------------------------------------------------------------------------------------------
  !
  ! function: Add the omega pressure tendency to the static pressure field
  !
  !----------------------------------------------------------------------------------------------
  subroutine updated_pressure_with_omega(omega, pressure, dt, nlev,  missing, new_pressure)
  
        integer, intent(in )  ::  nlev                !*** # of atmospheric levels
        real(8), intent(in )  ::  omega   (nlev)      !*** pressure velocity [Pa/s]
        real(8), intent(in )  ::  pressure(nlev)      !*** original pressure level [Pa]
        real(8), intent(in )  ::  dt                  !*** time step [s]
        real(8), intent(in )  ::  missing             !*** missing values
        real(8), intent(out)  ::  new_pressure(nlev)  !*** updated pressure [Pa]
  
        new_pressure  =  pressure
        where( pressure.ne.missing  .and.  omega.ne.missing )
           new_pressure  =  pressure + (dt * omega)
        end where
  
  end subroutine updated_pressure_with_omega
  
  
  
  
  
  