!copyright (C) 2001  MSC-RPN COMM  %%%RPNPHY%%%
*** S/P LACS
#include "phy_macros_f.h"

      SUBROUTINE LACS (F, FSIZ, NI) 2
#include "impnone.cdk"
*
      integer fsiz, ni
      real f(fsiz)
*
*Author
*          Bernard Bilodeau (June 2001) - From lacs.cdk
*
*Revisions
* 001     B. Dugas (Jul 03)   - Introduce CRITLAC
*
*Object
*          define sea ice fraction and thickness over lakes
*
*Arguments
*          - Input/Output -
* F        permanent bus of the physics variables
*
*          - Input -
* FSIZ     dimension of F
* NI       horizontal length
*
*Implicites
*
#include "surfacepar.cdk"
#include "phybus.cdk"
#include "consphy.cdk"
#include "leads.cdk"
*
***
*
       integer i
*         
*VDIR NODEP
      DO i=0,ni-1
*
*        Array ML is the fraction of lakes.
*
         IF (f(ml+i).lt.critlac) then         ! Not over lakes
*
*           Leadfrac is the climatological value of % of leads in
*           MARINE ice. The ice-covered lakes remain untouched.
*           GLSEA0 contains the original value of the sea-ice
*           analysis (updated if needed with daily increments
*           if switch "CLIMAT" is true in subroutine CLIMPHS).
*
            f(glsea   +i                 ) = f(glsea +i) *
     +                                        (1. - leadfrac)
*
*           Set minimal ice depth if zero ice thickness in 
*           analysis (or climatology) while ice fraction is non zero
            if (f(glsea+i).ge.0..and.f(icedp+i).le.0.) then
               f(icedp+i) = max(minicedp, 0.25 * f(glsea+i))
            endif
*
         ELSE                                       ! Over lakes
*
*           Water temperature of ice-covered lakes is 0 C.
            if (f(glsea+i) .gt. 10.*critmask) f(twater+i) = TRPL 
*
*           Over lakes, ice thickness is set to a minimum of 30 cm
*           if GL > 50%. GL is then changed to 100% since the lakes
*           are usually fully frozen. Otherwise, linear interpolation
*           of ice thickness (varying between 0 and 30 cm) is performed
*           when GL ranges from 0 to 50%.
*
            IF (f(glsea+i).gt.0.50) then
               f(icedp   +i              ) = 0.30
               f(glsea   +i              ) = 1.00
            ELSE
               f(icedp   +i              ) = 0.60 * f(glsea+i)
            END IF 
*
         END IF
*
      END DO
*
      RETURN
      END