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

subroutine da_lcl(p0, z0, t0, q0, plcl, zlcl, tlcl, qlcl) 1,5

   !-----------------------------------------------------------------------
   ! Purpose: TBD
   !-----------------------------------------------------------------------

   implicit none

   real, intent(in)   :: p0, z0, t0, q0
   real, intent(out)  :: plcl, zlcl, tlcl, qlcl

   real   :: dp, qs, eps

   if (trace_use) call da_trace_entry("da_lcl")

   dp=5.0
   plcl=300.0

   do
      tlcl=t0*((plcl/p0)**0.286)

      call da_qfrmrh(plcl, tlcl, 100.0, qs)

      eps=qs-q0

      if (eps &gt;= 0.0) then
         zlcl=(1004.0/gravity)*(t0-tlcl)+z0
         qlcl=qs
         if (trace_use) call da_trace_exit("da_lcl")
         return
      else
         plcl=plcl+dp

         if (plcl &gt;= p0) then
            zlcl=z0
            qlcl=q0
            plcl=p0
            if (trace_use) call da_trace_exit("da_lcl")
            return
        end if
      end if
   end do

   if (trace_use) call da_trace_exit("da_lcl")

end subroutine da_lcl