      subroutine mxlcall
c
c  Performs mixed layer calculations.
c

#include "oparams.F.h"
#include "poseidon.F.h"


C--------------------MIXED LAYER ---------------------- 

        if (LOTH) then
          dtmix = 86400.0
          if ( tbuoy .GT. 0. ) then
           do i=1,LEN
             Qbuoy(i) = Qbuoy_acc(i) / tbuoy
           enddo
          else
           print *,'WARNING tbuoy = 0 in POSEIDON'
           do i=1,LEN
             Qbuoy(i) = 0.
           enddo
          endif
          call MIXDLYR( LEN, nwater, dtmix,
     &                  H(1,1,indext3), U(1,1,indext3),
     &                  V(1,1,indext3), T(1,1,indext3),
     &                  S(1,1,indext3), B(1,1,indext3),
     &                  Qbuoy, Qrad_net, U3,
     &                  ieast,iwest,inorth,isouth,
     &                  Entrainment, M_O_Depth )
 
          do i=1,LEN
           Qbuoy_acc(i) = 0.  !reset integrals for surface buoyancy flux
          enddo
          tbuoy = 0.
 
          ! Now we want to smooth the entrainment and MO depths
 
 
!          do i=1,im
!           if ( M_O_Depth(i) .LE. 0.0 ) then
!             M_O_Depth(i) = 5000.
!           endif
!          enddo
 
 
!          call SHAPCONS(nwater+nland,Entrainment,Area_h,Bh,
!     &              ieast,iwest,inorth,isouth,4,1.0)
!          call SHAPCONS(nwater+nland,M_O_Depth,Area_h,Bh,
!     &              ieast,iwest,inorth,isouth,4,1.0)
 
          ! In vveloc, we will use Entrainment if positive ,
 
 
 
        else
          do i=1,nwater
           Entrainment(i) = 0.
           M_O_Depth(i)   = 0.
          enddo
        endif
 
!yu      if ( RINGING( daily ) ) then
!        i = ISMAX( nwater , B , 1 )
!        call SET_BINIT( KM, binit(KM), B(i,1,1), binit )
!      endif


      return
      end
