SURFEX v8.1
General documentation of Surfex
mode_flake.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! File %M% from Library %Q%
6 ! Version %I% from %G% extracted: %H%
7 !------------------------------------------------------------------------------
8 
9 MODULE mode_flake
10 
11 !------------------------------------------------------------------------------
12 !
13 ! Description:
14 !
15 ! The main program unit of the lake model FLake,
16 ! containing most of the FLake procedures.
17 ! Most FLake variables and local parameters are declared.
18 !
19 ! FLake (Fresh-water Lake) is a lake model capable of predicting the surface temperature
20 ! in lakes of various depth on the time scales from a few hours to a year.
21 ! The model is based on a two-layer parametric representation of
22 ! the evolving temperature profile, where the structure of the stratified layer between the
23 ! upper mixed layer and the basin bottom, the lake thermocline,
24 ! is described using the concept of self-similarity of the temperature-depth curve.
25 ! The concept was put forward by Kitaigorodskii and Miropolsky (1970)
26 ! to describe the vertical temperature structure of the oceanic seasonal thermocline.
27 ! It has since been successfully used in geophysical applications.
28 ! The concept of self-similarity of the evolving temperature profile
29 ! is also used to describe the vertical structure of the thermally active upper layer
30 ! of bottom sediments and of the ice and snow cover.
31 !
32 ! The lake model incorporates the heat budget equations
33 ! for the four layers in question, viz., snow, ice, water and bottom sediments,
34 ! developed with due regard for the vertically distributed character
35 ! of solar radiation heating.
36 ! The entrainment equation that incorporates the Zilitinkevich (1975) spin-up term
37 ! is used to compute the depth of a convectively-mixed layer.
38 ! A relaxation-type equation is used
39 ! to compute the wind-mixed layer depth in stable and neutral stratification,
40 ! where a multi-limit formulation for the equilibrium mixed-layer depth
41 ! proposed by Zilitinkevich and Mironov (1996)
42 ! accounts for the effects of the earth's rotation, of the surface buoyancy flux
43 ! and of the static stability in the thermocline.
44 ! The equations for the mixed-layer depth are developed with due regard for
45 ! the volumetric character of the radiation heating.
46 ! Simple thermodynamic arguments are invoked to develop
47 ! the evolution equations for the ice thickness and for the snow thickness.
48 ! The heat flux through the water-bottom sediment interface is computed,
49 ! using a parameterization proposed by Golosov et al. (1998).
50 ! The heat flux trough the air-water interface
51 ! (or through the air-ice or air-snow interface)
52 ! is provided by the driving atmospheric model.
53 !
54 ! Empirical constants and parameters of the lake model
55 ! are estimated, using independent empirical and numerical data.
56 ! They should not be re-evaluated when the model is applied to a particular lake.
57 ! The only lake-specific parameters are the lake depth,
58 ! the optical characteristics of lake water,
59 ! the temperature at the bottom of the thermally active layer
60 ! of bottom sediments and the depth of that layer.
61 !
62 ! A detailed description of the lake model is given in
63 ! Mironov, D. V., 2005:
64 ! Parameterization of Lakes in Numerical Weather Prediction.
65 ! Part 1: Description of a Lake Model.
66 ! Manuscript is available from the author.
67 ! Dmitrii Mironov
68 ! German Weather Service, Kaiserleistr. 29/35, D-63067 Offenbach am Main, Germany.
69 ! dmitrii.mironov@dwd.de
70 !
71 ! Lines embraced with "!_tmp" contain temporary parts of the code.
72 ! Lines embraced/marked with "!_dev" may be replaced
73 ! as improved parameterizations are developed and tested.
74 ! Lines embraced/marked with "!_dm" are DM's comments
75 ! that may be helpful to a user.
76 ! Lines embraced/marked with "!_dbg" are used
77 ! for debugging purposes only.
78 !
79 !
80 ! Current Code Owner: DWD, Dmitrii Mironov
81 ! Phone: +49-69-8062 2705
82 ! Fax: +49-69-8062 3721
83 ! E-mail: dmitrii.mironov@dwd.de
84 !
85 ! History:
86 ! Version Date Name
87 ! ---------- ---------- ----
88 ! 1.00 2005/11/17 Dmitrii Mironov
89 ! Initial release
90 ! !VERSION! !DATE! <Your name>
91 ! <Modification comments>
92 !
93 ! Code Description:
94 ! Language: Fortran 90.
95 ! Software Standards: "European Standards for Writing and
96 ! Documenting Exchangeable Fortran 90 Code".
97 !==============================================================================
98 !
99 ! Declarations:
100 !
101 ! Modules used:
102 
103 !USE modd_data_parameters , ONLY : &
104 ! ireals , &! KIND-type parameter for real variables
105 ! iintegers ! KIND-type parameter for "normal" integer variables
106 
107 !==============================================================================
108 
109 !
110 USE yomhook ,ONLY : lhook, dr_hook
111 USE parkind1 ,ONLY : jprb
112 !
113 USE modd_surfex_omp, ONLY : nblock
114 !
115 IMPLICIT NONE
116 
117 !==============================================================================
118 !
119 ! Declarations
120 !
121 ! The variables declared below
122 ! are accessible to all program units of the MODULE flake.
123 ! Some of them should be USEd by the driving routines that call flake routines.
124 ! These are basically the quantities computed by FLake.
125 ! All variables declared below have a suffix "flk".
126 
127 ! FLake variables of type REAL
128 
129 !RJ: provide default unreasonable value to init for 'ifort -fpic -openmp', to avoid ICE
130 REAL,PARAMETER,PRIVATE :: z_=-huge(0.0)
131 
132 ! Temperatures at the previous time step ("p") and the updated temperatures ("n")
133 REAL :: t_mnw_p_flk=z_, t_mnw_n_flk=z_ ! Mean temperature of the water column [K]
134 REAL :: t_snow_p_flk=z_, t_snow_n_flk=z_ ! Temperature at the air-snow interface [K]
135 REAL :: t_ice_p_flk=z_, t_ice_n_flk=z_ ! Temperature at the snow-ice or air-ice interface [K]
136 REAL :: t_wml_p_flk=z_, t_wml_n_flk=z_ ! Mixed-layer temperature [K]
137 REAL :: t_bot_p_flk=z_, t_bot_n_flk=z_ ! Temperature at the water-bottom sediment interface [K]
138 REAL :: t_b1_p_flk=z_, t_b1_n_flk=z_ ! Temperature at the bottom of the upper layer of the sediments [K]
139 
140 ! Thickness of various layers at the previous time step ("p") and the updated values ("n")
141 REAL :: h_snow_p_flk=z_, h_snow_n_flk=z_ ! Snow thickness [m]*
142 REAL :: h_ice_p_flk=z_, h_ice_n_flk=z_ ! Ice thickness [m]
143 REAL :: h_ml_p_flk=z_, h_ml_n_flk=z_ ! Thickness of the mixed-layer [m]
144 REAL :: h_b1_p_flk=z_, h_b1_n_flk=z_ ! Thickness of the upper layer of bottom sediments [m]
145 
146 ! The shape factor(s) at the previous time step ("p") and the updated value(s) ("n")
147 REAL :: c_t_p_flk=z_, c_t_n_flk=z_ ! Shape factor (thermocline)
148 REAL :: c_tt_flk=z_ ! Dimensionless parameter (thermocline)
149 REAL :: c_q_flk=z_ ! Shape factor with respect to the heat flux (thermocline)
150 REAL :: c_i_flk=z_ ! Shape factor (ice)
151 REAL :: c_s_flk=z_ ! Shape factor (snow)
152 
153 ! Derivatives of the shape functions
154 REAL :: phi_t_pr0_flk=z_ ! d\Phi_T(0)/d\zeta (thermocline)
155 REAL :: phi_i_pr0_flk=z_ ! d\Phi_I(0)/d\zeta_I (ice)
156 REAL :: phi_i_pr1_flk=z_ ! d\Phi_I(1)/d\zeta_I (ice)
157 REAL :: phi_s_pr0_flk=z_ ! d\Phi_S(0)/d\zeta_S (snow)
158 
159 ! Heat and radiation fluxes
160 REAL :: q_snow_flk=z_ ! Heat flux through the air-snow interface [W m^{-2}]
161 REAL :: q_ice_flk=z_ ! Heat flux through the snow-ice or air-ice interface [W m^{-2}]
162 REAL :: q_w_flk=z_ ! Heat flux through the ice-water or air-water interface [W m^{-2}]
163 REAL :: q_bot_flk=z_ ! Heat flux through the water-bottom sediment interface [W m^{-2}]
164 REAL :: i_atm_flk=z_ ! Radiation flux at the lower boundary of the atmosphere [W m^{-2}],
165  ! i.e. the incident radiation flux with no regard for the surface albedo.
166 REAL :: i_snow_flk=z_ ! Radiation flux through the air-snow interface [W m^{-2}]
167 REAL :: i_ice_flk=z_ ! Radiation flux through the snow-ice or air-ice interface [W m^{-2}]
168 REAL :: i_w_flk=z_ ! Radiation flux through the ice-water or air-water interface [W m^{-2}]
169 REAL :: i_h_flk=z_ ! Radiation flux through the mixed-layer-thermocline interface [W m^{-2}]
170 REAL :: i_bot_flk=z_ ! Radiation flux through the water-bottom sediment interface [W m^{-2}]
171 REAL :: i_intm_0_h_flk=z_ ! Mean radiation flux over the mixed layer [W m^{-1}]
172 REAL :: i_intm_h_d_flk=z_ ! Mean radiation flux over the thermocline [W m^{-1}]
173 REAL :: q_star_flk=z_ ! A generalized heat flux scale [W m^{-2}]
174 
175 ! Velocity scales
176 REAL :: u_star_w_flk=z_ ! Friction velocity in the surface layer of lake water [m s^{-1}]
177 REAL :: w_star_sfc_flk=z_ ! Convective velocity scale,
178  ! using a generalized heat flux scale [m s^{-1}]
179 
180 ! The rate of snow accumulation
181 REAL :: dmsnowdt_flk=z_ ! The rate of snow accumulation [kg m^{-2} s^{-1}]
182 
183 !==============================================================================
184 ! Procedures
185 !==============================================================================
186 
187 CONTAINS
188 
189 !==============================================================================
190 ! The codes of the FLake procedures are stored in separate "*.incf" files
191 ! and are included below.
192 !------------------------------------------------------------------------------
193 
194 !==============================================================================
195 ! For SURFEX needs, separate *.incf files are explicitly expanded
196 !==============================================================================
197 !SURFEX include 'flake_radflux.incf'
198 ! File %M% from Library %Q%
199 ! Version %I% from %G% extracted: %H%
200 !------------------------------------------------------------------------------
201 
202 SUBROUTINE flake_radflux(depth_w,albedo,opticpar_water,opticpar_ice,opticpar_snow)
204 !------------------------------------------------------------------------------
205 !
206 ! Description:
207 !
208 ! Computes the radiation fluxes
209 ! at the snow-ice, ice-water, air-water,
210 ! mixed layer-thermocline and water column-bottom sediment interfaces,
211 ! the mean radiation flux over the mixed layer,
212 ! and the mean radiation flux over the thermocline.
213 !
214 !
215 ! Current Code Owner: DWD, Dmitrii Mironov
216 ! Phone: +49-69-8062 2705
217 ! Fax: +49-69-8062 3721
218 ! E-mail: dmitrii.mironov@dwd.de
219 !
220 ! History:
221 ! Version Date Name
222 ! ---------- ---------- ----
223 ! 1.00 2005/11/17 Dmitrii Mironov
224 ! Initial release
225 ! !VERSION! !DATE! <Your name>
226 ! <Modification comments>
227 !
228 ! Code Description:
229 ! Language: Fortran 90.
230 ! Software Standards: "European Standards for Writing and
231 ! Documenting Exchangeable Fortran 90 Code".
232 !==============================================================================
233 !
234 ! Declarations:
235 !
236 ! Modules used:
237 
238 !_dm Parameters are USEd in module "flake".
239 !_nu USE modd_data_parameters , ONLY : &
240 !_nu ireals, & ! KIND-type parameter for real variables
241 !_nu iintegers ! KIND-type parameter for "normal" integer variables
242 
243 USE modd_flake_derivedtypes ! Definitions of derived TYPEs
244 
245 USE modd_flake_parameters , ONLY : &
246  h_snow_min_flk , &! Minimum snow thickness [m]
247  h_ice_min_flk , &! Minimum ice thickness [m]
248  h_ml_min_flk ! Minimum mixed-layer depth [m]
249 
250 !==============================================================================
251 
252 IMPLICIT NONE
253 
254 !==============================================================================
255 !
256 ! Declarations
257 
258 ! Input (procedure arguments)
259 
260 REAL, INTENT(IN) :: &
261  depth_w , &! The lake depth [m]
262  albedo ! Albedo of all surfaces
263 
264 type(opticpar_medium), INTENT(IN) :: &
265  opticpar_water , &! Optical characteristics of water
266  opticpar_ice , &! Optical characteristics of ice
267  opticpar_snow ! Optical characteristics of snow
268 
269 
270 ! Local variables of type INTEGER
271 INTEGER :: &! Help variable(s)
272  i ! DO loop index
273 REAL(KIND=JPRB) :: ZHOOK_HANDLE
274 
275 !==============================================================================
276 ! Start calculations
277 !------------------------------------------------------------------------------
278 
279  IF (lhook) CALL dr_hook('FLAKE:FLAKE_RADFLUX',0,zhook_handle)
280  IF(h_ice_p_flk.GE.h_ice_min_flk) THEN ! Ice exists
281  IF(h_snow_p_flk.GE.h_snow_min_flk) THEN ! There is snow above the ice
282  i_snow_flk = i_atm_flk*(1.-albedo)
283  i_bot_flk = 0.
284  DO i=1, opticpar_snow%nband_optic
285  i_bot_flk = i_bot_flk + &
286  opticpar_snow%frac_optic(i)*exp(-opticpar_snow%extincoef_optic(i)*h_snow_p_flk)
287  END DO
289  ELSE ! No snow above the ice
291  i_ice_flk = i_atm_flk*(1.-albedo)
292  END IF
293  i_bot_flk = 0.
294  DO i=1, opticpar_ice%nband_optic
295  i_bot_flk = i_bot_flk + &
296  opticpar_ice%frac_optic(i)*exp(-opticpar_ice%extincoef_optic(i)*h_ice_p_flk)
297  END DO
299  ELSE ! No ice-snow cover
302  i_w_flk = i_atm_flk*(1.-albedo)
303  END IF
304 
305  IF(h_ml_p_flk.GE.h_ml_min_flk) THEN ! Radiation flux at the bottom of the mixed layer
306  i_bot_flk = 0.
307  DO i=1, opticpar_water%nband_optic
308  i_bot_flk = i_bot_flk + &
309  opticpar_water%frac_optic(i)*exp(-opticpar_water%extincoef_optic(i)*h_ml_p_flk)
310  END DO
312  ELSE ! Mixed-layer depth is less then a minimum value
313  i_h_flk = i_w_flk
314  END IF
315 
316  i_bot_flk = 0. ! Radiation flux at the lake bottom
317  DO i=1, opticpar_water%nband_optic
318  i_bot_flk = i_bot_flk + &
319  opticpar_water%frac_optic(i)*exp(-opticpar_water%extincoef_optic(i)*depth_w)
320  END DO
322 
323  IF(h_ml_p_flk.GE.h_ml_min_flk) THEN ! Integral-mean radiation flux over the mixed layer
324  i_intm_0_h_flk = 0.
325  DO i=1, opticpar_water%nband_optic
327  opticpar_water%frac_optic(i)/opticpar_water%extincoef_optic(i)* &
328  (1. - exp(-opticpar_water%extincoef_optic(i)*h_ml_p_flk))
329  END DO
331  ELSE
333  END IF
334 
335  IF(h_ml_p_flk.LE.depth_w-h_ml_min_flk) THEN ! Integral-mean radiation flux over the thermocline
336  i_intm_h_d_flk = 0.
337  DO i=1, opticpar_water%nband_optic
339  opticpar_water%frac_optic(i)/opticpar_water%extincoef_optic(i)* &
340  ( exp(-opticpar_water%extincoef_optic(i)*h_ml_p_flk) &
341  - exp(-opticpar_water%extincoef_optic(i)*depth_w) )
342  END DO
344  ELSE
346  END IF
347 IF (lhook) CALL dr_hook('FLAKE:FLAKE_RADFLUX',1,zhook_handle)
348 
349 !------------------------------------------------------------------------------
350 ! End calculations
351 !==============================================================================
352 
353 END SUBROUTINE flake_radflux
354 
355 
356 !==============================================================================
357 
358 !==============================================================================
359 !SURFEX include 'flake_driver.incf'
360 ! File %M% from Library %Q%
361 ! Version %I% from %G% extracted: %H%
362 !------------------------------------------------------------------------------
363 
364 SUBROUTINE flake_driver ( depth_w, depth_bs, T_bs, par_Coriolis, &
365  extincoef_water_typ, &
366  del_time, T_sfc_p, T_sfc_n )
368 !------------------------------------------------------------------------------
369 !
370 ! Description:
371 !
372 ! The main driving routine of the lake model FLake
373 ! where computations are performed.
374 ! Advances the surface temperature
375 ! and other FLake variables one time step.
376 ! At the moment, the Euler explicit scheme is used.
377 !
378 ! Lines embraced with "!_tmp" contain temporary parts of the code.
379 ! Lines embraced/marked with "!_dev" may be replaced
380 ! as improved parameterizations are developed and tested.
381 ! Lines embraced/marked with "!_dm" are DM's comments
382 ! that may be helpful to a user.
383 ! Lines embraced/marked with "!_dbg" are used
384 ! for debugging purposes only.
385 !
386 !
387 ! Current Code Owner: DWD, Dmitrii Mironov
388 ! Phone: +49-69-8062 2705
389 ! Fax: +49-69-8062 3721
390 ! E-mail: dmitrii.mironov@dwd.de
391 !
392 ! History:
393 ! Version Date Name
394 ! ---------- ---------- ----
395 ! 1.00 2005/11/17 Dmitrii Mironov
396 ! Initial release
397 ! !VERSION! !DATE! <Your name>
398 ! <Modification comments>
399 !
400 ! Code Description:
401 ! Language: Fortran 90.
402 ! Software Standards: "European Standards for Writing and
403 ! Documenting Exchangeable Fortran 90 Code".
404 !==============================================================================
405 !
406 ! Declarations:
407 !
408 ! Modules used:
409 
410 !_dm Parameters are USEd in module "flake".
411 !_nu USE modd_data_parameters , ONLY : &
412 !_nu ireals, & ! KIND-type parameter for real variables
413 !_nu iintegers ! KIND-type parameter for "normal" integer variables
414 
415 USE modd_flake_parameters ! Thermodynamic parameters and dimensionless constants of FLake
416 
417 USE modd_flake_configure ! Switches and parameters that configure FLake
418 
419 !==============================================================================
420 
421 IMPLICIT NONE
422 
423 !==============================================================================
424 !
425 ! Declarations
426 
427 ! Input (procedure arguments)
428 
429 REAL, INTENT(IN) :: &
430  depth_w , &! The lake depth [m]
431  depth_bs , &! Depth of the thermally active layer of bottom sediments [m]
432  T_bs , &! Temperature at the outer edge of
433  ! the thermally active layer of bottom sediments [K]
434  par_coriolis , &! The Coriolis parameter [s^{-1}]
435  extincoef_water_typ , &! "Typical" extinction coefficient of the lake water [m^{-1}],
436  ! used to compute the equilibrium CBL depth
437  del_time , &! The model time step [s]
438  t_sfc_p ! Surface temperature at the previous time step [K]
439  ! (equal to either T_ice, T_snow or to T_wML)
440 
441 ! Output (procedure arguments)
442 
443 REAL, INTENT(OUT) :: &
444  T_sfc_n ! Updated surface temperature [K]
445  ! (equal to the updated value of either T_ice, T_snow or T_wML)
446 
447 
448 ! Local variables of type LOGICAL
449 LOGICAL :: &
450  l_ice_create , &! Switch, .TRUE. = ice does not exist but should be created
451  l_snow_exists , &! Switch, .TRUE. = there is snow above the ice
452  l_ice_meltabove ! Switch, .TRUE. = snow/ice melting from above takes place
453 
454 ! Local variables of type INTEGER
455 INTEGER :: &
456  i ! Loop index
457 
458 ! Local variables of type REAL
459 REAL :: &
460  d_T_mnw_dt , &! Time derivative of T_mnw [K s^{-1}]
461  d_T_ice_dt , &! Time derivative of T_ice [K s^{-1}]
462  d_T_bot_dt , &! Time derivative of T_bot [K s^{-1}]
463  d_T_B1_dt , &! Time derivative of T_B1 [K s^{-1}]
464  d_h_snow_dt , &! Time derivative of h_snow [m s^{-1}]
465  d_h_ice_dt , &! Time derivative of h_ice [m s^{-1}]
466  d_h_ML_dt , &! Time derivative of h_ML [m s^{-1}]
467  d_H_B1_dt , &! Time derivative of H_B1 [m s^{-1}]
468  d_C_T_dt ! Time derivative of C_T [s^{-1}]
469 
470 ! Local variables of type REAL
471 REAL :: &
472  N_T_mean , &! The mean buoyancy frequency in the thermocline [s^{-1}]
473  ZM_h_scale , &! The ZM96 equilibrium SBL depth scale [m]
474  conv_equil_h_scale ! The equilibrium CBL depth scale [m]
475 
476 ! Local variables of type REAL
477 REAL :: &
478  h_ice_threshold , &! If h_ice<h_ice_threshold, use quasi-equilibrium ice model
479  flk_str_1 , &! Help storage variable
480  flk_str_2 , &! Help storage variable
481  R_H_icesnow , &! Dimensionless ratio, used to store intermediate results
482  R_rho_c_icesnow , &! Dimensionless ratio, used to store intermediate results
483  R_TI_icesnow , &! Dimensionless ratio, used to store intermediate results
484  R_Tstar_icesnow ! Dimensionless ratio, used to store intermediate results
485 REAL(KIND=JPRB) :: ZHOOK_HANDLE
486 
487 !rsal
488 !REAL :: aux1,aux2,aux3,aux4,aux5
489 
490 !==============================================================================
491 ! Start calculations
492 !------------------------------------------------------------------------------
493 
494 !_dm
495 ! Security. Set time-rate-of-change of prognostic variables to zero.
496 ! Set prognostic variables to their values at the previous time step.
497 ! (This is to avoid spurious changes of prognostic variables
498 ! when FLake is used within a 3D model, e.g. to avoid spurious generation of ice
499 ! at the neighbouring lake points as noticed by Burkhardt Rockel.)
500 !_dm
501 
502 
503 IF (lhook) CALL dr_hook('FLAKE:FLAKE_DRIVER',0,zhook_handle)
504 d_t_mnw_dt = 0.
505 d_t_ice_dt = 0.
506 d_t_bot_dt = 0.
507 d_t_b1_dt = 0.
508 d_h_snow_dt = 0.
509 d_h_ice_dt = 0.
510 d_h_ml_dt = 0.
511 d_h_b1_dt = 0.
512 d_c_t_dt = 0.
524 
525 !------------------------------------------------------------------------------
526 ! Compute fluxes, using variables from the previous time step.
527 !------------------------------------------------------------------------------
528 
529 !_dm
530 ! At this point, the heat and radiation fluxes, namely,
531 ! Q_snow_flk, Q_ice_flk, Q_w_flk,
532 ! I_atm_flk, I_snow_flk, I_ice_flk, I_w_flk, I_h_flk, I_bot_flk,
533 ! the mean radiation flux over the mixed layer, I_intm_0_h_flk,
534 ! and the mean radiation flux over the thermocline, I_intm_h_D_flk,
535 ! should be known.
536 ! They are computed within "flake_interface" (or within the driving model)
537 ! and are available to "flake_driver"
538 ! through the above variables declared in the MODULE "flake".
539 ! In case a lake is ice-covered, Q_w_flk is re-computed below.
540 !_dm
541 
542 ! Heat flux through the ice-water interface
543 IF(h_ice_p_flk.GE.h_ice_min_flk) THEN ! Ice exists
544  IF(h_ml_p_flk.LE.h_ml_min_flk) THEN ! Mixed-layer depth is zero, compute flux
545  q_w_flk = -tpl_kappa_w*(t_bot_p_flk-t_wml_p_flk)/depth_w ! Flux with linear T(z)
546  phi_t_pr0_flk = phi_t_pr0_1*c_t_p_flk-phi_t_pr0_2 ! d\Phi(0)/d\zeta (thermocline)
547  q_w_flk = q_w_flk*max(phi_t_pr0_flk, 1.) ! Account for an increased d\Phi(0)/d\zeta
548  ELSE
549  q_w_flk = 0. ! Mixed-layer depth is greater than zero, set flux to zero
550  END IF
551 END IF
552 
553 ! A generalized heat flux scale
555 
556 ! Heat flux through the water-bottom sediment interface
557 IF(lflk_botsed_use) THEN
559 ELSE
560  q_bot_flk = 0. ! The bottom-sediment scheme is not used
561 END IF
562 
563 
564 !------------------------------------------------------------------------------
565 ! Check if ice exists or should be created.
566 ! If so, compute the thickness and the temperature of ice and snow.
567 !------------------------------------------------------------------------------
568 
569 !_dm
570 ! Notice that a quasi-equilibrium ice-snow model is used
571 ! to avoid numerical instability when the ice is thin.
572 ! This is always the case when new ice is created.
573 !_dm
574 
575 !_dev
576 ! The dependence of snow density and of snow heat conductivity
577 ! on the snow thickness is accounted for parametrically.
578 ! That is, the time derivatives of \rho_S and \kappa_S are neglected.
579 ! The exception is the equation for the snow thickness
580 ! in case of snow accumulation and no melting,
581 ! where d\rho_S/dt is incorporated.
582 ! Furthermore, some (presumably small) correction terms incorporating
583 ! the snow density and the snow heat conductivity are dropped out.
584 ! Those terms may be included as better formulations
585 ! for \rho_S and \kappa_S are available.
586 !_dev
587 
588 ! Default values
589 l_ice_create = .false.
590 l_ice_meltabove = .false.
591 
592 ice_exist: IF(h_ice_p_flk.LT.h_ice_min_flk) THEN ! Ice does not exist
593 
594  l_ice_create = t_wml_p_flk.LE.(tpl_t_f+c_small_flk).AND.q_w_flk.LT.0.
595  IF(l_ice_create) THEN ! Ice does not exist but should be created
596  d_h_ice_dt = -q_w_flk/tpl_rho_i/tpl_l_f
597  h_ice_n_flk = h_ice_p_flk + d_h_ice_dt*del_time ! Advance h_ice
599  d_h_snow_dt = dmsnowdt_flk/tpl_rho_s_min
600  h_snow_n_flk = h_snow_p_flk + d_h_snow_dt*del_time ! Advance h_snow
602  + phi_i_ast_mr*min(1., h_ice_n_flk/h_ice_max) ! d\Phi_I(1)/d\zeta_I (ice)
605  t_snow_n_flk = t_ice_n_flk + r_h_icesnow*(t_ice_n_flk-tpl_t_f) ! Snow temperature
606  ELSE !kk, 30092004 - to avoid unsertainty here
611  END IF
612 
613 ELSE ice_exist ! Ice exists
614 
615  l_snow_exists = h_snow_p_flk.GE.h_snow_min_flk ! Check if there is snow above the ice
616 
617  melting: IF(t_snow_p_flk.GE.(tpl_t_f-c_small_flk)) THEN ! T_sfc = T_f, check for melting from above
618  ! T_snow = T_ice if snow is absent
619  IF(l_snow_exists) THEN ! There is snow above the ice
620  flk_str_1 = q_snow_flk + i_snow_flk - i_ice_flk ! Atmospheric forcing
621  IF(flk_str_1.GE.0.) THEN ! Melting of snow and ice from above
622  l_ice_meltabove = .true.
623  d_h_snow_dt = (-flk_str_1/tpl_l_f+dmsnowdt_flk)/flake_snowdensity(h_snow_p_flk)
624  d_h_ice_dt = -(i_ice_flk - i_w_flk - q_w_flk)/tpl_l_f/tpl_rho_i
625  END IF
626  ELSE ! No snow above the ice
627  flk_str_1 = q_ice_flk + i_ice_flk - i_w_flk - q_w_flk ! Atmospheric forcing + heating from the water
628  IF(flk_str_1.GE.0.) THEN ! Melting of ice from above, snow accumulation may occur
629  l_ice_meltabove = .true.
630  d_h_ice_dt = -flk_str_1/tpl_l_f/tpl_rho_i
631  d_h_snow_dt = dmsnowdt_flk/tpl_rho_s_min
632  END IF
633  END IF
634  IF(l_ice_meltabove) THEN ! Melting from above takes place
635  h_ice_n_flk = h_ice_p_flk + d_h_ice_dt *del_time ! Advance h_ice
636  h_snow_n_flk = h_snow_p_flk + d_h_snow_dt*del_time ! Advance h_snow
637  t_ice_n_flk = tpl_t_f ! Set T_ice to the freezing point
638  t_snow_n_flk = tpl_t_f ! Set T_snow to the freezing point
639  END IF
640 
641  END IF melting
642 
643  no_melting: IF(.NOT.l_ice_meltabove) THEN ! No melting from above
644 
645  d_h_snow_dt = flake_snowdensity(h_snow_p_flk)
646  IF(d_h_snow_dt.LT.tpl_rho_s_max) THEN ! Account for d\rho_S/dt
648  flk_str_1 = flk_str_1/(1.-flk_str_1)
649  ELSE ! Snow density is equal to its maximum value, d\rho_S/dt=0
650  flk_str_1 = 0.
651  END IF
652  d_h_snow_dt = dmsnowdt_flk/d_h_snow_dt/(1.+flk_str_1) ! Snow accumulation
653  h_snow_n_flk = h_snow_p_flk + d_h_snow_dt*del_time ! Advance h_snow
654 
655  phi_i_pr0_flk = h_ice_p_flk/h_ice_max ! h_ice relative to its maximum value
656  c_i_flk = c_i_lin - c_i_mr*(1.+phi_i_ast_mr)*phi_i_pr0_flk ! Shape factor (ice)
657  phi_i_pr1_flk = phi_i_pr1_lin + phi_i_ast_mr*phi_i_pr0_flk ! d\Phi_I(1)/d\zeta_I (ice)
658  phi_i_pr0_flk = phi_i_pr0_lin - phi_i_pr0_flk ! d\Phi_I(0)/d\zeta_I (ice)
659 
660  h_ice_threshold = max(1., 2.*c_i_flk*tpl_c_i*(tpl_t_f-t_ice_p_flk)/tpl_l_f)
661  h_ice_threshold = phi_i_pr0_flk/c_i_flk*tpl_kappa_i/tpl_rho_i/tpl_c_i*h_ice_threshold
662  h_ice_threshold = sqrt(h_ice_threshold*del_time) ! Threshold value of h_ice
663  h_ice_threshold = min(0.9*h_ice_max, max(h_ice_threshold, h_ice_min_flk))
664  ! h_ice(threshold) < 0.9*H_Ice_max
665 
666  IF(h_ice_p_flk.LT.h_ice_threshold) THEN ! Use a quasi-equilibrium ice model
667 
668  IF(l_snow_exists) THEN ! Use fluxes at the air-snow interface
669  flk_str_1 = q_snow_flk + i_snow_flk - i_w_flk
670  ELSE ! Use fluxes at the air-ice interface
671  flk_str_1 = q_ice_flk + i_ice_flk - i_w_flk
672  END IF
673  d_h_ice_dt = -(flk_str_1-q_w_flk)/tpl_l_f/tpl_rho_i
674  h_ice_n_flk = h_ice_p_flk + d_h_ice_dt *del_time ! Advance h_ice
675  t_ice_n_flk = tpl_t_f + h_ice_n_flk*flk_str_1/tpl_kappa_i/phi_i_pr0_flk ! Ice temperature
676 
677  ELSE ! Use a complete ice model
678 
680  d_h_ice_dt = (q_w_flk+d_h_ice_dt)/tpl_l_f/tpl_rho_i
681  h_ice_n_flk = h_ice_p_flk + d_h_ice_dt*del_time ! Advance h_ice
682 
683  r_ti_icesnow = tpl_c_i*(tpl_t_f-t_ice_p_flk)/tpl_l_f ! Dimensionless parameter
684  r_tstar_icesnow = 1. - c_i_flk ! Dimensionless parameter
685  IF(l_snow_exists) THEN ! There is snow above the ice
689 !_dev
690 !_dm
691 ! These terms should be included as an improved understanding of the snow scheme is gained,
692 ! of the effect of snow density in particular.
693 !_dm
694 !_nu R_Tstar_icesnow = R_Tstar_icesnow &
695 !_nu + (1.+C_S_lin*h_snow_p_flk/h_ice_p_flk)*R_H_icesnow*R_rho_c_icesnow
696 !_dev
697 
698  r_tstar_icesnow = r_tstar_icesnow*r_ti_icesnow ! Dimensionless parameter
699 
700 !_dev
701 !_nu R_Tstar_icesnow = R_Tstar_icesnow &
702 !_nu + (1.-R_rho_c_icesnow)*tpl_c_I*T_ice_p_flk/tpl_L_f
703 !_dev
704  flk_str_2 = q_snow_flk+i_snow_flk-i_w_flk ! Atmospheric fluxes
705  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
706  d_t_ice_dt = -(1.-2.*c_s_lin)*r_h_icesnow*(tpl_t_f-t_ice_p_flk) &
707  * tpl_c_s*dmsnowdt_flk ! Effect of snow accumulation
708  ELSE ! No snow above the ice
709  r_tstar_icesnow = r_tstar_icesnow*r_ti_icesnow ! Dimensionless parameter
710  flk_str_2 = q_ice_flk+i_ice_flk-i_w_flk ! Atmospheric fluxes
711  flk_str_1 = c_i_flk*h_ice_p_flk
712  d_t_ice_dt = 0.
713  END IF
714  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 &
715  * (1.-r_tstar_icesnow) ! Add flux due to heat conduction
716  d_t_ice_dt = d_t_ice_dt - r_tstar_icesnow*q_w_flk ! Add flux from water to ice
717  d_t_ice_dt = d_t_ice_dt + flk_str_2 ! Add atmospheric fluxes
718  d_t_ice_dt = d_t_ice_dt/tpl_rho_i/tpl_c_i ! Total forcing
719  d_t_ice_dt = d_t_ice_dt/flk_str_1 ! dT_ice/dt
720  t_ice_n_flk = t_ice_p_flk + d_t_ice_dt*del_time ! Advance T_ice
721  END IF
722 
723  phi_i_pr1_flk = min(1., h_ice_n_flk/h_ice_max) ! h_ice relative to its maximum value
724  phi_i_pr1_flk = phi_i_pr1_lin + phi_i_ast_mr*phi_i_pr1_flk ! d\Phi_I(1)/d\zeta_I (ice)
727  t_snow_n_flk = t_ice_n_flk + r_h_icesnow*(t_ice_n_flk-tpl_t_f) ! Snow temperature
728 
729  END IF no_melting
730 
731 END IF ice_exist
732 
733 ! Security, limit h_ice by its maximum value
735 
736 ! Security, limit the ice and snow temperatures by the freezing point
739 
740 !_tmp
741 ! Security, avoid too low values (these constraints are used for debugging purposes)
742 ! not good must be deleteted !!!!!!! But the snow scheme is not robust !!!!!!!
743 ! not good must be deleteted !!!!!!! But the snow scheme is not robust !!!!!!!
744 ! not good must be deleteted !!!!!!! But the snow scheme is not robust !!!!!!!
745  t_snow_n_flk = max(t_snow_n_flk, 200.15)
746  t_ice_n_flk = max(t_ice_n_flk, 200.15)
747 !_tmp
748 
749 ! Remove too thin ice and/or snow
750 IF(h_ice_n_flk.LT.h_ice_min_flk) THEN ! Check ice
751  h_ice_n_flk = 0. ! Ice is too thin, remove it, and
752  t_ice_n_flk = tpl_t_f ! set T_ice to the freezing point.
753  h_snow_n_flk = 0. ! Remove snow when there is no ice, and
754  t_snow_n_flk = tpl_t_f ! set T_snow to the freezing point.
755  l_ice_create = .false. ! "Exotic" case, ice has been created but proved to be too thin
756 ELSE IF(h_snow_n_flk.LT.h_snow_min_flk) THEN ! Ice exists, check snow
757  h_snow_n_flk = 0. ! Snow is too thin, remove it,
758  t_snow_n_flk = t_ice_n_flk ! and set the snow temperature equal to the ice temperature.
759 END IF
760 
761 
762 !------------------------------------------------------------------------------
763 ! Compute the mean temperature of the water column.
764 !------------------------------------------------------------------------------
765 
766 IF(l_ice_create) q_w_flk = 0. ! Ice has just been created, set Q_w to zero
767 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
768 t_mnw_n_flk = t_mnw_p_flk + d_t_mnw_dt*del_time ! Advance T_mnw
769 t_mnw_n_flk = max(t_mnw_n_flk, tpl_t_f) ! Limit T_mnw by the freezing point
770 
771 
772 !------------------------------------------------------------------------------
773 ! Compute the mixed-layer depth, the mixed-layer temperature,
774 ! the bottom temperature and the shape factor
775 ! with respect to the temperature profile in the thermocline.
776 ! Different formulations are used, depending on the regime of mixing.
777 !------------------------------------------------------------------------------
778 
779 htc_water: IF(h_ice_n_flk.GE.h_ice_min_flk) THEN ! Ice exists
780 
781  t_mnw_n_flk = min(t_mnw_n_flk, tpl_t_r) ! Limit the mean temperature under the ice by T_r
782  t_wml_n_flk = tpl_t_f ! The mixed-layer temperature is equal to the freezing point
783 
784  IF(l_ice_create) THEN ! Ice has just been created
785  IF(h_ml_p_flk.GE.depth_w-h_ml_min_flk) THEN ! h_ML=D when ice is created
786  h_ml_n_flk = 0. ! Set h_ML to zero
787  c_t_n_flk = c_t_min ! Set C_T to its minimum value
788  ELSE ! h_ML<D when ice is created
789  h_ml_n_flk = h_ml_p_flk ! h_ML remains unchanged
790  c_t_n_flk = c_t_p_flk ! C_T (thermocline) remains unchanged
791  END IF
793  ! Update the bottom temperature
794 
795  ELSE IF(t_bot_p_flk.LT.tpl_t_r) THEN ! Ice exists and T_bot < T_r, molecular heat transfer
796  h_ml_n_flk = h_ml_p_flk ! h_ML remains unchanged
797  c_t_n_flk = c_t_p_flk ! C_T (thermocline) remains unchanged
799  ! Update the bottom temperature
800 
801  ELSE ! Ice exists and T_bot = T_r, convection due to bottom heating
802  t_bot_n_flk = tpl_t_r ! T_bot is equal to the temperature of maximum density
803  IF(h_ml_p_flk.GE.c_small_flk) THEN ! h_ML > 0
804  c_t_n_flk = c_t_p_flk ! C_T (thermocline) remains unchanged
806  h_ml_n_flk = max(h_ml_n_flk, 0.) ! Update the mixed-layer depth
807  ELSE ! h_ML = 0
808  h_ml_n_flk = h_ml_p_flk ! h_ML remains unchanged
810  c_t_n_flk = min(c_t_max, max(c_t_n_flk, c_t_min)) ! Update the shape factor (thermocline)
811  END IF
812  END IF
813 
814  t_bot_n_flk = min(t_bot_n_flk, tpl_t_r) ! Security, limit the bottom temperature by T_r
815 
816 ELSE htc_water ! Open water
817 
818 ! Generalised buoyancy flux scale and convective velocity scale
820  IF(flk_str_1.LT.0.) THEN
821  w_star_sfc_flk = (-flk_str_1*h_ml_p_flk)**(1./3.) ! Convection
822  ELSE
823  w_star_sfc_flk = 0. ! Neutral or stable stratification
824  END IF
825 
826 !_dm
827 ! The equilibrium depth of the CBL due to surface cooling with the volumetric heating
828 ! is not computed as a solution to the transcendental equation.
829 ! Instead, an algebraic formula is used
830 ! that interpolates between the two asymptotic limits.
831 !_dm
832  conv_equil_h_scale = -q_w_flk/max(i_w_flk, c_small_flk)
833  IF(conv_equil_h_scale.GT.0. .AND. conv_equil_h_scale.LT.1. &
834  .AND. t_wml_p_flk.GT.tpl_t_r) THEN ! The equilibrium CBL depth scale is only used above T_r
835  conv_equil_h_scale = sqrt(6.*conv_equil_h_scale) &
836  + 2.*conv_equil_h_scale/(1.-conv_equil_h_scale)
837  conv_equil_h_scale = min(depth_w, conv_equil_h_scale/extincoef_water_typ)
838  ELSE
839  conv_equil_h_scale = 0. ! Set the equilibrium CBL depth to zero
840  END IF
841 
842 ! Mean buoyancy frequency in the thermocline
843  n_t_mean = flake_buoypar(0.5*(t_wml_p_flk+t_bot_p_flk))*max(0.,(t_wml_p_flk-t_bot_p_flk))
844  IF(h_ml_p_flk.LE.depth_w-h_ml_min_flk) THEN
845  n_t_mean = sqrt(n_t_mean/(depth_w-h_ml_p_flk)) ! Compute N
846  ELSE
847  n_t_mean = 0. ! h_ML=D, set N to zero
848  END IF
849 
850 ! The rate of change of C_T
851  d_c_t_dt = max(w_star_sfc_flk, u_star_w_flk, u_star_min_flk)**2
852  d_c_t_dt = n_t_mean*(depth_w-h_ml_p_flk)**2 &
853  / c_relax_c/d_c_t_dt ! Relaxation time scale for C_T
854  d_c_t_dt = (c_t_max-c_t_min)/max(d_c_t_dt, c_small_flk) ! Rate-of-change of C_T
855  !rsal:
856  d_c_t_dt = min(d_c_t_dt,0.01/del_time)
857 
858 ! Compute the shape factor and the mixed-layer depth,
859 ! using different formulations for convection and wind mixing
860 
861  c_tt_flk = c_tt_1*c_t_p_flk-c_tt_2 ! C_TT, using C_T at the previous time step
862  c_q_flk = 2.*c_tt_flk/c_t_p_flk ! C_Q using C_T at the previous time step
863 
864  mixing_regime: IF(flk_str_1.LT.0.) THEN ! Convective mixing
865 
866  c_t_n_flk = c_t_p_flk + d_c_t_dt*del_time ! Update C_T, assuming dh_ML/dt>0
867  c_t_n_flk = min(c_t_max, max(c_t_n_flk, c_t_min)) ! Limit C_T
868  d_c_t_dt = (c_t_n_flk-c_t_p_flk)/del_time ! Re-compute dC_T/dt
869 
870  IF(h_ml_p_flk.LE.depth_w-h_ml_min_flk) THEN ! Compute dh_ML/dt
871  IF(h_ml_p_flk.LE.h_ml_min_flk) THEN ! Use a reduced entrainment equation (spin-up)
872  d_h_ml_dt = c_cbl_1/c_cbl_2*max(w_star_sfc_flk, c_small_flk)
873 
874 !_dbg
875 ! WRITE*, ' FLake: reduced entrainment eq. D_time*d_h_ML_dt = ', d_h_ML_dt*del_time
876 ! WRITE*, ' w_* = ', w_star_sfc_flk
877 ! WRITE*, ' \beta*Q_* = ', flk_str_1
878 !_dbg
879 
880  ELSE ! Use a complete entrainment equation
881  r_h_icesnow = depth_w/h_ml_p_flk
882  r_rho_c_icesnow = r_h_icesnow-1.
883  r_ti_icesnow = c_t_p_flk/c_tt_flk
884  r_tstar_icesnow = (r_ti_icesnow/2.-1.)*r_rho_c_icesnow + 1.
885  d_h_ml_dt = -q_star_flk*(r_tstar_icesnow*(1.+c_cbl_1)-1.) - q_bot_flk
886  d_h_ml_dt = d_h_ml_dt/tpl_rho_w_r/tpl_c_w ! Q_* and Q_b flux terms
887  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
888  d_h_ml_dt = d_h_ml_dt + flk_str_2 ! Add dC_T/dt term
889  flk_str_2 = i_bot_flk + (r_ti_icesnow-1.)*i_h_flk - r_ti_icesnow*i_intm_h_d_flk
890  flk_str_2 = flk_str_2 + (r_ti_icesnow-2.)*r_rho_c_icesnow*(i_h_flk-i_intm_0_h_flk)
891  flk_str_2 = flk_str_2/tpl_rho_w_r/tpl_c_w
892  d_h_ml_dt = d_h_ml_dt + flk_str_2 ! Add radiation terms
893  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)
894  flk_str_2 = flk_str_2 + c_t_p_flk*(t_wml_p_flk-t_bot_p_flk)
895  d_h_ml_dt = d_h_ml_dt/flk_str_2 ! dh_ML/dt = r.h.s.
896  END IF
897 !_dm
898 ! Notice that dh_ML/dt may appear to be negative
899 ! (e.g. due to buoyancy loss to bottom sediments and/or
900 ! the effect of volumetric radiation heating),
901 ! although a negative generalized buoyancy flux scale indicates
902 ! that the equilibrium CBL depth has not yet been reached
903 ! and convective deepening of the mixed layer should take place.
904 ! Physically, this situation reflects an approximate character of the lake model.
905 ! Using the self-similar temperature profile in the thermocline,
906 ! there is always communication between the mixed layer, the thermocline
907 ! and the lake bottom. As a result, the rate of change of the CBL depth
908 ! is always dependent on the bottom heat flux and the radiation heating of the thermocline.
909 ! In reality, convective mixed-layer deepening may be completely decoupled
910 ! from the processes underneath. In order to account for this fact,
911 ! the rate of CBL deepening is set to a small value
912 ! if dh_ML/dt proves to be negative.
913 ! This is "double insurance" however,
914 ! as a negative dh_ML/dt is encountered very rarely.
915 !_dm
916 
917  d_h_ml_dt = max(d_h_ml_dt, c_small_flk)
918  h_ml_n_flk = h_ml_p_flk + d_h_ml_dt*del_time ! Update h_ML
919  h_ml_n_flk = max(h_ml_min_flk, min(h_ml_n_flk, depth_w)) ! Security, limit h_ML
920  ELSE ! Mixing down to the lake bottom
921  h_ml_n_flk = depth_w
922  END IF
923 
924  ELSE mixing_regime ! Wind mixing
925 
926  d_h_ml_dt = max(u_star_w_flk, u_star_min_flk) ! The surface friction velocity
927  zm_h_scale = (abs(par_coriolis)/c_sbl_zm_n + n_t_mean/c_sbl_zm_i)*d_h_ml_dt**2
928  zm_h_scale = zm_h_scale + flk_str_1/c_sbl_zm_s
929  zm_h_scale = max(zm_h_scale, c_small_flk)
930  zm_h_scale = d_h_ml_dt**3/zm_h_scale
931  zm_h_scale = max(h_ml_min_flk, min(zm_h_scale, h_ml_max_flk)) ! The ZM96 SBL depth scale
932  zm_h_scale = max(zm_h_scale, conv_equil_h_scale) ! Equilibrium mixed-layer depth
933 
934 !_dm
935 ! In order to avoid numerical discretization problems,
936 ! an analytical solution to the evolution equation
937 ! for the wind-mixed layer depth is used.
938 ! That is, an exponential relaxation formula is applied
939 ! over the time interval equal to the model time step.
940 !_dm
941 
942  d_h_ml_dt = c_relax_h*d_h_ml_dt/zm_h_scale*del_time
943  h_ml_n_flk = zm_h_scale - (zm_h_scale-h_ml_p_flk)*exp(-d_h_ml_dt) ! Update h_ML
944  h_ml_n_flk = max(h_ml_min_flk, min(h_ml_n_flk, depth_w)) ! Limit h_ML
945  d_h_ml_dt = (h_ml_n_flk-h_ml_p_flk)/del_time ! Re-compute dh_ML/dt
946 
947  IF(h_ml_n_flk.LE.h_ml_p_flk) &
948  d_c_t_dt = -d_c_t_dt ! Mixed-layer retreat or stationary state, dC_T/dt<0
949  c_t_n_flk = c_t_p_flk + d_c_t_dt*del_time ! Update C_T
950  c_t_n_flk = min(c_t_max, max(c_t_n_flk, c_t_min)) ! Limit C_T
951  d_c_t_dt = (c_t_n_flk-c_t_p_flk)/del_time ! Re-compute dC_T/dt
952 
953 
954  END IF mixing_regime
955 
956 ! Compute the time-rate-of-change of the the bottom temperature,
957 ! depending on the sign of dh_ML/dt
958 ! Update the bottom temperature and the mixed-layer temperature
959 
960  IF(h_ml_n_flk.LE.depth_w-h_ml_min_flk) THEN ! Mixing did not reach the bottom
961 
962  IF(h_ml_n_flk.GT.h_ml_p_flk) THEN ! Mixed-layer deepening
963  r_h_icesnow = h_ml_p_flk/depth_w
964  r_rho_c_icesnow = 1.-r_h_icesnow
965  r_ti_icesnow = 0.5*c_t_p_flk*r_rho_c_icesnow+c_tt_flk*(2.*r_h_icesnow-1.)
966  r_tstar_icesnow = (0.5+c_tt_flk-c_q_flk)/r_ti_icesnow
967  r_ti_icesnow = (1.-c_t_p_flk*r_rho_c_icesnow)/r_ti_icesnow
968 
970  d_t_bot_dt = d_t_bot_dt - c_t_p_flk*(t_wml_p_flk-t_bot_p_flk)*d_h_ml_dt
971  d_t_bot_dt = d_t_bot_dt*r_tstar_icesnow/depth_w ! Q+I fluxes and dh_ML/dt term
972 
973  flk_str_2 = i_intm_h_d_flk - (1.-c_q_flk)*i_h_flk - c_q_flk*i_bot_flk
974  flk_str_2 = flk_str_2*r_ti_icesnow/(depth_w-h_ml_p_flk)/tpl_rho_w_r/tpl_c_w
975  d_t_bot_dt = d_t_bot_dt + flk_str_2 ! Add radiation-flux term
976 
977  flk_str_2 = (1.-c_tt_2*r_ti_icesnow)/c_t_p_flk
978  flk_str_2 = flk_str_2*(t_wml_p_flk-t_bot_p_flk)*d_c_t_dt
979  d_t_bot_dt = d_t_bot_dt + flk_str_2 ! Add dC_T/dt term
980 
981  ELSE ! Mixed-layer retreat or stationary state
982  d_t_bot_dt = 0. ! dT_bot/dt=0
983  END IF
984 
985  t_bot_n_flk = t_bot_p_flk + d_t_bot_dt*del_time ! Update T_bot
986  t_bot_n_flk = max(t_bot_n_flk, tpl_t_f) ! Security, limit T_bot by the freezing point
988  IF(flk_str_2.LT.0.) t_bot_n_flk = tpl_t_r ! Security, avoid T_r crossover
989  t_wml_n_flk = c_t_n_flk*(1.-h_ml_n_flk/depth_w)
991  t_wml_n_flk = max(t_wml_n_flk, tpl_t_f) ! Security, limit T_wML by the freezing point
992 
993  ELSE ! Mixing down to the lake bottom
994 
995  h_ml_n_flk = depth_w
999 !rsal:
1000  c_t_n_flk = 0.65
1001 
1002 
1003  END IF
1004 
1005 END IF htc_water
1006 
1007 !------------------------------------------------------------------------------
1008 ! Compute the depth of the upper layer of bottom sediments
1009 ! and the temperature at that depth.
1010 !------------------------------------------------------------------------------
1011 
1012 !SURFEX
1013 sediment: IF(lflk_botsed_use) THEN ! The bottom-sediment scheme is used
1014 
1015  IF(h_b1_p_flk.GE.depth_bs-h_b1_min_flk) THEN ! No T(z) maximum (no thermal wave)
1016  h_b1_p_flk = 0. ! Set H_B1_p to zero
1017  t_b1_p_flk = t_bot_p_flk ! Set T_B1_p to the bottom temperature
1018  END IF
1019 
1020  flk_str_1 = 2.*phi_b1_pr0/(1.-c_b1)*tpl_kappa_w/tpl_rho_w_r/tpl_c_w*del_time
1021  h_ice_threshold = sqrt(flk_str_1) ! Threshold value of H_B1
1022  h_ice_threshold = min(0.9*depth_bs, h_ice_threshold) ! Limit H_B1
1023  flk_str_2 = c_b2/(1.-c_b2)*(t_bs-t_b1_p_flk)/(depth_bs-h_b1_p_flk)
1024 
1025  IF(h_b1_p_flk.LT.h_ice_threshold) THEN ! Use a truncated equation for H_B1(t)
1026  h_b1_n_flk = sqrt(h_b1_p_flk**2+flk_str_1) ! Advance H_B1
1027  d_h_b1_dt = (h_b1_n_flk-h_b1_p_flk)/del_time ! Re-compute dH_B1/dt
1028  ELSE ! Use a full equation for H_B1(t)
1030  flk_str_1 = flk_str_1 - (1.-c_b1)*(t_bot_n_flk-t_bot_p_flk)/del_time
1031  d_h_b1_dt = (1.-c_b1)*(t_bot_p_flk-t_b1_p_flk)/h_b1_p_flk + c_b1*flk_str_2
1032  d_h_b1_dt = flk_str_1/d_h_b1_dt
1033  h_b1_n_flk = h_b1_p_flk + d_h_b1_dt*del_time ! Advance H_B1
1034  END IF
1035  d_t_b1_dt = flk_str_2*d_h_b1_dt
1036  t_b1_n_flk = t_b1_p_flk + d_t_b1_dt*del_time ! Advance T_B1
1037 
1038 ! Use a very simplistic procedure, where only the upper layer profile is used,
1039 ! H_B1 is always set to depth_bs, and T_B1 is always set to T_bs.
1040 ! Then, the time derivatives are zero, and the sign of the bottom heat flux depends on
1041 ! whether T_bot is smaller or greater than T_bs.
1042 ! This is, of course, an oversimplified scheme.
1043 
1044  l_snow_exists = h_b1_n_flk.GE.depth_bs-h_b1_min_flk &! H_B1 reached depth_bs, or
1045  .OR. h_b1_n_flk.LT.h_b1_min_flk &! H_B1 decreased to zero, or
1046  .OR.(t_bot_n_flk-t_b1_n_flk)*(t_bs-t_b1_n_flk).LE.0. ! there is no T(z) maximum
1047  IF(l_snow_exists) THEN
1048  h_b1_n_flk = depth_bs ! Set H_B1 to the depth of the thermally active layer
1049  t_b1_n_flk = t_bs ! Set T_B1 to the climatological temperature
1050  END IF
1051 
1052 ELSE sediment ! The bottom-sediment scheme is not used
1053 
1054  h_b1_n_flk = rflk_depth_bs_ref ! H_B1 is set to a reference value
1055  t_b1_n_flk = tpl_t_r ! T_B1 is set to the temperature of maximum density
1056 
1057 END IF sediment
1058 
1059 
1060 !------------------------------------------------------------------------------
1061 ! Impose additional constraints.
1062 !------------------------------------------------------------------------------
1063 
1064 ! In case of unstable stratification, force mixing down to the bottom
1066 IF(flk_str_2.LT.0.) THEN
1067 
1068  h_ml_n_flk = depth_w
1071  c_t_n_flk = c_t_min
1072 !rsal:
1073  c_t_n_flk = 0.65
1074 
1075 END IF
1076 
1077 
1078 !------------------------------------------------------------------------------
1079 ! Update the surface temperature.
1080 !------------------------------------------------------------------------------
1081 
1082 IF(h_snow_n_flk.GE.h_snow_min_flk) THEN
1083  t_sfc_n = t_snow_n_flk ! Snow exists, use the snow temperature
1084 ELSE IF(h_ice_n_flk.GE.h_ice_min_flk) THEN
1085  t_sfc_n = t_ice_n_flk ! Ice exists but there is no snow, use the ice temperature
1086 ELSE
1087  t_sfc_n = t_wml_n_flk ! No ice-snow cover, use the mixed-layer temperature
1088 END IF
1089 IF (lhook) CALL dr_hook('FLAKE:FLAKE_DRIVER',1,zhook_handle)
1090 
1091 !------------------------------------------------------------------------------
1092 ! End calculations
1093 !==============================================================================
1094 
1095 END SUBROUTINE flake_driver
1096 
1097 
1098 !==============================================================================
1099 
1100 !==============================================================================
1101 !SURFEX include 'flake_buoypar.incf'
1102 ! File %M% from Library %Q%
1103 ! Version %I% from %G% extracted: %H%
1104 !------------------------------------------------------------------------------
1105 
1106 !SURFEX REAL FUNCTION flake_buoypar (T_water)
1107 FUNCTION flake_buoypar (T_water)
1109 !------------------------------------------------------------------------------
1110 !
1111 ! Description:
1112 !
1113 ! Computes the buoyancy parameter,
1114 ! using a quadratic equation of state for the fresh-water.
1115 !
1116 !
1117 ! Current Code Owner: DWD, Dmitrii Mironov
1118 ! Phone: +49-69-8062 2705
1119 ! Fax: +49-69-8062 3721
1120 ! E-mail: dmitrii.mironov@dwd.de
1121 !
1122 ! History:
1123 ! Version Date Name
1124 ! ---------- ---------- ----
1125 ! 1.00 2005/11/17 Dmitrii Mironov
1126 ! Initial release
1127 ! !VERSION! !DATE! <Your name>
1128 ! <Modification comments>
1129 !
1130 ! Code Description:
1131 ! Language: Fortran 90.
1132 ! Software Standards: "European Standards for Writing and
1133 ! Documenting Exchangeable Fortran 90 Code".
1134 !==============================================================================
1135 !
1136 ! Declarations:
1137 !
1138 ! Modules used:
1139 
1140 !_dm Parameters are USEd in module "flake".
1141 !_nu USE modd_data_parameters , ONLY : &
1142 !_nu ireals, & ! KIND-type parameter for real variables
1143 !_nu iintegers ! KIND-type parameter for "normal" integer variables
1144 
1145 USE modd_flake_parameters , ONLY : &
1146  tpl_grav , &! Acceleration due to gravity [m s^{-2}]
1147  tpl_t_r , &! Temperature of maximum density of fresh water [K]
1148  tpl_a_t ! Constant in the fresh-water equation of state [K^{-2}]
1149 
1150 !==============================================================================
1151 
1152 IMPLICIT NONE
1153 
1154 !==============================================================================
1155 !
1156 ! Declarations
1157 
1158 ! Input (function argument)
1159 REAL , INTENT(IN) :: &
1160  T_water ! Water temperature [K]
1161 
1162 ! Output (function result)
1163 REAL :: &
1164  flake_buoypar ! Buoyancy parameter [m s^{-2} K^{-1}]
1165 REAL(KIND=JPRB) :: ZHOOK_HANDLE
1166 
1167 !==============================================================================
1168 ! Start calculations
1169 !------------------------------------------------------------------------------
1170 
1171 ! Buoyancy parameter [m s^{-2} K^{-1}]
1172 
1173  IF (lhook) CALL dr_hook('FLAKE:FLAKE_BUOYPAR',0,zhook_handle)
1174  flake_buoypar = tpl_grav*tpl_a_t*(t_water-tpl_t_r)
1175 IF (lhook) CALL dr_hook('FLAKE:FLAKE_BUOYPAR',1,zhook_handle)
1176 
1177 !------------------------------------------------------------------------------
1178 ! End calculations
1179 !==============================================================================
1180 
1181 END FUNCTION flake_buoypar
1182 
1183 
1184 !==============================================================================
1185 !SURFEX include 'flake_snowdensity.incf'
1186 ! File %M% from Library %Q%
1187 ! Version %I% from %G% extracted: %H%
1188 !------------------------------------------------------------------------------
1189 
1190 !SURFEX REAL FUNCTION flake_snowdensity (h_snow)
1191 FUNCTION flake_snowdensity (h_snow)
1193 !------------------------------------------------------------------------------
1194 !
1195 ! Description:
1196 !
1197 ! Computes the snow density,
1198 ! using an empirical approximation from Heise et al. (2003).
1199 !
1200 !
1201 ! Current Code Owner: DWD, Dmitrii Mironov
1202 ! Phone: +49-69-8062 2705
1203 ! Fax: +49-69-8062 3721
1204 ! E-mail: dmitrii.mironov@dwd.de
1205 !
1206 ! History:
1207 ! Version Date Name
1208 ! ---------- ---------- ----
1209 ! 1.00 2005/11/17 Dmitrii Mironov
1210 ! Initial release
1211 ! !VERSION! !DATE! <Your name>
1212 ! <Modification comments>
1213 !
1214 ! Code Description:
1215 ! Language: Fortran 90.
1216 ! Software Standards: "European Standards for Writing and
1217 ! Documenting Exchangeable Fortran 90 Code".
1218 !==============================================================================
1219 !
1220 ! Declarations:
1221 !
1222 ! Modules used:
1223 
1224 !_dm Parameters are USEd in module "flake".
1225 !_nu USE modd_data_parameters , ONLY : &
1226 !_nu ireals, & ! KIND-type parameter for real variables
1227 !_nu iintegers ! KIND-type parameter for "normal" integer variables
1228 
1229 USE modd_flake_parameters , ONLY : &
1230  tpl_rho_w_r , &! Maximum density of fresh water [kg m^{-3}]
1231  tpl_rho_s_min , &! Minimum snow density [kg m^{-3}]
1232  tpl_rho_s_max , &! Maximum snow density [kg m^{-3}]
1233  tpl_gamma_rho_s , &! Empirical parameter [kg m^{-4}] in the expression for the snow density
1234  c_small_flk ! A small number
1235 
1236 !==============================================================================
1237 
1238 IMPLICIT NONE
1239 
1240 !==============================================================================
1241 !
1242 ! Declarations
1243 
1244 ! Input (function argument)
1245 REAL , INTENT(IN) :: &
1246  h_snow ! Snow thickness [m]
1247 
1248 ! Output (function result)
1249 REAL :: &
1250  flake_snowdensity ! Snow density [kg m^{-3}]
1251 REAL(KIND=JPRB) :: ZHOOK_HANDLE
1252 
1253 !==============================================================================
1254 ! Start calculations
1255 !------------------------------------------------------------------------------
1256 
1257 ! Snow density [kg m^{-3}]
1258 
1259 ! Security. Ensure that the expression in () does not become negative at a very large h_snow.
1260  IF (lhook) CALL dr_hook('FLAKE:FLAKE_SNOWDENSITY',0,zhook_handle)
1261  flake_snowdensity = max( c_small_flk, (1. - h_snow*tpl_gamma_rho_s/tpl_rho_w_r) )
1262  flake_snowdensity = min( tpl_rho_s_max, tpl_rho_s_min/flake_snowdensity )
1263 IF (lhook) CALL dr_hook('FLAKE:FLAKE_SNOWDENSITY',1,zhook_handle)
1264 
1265 !------------------------------------------------------------------------------
1266 ! End calculations
1267 !==============================================================================
1268 
1269 END FUNCTION flake_snowdensity
1270 
1271 
1272 !==============================================================================
1273 !SURFEX include 'flake_snowheatconduct.incf'
1274 ! File %M% from Library %Q%
1275 ! Version %I% from %G% extracted: %H%
1276 !------------------------------------------------------------------------------
1277 
1278 !SURFEX REAL FUNCTION flake_snowheatconduct (h_snow)
1279 FUNCTION flake_snowheatconduct (h_snow)
1281 !------------------------------------------------------------------------------
1282 !
1283 ! Description:
1284 !
1285 ! Computes the snow heat conductivity,
1286 ! using an empirical approximation from Heise et al. (2003).
1287 !
1288 !
1289 ! Current Code Owner: DWD, Dmitrii Mironov
1290 ! Phone: +49-69-8062 2705
1291 ! Fax: +49-69-8062 3721
1292 ! E-mail: dmitrii.mironov@dwd.de
1293 !
1294 ! History:
1295 ! Version Date Name
1296 ! ---------- ---------- ----
1297 ! 1.00 2005/11/17 Dmitrii Mironov
1298 ! Initial release
1299 ! !VERSION! !DATE! <Your name>
1300 ! <Modification comments>
1301 !
1302 ! Code Description:
1303 ! Language: Fortran 90.
1304 ! Software Standards: "European Standards for Writing and
1305 ! Documenting Exchangeable Fortran 90 Code".
1306 !==============================================================================
1307 !
1308 ! Declarations:
1309 !
1310 ! Modules used:
1311 
1312 !_dm Parameters are USEd in module "flake".
1313 !_nu USE modd_data_parameters , ONLY : &
1314 !_nu ireals, & ! KIND-type parameter for real variables
1315 !_nu iintegers ! KIND-type parameter for "normal" integer variables
1316 
1317 USE modd_flake_parameters , ONLY : &
1318  tpl_rho_w_r , &! Maximum density of fresh water [kg m^{-3}]
1319  tpl_kappa_s_min , &! Minimum molecular heat conductivity of snow [J m^{-1} s^{-1} K^{-1}]
1320  tpl_kappa_s_max , &! Maximum molecular heat conductivity of snow [J m^{-1} s^{-1} K^{-1}]
1321  tpl_gamma_kappa_s ! Empirical parameter [J m^{-2} s^{-1} K^{-1}] in the expression for kappa_S
1322 
1323 !==============================================================================
1324 
1325 IMPLICIT NONE
1326 
1327 !==============================================================================
1328 !
1329 ! Declarations
1330 
1331 ! Input (function argument)
1332 REAL , INTENT(IN) :: &
1333  h_snow ! Snow thickness [m]
1334 
1335 ! Output (function result)
1336 REAL :: &
1337  flake_snowheatconduct ! Snow heat conductivity [J m^{-1} s^{-1} K^{-1} = kg m s^{-3} K^{-1}]
1338 REAL(KIND=JPRB) :: ZHOOK_HANDLE
1339 
1340 !==============================================================================
1341 ! Start calculations
1342 !------------------------------------------------------------------------------
1343 
1344 ! Snow heat conductivity [J m^{-1} s^{-1} K^{-1} = kg m s^{-3} K^{-1}]
1345 
1346  IF (lhook) CALL dr_hook('FLAKE:FLAKE_SNOWHEATCONDUCT',0,zhook_handle)
1347  flake_snowheatconduct = flake_snowdensity( h_snow ) ! Compute snow density
1348  flake_snowheatconduct = min( tpl_kappa_s_max, tpl_kappa_s_min &
1349  + h_snow*tpl_gamma_kappa_s*flake_snowheatconduct/tpl_rho_w_r )
1350 IF (lhook) CALL dr_hook('FLAKE:FLAKE_SNOWHEATCONDUCT',1,zhook_handle)
1351 
1352 !------------------------------------------------------------------------------
1353 ! End calculations
1354 !==============================================================================
1355 
1356 END FUNCTION flake_snowheatconduct
1357 
1358 END MODULE mode_flake
1359 
real t_mnw_p_flk
Definition: mode_flake.F90:133
real phi_i_pr1_flk
Definition: mode_flake.F90:156
real t_wml_n_flk
Definition: mode_flake.F90:136
real h_ml_p_flk
Definition: mode_flake.F90:143
subroutine flake_radflux(depth_w, albedo, opticpar_water, opticpar_ice, opticpar_snow)
Definition: mode_flake.F90:203
subroutine flake_driver(depth_w, depth_bs, T_bs, par_Coriolis, extincoef_water_typ, del_time, T_sfc_p, T_sfc_n)
Definition: mode_flake.F90:367
logical, dimension(3), parameter lflk_botsed_use
real t_ice_n_flk
Definition: mode_flake.F90:135
real h_ml_n_flk
Definition: mode_flake.F90:143
real i_ice_flk
Definition: mode_flake.F90:167
real h_snow_p_flk
Definition: mode_flake.F90:141
real t_snow_p_flk
Definition: mode_flake.F90:134
real phi_i_pr0_flk
Definition: mode_flake.F90:155
real, parameter, private z_
Definition: mode_flake.F90:130
real t_b1_n_flk
Definition: mode_flake.F90:138
real h_ice_p_flk
Definition: mode_flake.F90:142
real i_intm_h_d_flk
Definition: mode_flake.F90:172
real c_t_n_flk
Definition: mode_flake.F90:147
real t_bot_p_flk
Definition: mode_flake.F90:137
real h_b1_p_flk
Definition: mode_flake.F90:144
real h_ice_n_flk
Definition: mode_flake.F90:142
real u_star_w_flk
Definition: mode_flake.F90:176
real i_bot_flk
Definition: mode_flake.F90:170
integer, parameter jprb
Definition: parkind1.F90:32
real function flake_buoypar(T_water)
real t_bot_n_flk
Definition: mode_flake.F90:137
real i_intm_0_h_flk
Definition: mode_flake.F90:171
real, parameter rflk_depth_bs_ref
real function flake_snowdensity(h_snow)
logical lhook
Definition: yomhook.F90:15
real q_star_flk
Definition: mode_flake.F90:173
real q_bot_flk
Definition: mode_flake.F90:163
real function flake_snowheatconduct(h_snow)
real phi_t_pr0_flk
Definition: mode_flake.F90:154
real h_b1_n_flk
Definition: mode_flake.F90:144
real q_snow_flk
Definition: mode_flake.F90:160
real q_ice_flk
Definition: mode_flake.F90:161
real c_t_p_flk
Definition: mode_flake.F90:147
real i_snow_flk
Definition: mode_flake.F90:166
real w_star_sfc_flk
Definition: mode_flake.F90:177
real t_ice_p_flk
Definition: mode_flake.F90:135
real h_snow_n_flk
Definition: mode_flake.F90:141
real t_mnw_n_flk
Definition: mode_flake.F90:133
real t_b1_p_flk
Definition: mode_flake.F90:138
real t_snow_n_flk
Definition: mode_flake.F90:134
real dmsnowdt_flk
Definition: mode_flake.F90:181
real phi_s_pr0_flk
Definition: mode_flake.F90:157
real t_wml_p_flk
Definition: mode_flake.F90:136
real i_atm_flk
Definition: mode_flake.F90:164