SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/mode_flake.F90
Go to the documentation of this file.
00001 ! File %M% from Library %Q%
00002 ! Version %I% from %G% extracted: %H%
00003 !------------------------------------------------------------------------------
00004 
00005 MODULE mode_flake
00006 
00007 !------------------------------------------------------------------------------
00008 !
00009 ! Description:
00010 !
00011 !  The main program unit of the lake model FLake,  
00012 !  containing most of the FLake procedures.
00013 !  Most FLake variables and local parameters are declared.
00014 !
00015 !  FLake (Fresh-water Lake) is a lake model capable of predicting the surface temperature 
00016 !  in lakes of various depth on the time scales from a few hours to a year.
00017 !  The model is based on a two-layer parametric representation of
00018 !  the evolving temperature profile, where the structure of the stratified layer between the
00019 !  upper mixed layer and the basin bottom, the lake thermocline,
00020 !  is described using the concept of self-similarity of the temperature-depth curve.
00021 !  The concept was put forward by Kitaigorodskii and Miropolsky (1970) 
00022 !  to describe the vertical temperature structure of the oceanic seasonal thermocline.
00023 !  It has since been successfully used in geophysical applications.
00024 !  The concept of self-similarity of the evolving temperature profile
00025 !  is also used to describe the vertical structure of the thermally active upper layer 
00026 !  of bottom sediments and of the ice and snow cover.
00027 !
00028 !  The lake model incorporates the heat budget equations
00029 !  for the four layers in question, viz., snow, ice, water and bottom sediments,
00030 !  developed with due regard for the vertically distributed character
00031 !  of solar radiation heating.
00032 !  The entrainment equation that incorporates the Zilitinkevich (1975) spin-up term
00033 !  is used to compute the depth of a convectively-mixed layer. 
00034 !  A relaxation-type equation is used
00035 !  to compute the wind-mixed layer depth in stable and neutral stratification,
00036 !  where a multi-limit formulation for the equilibrium mixed-layer depth
00037 !  proposed by Zilitinkevich and Mironov (1996)
00038 !  accounts for the effects of the earth's rotation, of the surface buoyancy flux
00039 !  and of the static stability in the thermocline.
00040 !  The equations for the mixed-layer depth are developed with due regard for  
00041 !  the volumetric character of the radiation heating.
00042 !  Simple thermodynamic arguments are invoked to develop
00043 !  the evolution equations for the ice thickness and for the snow thickness.
00044 !  The heat flux through the water-bottom sediment interface is computed,
00045 !  using a parameterization proposed by Golosov et al. (1998).
00046 !  The heat flux trough the air-water interface 
00047 !  (or through the air-ice or air-snow interface)
00048 !  is provided by the driving atmospheric model.
00049 !
00050 !  Empirical constants and parameters of the lake model
00051 !  are estimated, using independent empirical and numerical data.
00052 !  They should not be re-evaluated when the model is applied to a particular lake.
00053 !  The only lake-specific parameters are the lake depth,
00054 !  the optical characteristics of lake water,
00055 !  the temperature at the bottom of the thermally active layer
00056 !  of bottom sediments and the depth of that layer.
00057 !
00058 !  A detailed description of the lake model is given in
00059 !  Mironov, D. V., 2005:
00060 !  Parameterization of Lakes in Numerical Weather Prediction.
00061 !  Part 1: Description of a Lake Model.
00062 !  Manuscript is available from the author.
00063 !  Dmitrii Mironov 
00064 !  German Weather Service, Kaiserleistr. 29/35, D-63067 Offenbach am Main, Germany.
00065 !  dmitrii.mironov@dwd.de 
00066 !
00067 !  Lines embraced with "!_tmp" contain temporary parts of the code.
00068 !  Lines embraced/marked with "!_dev" may be replaced
00069 !  as improved parameterizations are developed and tested.
00070 !  Lines embraced/marked with "!_dm" are DM's comments
00071 !  that may be helpful to a user.
00072 !  Lines embraced/marked with "!_dbg" are used
00073 !  for debugging purposes only.
00074 !
00075 !
00076 ! Current Code Owner: DWD, Dmitrii Mironov
00077 !  Phone:  +49-69-8062 2705
00078 !  Fax:    +49-69-8062 3721
00079 !  E-mail: dmitrii.mironov@dwd.de
00080 !
00081 ! History:
00082 ! Version    Date       Name
00083 ! ---------- ---------- ----
00084 ! 1.00       2005/11/17 Dmitrii Mironov 
00085 !  Initial release
00086 ! !VERSION!  !DATE!     <Your name>
00087 !  <Modification comments>
00088 !
00089 ! Code Description:
00090 ! Language: Fortran 90.
00091 ! Software Standards: "European Standards for Writing and
00092 ! Documenting Exchangeable Fortran 90 Code".
00093 !==============================================================================
00094 !
00095 ! Declarations:
00096 !
00097 ! Modules used:
00098 
00099 !USE modd_data_parameters , ONLY : &
00100 !    ireals                   ,  &! KIND-type parameter for real variables
00101 !    iintegers                    ! KIND-type parameter for "normal" integer variables  
00102 
00103 !==============================================================================
00104 
00105 !
00106 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00107 USE PARKIND1  ,ONLY : JPRB
00108 !
00109 USE MODD_SURFEX_OMP, ONLY : NBLOCK
00110 !
00111 IMPLICIT NONE
00112 
00113 !==============================================================================
00114 !
00115 ! Declarations
00116 !
00117 !  The variables declared below
00118 !  are accessible to all program units of the MODULE flake.
00119 !  Some of them should be USEd by the driving routines that call flake routines.
00120 !  These are basically the quantities computed by FLake.
00121 !  All variables declared below have a suffix "flk".
00122 
00123 !  FLake variables of type REAL
00124 
00125 !  Temperatures at the previous time step ("p") and the updated temperatures ("n") 
00126 REAL :: T_mnw_p_flk, T_mnw_n_flk      ! Mean temperature of the water column [K] 
00127 !$OMP THREADPRIVATE(T_mnw_p_flk, T_mnw_n_flk)
00128 REAL :: T_snow_p_flk, T_snow_n_flk    ! Temperature at the air-snow interface [K] 
00129 !$OMP THREADPRIVATE(T_snow_p_flk, T_snow_n_flk)
00130 REAL :: T_ice_p_flk, T_ice_n_flk      ! Temperature at the snow-ice or air-ice interface [K] 
00131 !$OMP THREADPRIVATE(T_ice_p_flk, T_ice_n_flk) 
00132 REAL :: T_wML_p_flk, T_wML_n_flk      ! Mixed-layer temperature [K] 
00133 !$OMP THREADPRIVATE(T_wML_p_flk, T_wML_n_flk)
00134 REAL :: T_bot_p_flk, T_bot_n_flk      ! Temperature at the water-bottom sediment interface [K] 
00135 !$OMP THREADPRIVATE(T_bot_p_flk, T_bot_n_flk)
00136 REAL :: T_B1_p_flk, T_B1_n_flk        ! Temperature at the bottom of the upper layer of the sediments [K]   
00137 !$OMP THREADPRIVATE(T_B1_p_flk, T_B1_n_flk) 
00138 
00139 !  Thickness of various layers at the previous time step ("p") and the updated values ("n") 
00140 REAL :: h_snow_p_flk, h_snow_n_flk    ! Snow thickness [m]*
00141 !$OMP THREADPRIVATE(h_snow_p_flk, h_snow_n_flk)
00142 REAL :: h_ice_p_flk, h_ice_n_flk      ! Ice thickness [m]
00143 !$OMP THREADPRIVATE(h_ice_p_flk, h_ice_n_flk)
00144 REAL :: h_ML_p_flk, h_ML_n_flk        ! Thickness of the mixed-layer [m] 
00145 !$OMP THREADPRIVATE(h_ML_p_flk, h_ML_n_flk)  
00146 REAL :: H_B1_p_flk, H_B1_n_flk        ! Thickness of the upper layer of bottom sediments [m]   
00147 !$OMP THREADPRIVATE(H_B1_p_flk, H_B1_n_flk)
00148 
00149 !  The shape factor(s) at the previous time step ("p") and the updated value(s) ("n") 
00150 REAL :: C_T_p_flk, C_T_n_flk          ! Shape factor (thermocline)
00151 !$OMP THREADPRIVATE(C_T_p_flk, C_T_n_flk)  
00152 REAL :: C_TT_flk                      ! Dimensionless parameter (thermocline)
00153 !$OMP THREADPRIVATE(C_TT_flk)
00154 REAL :: C_Q_flk                       ! Shape factor with respect to the heat flux (thermocline)
00155 !$OMP THREADPRIVATE(C_Q_flk)
00156 REAL :: C_I_flk                       ! Shape factor (ice)
00157 !$OMP THREADPRIVATE(C_I_flk)
00158 REAL :: C_S_flk                       ! Shape factor (snow) 
00159 !$OMP THREADPRIVATE(C_S_flk) 
00160 
00161 !  Derivatives of the shape functions
00162 REAL :: Phi_T_pr0_flk                 ! d\Phi_T(0)/d\zeta   (thermocline)
00163 !$OMP THREADPRIVATE(Phi_T_pr0_flk) 
00164 REAL :: Phi_I_pr0_flk                 ! d\Phi_I(0)/d\zeta_I (ice)
00165 !$OMP THREADPRIVATE(Phi_I_pr0_flk)
00166 REAL :: Phi_I_pr1_flk                 ! d\Phi_I(1)/d\zeta_I (ice)
00167 !$OMP THREADPRIVATE(Phi_I_pr1_flk)
00168 REAL :: Phi_S_pr0_flk                 ! d\Phi_S(0)/d\zeta_S (snow)  
00169 !$OMP THREADPRIVATE(Phi_S_pr0_flk)  
00170 
00171 !  Heat and radiation fluxes
00172 REAL :: Q_snow_flk                    ! Heat flux through the air-snow interface [W m^{-2}]
00173 !$OMP THREADPRIVATE(Q_snow_flk)  
00174 REAL :: Q_ice_flk                     ! Heat flux through the snow-ice or air-ice interface [W m^{-2}]
00175 !$OMP THREADPRIVATE(Q_ice_flk)  
00176 REAL :: Q_w_flk                       ! Heat flux through the ice-water or air-water interface [W m^{-2}]
00177 !$OMP THREADPRIVATE(Q_w_flk) 
00178 REAL :: Q_bot_flk                     ! Heat flux through the water-bottom sediment interface [W m^{-2}]
00179 !$OMP THREADPRIVATE(Q_bot_flk)   
00180 REAL :: I_atm_flk                     ! Radiation flux at the lower boundary of the atmosphere [W m^{-2}],
00181                                     ! i.e. the incident radiation flux with no regard for the surface albedo.
00182 !$OMP THREADPRIVATE(I_atm_flk)                                  
00183 REAL :: I_snow_flk                    ! Radiation flux through the air-snow interface [W m^{-2}]
00184 !$OMP THREADPRIVATE(I_snow_flk)  
00185 REAL :: I_ice_flk                     ! Radiation flux through the snow-ice or air-ice interface [W m^{-2}]
00186 !$OMP THREADPRIVATE(I_ice_flk)  
00187 REAL :: I_w_flk                       ! Radiation flux through the ice-water or air-water interface [W m^{-2}]
00188 !$OMP THREADPRIVATE(I_w_flk)  
00189 REAL :: I_h_flk                       ! Radiation flux through the mixed-layer-thermocline interface [W m^{-2}]
00190 !$OMP THREADPRIVATE(I_h_flk)
00191 REAL :: I_bot_flk                     ! Radiation flux through the water-bottom sediment interface [W m^{-2}]
00192 !$OMP THREADPRIVATE(I_bot_flk)
00193 REAL :: I_intm_0_h_flk                ! Mean radiation flux over the mixed layer [W m^{-1}]
00194 !$OMP THREADPRIVATE(I_intm_0_h_flk)   
00195 REAL :: I_intm_h_D_flk                ! Mean radiation flux over the thermocline [W m^{-1}]
00196 !$OMP THREADPRIVATE(I_intm_h_D_flk)   
00197 REAL :: Q_star_flk                        ! A generalized heat flux scale [W m^{-2}]  
00198 !$OMP THREADPRIVATE(Q_star_flk)  
00199 
00200 !  Velocity scales
00201 REAL :: u_star_w_flk                  ! Friction velocity in the surface layer of lake water [m s^{-1}]
00202 !$OMP THREADPRIVATE(u_star_w_flk)   
00203 REAL :: w_star_sfc_flk                 ! Convective velocity scale,   
00204                                     ! using a generalized heat flux scale [m s^{-1}]
00205 !$OMP THREADPRIVATE(w_star_sfc_flk)                                  
00206 
00207 !  The rate of snow accumulation
00208 REAL :: dMsnowdt_flk                      ! The rate of snow accumulation [kg m^{-2} s^{-1}]  
00209 !$OMP THREADPRIVATE(dMsnowdt_flk)
00210 
00211 !==============================================================================
00212 ! Procedures 
00213 !==============================================================================
00214 
00215 CONTAINS
00216 
00217 !==============================================================================
00218 !  The codes of the FLake procedures are stored in separate "*.incf" files
00219 !  and are included below.
00220 !------------------------------------------------------------------------------
00221 
00222 !==============================================================================
00223 ! For SURFEX needs, separate *.incf files are explicitly expanded
00224 !==============================================================================
00225 !SURFEX include 'flake_radflux.incf'
00226 ! File %M% from Library %Q%
00227 ! Version %I% from %G% extracted: %H%
00228 !------------------------------------------------------------------------------
00229 
00230 SUBROUTINE flake_radflux ( depth_w, albedo_water, albedo_ice, albedo_snow,  &
00231                              opticpar_water, opticpar_ice, opticpar_snow )         
00232 
00233 !------------------------------------------------------------------------------
00234 !
00235 ! Description:
00236 !
00237 !  Computes the radiation fluxes 
00238 !  at the snow-ice, ice-water, air-water, 
00239 !  mixed layer-thermocline and water column-bottom sediment interfaces,
00240 !  the mean radiation flux over the mixed layer,
00241 !  and the mean radiation flux over the thermocline.
00242 !
00243 !
00244 ! Current Code Owner: DWD, Dmitrii Mironov
00245 !  Phone:  +49-69-8062 2705
00246 !  Fax:    +49-69-8062 3721
00247 !  E-mail: dmitrii.mironov@dwd.de
00248 !
00249 ! History:
00250 ! Version    Date       Name
00251 ! ---------- ---------- ----
00252 ! 1.00       2005/11/17 Dmitrii Mironov 
00253 !  Initial release
00254 ! !VERSION!  !DATE!     <Your name>
00255 !  <Modification comments>
00256 !
00257 ! Code Description:
00258 ! Language: Fortran 90.
00259 ! Software Standards: "European Standards for Writing and
00260 ! Documenting Exchangeable Fortran 90 Code".
00261 !==============================================================================
00262 !
00263 ! Declarations:
00264 !
00265 ! Modules used:
00266 
00267 !_dm Parameters are USEd in module "flake".
00268 !_nu USE modd_data_parameters , ONLY : &
00269 !_nu     ireals,                  & ! KIND-type parameter for real variables
00270 !_nu     iintegers                  ! KIND-type parameter for "normal" integer variables
00271 
00272 USE modd_flake_derivedtypes          ! Definitions of derived TYPEs
00273 
00274 USE modd_flake_parameters , ONLY :  &
00275     h_Snow_min_flk            ,  &! Minimum snow thickness [m]
00276     h_Ice_min_flk             ,  &! Minimum ice thickness [m]
00277     h_ML_min_flk                  ! Minimum mixed-layer depth [m]  
00278 
00279 !==============================================================================
00280 
00281 IMPLICIT NONE
00282 
00283 !==============================================================================
00284 !
00285 ! Declarations
00286 
00287 !  Input (procedure arguments)
00288 
00289 REAL, INTENT(IN) ::   
00290     depth_w                           ,  ! The lake depth [m]
00291     albedo_water                      ,  ! Albedo of the water surface 
00292     albedo_ice                        ,  ! Albedo of the ice surface
00293     albedo_snow                           ! Albedo of the snow surface  
00294 
00295 TYPE (opticpar_medium), INTENT(IN) ::  
00296     opticpar_water                    ,  ! Optical characteristics of water
00297     opticpar_ice                      ,  ! Optical characteristics of ice
00298     opticpar_snow                         ! Optical characteristics of snow   
00299 
00300 
00301 !  Local variables of type INTEGER
00302 INTEGER  ::  ! Help variable(s)
00303     i                             ! DO loop index  
00304 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00305 
00306 !==============================================================================
00307 !  Start calculations
00308 !------------------------------------------------------------------------------
00309 
00310   IF (LHOOK) CALL DR_HOOK('FLAKE:FLAKE_RADFLUX',0,ZHOOK_HANDLE)
00311   IF(h_ice_p_flk.GE.h_Ice_min_flk) THEN            ! Ice exists
00312     IF(h_snow_p_flk.GE.h_Snow_min_flk) THEN        ! There is snow above the ice
00313       I_snow_flk = I_atm_flk*(1.-albedo_snow) 
00314       I_bot_flk = 0.
00315       DO i=1, opticpar_snow%nband_optic
00316         I_bot_flk = I_bot_flk +                     &
00317           opticpar_snow%frac_optic(i)*EXP(-opticpar_snow%extincoef_optic(i)*h_snow_p_flk)   
00318       END DO 
00319       I_ice_flk  = I_snow_flk*I_bot_flk
00320     ELSE                                           ! No snow above the ice 
00321       I_snow_flk = I_atm_flk  
00322       I_ice_flk  = I_atm_flk*(1.-albedo_ice)
00323     END IF 
00324     I_bot_flk = 0.
00325     DO i=1, opticpar_ice%nband_optic
00326       I_bot_flk = I_bot_flk +                       &
00327         opticpar_ice%frac_optic(i)*EXP(-opticpar_ice%extincoef_optic(i)*h_ice_p_flk)   
00328     END DO 
00329     I_w_flk      = I_ice_flk*I_bot_flk
00330   ELSE                                             ! No ice-snow cover
00331     I_snow_flk   = I_atm_flk  
00332     I_ice_flk    = I_atm_flk
00333     I_w_flk      = I_atm_flk*(1.-albedo_water)
00334   END IF 
00335 
00336   IF(h_ML_p_flk.GE.h_ML_min_flk) THEN           ! Radiation flux at the bottom of the mixed layer
00337     I_bot_flk = 0.
00338     DO i=1, opticpar_water%nband_optic
00339       I_bot_flk = I_bot_flk +             &
00340         opticpar_water%frac_optic(i)*EXP(-opticpar_water%extincoef_optic(i)*h_ML_p_flk)   
00341     END DO 
00342     I_h_flk = I_w_flk*I_bot_flk
00343   ELSE                                          ! Mixed-layer depth is less then a minimum value
00344     I_h_flk = I_w_flk
00345   END IF
00346 
00347   I_bot_flk = 0.                       ! Radiation flux at the lake bottom
00348   DO i=1, opticpar_water%nband_optic
00349     I_bot_flk = I_bot_flk +               &
00350       opticpar_water%frac_optic(i)*EXP(-opticpar_water%extincoef_optic(i)*depth_w)   
00351   END DO 
00352   I_bot_flk = I_w_flk*I_bot_flk
00353 
00354   IF(h_ML_p_flk.GE.h_ML_min_flk) THEN           ! Integral-mean radiation flux over the mixed layer
00355     I_intm_0_h_flk = 0.
00356     DO i=1, opticpar_water%nband_optic
00357       I_intm_0_h_flk = I_intm_0_h_flk +                                &
00358         opticpar_water%frac_optic(i)/opticpar_water%extincoef_optic(i)*  &
00359         (1. - EXP(-opticpar_water%extincoef_optic(i)*h_ML_p_flk))  
00360     END DO 
00361     I_intm_0_h_flk = I_w_flk*I_intm_0_h_flk/h_ML_p_flk
00362   ELSE
00363     I_intm_0_h_flk = I_h_flk
00364   END IF
00365 
00366   IF(h_ML_p_flk.LE.depth_w-h_ML_min_flk) THEN   ! Integral-mean radiation flux over the thermocline
00367     I_intm_h_D_flk = 0. 
00368     DO i=1, opticpar_water%nband_optic
00369       I_intm_h_D_flk = I_intm_h_D_flk +                                &
00370         opticpar_water%frac_optic(i)/opticpar_water%extincoef_optic(i)*  &
00371         ( EXP(-opticpar_water%extincoef_optic(i)*h_ML_p_flk)             &
00372         - EXP(-opticpar_water%extincoef_optic(i)*depth_w) )  
00373     END DO 
00374     I_intm_h_D_flk = I_w_flk*I_intm_h_D_flk/(depth_w-h_ML_p_flk)
00375   ELSE
00376     I_intm_h_D_flk = I_h_flk
00377   END IF
00378 IF (LHOOK) CALL DR_HOOK('FLAKE:FLAKE_RADFLUX',1,ZHOOK_HANDLE)
00379 
00380 !------------------------------------------------------------------------------
00381 !  End calculations
00382 !==============================================================================
00383 
00384 END SUBROUTINE flake_radflux
00385 
00386 
00387 !==============================================================================
00388 
00389 !==============================================================================
00390 !SURFEX include 'flake_driver.incf'
00391 ! File %M% from Library %Q%
00392 ! Version %I% from %G% extracted: %H%
00393 !------------------------------------------------------------------------------
00394 
00395 SUBROUTINE flake_driver ( depth_w, depth_bs, T_bs, par_Coriolis,       &
00396                             extincoef_water_typ,                         &
00397                             del_time, T_sfc_p, T_sfc_n )           
00398 
00399 !------------------------------------------------------------------------------
00400 !
00401 ! Description:
00402 !
00403 !  The main driving routine of the lake model FLake 
00404 !  where computations are performed.
00405 !  Advances the surface temperature
00406 !  and other FLake variables one time step.
00407 !  At the moment, the Euler explicit scheme is used.
00408 !
00409 !  Lines embraced with "!_tmp" contain temporary parts of the code.
00410 !  Lines embraced/marked with "!_dev" may be replaced
00411 !  as improved parameterizations are developed and tested.
00412 !  Lines embraced/marked with "!_dm" are DM's comments
00413 !  that may be helpful to a user.
00414 !  Lines embraced/marked with "!_dbg" are used 
00415 !  for debugging purposes only.
00416 !
00417 !
00418 ! Current Code Owner: DWD, Dmitrii Mironov
00419 !  Phone:  +49-69-8062 2705
00420 !  Fax:    +49-69-8062 3721
00421 !  E-mail: dmitrii.mironov@dwd.de
00422 !
00423 ! History:
00424 ! Version    Date       Name
00425 ! ---------- ---------- ----
00426 ! 1.00       2005/11/17 Dmitrii Mironov 
00427 !  Initial release
00428 ! !VERSION!  !DATE!     <Your name>
00429 !  <Modification comments>
00430 !
00431 ! Code Description:
00432 ! Language: Fortran 90.
00433 ! Software Standards: "European Standards for Writing and
00434 ! Documenting Exchangeable Fortran 90 Code".
00435 !==============================================================================
00436 !
00437 ! Declarations:
00438 !
00439 ! Modules used:
00440 
00441 !_dm Parameters are USEd in module "flake".
00442 !_nu USE modd_data_parameters , ONLY : &
00443 !_nu     ireals,                  & ! KIND-type parameter for real variables
00444 !_nu     iintegers                  ! KIND-type parameter for "normal" integer variables
00445 
00446 USE modd_flake_parameters            ! Thermodynamic parameters and dimensionless constants of FLake
00447 
00448 USE modd_flake_configure             ! Switches and parameters that configure FLake
00449 
00450 !==============================================================================
00451 
00452 IMPLICIT NONE
00453 
00454 !==============================================================================
00455 !
00456 ! Declarations
00457 
00458 !  Input (procedure arguments)
00459 
00460 REAL, INTENT(IN) ::   
00461     depth_w                           ,  ! The lake depth [m]
00462     depth_bs                          ,  ! Depth of the thermally active layer of bottom sediments [m]
00463     T_bs                              ,  ! Temperature at the outer edge of 
00464                                         ! the thermally active layer of bottom sediments [K]
00465     par_Coriolis                      ,  &! The Coriolis parameter [s^{-1}]
00466     extincoef_water_typ               ,  &! "Typical" extinction coefficient of the lake water [m^{-1}],
00467                                         ! used to compute the equilibrium CBL depth
00468     del_time                          ,  &! The model time step [s]
00469     T_sfc_p                               ! Surface temperature at the previous time step [K]    
00470                                         ! (equal to either T_ice, T_snow or to T_wML)
00471 
00472 !  Output (procedure arguments)
00473 
00474 REAL, INTENT(OUT) ::  
00475     T_sfc_n                               ! Updated surface temperature [K]   
00476                                         ! (equal to the updated value of either T_ice, T_snow or T_wML)
00477 
00478 
00479 !  Local variables of type LOGICAL
00480 LOGICAL ::          
00481     l_ice_create    ,  ! Switch, .TRUE. = ice does not exist but should be created
00482     l_snow_exists   ,  ! Switch, .TRUE. = there is snow above the ice
00483     l_ice_meltabove     ! Switch, .TRUE. = snow/ice melting from above takes place  
00484 
00485 !  Local variables of type INTEGER
00486 INTEGER  :: 
00487     i                             ! Loop index  
00488 
00489 !  Local variables of type REAL
00490 REAL ::    
00491     d_T_mnw_dt             ,  ! Time derivative of T_mnw [K s^{-1}] 
00492     d_T_ice_dt             ,  ! Time derivative of T_ice [K s^{-1}] 
00493     d_T_bot_dt             ,  ! Time derivative of T_bot [K s^{-1}] 
00494     d_T_B1_dt              ,  ! Time derivative of T_B1 [K s^{-1}] 
00495     d_h_snow_dt            ,  ! Time derivative of h_snow [m s^{-1}]
00496     d_h_ice_dt             ,  ! Time derivative of h_ice [m s^{-1}]
00497     d_h_ML_dt              ,  ! Time derivative of h_ML [m s^{-1}]
00498     d_H_B1_dt              ,  ! Time derivative of H_B1 [m s^{-1}]
00499     d_C_T_dt                   ! Time derivative of C_T [s^{-1}]  
00500 
00501 !  Local variables of type REAL
00502 REAL ::    
00503     N_T_mean               ,  ! The mean buoyancy frequency in the thermocline [s^{-1}] 
00504     ZM_h_scale             ,  ! The ZM96 equilibrium SBL depth scale [m] 
00505     conv_equil_h_scale         ! The equilibrium CBL depth scale [m]  
00506 
00507 !  Local variables of type REAL
00508 REAL :: 
00509     h_ice_threshold     ,  ! If h_ice<h_ice_threshold, use quasi-equilibrium ice model 
00510     flk_str_1           ,  ! Help storage variable
00511     flk_str_2           ,  ! Help storage variable
00512     R_H_icesnow         ,  ! Dimensionless ratio, used to store intermediate results
00513     R_rho_c_icesnow     ,  ! Dimensionless ratio, used to store intermediate results
00514     R_TI_icesnow        ,  ! Dimensionless ratio, used to store intermediate results
00515     R_Tstar_icesnow         ! Dimensionless ratio, used to store intermediate results  
00516 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00517 
00518 !rsal
00519 !REAL :: aux1,aux2,aux3,aux4,aux5
00520 
00521 !==============================================================================
00522 !  Start calculations
00523 !------------------------------------------------------------------------------
00524 
00525 !_dm 
00526 ! Security. Set time-rate-of-change of prognostic variables to zero.
00527 ! Set prognostic variables to their values at the previous time step.
00528 ! (This is to avoid spurious changes of prognostic variables 
00529 ! when FLake is used within a 3D model, e.g. to avoid spurious generation of ice 
00530 ! at the neighbouring lake points as noticed by Burkhardt Rockel.)
00531 !_dm 
00532 
00533 
00534 IF (LHOOK) CALL DR_HOOK('FLAKE:FLAKE_DRIVER',0,ZHOOK_HANDLE)
00535 d_T_mnw_dt   = 0. 
00536 d_T_ice_dt   = 0. 
00537 d_T_bot_dt   = 0. 
00538 d_T_B1_dt    = 0. 
00539 d_h_snow_dt  = 0. 
00540 d_h_ice_dt   = 0. 
00541 d_h_ML_dt    = 0. 
00542 d_H_B1_dt    = 0. 
00543 d_C_T_dt     = 0. 
00544 T_snow_n_flk = T_snow_p_flk   
00545 T_ice_n_flk  = T_ice_p_flk    
00546 T_wML_n_flk  = T_wML_p_flk   
00547 T_mnw_n_flk  = T_mnw_p_flk     
00548 T_bot_n_flk  = T_bot_p_flk  
00549 T_B1_n_flk   = T_B1_p_flk      
00550 h_snow_n_flk = h_snow_p_flk 
00551 h_ice_n_flk  = h_ice_p_flk   
00552 h_ML_n_flk   = h_ML_p_flk    
00553 H_B1_n_flk   = H_B1_p_flk   
00554 C_T_n_flk    = C_T_p_flk    
00555 
00556 !------------------------------------------------------------------------------
00557 !  Compute fluxes, using variables from the previous time step.
00558 !------------------------------------------------------------------------------
00559 
00560 !_dm
00561 ! At this point, the heat and radiation fluxes, namely,
00562 ! Q_snow_flk, Q_ice_flk, Q_w_flk, 
00563 ! I_atm_flk, I_snow_flk, I_ice_flk, I_w_flk, I_h_flk, I_bot_flk,     
00564 ! the mean radiation flux over the mixed layer, I_intm_0_h_flk, 
00565 ! and the mean radiation flux over the thermocline, I_intm_h_D_flk, 
00566 ! should be known.
00567 ! They are computed within "flake_interface" (or within the driving model)
00568 ! and are available to "flake_driver"
00569 ! through the above variables declared in the MODULE "flake".
00570 ! In case a lake is ice-covered, Q_w_flk is re-computed below.
00571 !_dm
00572 
00573 ! Heat flux through the ice-water interface
00574 IF(h_ice_p_flk.GE.h_Ice_min_flk) THEN    ! Ice exists 
00575   IF(h_ML_p_flk.LE.h_ML_min_flk) THEN    ! Mixed-layer depth is zero, compute flux 
00576     Q_w_flk = -tpl_kappa_w*(T_bot_p_flk-T_wML_p_flk)/depth_w  ! Flux with linear T(z) 
00577     Phi_T_pr0_flk = Phi_T_pr0_1*C_T_p_flk-Phi_T_pr0_2         ! d\Phi(0)/d\zeta (thermocline)
00578     Q_w_flk = Q_w_flk*MAX(Phi_T_pr0_flk, 1.)           ! Account for an increased d\Phi(0)/d\zeta 
00579   ELSE                    
00580     Q_w_flk = 0.                  ! Mixed-layer depth is greater than zero, set flux to zero
00581   END IF   
00582 END IF   
00583 
00584 ! A generalized heat flux scale 
00585 Q_star_flk = Q_w_flk + I_w_flk + I_h_flk - 2.*I_intm_0_h_flk
00586 
00587 ! Heat flux through the water-bottom sediment interface
00588 IF(lflk_botsed_use) THEN
00589   Q_bot_flk = -tpl_kappa_w*(T_B1_p_flk-T_bot_p_flk)/MAX(H_B1_p_flk, H_B1_min_flk)*Phi_B1_pr0
00590 ELSE  
00591   Q_bot_flk = 0.   ! The bottom-sediment scheme is not used
00592 END IF
00593 
00594 
00595 !------------------------------------------------------------------------------
00596 !  Check if ice exists or should be created.
00597 !  If so, compute the thickness and the temperature of ice and snow.
00598 !------------------------------------------------------------------------------
00599 
00600 !_dm
00601 ! Notice that a quasi-equilibrium ice-snow model is used 
00602 ! to avoid numerical instability when the ice is thin.
00603 ! This is always the case when new ice is created.
00604 !_dm
00605 
00606 !_dev
00607 ! The dependence of snow density and of snow heat conductivity 
00608 ! on the snow thickness is accounted for parametrically.
00609 ! That is, the time derivatives of \rho_S and \kappa_S are neglected.
00610 ! The exception is the equation for the snow thickness 
00611 ! in case of snow accumulation and no melting, 
00612 ! where d\rho_S/dt is incorporated.
00613 ! Furthermore, some (presumably small) correction terms incorporating 
00614 ! the snow density and the snow heat conductivity are dropped out.
00615 ! Those terms may be included as better formulations 
00616 ! for \rho_S and \kappa_S are available.
00617 !_dev
00618 
00619 ! Default values
00620 l_ice_create    = .FALSE.  
00621 l_ice_meltabove = .FALSE.  
00622 
00623 Ice_exist: IF(h_ice_p_flk.LT.h_Ice_min_flk) THEN   ! Ice does not exist 
00624 
00625   l_ice_create = T_wML_p_flk.LE.(tpl_T_f+c_small_flk).AND.Q_w_flk.LT.0.
00626   IF(l_ice_create) THEN                            ! Ice does not exist but should be created
00627     d_h_ice_dt = -Q_w_flk/tpl_rho_I/tpl_L_f                                  
00628     h_ice_n_flk = h_ice_p_flk + d_h_ice_dt*del_time                          ! Advance h_ice 
00629     T_ice_n_flk = tpl_T_f + h_ice_n_flk*Q_w_flk/tpl_kappa_I/Phi_I_pr0_lin    ! Ice temperature
00630     d_h_snow_dt = dMsnowdt_flk/tpl_rho_S_min 
00631     h_snow_n_flk = h_snow_p_flk + d_h_snow_dt*del_time                       ! Advance h_snow
00632     Phi_I_pr1_flk = Phi_I_pr1_lin                                     &
00633                     + Phi_I_ast_MR*MIN(1., h_ice_n_flk/H_Ice_max)       ! d\Phi_I(1)/d\zeta_I (ice)  
00634     R_H_icesnow = Phi_I_pr1_flk/Phi_S_pr0_lin*tpl_kappa_I/flake_snowheatconduct(h_snow_n_flk) &
00635                   * h_snow_n_flk/MAX(h_ice_n_flk, h_Ice_min_flk)  
00636     T_snow_n_flk = T_ice_n_flk + R_H_icesnow*(T_ice_n_flk-tpl_T_f)           ! Snow temperature
00637   ELSE !kk, 30092004 - to avoid unsertainty here
00638    h_ice_n_flk = h_ice_p_flk
00639    h_snow_n_flk = h_snow_p_flk
00640    T_ice_n_flk = T_ice_p_flk
00641    T_snow_n_flk = T_snow_p_flk    
00642   END IF
00643 
00644 ELSE Ice_exist                                     ! Ice exists
00645 
00646   l_snow_exists = h_snow_p_flk.GE.h_Snow_min_flk   ! Check if there is snow above the ice
00647 
00648   Melting: IF(T_snow_p_flk.GE.(tpl_T_f-c_small_flk)) THEN  ! T_sfc = T_f, check for melting from above
00649                                                            ! T_snow = T_ice if snow is absent 
00650     IF(l_snow_exists) THEN   ! There is snow above the ice
00651       flk_str_1 = Q_snow_flk + I_snow_flk - I_ice_flk        ! Atmospheric forcing
00652       IF(flk_str_1.GE.0.) THEN  ! Melting of snow and ice from above
00653         l_ice_meltabove = .TRUE.
00654         d_h_snow_dt = (-flk_str_1/tpl_L_f+dMsnowdt_flk)/flake_snowdensity(h_snow_p_flk)
00655         d_h_ice_dt  = -(I_ice_flk - I_w_flk - Q_w_flk)/tpl_L_f/tpl_rho_I 
00656       END IF 
00657     ELSE                     ! No snow above the ice
00658       flk_str_1 = Q_ice_flk + I_ice_flk - I_w_flk - Q_w_flk  ! Atmospheric forcing + heating from the water
00659       IF(flk_str_1.GE.0.) THEN  ! Melting of ice from above, snow accumulation may occur
00660         l_ice_meltabove = .TRUE.
00661         d_h_ice_dt  = -flk_str_1/tpl_L_f/tpl_rho_I 
00662         d_h_snow_dt = dMsnowdt_flk/tpl_rho_S_min
00663       END IF 
00664     END IF 
00665     IF(l_ice_meltabove) THEN  ! Melting from above takes place
00666       h_ice_n_flk  = h_ice_p_flk  + d_h_ice_dt *del_time  ! Advance h_ice
00667       h_snow_n_flk = h_snow_p_flk + d_h_snow_dt*del_time  ! Advance h_snow
00668       T_ice_n_flk  = tpl_T_f                              ! Set T_ice to the freezing point
00669       T_snow_n_flk = tpl_T_f                              ! Set T_snow to the freezing point
00670     END IF
00671 
00672   END IF Melting
00673 
00674   No_Melting: IF(.NOT.l_ice_meltabove) THEN                 ! No melting from above
00675 
00676     d_h_snow_dt = flake_snowdensity(h_snow_p_flk)  
00677     IF(d_h_snow_dt.LT.tpl_rho_S_max) THEN    ! Account for d\rho_S/dt
00678      flk_str_1 = h_snow_p_flk*tpl_Gamma_rho_S/tpl_rho_w_r
00679      flk_str_1 = flk_str_1/(1.-flk_str_1)
00680     ELSE                                     ! Snow density is equal to its maximum value, d\rho_S/dt=0
00681      flk_str_1 = 0.
00682     END IF
00683     d_h_snow_dt = dMsnowdt_flk/d_h_snow_dt/(1.+flk_str_1)       ! Snow accumulation
00684     h_snow_n_flk = h_snow_p_flk + d_h_snow_dt*del_time                         ! Advance h_snow
00685     
00686     Phi_I_pr0_flk = h_ice_p_flk/H_Ice_max                              ! h_ice relative to its maximum value
00687     C_I_flk = C_I_lin - C_I_MR*(1.+Phi_I_ast_MR)*Phi_I_pr0_flk  ! Shape factor (ice)
00688     Phi_I_pr1_flk = Phi_I_pr1_lin + Phi_I_ast_MR*Phi_I_pr0_flk         ! d\Phi_I(1)/d\zeta_I (ice)
00689     Phi_I_pr0_flk = Phi_I_pr0_lin - Phi_I_pr0_flk                      ! d\Phi_I(0)/d\zeta_I (ice)
00690 
00691     h_ice_threshold = MAX(1., 2.*C_I_flk*tpl_c_I*(tpl_T_f-T_ice_p_flk)/tpl_L_f)
00692     h_ice_threshold = Phi_I_pr0_flk/C_I_flk*tpl_kappa_I/tpl_rho_I/tpl_c_I*h_ice_threshold
00693     h_ice_threshold = SQRT(h_ice_threshold*del_time)                   ! Threshold value of h_ice
00694     h_ice_threshold = MIN(0.9*H_Ice_max, MAX(h_ice_threshold, h_Ice_min_flk))
00695                                                                        ! h_ice(threshold) < 0.9*H_Ice_max
00696 
00697     IF(h_ice_p_flk.LT.h_ice_threshold) THEN  ! Use a quasi-equilibrium ice model
00698 
00699       IF(l_snow_exists) THEN   ! Use fluxes at the air-snow interface
00700         flk_str_1 = Q_snow_flk + I_snow_flk - I_w_flk
00701       ELSE                     ! Use fluxes at the air-ice interface
00702         flk_str_1 = Q_ice_flk + I_ice_flk - I_w_flk
00703       END IF
00704       d_h_ice_dt = -(flk_str_1-Q_w_flk)/tpl_L_f/tpl_rho_I
00705       h_ice_n_flk = h_ice_p_flk + d_h_ice_dt *del_time                         ! Advance h_ice
00706       T_ice_n_flk = tpl_T_f + h_ice_n_flk*flk_str_1/tpl_kappa_I/Phi_I_pr0_flk  ! Ice temperature
00707 
00708     ELSE                                     ! Use a complete ice model
00709 
00710       d_h_ice_dt = tpl_kappa_I*(tpl_T_f-T_ice_p_flk)/h_ice_p_flk*Phi_I_pr0_flk
00711       d_h_ice_dt = (Q_w_flk+d_h_ice_dt)/tpl_L_f/tpl_rho_I
00712       h_ice_n_flk = h_ice_p_flk  + d_h_ice_dt*del_time                         ! Advance h_ice
00713 
00714       R_TI_icesnow = tpl_c_I*(tpl_T_f-T_ice_p_flk)/tpl_L_f         ! Dimensionless parameter
00715       R_Tstar_icesnow = 1. - C_I_flk                        ! Dimensionless parameter
00716       IF(l_snow_exists) THEN  ! There is snow above the ice
00717         R_H_icesnow = Phi_I_pr1_flk/Phi_S_pr0_lin*tpl_kappa_I/flake_snowheatconduct(h_snow_p_flk) &
00718                       * h_snow_p_flk/h_ice_p_flk  
00719         R_rho_c_icesnow = flake_snowdensity(h_snow_p_flk)*tpl_c_S/tpl_rho_I/tpl_c_I 
00720 !_dev 
00721 !_dm 
00722 ! These terms should be included as an improved understanding of the snow scheme is gained, 
00723 ! of the effect of snow density in particular. 
00724 !_dm 
00725 !_nu        R_Tstar_icesnow = R_Tstar_icesnow                                                           &
00726 !_nu                        + (1.+C_S_lin*h_snow_p_flk/h_ice_p_flk)*R_H_icesnow*R_rho_c_icesnow
00727 !_dev
00728 
00729         R_Tstar_icesnow = R_Tstar_icesnow*R_TI_icesnow             ! Dimensionless parameter
00730 
00731 !_dev
00732 !_nu        R_Tstar_icesnow = R_Tstar_icesnow                                                         &
00733 !_nu                        + (1.-R_rho_c_icesnow)*tpl_c_I*T_ice_p_flk/tpl_L_f
00734 !_dev
00735         flk_str_2 = Q_snow_flk+I_snow_flk-I_w_flk                  ! Atmospheric fluxes
00736         flk_str_1  = C_I_flk*h_ice_p_flk + (1.+C_S_lin*R_H_icesnow)*R_rho_c_icesnow*h_snow_p_flk
00737         d_T_ice_dt = -(1.-2.*C_S_lin)*R_H_icesnow*(tpl_T_f-T_ice_p_flk)              &
00738                      * tpl_c_S*dMsnowdt_flk                          ! Effect of snow accumulation  
00739       ELSE                    ! No snow above the ice
00740         R_Tstar_icesnow = R_Tstar_icesnow*R_TI_icesnow             ! Dimensionless parameter
00741         flk_str_2 = Q_ice_flk+I_ice_flk-I_w_flk                    ! Atmospheric fluxes
00742         flk_str_1  = C_I_flk*h_ice_p_flk
00743         d_T_ice_dt = 0.
00744       END IF 
00745       d_T_ice_dt = d_T_ice_dt + tpl_kappa_I*(tpl_T_f-T_ice_p_flk)/h_ice_p_flk*Phi_I_pr0_flk       &
00746                    * (1.-R_Tstar_icesnow)                     ! Add flux due to heat conduction  
00747       d_T_ice_dt = d_T_ice_dt - R_Tstar_icesnow*Q_w_flk            ! Add flux from water to ice
00748       d_T_ice_dt = d_T_ice_dt + flk_str_2                          ! Add atmospheric fluxes
00749       d_T_ice_dt = d_T_ice_dt/tpl_rho_I/tpl_c_I                    ! Total forcing
00750       d_T_ice_dt = d_T_ice_dt/flk_str_1                            ! dT_ice/dt 
00751       T_ice_n_flk = T_ice_p_flk + d_T_ice_dt*del_time                          ! Advance T_ice
00752     END IF
00753 
00754     Phi_I_pr1_flk = MIN(1., h_ice_n_flk/H_Ice_max)          ! h_ice relative to its maximum value
00755     Phi_I_pr1_flk = Phi_I_pr1_lin + Phi_I_ast_MR*Phi_I_pr1_flk     ! d\Phi_I(1)/d\zeta_I (ice)
00756     R_H_icesnow = Phi_I_pr1_flk/Phi_S_pr0_lin*tpl_kappa_I/flake_snowheatconduct(h_snow_n_flk) &
00757                    *h_snow_n_flk/MAX(h_ice_n_flk, h_Ice_min_flk)  
00758     T_snow_n_flk = T_ice_n_flk + R_H_icesnow*(T_ice_n_flk-tpl_T_f)             ! Snow temperature
00759 
00760   END IF No_Melting
00761 
00762 END IF Ice_exist   
00763 
00764 ! Security, limit h_ice by its maximum value
00765 h_ice_n_flk = MIN(h_ice_n_flk, H_Ice_max)      
00766 
00767 ! Security, limit the ice and snow temperatures by the freezing point 
00768 T_snow_n_flk = MIN(T_snow_n_flk, tpl_T_f)  
00769 T_ice_n_flk =  MIN(T_ice_n_flk,  tpl_T_f)    
00770 
00771 !_tmp
00772 ! Security, avoid too low values (these constraints are used for debugging purposes)
00773   T_snow_n_flk = MAX(T_snow_n_flk, 73.15)  
00774   T_ice_n_flk =  MAX(T_ice_n_flk,  73.15)    
00775 !_tmp
00776 
00777 ! Remove too thin ice and/or snow
00778 IF(h_ice_n_flk.LT.h_Ice_min_flk)  THEN        ! Check ice
00779   h_ice_n_flk = 0.       ! Ice is too thin, remove it, and
00780   T_ice_n_flk = tpl_T_f         ! set T_ice to the freezing point.
00781   h_snow_n_flk = 0.      ! Remove snow when there is no ice, and
00782   T_snow_n_flk = tpl_T_f        ! set T_snow to the freezing point.
00783   l_ice_create = .FALSE.        ! "Exotic" case, ice has been created but proved to be too thin
00784 ELSE IF(h_snow_n_flk.LT.h_Snow_min_flk) THEN  ! Ice exists, check snow
00785   h_snow_n_flk = 0.      ! Snow is too thin, remove it, 
00786   T_snow_n_flk = T_ice_n_flk    ! and set the snow temperature equal to the ice temperature.
00787 END IF
00788 
00789 
00790 !------------------------------------------------------------------------------
00791 !  Compute the mean temperature of the water column.
00792 !------------------------------------------------------------------------------
00793 
00794 IF(l_ice_create) Q_w_flk = 0.     ! Ice has just been created, set Q_w to zero
00795 d_T_mnw_dt = (Q_w_flk - Q_bot_flk + I_w_flk - I_bot_flk)/tpl_rho_w_r/tpl_c_w/depth_w
00796 T_mnw_n_flk = T_mnw_p_flk + d_T_mnw_dt*del_time   ! Advance T_mnw
00797 T_mnw_n_flk = MAX(T_mnw_n_flk, tpl_T_f)           ! Limit T_mnw by the freezing point 
00798 
00799 
00800 !------------------------------------------------------------------------------
00801 !  Compute the mixed-layer depth, the mixed-layer temperature, 
00802 !  the bottom temperature and the shape factor
00803 !  with respect to the temperature profile in the thermocline. 
00804 !  Different formulations are used, depending on the regime of mixing. 
00805 !------------------------------------------------------------------------------
00806 
00807 HTC_Water: IF(h_ice_n_flk.GE.h_Ice_min_flk) THEN    ! Ice exists
00808 
00809   T_mnw_n_flk = MIN(T_mnw_n_flk, tpl_T_r) ! Limit the mean temperature under the ice by T_r 
00810   T_wML_n_flk = tpl_T_f                   ! The mixed-layer temperature is equal to the freezing point 
00811 
00812   IF(l_ice_create) THEN                  ! Ice has just been created 
00813     IF(h_ML_p_flk.GE.depth_w-h_ML_min_flk) THEN    ! h_ML=D when ice is created 
00814       h_ML_n_flk = 0.                 ! Set h_ML to zero 
00815       C_T_n_flk = C_T_min                    ! Set C_T to its minimum value 
00816     ELSE                                          ! h_ML<D when ice is created 
00817       h_ML_n_flk = h_ML_p_flk                ! h_ML remains unchanged 
00818       C_T_n_flk = C_T_p_flk                  ! C_T (thermocline) remains unchanged 
00819     END IF 
00820     T_bot_n_flk = T_wML_n_flk - (T_wML_n_flk-T_mnw_n_flk)/C_T_n_flk/(1.-h_ML_n_flk/depth_w)
00821                                              ! Update the bottom temperature 
00822 
00823   ELSE IF(T_bot_p_flk.LT.tpl_T_r) THEN   ! Ice exists and T_bot < T_r, molecular heat transfer 
00824     h_ML_n_flk = h_ML_p_flk                  ! h_ML remains unchanged 
00825     C_T_n_flk = C_T_p_flk                    ! C_T (thermocline) remains unchanged 
00826     T_bot_n_flk = T_wML_n_flk - (T_wML_n_flk-T_mnw_n_flk)/C_T_n_flk/(1.-h_ML_n_flk/depth_w)
00827                                              ! Update the bottom temperature 
00828 
00829   ELSE                                   ! Ice exists and T_bot = T_r, convection due to bottom heating 
00830     T_bot_n_flk = tpl_T_r                      ! T_bot is equal to the temperature of maximum density 
00831     IF(h_ML_p_flk.GE.c_small_flk) THEN   ! h_ML > 0 
00832       C_T_n_flk = C_T_p_flk                     ! C_T (thermocline) remains unchanged 
00833       h_ML_n_flk = depth_w*(1.-(T_wML_n_flk-T_mnw_n_flk)/(T_wML_n_flk-T_bot_n_flk)/C_T_n_flk)
00834       h_ML_n_flk = MAX(h_ML_n_flk, 0.)   ! Update the mixed-layer depth  
00835     ELSE                                 ! h_ML = 0 
00836       h_ML_n_flk = h_ML_p_flk                   ! h_ML remains unchanged 
00837       C_T_n_flk = (T_wML_n_flk-T_mnw_n_flk)/(T_wML_n_flk-T_bot_n_flk) 
00838       C_T_n_flk = MIN(C_T_max, MAX(C_T_n_flk, C_T_min)) ! Update the shape factor (thermocline)  
00839     END IF 
00840   END IF 
00841 
00842   T_bot_n_flk = MIN(T_bot_n_flk, tpl_T_r)    ! Security, limit the bottom temperature by T_r 
00843 
00844 ELSE HTC_Water                                      ! Open water
00845 
00846 ! Generalised buoyancy flux scale and convective velocity scale
00847   flk_str_1 = flake_buoypar(T_wML_p_flk)*Q_star_flk/tpl_rho_w_r/tpl_c_w                    
00848   IF(flk_str_1.LT.0.) THEN       
00849     w_star_sfc_flk = (-flk_str_1*h_ML_p_flk)**(1./3.)  ! Convection     
00850   ELSE 
00851     w_star_sfc_flk = 0.                                       ! Neutral or stable stratification
00852   END IF 
00853 
00854 !_dm
00855 ! The equilibrium depth of the CBL due to surface cooling with the volumetric heating
00856 ! is not computed as a solution to the transcendental equation.
00857 ! Instead, an algebraic formula is used
00858 ! that interpolates between the two asymptotic limits.
00859 !_dm
00860   conv_equil_h_scale = -Q_w_flk/MAX(I_w_flk, c_small_flk)
00861   IF(conv_equil_h_scale.GT.0. .AND. conv_equil_h_scale.LT.1.  &
00862       .AND. T_wML_p_flk.GT.tpl_T_r) THEN   ! The equilibrium CBL depth scale is only used above T_r  
00863     conv_equil_h_scale = SQRT(6.*conv_equil_h_scale)                 &
00864                          + 2.*conv_equil_h_scale/(1.-conv_equil_h_scale)  
00865     conv_equil_h_scale = MIN(depth_w, conv_equil_h_scale/extincoef_water_typ)
00866   ELSE
00867     conv_equil_h_scale = 0.       ! Set the equilibrium CBL depth to zero
00868   END IF
00869 
00870 ! Mean buoyancy frequency in the thermocline
00871   N_T_mean = flake_buoypar(0.5*(T_wML_p_flk+T_bot_p_flk))*(T_wML_p_flk-T_bot_p_flk)
00872   IF(h_ML_p_flk.LE.depth_w-h_ML_min_flk) THEN
00873     N_T_mean = SQRT(N_T_mean/(depth_w-h_ML_p_flk))  ! Compute N                   
00874   ELSE 
00875     N_T_mean = 0.                            ! h_ML=D, set N to zero
00876   END IF 
00877 
00878 ! The rate of change of C_T
00879   d_C_T_dt = MAX(w_star_sfc_flk, u_star_w_flk, u_star_min_flk)**2
00880   d_C_T_dt = N_T_mean*(depth_w-h_ML_p_flk)**2       &
00881              / c_relax_C/d_C_T_dt                               ! Relaxation time scale for C_T  
00882   d_C_T_dt = (C_T_max-C_T_min)/MAX(d_C_T_dt, c_small_flk)     ! Rate-of-change of C_T 
00883   !rsal:
00884   d_C_T_dt = min(d_C_T_dt,0.01/del_time)
00885 
00886 ! Compute the shape factor and the mixed-layer depth, 
00887 ! using different formulations for convection and wind mixing
00888 
00889   C_TT_flk = C_TT_1*C_T_p_flk-C_TT_2         ! C_TT, using C_T at the previous time step
00890   C_Q_flk = 2.*C_TT_flk/C_T_p_flk     ! C_Q using C_T at the previous time step
00891 
00892   Mixing_regime: IF(flk_str_1.LT.0.) THEN  ! Convective mixing 
00893 
00894     C_T_n_flk = C_T_p_flk + d_C_T_dt*del_time                        ! Update C_T, assuming dh_ML/dt>0
00895     C_T_n_flk = MIN(C_T_max, MAX(C_T_n_flk, C_T_min))                ! Limit C_T 
00896     d_C_T_dt = (C_T_n_flk-C_T_p_flk)/del_time                        ! Re-compute dC_T/dt
00897 
00898     IF(h_ML_p_flk.LE.depth_w-h_ML_min_flk) THEN       ! Compute dh_ML/dt
00899       IF(h_ML_p_flk.LE.h_ML_min_flk) THEN    ! Use a reduced entrainment equation (spin-up)
00900         d_h_ML_dt = c_cbl_1/c_cbl_2*MAX(w_star_sfc_flk, c_small_flk)
00901 
00902 !_dbg
00903 ! WRITE*, ' FLake: reduced entrainment eq. D_time*d_h_ML_dt  = ', d_h_ML_dt*del_time
00904 ! WRITE*, '         w_*       = ', w_star_sfc_flk
00905 ! WRITE*, '         \beta*Q_* = ', flk_str_1
00906 !_dbg
00907 
00908       ELSE                                   ! Use a complete entrainment equation 
00909         R_H_icesnow     = depth_w/h_ML_p_flk
00910         R_rho_c_icesnow = R_H_icesnow-1.
00911         R_TI_icesnow    = C_T_p_flk/C_TT_flk
00912         R_Tstar_icesnow = (R_TI_icesnow/2.-1.)*R_rho_c_icesnow + 1.
00913         d_h_ML_dt = -Q_star_flk*(R_Tstar_icesnow*(1.+c_cbl_1)-1.) - Q_bot_flk
00914         d_h_ML_dt = d_h_ML_dt/tpl_rho_w_r/tpl_c_w                        ! Q_* and Q_b flux terms
00915         flk_str_2 = (depth_w-h_ML_p_flk)*(T_wML_p_flk-T_bot_p_flk)*C_TT_2/C_TT_flk*d_C_T_dt 
00916         d_h_ML_dt = d_h_ML_dt + flk_str_2                                 ! Add dC_T/dt term
00917         flk_str_2 = I_bot_flk + (R_TI_icesnow-1.)*I_h_flk - R_TI_icesnow*I_intm_h_D_flk
00918         flk_str_2 = flk_str_2 + (R_TI_icesnow-2.)*R_rho_c_icesnow*(I_h_flk-I_intm_0_h_flk)
00919         flk_str_2 = flk_str_2/tpl_rho_w_r/tpl_c_w
00920         d_h_ML_dt = d_h_ML_dt + flk_str_2                                 ! Add radiation terms
00921         flk_str_2 = -c_cbl_2*R_Tstar_icesnow*Q_star_flk/tpl_rho_w_r/tpl_c_w/MAX(w_star_sfc_flk, c_small_flk)
00922         flk_str_2 = flk_str_2 + C_T_p_flk*(T_wML_p_flk-T_bot_p_flk)
00923         d_h_ML_dt = d_h_ML_dt/flk_str_2                                   ! dh_ML/dt = r.h.s.
00924       END IF 
00925 !_dm
00926 ! Notice that dh_ML/dt may appear to be negative  
00927 ! (e.g. due to buoyancy loss to bottom sediments and/or
00928 ! the effect of volumetric radiation heating),
00929 ! although a negative generalized buoyancy flux scale indicates 
00930 ! that the equilibrium CBL depth has not yet been reached
00931 ! and convective deepening of the mixed layer should take place.
00932 ! Physically, this situation reflects an approximate character of the lake model.
00933 ! Using the self-similar temperature profile in the thermocline, 
00934 ! there is always communication between the mixed layer, the thermocline 
00935 ! and the lake bottom. As a result, the rate of change of the CBL depth
00936 ! is always dependent on the bottom heat flux and the radiation heating of the thermocline.
00937 ! In reality, convective mixed-layer deepening may be completely decoupled
00938 ! from the processes underneath. In order to account for this fact,
00939 ! the rate of CBL deepening is set to a small value
00940 ! if dh_ML/dt proves to be negative.
00941 ! This is "double insurance" however, 
00942 ! as a negative dh_ML/dt is encountered very rarely.
00943 !_dm
00944 
00945 !_dbg
00946 ! IF(d_h_ML_dt.LT.0.) THEN 
00947 !   WRITE*, 'FLake: negative d_h_ML_dt during convection, = ', d_h_ML_dt
00948 !   WRITE*, '                d_h_ML_dt*del_time = ', MAX(d_h_ML_dt, c_small_flk)*del_time
00949 !   WRITE*, '         u_*       = ', u_star_w_flk   
00950 !   WRITE*, '         w_*       = ', w_star_sfc_flk
00951 !   WRITE*, '         h_CBL_eqi = ', conv_equil_h_scale
00952 !   WRITE*, '         ZM scale  = ', ZM_h_scale
00953 !   WRITE*, '        h_ML_p_flk = ', h_ML_p_flk
00954 ! END IF
00955 !   WRITE*, 'FLake: Convection, = ', d_h_ML_dt
00956 !   WRITE*, '         Q_*       = ', Q_star_flk
00957 !   WRITE*, '         \beta*Q_* = ', flk_str_1
00958 !_dbg
00959 
00960       d_h_ML_dt = MAX(d_h_ML_dt, c_small_flk)    
00961       h_ML_n_flk = h_ML_p_flk + d_h_ML_dt*del_time                       ! Update h_ML 
00962       h_ML_n_flk = MAX(h_ML_min_flk, MIN(h_ML_n_flk, depth_w))           ! Security, limit h_ML
00963     ELSE                                              ! Mixing down to the lake bottom
00964       h_ML_n_flk = depth_w
00965     END IF
00966 
00967   ELSE Mixing_regime                              ! Wind mixing
00968 
00969     d_h_ML_dt = MAX(u_star_w_flk, u_star_min_flk)                        ! The surface friction velocity
00970     ZM_h_scale = (ABS(par_Coriolis)/c_sbl_ZM_n + N_T_mean/c_sbl_ZM_i)*d_h_ML_dt**2
00971     ZM_h_scale = ZM_h_scale + flk_str_1/c_sbl_ZM_s
00972     ZM_h_scale = MAX(ZM_h_scale, c_small_flk)
00973     ZM_h_scale = d_h_ML_dt**3/ZM_h_scale 
00974     ZM_h_scale = MAX(h_ML_min_flk, MIN(ZM_h_scale, h_ML_max_flk))        ! The ZM96 SBL depth scale 
00975     ZM_h_scale = MAX(ZM_h_scale, conv_equil_h_scale)                     ! Equilibrium mixed-layer depth 
00976 
00977 !_dm 
00978 ! In order to avoid numerical discretization problems,
00979 ! an analytical solution to the evolution equation 
00980 ! for the wind-mixed layer depth is used.
00981 ! That is, an exponential relaxation formula is applied
00982 ! over the time interval equal to the model time step.
00983 !_dm 
00984 
00985     d_h_ML_dt = c_relax_h*d_h_ML_dt/ZM_h_scale*del_time
00986     h_ML_n_flk = ZM_h_scale - (ZM_h_scale-h_ML_p_flk)*EXP(-d_h_ML_dt)    ! Update h_ML 
00987     h_ML_n_flk = MAX(h_ML_min_flk, MIN(h_ML_n_flk, depth_w))             ! Limit h_ML 
00988     d_h_ML_dt = (h_ML_n_flk-h_ML_p_flk)/del_time                         ! Re-compute dh_ML/dt
00989 
00990     IF(h_ML_n_flk.LE.h_ML_p_flk)           &
00991         d_C_T_dt = -d_C_T_dt                 ! Mixed-layer retreat or stationary state, dC_T/dt<0  
00992     C_T_n_flk = C_T_p_flk + d_C_T_dt*del_time                            ! Update C_T
00993     C_T_n_flk = MIN(C_T_max, MAX(C_T_n_flk, C_T_min))                    ! Limit C_T 
00994     d_C_T_dt = (C_T_n_flk-C_T_p_flk)/del_time                            ! Re-compute dC_T/dt
00995 
00996 !_dbg
00997 ! WRITE*, 'FLake: wind mixing: d_h_ML_dt*del_time = ', d_h_ML_dt*del_time
00998 ! WRITE*, '              h_CBL_eqi = ', conv_equil_h_scale
00999 ! WRITE*, '              ZM scale  = ', ZM_h_scale
01000 ! WRITE*, '              w_*       = ', w_star_sfc_flk
01001 ! WRITE*, '              u_*       = ', u_star_w_flk
01002 ! WRITE*, '             h_ML_p_flk = ', h_ML_p_flk
01003 !_dbg
01004 
01005   END IF Mixing_regime
01006 
01007 ! Compute the time-rate-of-change of the the bottom temperature, 
01008 ! depending on the sign of dh_ML/dt 
01009 ! Update the bottom temperature and the mixed-layer temperature
01010 
01011   IF(h_ML_n_flk.LE.depth_w-h_ML_min_flk) THEN       ! Mixing did not reach the bottom 
01012 
01013     IF(h_ML_n_flk.GT.h_ML_p_flk) THEN   ! Mixed-layer deepening 
01014       R_H_icesnow     = h_ML_p_flk/depth_w
01015       R_rho_c_icesnow = 1.-R_H_icesnow 
01016       R_TI_icesnow    = 0.5*C_T_p_flk*R_rho_c_icesnow+C_TT_flk*(2.*R_H_icesnow-1.)
01017       R_Tstar_icesnow = (0.5+C_TT_flk-C_Q_flk)/R_TI_icesnow
01018       R_TI_icesnow    = (1.-C_T_p_flk*R_rho_c_icesnow)/R_TI_icesnow
01019      
01020       d_T_bot_dt = (Q_w_flk-Q_bot_flk+I_w_flk-I_bot_flk)/tpl_rho_w_r/tpl_c_w
01021       d_T_bot_dt = d_T_bot_dt - C_T_p_flk*(T_wML_p_flk-T_bot_p_flk)*d_h_ML_dt
01022       d_T_bot_dt = d_T_bot_dt*R_Tstar_icesnow/depth_w                   ! Q+I fluxes and dh_ML/dt term
01023 
01024       flk_str_2 = I_intm_h_D_flk - (1.-C_Q_flk)*I_h_flk - C_Q_flk*I_bot_flk
01025       flk_str_2 = flk_str_2*R_TI_icesnow/(depth_w-h_ML_p_flk)/tpl_rho_w_r/tpl_c_w
01026       d_T_bot_dt = d_T_bot_dt + flk_str_2                               ! Add radiation-flux term
01027 
01028       flk_str_2 = (1.-C_TT_2*R_TI_icesnow)/C_T_p_flk
01029       flk_str_2 = flk_str_2*(T_wML_p_flk-T_bot_p_flk)*d_C_T_dt
01030       d_T_bot_dt = d_T_bot_dt + flk_str_2                               ! Add dC_T/dt term
01031       
01032     ELSE                                ! Mixed-layer retreat or stationary state
01033       d_T_bot_dt = 0.                                            ! dT_bot/dt=0
01034     END IF
01035 
01036     T_bot_n_flk = T_bot_p_flk + d_T_bot_dt*del_time                      ! Update T_bot  
01037     T_bot_n_flk = MAX(T_bot_n_flk, tpl_T_f)           ! Security, limit T_bot by the freezing point
01038     flk_str_2 = (T_bot_n_flk-tpl_T_r)*flake_buoypar(T_mnw_n_flk)
01039     IF(flk_str_2.LT.0.) T_bot_n_flk = tpl_T_r  ! Security, avoid T_r crossover 
01040     T_wML_n_flk = C_T_n_flk*(1.-h_ML_n_flk/depth_w)
01041     T_wML_n_flk = (T_mnw_n_flk-T_bot_n_flk*T_wML_n_flk)/(1.-T_wML_n_flk)
01042     T_wML_n_flk = MAX(T_wML_n_flk, tpl_T_f)           ! Security, limit T_wML by the freezing point
01043 
01044   ELSE                                              ! Mixing down to the lake bottom 
01045 
01046     h_ML_n_flk = depth_w
01047     T_wML_n_flk = T_mnw_n_flk
01048     T_bot_n_flk = T_mnw_n_flk
01049     C_T_n_flk = C_T_min
01050 !rsal:
01051     C_T_n_flk = 0.65
01052 
01053 
01054   END IF
01055 
01056 !    print '(6(F12.5,1x))',d_T_bot_dt*del_time,aux1*del_time,aux2*del_time,aux3 &
01057 !                         ,aux4,aux5
01058 
01059 END IF HTC_Water
01060 
01061 
01062 !------------------------------------------------------------------------------
01063 !  Compute the depth of the upper layer of bottom sediments
01064 !  and the temperature at that depth.
01065 !------------------------------------------------------------------------------
01066 
01067 !SURFEX
01068 Sediment: IF(lflk_botsed_use) THEN   ! The bottom-sediment scheme is used
01069   
01070   IF(H_B1_p_flk.GE.depth_bs-H_B1_min_flk) THEN   ! No T(z) maximum (no thermal wave) 
01071     H_B1_p_flk = 0.                       ! Set H_B1_p to zero
01072     T_B1_p_flk = T_bot_p_flk                     ! Set T_B1_p to the bottom temperature
01073   END IF 
01074 
01075   flk_str_1 = 2.*Phi_B1_pr0/(1.-C_B1)*tpl_kappa_w/tpl_rho_w_r/tpl_c_w*del_time
01076   h_ice_threshold = SQRT(flk_str_1)                              ! Threshold value of H_B1
01077   h_ice_threshold = MIN(0.9*depth_bs, h_ice_threshold)    ! Limit H_B1
01078   flk_str_2 = C_B2/(1.-C_B2)*(T_bs-T_B1_p_flk)/(depth_bs-H_B1_p_flk)
01079 
01080   IF(H_B1_p_flk.LT.h_ice_threshold) THEN  ! Use a truncated equation for H_B1(t)
01081     H_B1_n_flk = SQRT(H_B1_p_flk**2+flk_str_1)  ! Advance H_B1
01082     d_H_B1_dt = (H_B1_n_flk-H_B1_p_flk)/del_time          ! Re-compute dH_B1/dt 
01083   ELSE                                    ! Use a full equation for H_B1(t)
01084     flk_str_1 = (Q_bot_flk+I_bot_flk)/H_B1_p_flk/tpl_rho_w_r/tpl_c_w
01085     flk_str_1 = flk_str_1 - (1.-C_B1)*(T_bot_n_flk-T_bot_p_flk)/del_time
01086     d_H_B1_dt = (1.-C_B1)*(T_bot_p_flk-T_B1_p_flk)/H_B1_p_flk + C_B1*flk_str_2
01087     d_H_B1_dt = flk_str_1/d_H_B1_dt
01088     H_B1_n_flk = H_B1_p_flk + d_H_B1_dt*del_time          ! Advance H_B1
01089   END IF 
01090   d_T_B1_dt = flk_str_2*d_H_B1_dt
01091   T_B1_n_flk = T_B1_p_flk + d_T_B1_dt*del_time            ! Advance T_B1
01092 
01093 !_dbg
01094 ! WRITE*, 'BS module: '
01095 ! WRITE*, '  Q_bot   = ', Q_bot_flk
01096 ! WRITE*, '  d_H_B1_dt = ', d_H_B1_dt
01097 ! WRITE*, '  d_T_B1_dt = ', d_T_B1_dt
01098 ! WRITE*, '  H_B1    = ', H_B1_n_flk
01099 ! WRITE*, '    T_bot = ', T_bot_n_flk
01100 ! WRITE*, '  T_B1    = ', T_B1_n_flk
01101 ! WRITE*, '    T_bs  = ',  T_bs
01102 !_dbg
01103 
01104 !_nu  
01105 ! Use a very simplistic procedure, where only the upper layer profile is used, 
01106 ! H_B1 is always set to depth_bs, and T_B1 is always set to T_bs.
01107 ! Then, the time derivatives are zero, and the sign of the bottom heat flux depends on 
01108 ! whether T_bot is smaller or greater than T_bs.
01109 ! This is, of course, an oversimplified scheme.
01110 !_nu  d_H_B1_dt = 0.
01111 !_nu  d_T_B1_dt = 0.
01112 !_nu  H_B1_n_flk = H_B1_p_flk + d_H_B1_dt*del_time   ! Advance H_B1
01113 !_nu  T_B1_n_flk = T_B1_p_flk + d_T_B1_dt*del_time   ! Advance T_B1
01114 !_nu  
01115 
01116   l_snow_exists = H_B1_n_flk.GE.depth_bs-H_B1_min_flk                     &! H_B1 reached depth_bs, or
01117                .OR. H_B1_n_flk.LT.H_B1_min_flk                              &! H_B1 decreased to zero, or
01118                .OR.(T_bot_n_flk-T_B1_n_flk)*(T_bs-T_B1_n_flk).LE.0.   ! there is no T(z) maximum  
01119   IF(l_snow_exists) THEN      
01120     H_B1_n_flk = depth_bs                     ! Set H_B1 to the depth of the thermally active layer
01121     T_B1_n_flk = T_bs                         ! Set T_B1 to the climatological temperature 
01122   END IF
01123 
01124 ELSE Sediment                        ! The bottom-sediment scheme is not used
01125 
01126   H_B1_n_flk = rflk_depth_bs_ref              ! H_B1 is set to a reference value 
01127   T_B1_n_flk = tpl_T_r                        ! T_B1 is set to the temperature of maximum density
01128 
01129 END IF Sediment
01130 
01131 
01132 !------------------------------------------------------------------------------
01133 !  Impose additional constraints.
01134 !------------------------------------------------------------------------------
01135 
01136 ! In case of unstable stratification, force mixing down to the bottom
01137 flk_str_2 = (T_wML_n_flk-T_bot_n_flk)*flake_buoypar(T_mnw_n_flk)
01138 IF(flk_str_2.LT.0.) THEN 
01139 
01140 !_dbg
01141 ! WRITE*, 'FLake: inverse (unstable) stratification !!! '
01142 ! WRITE*, '       Mixing down to the bottom is forced.'
01143 ! WRITE*, '  T_wML_p, T_wML_n ', T_wML_p_flk-tpl_T_f, T_wML_n_flk-tpl_T_f
01144 ! WRITE*, '  T_mnw_p, T_mnw_n ', T_mnw_p_flk-tpl_T_f, T_mnw_n_flk-tpl_T_f
01145 ! WRITE*, '  T_bot_p, T_bot_n ', T_bot_p_flk-tpl_T_f, T_bot_n_flk-tpl_T_f
01146 ! WRITE*, '  h_ML_p,  h_ML_n  ', h_ML_p_flk,          h_ML_n_flk
01147 ! WRITE*, '  C_T_p,   C_T_n   ', C_T_p_flk,           C_T_n_flk
01148 !_dbg
01149 
01150   h_ML_n_flk = depth_w
01151   T_wML_n_flk = T_mnw_n_flk
01152   T_bot_n_flk = T_mnw_n_flk
01153   C_T_n_flk = C_T_min
01154 !rsal:
01155     C_T_n_flk = 0.65
01156 
01157 END IF
01158 
01159 
01160 !------------------------------------------------------------------------------
01161 !  Update the surface temperature.
01162 !------------------------------------------------------------------------------
01163 
01164 IF(h_snow_n_flk.GE.h_Snow_min_flk) THEN   
01165   T_sfc_n = T_snow_n_flk                   ! Snow exists, use the snow temperature
01166 ELSE IF(h_ice_n_flk.GE.h_Ice_min_flk) THEN
01167   T_sfc_n = T_ice_n_flk                    ! Ice exists but there is no snow, use the ice temperature
01168 ELSE 
01169   T_sfc_n = T_wML_n_flk                    ! No ice-snow cover, use the mixed-layer temperature
01170 END IF
01171 IF (LHOOK) CALL DR_HOOK('FLAKE:FLAKE_DRIVER',1,ZHOOK_HANDLE)
01172 
01173 !------------------------------------------------------------------------------
01174 !  End calculations
01175 !==============================================================================
01176 
01177 END SUBROUTINE flake_driver
01178 
01179 
01180 !==============================================================================
01181 
01182 !==============================================================================
01183 !SURFEX include 'flake_buoypar.incf'
01184 ! File %M% from Library %Q%
01185 ! Version %I% from %G% extracted: %H%
01186 !------------------------------------------------------------------------------
01187 
01188 !SURFEX REAL  FUNCTION flake_buoypar (T_water)
01189 FUNCTION flake_buoypar (T_water)
01190 
01191 !------------------------------------------------------------------------------
01192 !
01193 ! Description:
01194 !
01195 !  Computes the buoyancy parameter,
01196 !  using a quadratic equation of state for the fresh-water.
01197 !  
01198 !
01199 ! Current Code Owner: DWD, Dmitrii Mironov
01200 !  Phone:  +49-69-8062 2705
01201 !  Fax:    +49-69-8062 3721
01202 !  E-mail: dmitrii.mironov@dwd.de
01203 !
01204 ! History:
01205 ! Version    Date       Name
01206 ! ---------- ---------- ----
01207 ! 1.00       2005/11/17 Dmitrii Mironov 
01208 !  Initial release
01209 ! !VERSION!  !DATE!     <Your name>
01210 !  <Modification comments>
01211 !
01212 ! Code Description:
01213 ! Language: Fortran 90.
01214 ! Software Standards: "European Standards for Writing and
01215 ! Documenting Exchangeable Fortran 90 Code".
01216 !==============================================================================
01217 !
01218 ! Declarations:
01219 !
01220 ! Modules used:
01221 
01222 !_dm Parameters are USEd in module "flake".
01223 !_nu USE modd_data_parameters , ONLY : &
01224 !_nu     ireals,                  & ! KIND-type parameter for real variables
01225 !_nu     iintegers                  ! KIND-type parameter for "normal" integer variables
01226 
01227 USE modd_flake_parameters , ONLY : &
01228     tpl_grav                  ,  &! Acceleration due to gravity [m s^{-2}]
01229     tpl_T_r                   ,  &! Temperature of maximum density of fresh water [K]
01230     tpl_a_T                       ! Constant in the fresh-water equation of state [K^{-2}]  
01231 
01232 !==============================================================================
01233 
01234 IMPLICIT NONE
01235 
01236 !==============================================================================
01237 !
01238 ! Declarations
01239  
01240 !  Input (function argument) 
01241 REAL , INTENT(IN) :: 
01242     T_water                             ! Water temperature [K]  
01243 
01244 !  Output (function result) 
01245 REAL               :: 
01246     flake_buoypar                       ! Buoyancy parameter [m s^{-2} K^{-1}]  
01247 REAL(KIND=JPRB) :: ZHOOK_HANDLE
01248 
01249 !==============================================================================
01250 !  Start calculations
01251 !------------------------------------------------------------------------------
01252 
01253 ! Buoyancy parameter [m s^{-2} K^{-1}]
01254 
01255   IF (LHOOK) CALL DR_HOOK('FLAKE:FLAKE_BUOYPAR',0,ZHOOK_HANDLE)
01256   flake_buoypar = tpl_grav*tpl_a_T*(T_water-tpl_T_r)
01257 IF (LHOOK) CALL DR_HOOK('FLAKE:FLAKE_BUOYPAR',1,ZHOOK_HANDLE)
01258 
01259 !------------------------------------------------------------------------------
01260 !  End calculations
01261 !==============================================================================
01262 
01263 END FUNCTION flake_buoypar
01264 
01265 
01266 !==============================================================================
01267 !SURFEX include 'flake_snowdensity.incf'
01268 ! File %M% from Library %Q%
01269 ! Version %I% from %G% extracted: %H%
01270 !------------------------------------------------------------------------------
01271 
01272 !SURFEX REAL  FUNCTION flake_snowdensity (h_snow)
01273 FUNCTION flake_snowdensity (h_snow)
01274 
01275 !------------------------------------------------------------------------------
01276 !
01277 ! Description:
01278 !
01279 !  Computes the snow density,
01280 !  using an empirical approximation from Heise et al. (2003).
01281 !  
01282 !
01283 ! Current Code Owner: DWD, Dmitrii Mironov
01284 !  Phone:  +49-69-8062 2705
01285 !  Fax:    +49-69-8062 3721
01286 !  E-mail: dmitrii.mironov@dwd.de
01287 !
01288 ! History:
01289 ! Version    Date       Name
01290 ! ---------- ---------- ----
01291 ! 1.00       2005/11/17 Dmitrii Mironov 
01292 !  Initial release
01293 ! !VERSION!  !DATE!     <Your name>
01294 !  <Modification comments>
01295 !
01296 ! Code Description:
01297 ! Language: Fortran 90.
01298 ! Software Standards: "European Standards for Writing and
01299 ! Documenting Exchangeable Fortran 90 Code".
01300 !==============================================================================
01301 !
01302 ! Declarations:
01303 !
01304 ! Modules used:
01305 
01306 !_dm Parameters are USEd in module "flake".
01307 !_nu USE modd_data_parameters , ONLY : &
01308 !_nu     ireals,                  & ! KIND-type parameter for real variables
01309 !_nu     iintegers                  ! KIND-type parameter for "normal" integer variables
01310 
01311 USE modd_flake_parameters , ONLY : &
01312     tpl_rho_w_r               ,  &! Maximum density of fresh water [kg m^{-3}]
01313     tpl_rho_S_min             ,  &! Minimum snow density [kg m^{-3}]
01314     tpl_rho_S_max             ,  &! Maximum snow density [kg m^{-3}]
01315     tpl_Gamma_rho_S           ,  &! Empirical parameter [kg m^{-4}] in the expression for the snow density
01316     c_small_flk                   ! A small number  
01317 
01318 !==============================================================================
01319 
01320 IMPLICIT NONE
01321 
01322 !==============================================================================
01323 !
01324 ! Declarations
01325  
01326 !  Input (function argument) 
01327 REAL , INTENT(IN) :: 
01328     h_snow                              ! Snow thickness [m]  
01329 
01330 !  Output (function result) 
01331 REAL               :: 
01332     flake_snowdensity                   ! Snow density [kg m^{-3}]  
01333 REAL(KIND=JPRB) :: ZHOOK_HANDLE
01334 
01335 !==============================================================================
01336 !  Start calculations
01337 !------------------------------------------------------------------------------
01338 
01339 ! Snow density [kg m^{-3}]
01340 
01341 !  Security. Ensure that the expression in () does not become negative at a very large h_snow.
01342   IF (LHOOK) CALL DR_HOOK('FLAKE:FLAKE_SNOWDENSITY',0,ZHOOK_HANDLE)
01343   flake_snowdensity = MAX( c_small_flk, (1. - h_snow*tpl_Gamma_rho_S/tpl_rho_w_r) )
01344   flake_snowdensity = MIN( tpl_rho_S_max, tpl_rho_S_min/flake_snowdensity )
01345 IF (LHOOK) CALL DR_HOOK('FLAKE:FLAKE_SNOWDENSITY',1,ZHOOK_HANDLE)
01346 
01347 !------------------------------------------------------------------------------
01348 !  End calculations
01349 !==============================================================================
01350 
01351 END FUNCTION flake_snowdensity 
01352 
01353 
01354 !==============================================================================
01355 !SURFEX include 'flake_snowheatconduct.incf'
01356 ! File %M% from Library %Q%
01357 ! Version %I% from %G% extracted: %H%
01358 !------------------------------------------------------------------------------
01359 
01360 !SURFEX REAL  FUNCTION flake_snowheatconduct (h_snow)
01361 FUNCTION flake_snowheatconduct (h_snow)
01362 
01363 !------------------------------------------------------------------------------
01364 !
01365 ! Description:
01366 !
01367 !  Computes the snow heat conductivity,
01368 !  using an empirical approximation from Heise et al. (2003).
01369 !  
01370 !
01371 ! Current Code Owner: DWD, Dmitrii Mironov
01372 !  Phone:  +49-69-8062 2705
01373 !  Fax:    +49-69-8062 3721
01374 !  E-mail: dmitrii.mironov@dwd.de
01375 !
01376 ! History:
01377 ! Version    Date       Name
01378 ! ---------- ---------- ----
01379 ! 1.00       2005/11/17 Dmitrii Mironov 
01380 !  Initial release
01381 ! !VERSION!  !DATE!     <Your name>
01382 !  <Modification comments>
01383 !
01384 ! Code Description:
01385 ! Language: Fortran 90.
01386 ! Software Standards: "European Standards for Writing and
01387 ! Documenting Exchangeable Fortran 90 Code".
01388 !==============================================================================
01389 !
01390 ! Declarations:
01391 !
01392 ! Modules used:
01393 
01394 !_dm Parameters are USEd in module "flake".
01395 !_nu USE modd_data_parameters , ONLY : &
01396 !_nu     ireals,                  & ! KIND-type parameter for real variables
01397 !_nu     iintegers                  ! KIND-type parameter for "normal" integer variables
01398 
01399 USE modd_flake_parameters , ONLY : &
01400     tpl_rho_w_r               ,  &! Maximum density of fresh water [kg m^{-3}]
01401     tpl_kappa_S_min           ,  &! Minimum molecular heat conductivity of snow [J m^{-1} s^{-1} K^{-1}]
01402     tpl_kappa_S_max           ,  &! Maximum molecular heat conductivity of snow [J m^{-1} s^{-1} K^{-1}]
01403     tpl_Gamma_kappa_S             ! Empirical parameter [J m^{-2} s^{-1} K^{-1}] in the expression for kappa_S  
01404 
01405 !==============================================================================
01406 
01407 IMPLICIT NONE
01408 
01409 !==============================================================================
01410 !
01411 ! Declarations
01412  
01413 !  Input (function argument) 
01414 REAL , INTENT(IN) :: 
01415     h_snow                              ! Snow thickness [m]  
01416 
01417 !  Output (function result) 
01418 REAL               :: 
01419     flake_snowheatconduct               ! Snow heat conductivity [J m^{-1} s^{-1} K^{-1} = kg m s^{-3} K^{-1}]  
01420 REAL(KIND=JPRB) :: ZHOOK_HANDLE
01421 
01422 !==============================================================================
01423 !  Start calculations
01424 !------------------------------------------------------------------------------
01425 
01426 ! Snow heat conductivity [J m^{-1} s^{-1} K^{-1} = kg m s^{-3} K^{-1}]
01427 
01428   IF (LHOOK) CALL DR_HOOK('FLAKE:FLAKE_SNOWHEATCONDUCT',0,ZHOOK_HANDLE)
01429   flake_snowheatconduct = flake_snowdensity( h_snow )   ! Compute snow density
01430   flake_snowheatconduct = MIN( tpl_kappa_S_max, tpl_kappa_S_min                      &
01431                           + h_snow*tpl_Gamma_kappa_S*flake_snowheatconduct/tpl_rho_w_r )  
01432 IF (LHOOK) CALL DR_HOOK('FLAKE:FLAKE_SNOWHEATCONDUCT',1,ZHOOK_HANDLE)
01433 
01434 !------------------------------------------------------------------------------
01435 !  End calculations
01436 !==============================================================================
01437 
01438 END FUNCTION flake_snowheatconduct
01439 
01440 END MODULE mode_flake
01441