! File %M% from Library %Q%
! Version %I% from %G% extracted: %H%
!------------------------------------------------------------------------------

MODULE SUSFLAKE_MOD

CONTAINS
SUBROUTINE SUSFLAKE(LD_LEFLAKE)

!------------------------------------------------------------------------------
!
! Description:
!
!  Initialization of YOS_FLAKE 
!
!
! Current Code Owner: DWD, Dmitrii Mironov
!  Phone:  +49-69-8062 2705
!  Fax:    +49-69-8062 3721
!  E-mail: dmitrii.mironov@dwd.de
!
! History:
! Version    Date       Name
! ---------- ---------- ----
! 1.00       2005/11/17 Dmitrii Mironov 
!  Initial release 
! !VERSION!  !DATE!     <Your name>
!  <Modification comments>
!
! Code Description:
! Language: Fortran 90.
! Software Standards: "European Standards for Writing and
! Documenting Exchangeable Fortran 90 Code".
!==============================================================================
!
! Declarations:
!
! Modules used:

USE PARKIND1 , ONLY: JPIM     ,JPRB
USE YOS_FLAKE, ONLY: &
 & RC_CBL_1,         &
 & RC_CBL_2,         &
 & RC_SBL_ZM_N,      &
 & RC_SBL_ZM_S,      &
 & RC_SBL_ZM_I,      &
 & RC_RELAX_H,       &
 & RC_RELAX_C,       &

 & RC_T_MIN,         &
 & RC_T_MAX,         &
 & RPHI_T_PR0_1,     &
 & RPHI_T_PR0_2,     &
 & RC_TT_1,          &
 & RC_TT_2,          &
 & RC_B1,            &
 & RC_B2,            &
 & RC_S_LIN,         &
 & RPHI_S_PR0_LIN,   &
 & RC_I_LIN,         &
 & RPHI_I_PR0_LIN,   &
 & RPHI_I_PR1_LIN,   &
 & RPHI_I_AST_MR,    &
 & RC_I_MR,          &
 & RH_ICE_MAX,       &

 & RH_SNOW_MIN_FLK,  &
 & RH_ICE_MIN_FLK,   &
 & RH_ML_MIN_FLK,    &
 & RH_ML_MAX_FLK,    &
 & RU_STAR_MIN_FLK,  &

 & RC_SMALL_FLK,  &

 & RTPL_GRAV,     &
 & RTPL_T_R,      &
 & RTPL_T_F,      &
 & RTPL_A_T,      &
 & RTPL_RHO_W_R,  &
 & RTPL_RHO_I,    &
 & RTPL_L_F,      &
 & RTPL_C_W,      &
 & RTPL_C_I,      &
 & RTPL_KAPPA_W,  &
 & RTPL_KAPPA_I,  &
 & RTPSF_L_EVAP,  &

 & ROPTICPAR_MEDIUM, &
 & NBAND_OPTIC_MAX, &

 & ROPTICPAR_WATER_REF,      &
 & ROPTICPAR_WATER_TRANS,    &
 & ROPTICPAR_WHITEICE_REF,   &
 & ROPTICPAR_BLUEICE_REF,    &
 & ROPTICPAR_ICE_OPAQUE,     &

 & LEFLAKE  

!==============================================================================

IMPLICIT NONE

LOGICAL, INTENT(IN) :: LD_LEFLAKE 

!==============================================================================
!
! Declarations

INTEGER (KIND = JPIM) :: J ! DO loop index

!  Dimensionless constants 
!  in the equations for the mixed-layer depth 
!  and for the shape factor with respect to the temperature profile in the thermocline
RC_CBL_1       = 0.17_JPRB             ! Constant in the CBL entrainment equation
RC_CBL_2       = 1._JPRB               ! Constant in the CBL entrainment equation
RC_SBL_ZM_N    = 0.5_JPRB              ! Constant in the ZM1996 equation for the equilibrium SBL depth
RC_SBL_ZM_S    = 10._JPRB              ! Constant in the ZM1996 equation for the equilibrium SBL depth
RC_SBL_ZM_I    = 20._JPRB              ! Constant in the ZM1996 equation for the equilibrium SBL depth
RC_RELAX_H     = 0.030_JPRB            ! Constant in the relaxation equation for the SBL depth
RC_RELAX_C     = 0.030_JPRB           ! Constant with respect to the temperature profile in the thermocline

!  Parameters of the shape functions 
!  Indices refer to T - thermocline, S - snow, I - ice,
!  B1 - upper layer of the bottom sediments, B2 - lower layer of the bottom sediments.
!  "pr0" and "pr1" denote zeta derivatives of the corresponding shape function 
!  at "zeta=0" ad "zeta=1", respectively.

RC_T_MIN       = 0.5_JPRB            ! Minimum value of the shape factor C_T (thermocline)
RC_T_MAX       = 0.8_JPRB            ! Maximum value of the shape factor C_T (thermocline)
RPHI_T_PR0_1   = 40._JPRB/3._JPRB    ! Constant in the expression for the T shape-function derivative 
RPHI_T_PR0_2   = 20._JPRB/3._JPRB    ! Constant in the expression for the T shape-function derivative 
RC_TT_1        = 11._JPRB/18._JPRB   ! Constant in the expression for C_TT (thermocline)
RC_TT_2        = 7._JPRB/45._JPRB    ! Constant in the expression for C_TT (thermocline)
RC_B1          = 2._JPRB/3._JPRB     ! Shape factor (upper layer of bottom sediments)
RC_B2          = 3._JPRB/5._JPRB     ! Shape factor (lower layer of bottom sediments)
RC_S_LIN       = 0.5_JPRB            ! Shape factor (linear temperature profile in the snow layer)
RPHI_S_PR0_LIN = 1._JPRB             ! S shape-function derivative (linear profile) 
RC_I_LIN       = 0.5_JPRB            ! Shape factor (linear temperature profile in the ice layer)
RPHI_I_PR0_LIN = 1._JPRB             ! I shape-function derivative (linear profile) 
RPHI_I_PR1_LIN = 1._JPRB             ! I shape-function derivative (linear profile) 
RPHI_I_AST_MR  = 2._JPRB             ! Constant in the MR2004 expression for I shape factor
RC_I_MR        = 1._JPRB/12._JPRB    ! Constant in the MR2004 expression for I shape factor
RH_ICE_MAX     = 3._JPRB             ! Maximum ice tickness in 
                                    ! the Mironov and Ritter (2004, MR2004) ice model [m] 

!  Security constants

RH_SNOW_MIN_FLK = 1.0E-5_JPRB          ! Minimum snow thickness [m]
RH_ICE_MIN_FLK  = 1.0E-9_JPRB          ! Minimum ice thickness [m]
RH_ML_MIN_FLK   = 1.0E-2_JPRB          ! Minimum mixed-layer depth [m]
RH_ML_MAX_FLK   = 1.0E+3_JPRB          ! Maximum mixed-layer depth [m]
RU_STAR_MIN_FLK = 1.0E-6_JPRB          ! Minimum value of the surface friction velocity [m s^{-1}]

!  Security constant(s)

RC_SMALL_FLK    = 1.0E-10_JPRB         ! A small number

!  Thermodynamic parameters

RTPL_GRAV          = 9.81_JPRB        ! Acceleration due to gravity [m s^{-2}]
RTPL_T_R           = 277.13_JPRB      ! Temperature of maximum density of fresh water [K]
RTPL_T_F           = 273.15_JPRB      ! Fresh water freezing point [K]
RTPL_A_T           = 1.6509E-05_JPRB  ! Constant in the fresh-water equation of state [K^{-2}]
RTPL_RHO_W_R       = 1.0E+03_JPRB     ! Maximum density of fresh water [kg m^{-3}]
RTPL_RHO_I         = 9.1E+02_JPRB     ! Density of ice [kg m^{-3}]
RTPL_L_F           = 3.3E+05_JPRB     ! Latent heat of fusion [J kg^{-1}]
RTPL_C_W           = 4.2E+03_JPRB     ! Specific heat of water [J kg^{-1} K^{-1}]
RTPL_C_I           = 2.1E+03_JPRB     ! Specific heat of ice [J kg^{-1} K^{-1}]
RTPL_KAPPA_W       = 5.46E-01_JPRB    ! Molecular heat conductivity of water [J m^{-1} s^{-1} K^{-1}]
RTPL_KAPPA_I       = 2.29_JPRB        ! Molecular heat conductivity of ice [J m^{-1} s^{-1} K^{-1}]
RTPSF_L_EVAP       = 2.501E+06_JPRB   ! Specific heat of evaporation [J kg^{-1}]


! Optical characteristics for water, ice and snow.
! The simplest one-band approximation is used as a reference.

ROPTICPAR_WATER_REF = ROPTICPAR_MEDIUM(1,                          & ! Water (reference)
& (/1._JPRB, (0._JPRB    , J=2,NBAND_OPTIC_MAX)/),               &
& (/3._JPRB, (1.E+10_JPRB, J=2,NBAND_OPTIC_MAX)/))
ROPTICPAR_WATER_TRANS = ROPTICPAR_MEDIUM(2,                        & ! Transparent Water (two-band)
& (/0.10_JPRB, 0.90_JPRB, (0._JPRB    , J=3,NBAND_OPTIC_MAX)/),  &
& (/2.0_JPRB , 0.20_JPRB, (1.E+10_JPRB, J=3,NBAND_OPTIC_MAX)/))
ROPTICPAR_WHITEICE_REF = ROPTICPAR_MEDIUM(1,                       & ! White ice
& (/1._JPRB  , (0._JPRB    , J=2,NBAND_OPTIC_MAX)/),             &
& (/17.1_JPRB, (1.E+10_JPRB, J=2,NBAND_OPTIC_MAX)/))
ROPTICPAR_BLUEICE_REF = ROPTICPAR_MEDIUM(1,                        & ! Blue ice
& (/1._JPRB , (0._JPRB    , J=2,NBAND_OPTIC_MAX)/),              &
& (/8.4_JPRB, (1.E+10_JPRB, J=2,NBAND_OPTIC_MAX)/))
ROPTICPAR_ICE_OPAQUE = ROPTICPAR_MEDIUM(1,                         & ! Opaque ice
& (/1._JPRB     , (0._JPRB    , J=2,NBAND_OPTIC_MAX)/),          &
& (/1.0E+07_JPRB, (1.E+10_JPRB, J=2,NBAND_OPTIC_MAX)/))

LEFLAKE=LD_LEFLAKE
 
!==============================================================================

END SUBROUTINE SUSFLAKE
END MODULE SUSFLAKE_MOD

