SURFEX v8.1
General documentation of Surfex
flake_interface.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 ! ###############################################################################
6 SUBROUTINE flake_interface (F, KI, &
7 ! Atmospheric forcing
8  dMsnowdt_in, I_atm_in, Q_atm_lw_in, height_u_in, height_tq_in, &
9  U_a_in, T_a_in, q_a_in, P_a_in, &
10 ! Constant parameters
11  del_time, &
12 ! Parameters that may change
13  albedo, &
14 ! Surface heat, momentum fluxes, and other diags
15  Q_sensible, Q_latent ,Q_momentum, z0t, Qsat, Ri, ustar, Cd_a, &
16  Q_watvap, Q_latenti, Q_sublim, Q_atm_lw_up, pswe, &
17 ! Switches to configure FLake runs
18  PPEW_A_COEF, PPEW_B_COEF, rho_a, HIMPLICIT_WIND )
19 !------------------------------------------------------------------------------
20 !
21 ! Description:
22 !
23 ! The FLake interface is
24 ! a communication routine between "flake_driver"
25 ! and a prediction system that uses FLake.
26 ! It assigns the FLake variables at the previous time step
27 ! to their input values given by the driving model,
28 ! calls a number of routines to compute the heat and radiation fluxes,
29 ! calls "flake_driver",
30 ! and returns the updated FLake variables to the driving model.
31 ! The "flake_interface" does not contain any Flake physics.
32 ! It only serves as a convenient means to organize calls of "flake_driver"
33 ! and of external routines that compute heat and radiation fluxes.
34 ! The interface may (should) be changed so that to provide
35 ! the most convenient use of FLake.
36 ! Within a 3D atmospheric prediction system,
37 ! "flake_driver" may be called in a DO loop within "flake_interface"
38 ! for each grid-point where a lake is present.
39 ! In this way, the driving atmospheric model should call "flake_interface"
40 ! only once, passing the FLake variables to "flake_interface" as 2D fields.
41 !
42 ! Lines embraced with "!_tmp" contain temporary parts of the code.
43 ! These should be removed prior to using FLake in applications.
44 ! Lines embraced/marked with "!_dev" may be replaced
45 ! as improved parameterizations are developed and tested.
46 ! Lines embraced/marked with "!_dm" are DM's comments
47 ! that may be helpful to a user.
48 !
49 !
50 ! Current Code Owner: DWD, Dmitrii Mironov
51 ! Phone: +49-69-8062 2705
52 ! Fax: +49-69-8062 3721
53 ! E-mail: dmitrii.mironov@dwd.de
54 !
55 ! History:
56 ! Version Date Name
57 ! ---------- ---------- ----
58 ! 1.00 2005/11/17 Dmitrii Mironov
59 ! Initial release
60 ! !VERSION! !DATE! <Your name>
61 ! <Modification comments>
62 !
63 ! Code Description:
64 ! Language: Fortran 90.
65 ! Software Standards: "European Standards for Writing and
66 ! Documenting Exchangeable Fortran 90 Code".
67 !==============================================================================
68 !
69 ! Declarations:
70 !
71 USE modd_flake_n, ONLY : flake_t
72 !
73 ! Modules used:
74 
75 !USE modd_data_parameters , ONLY : &
76 ! ireals, &! KIND-type parameter for real variables
77 ! iintegers ! KIND-type parameter for "normal" integer variables
78 
79 USE modd_flake_derivedtypes ! Definitions of several derived TYPEs
80 
81 USE modd_flake_parameters , ONLY : &
82  tpl_kappa_w , &! Molecular heat conductivity of water [J m^{-1} s^{-1} K^{-1}]
83  tpl_t_f , &! Fresh water freezing point [K]
84  tpl_rho_w_r , &! Maximum density of fresh water [kg m^{-3}]
85  h_snow_min_flk , &! Minimum snow thickness [m]
86  h_ice_min_flk , &! Minimum ice thickness [m]
87  h_skinlayer_flk ! Skin layer thickness [m]
88 
89 USE modd_flake_paramoptic_ref ! Reference values of the optical characteristics
90  ! of the lake water, lake ice and snow
91 
92 USE mode_flake , ONLY : &
93  flake_driver , &! Subroutine, FLake driver
94  flake_radflux , &! Subroutine, computes radiation fluxes at various depths
95  flake_snowdensity , &! Function, computes snow density
96  !
97  t_snow_p_flk, t_snow_n_flk , &! Temperature at the air-snow interface [K]
98  t_ice_p_flk, t_ice_n_flk , &! Temperature at the snow-ice or air-ice interface [K]
99  t_mnw_p_flk, t_mnw_n_flk , &! Mean temperature of the water column [K]
100  t_wml_p_flk, t_wml_n_flk , &! Mixed-layer temperature [K]
101  t_bot_p_flk, t_bot_n_flk , &! Temperature at the water-bottom sediment interface [K]
102  t_b1_p_flk, t_b1_n_flk , &! Temperature at the bottom of the upper layer of the sediments [K]
103  c_t_p_flk, c_t_n_flk , &! Shape factor (thermocline)
104  h_snow_p_flk, h_snow_n_flk , &! Snow thickness [m]
105  h_ice_p_flk, h_ice_n_flk , &! Ice thickness [m]
106  h_ml_p_flk, h_ml_n_flk , &! Thickness of the mixed-layer [m]
107  h_b1_p_flk, h_b1_n_flk , &! Thickness of the upper layer of bottom sediments [m]
108  !
109  q_snow_flk , &! Heat flux through the air-snow interface [W m^{-2}]
110  q_ice_flk , &! Heat flux through the snow-ice or air-ice interface [W m^{-2}]
111  q_w_flk , &! Heat flux through the ice-water or air-water interface [W m^{-2}]
112  q_bot_flk , &! Heat flux through the water-bottom sediment interface [W m^{-2}]
113  i_atm_flk , &! Radiation flux at the lower boundary of the atmosphere [W m^{-2}],
114  ! i.e. the incident radiation flux with no regard for the surface albedo
115  i_snow_flk , &! Radiation flux through the air-snow interface [W m^{-2}]
116  i_ice_flk , &! Radiation flux through the snow-ice or air-ice interface [W m^{-2}]
117  i_w_flk , &! Radiation flux through the ice-water or air-water interface [W m^{-2}]
118  i_h_flk , &! Radiation flux through the mixed-layer-thermocline interface [W m^{-2}]
119  i_bot_flk , &! Radiation flux through the water-bottom sediment interface [W m^{-2}]
120  i_intm_0_h_flk , &! Mean radiation flux over the mixed layer [W m^{-1}]
121  i_intm_h_d_flk , &! Mean radiation flux over the thermocline [W m^{-1}]
122  q_star_flk , &! A generalized heat flux scale [W m^{-2}]
123  u_star_w_flk , &! Friction velocity in the surface layer of lake water [m s^{-1}]
124  w_star_sfc_flk , &! Convective velocity scale, using a generalized heat flux scale [m s^{-1}]
125  dmsnowdt_flk ! The rate of snow accumulation [kg m^{-2} s^{-1}]
126 
127 
128 USE mode_sfcflx , ONLY : &
129  sfcflx_lwradwsfc , &! Function, returns the surface long-wave radiation flux
130  sfcflx_momsenlat , &! Subroutine, computes fluxes of momentum and of sensible and latent heat
131  z0u_sf , &! Roughness length with respect to wind velocity [m]
132  z0t_sf ! Roughness length with respect to potential temperature [m]
133 
134 
136 !==============================================================================
137 !
138 USE modi_wind_threshold
139 !
140 USE yomhook ,ONLY : lhook, dr_hook
141 USE parkind1 ,ONLY : jprb
142 !
143 !
144 IMPLICIT NONE
145 
146 !==============================================================================
147 !
148 ! Declarations
149 
150 !
151 !* 0.1 declarations of arguments
152 !
153 ! Input (procedure arguments)
154 !
155 TYPE(flake_t), INTENT(INOUT) :: F
156 !
157 INTEGER, INTENT(IN) :: KI ! number of points
158 !
159 INTEGER :: i ! DO loop index
160 !
161 REAL, DIMENSION(KI), INTENT(IN) :: &
162  dMsnowdt_in , &! The rate of snow accumulation [kg m^{-2} s^{-1}]
163  I_atm_in , &! Solar radiation flux at the surface [W m^{-2}]
164  Q_atm_lw_in , &! Long-wave radiation flux from the atmosphere [W m^{-2}]
165  height_u_in , &! Height above the lake surface where the wind speed is measured [m]
166  height_tq_in , &! Height where temperature and humidity are measured [m]
167  U_a_in , &! Wind speed at z=height_u_in [m s^{-1}]
168  T_a_in , &! Air temperature at z=height_tq_in [K]
169  q_a_in , &! Air specific humidity at z=height_tq_in
170  P_a_in ! Surface air pressure [N m^{-2} = kg m^{-1} s^{-2}]
171 
172 REAL, DIMENSION(KI), INTENT(IN) :: &
173  del_time , &! The model time step [s]
174  PPEW_A_COEF , &! coefficient A (m^2 s kg^{-1}) and B (m s^{-1})
175  PPEW_B_COEF , &! for wind implicitation : V+ = - A * rho_a u'w' + B
176  rho_a ! Air density (kg m ^{-3}) (from forcing atm. data)
177 !
178  CHARACTER(LEN=*), INTENT(IN) :: HIMPLICIT_WIND ! wind implicitation option
179 ! ! 'OLD' = direct
180 ! ! 'NEW' = Taylor serie, order 1
181 !
182 !
183 ! Input/Output (procedure arguments)
184 
185 REAL, DIMENSION(KI), INTENT(IN) :: albedo ! surface albedo with respect to the solar radiation
186  ! (free water, ice or snow; e.g. update_rade_flake.f90)
187 
188 ! Output (procedure arguments)
189 
190 REAL, DIMENSION(KI), INTENT(INOUT) :: &
191  Q_sensible , &! Sensible heat flux [W m^{-2}]
192  Q_latent , &! Total Latent heat flux [W m^{-2}]
193  Q_watvap , &! Total Flux of water vapour [kg m^{-2} s^{-1}]
194  Q_latenti , &! Sublimation Latent heat flux [W m^{-2}]
195  Q_sublim , &! Flux of sublimation [kg m^{-2} s^{-1}]
196  Q_momentum , &! Momentum flux [N m^{-2}]
197  z0t , &! Roughness length with respect to potential temperature [m]
198  Ri , &! Gradient Richardson number
199  ustar , &! air friction velocity
200  Cd_a ! wind drag coefficient [no unit]
201 !
202 REAL, DIMENSION(KI), INTENT(OUT) :: &
203  Qsat , &! specific humidity at saturation [kg.kg-1]
204  Q_atm_lw_up , &! Upward longwave flux at t [W m^{-2}]
205  pswe ! snow water equivalent [kg.m-2]
206 !
207 !* 0.2 declarations of local variables
208 !
209 INTEGER :: JL ! loop counter on horizontal points
210 
211 REAL :: T_sfc_n ! Surface temperature at the new time step [K]
212 REAL :: ustar2 ! square of air friction velocity (m2/s2)
213 REAL :: zvmod ! wind at t+1
214 REAL, DIMENSION(KI) :: &
215  zwind ! thresholded wind
216 
217 type(opticpar_medium), DIMENSION(KI) :: &
218  opticpar_water , &! Optical characteristics of water
219  opticpar_ice , &! Optical characteristics of ice
220  opticpar_snow ! Optical characteristics of snow
221 REAL(KIND=JPRB) :: ZHOOK_HANDLE
222 !
223 REAL, PARAMETER :: ZTIMEMAX = 300. ! s Maximum timescale without time spliting
224 !
225 INTEGER :: JDT, INDT
226 REAL :: zaux, zcond, zloc, ZTSTEP
227 !
228 !==============================================================================
229 ! Start calculations
230 !------------------------------------------------------------------------------
231 IF (lhook) CALL dr_hook('FLAKE_INTERFACE',0,zhook_handle)
232 !
233 !------------------------------------------------------------------------------
234 ! Set optical characteristics of the lake water, lake ice and snow
235 !------------------------------------------------------------------------------
236 !
237 ! Use default values
238 !opticpar_water = opticpar_water_ref ! don't use default values
239 
240 opticpar_ice = opticpar_ice_opaque ! Opaque ice
241 opticpar_snow = opticpar_snow_opaque ! Opaque snow
242 !
243 lflk_botsed_use = f%LSEDIMENTS
244 !
245 zwind = wind_threshold(u_a_in,height_u_in)
246 !
247 h_point_loop: DO jl = 1,ki ! begin of loop on horizontal points
248 !------------------------------------------------------------------------------
249 ! Set initial values
250 !------------------------------------------------------------------------------
251 
252 opticpar_water(jl) = opticpar_medium(1, &
253  (/1., (0.,i=2,nband_optic_max)/), &
254  (/f%XEXTCOEF_WATER(jl), (1.e+10,i=2,nband_optic_max)/))
255  t_snow_p_flk = f%XT_SNOW(jl)
256  t_ice_p_flk = f%XT_ICE(jl)
257  t_mnw_p_flk = f%XT_MNW(jl)
258  t_wml_p_flk = f%XT_WML(jl)
259  t_bot_p_flk = f%XT_BOT(jl)
260  t_b1_p_flk = f%XT_B1(jl)
261  c_t_p_flk = f%XCT(jl)
262  h_snow_p_flk = f%XH_SNOW(jl)
263  h_ice_p_flk = f%XH_ICE(jl)
264  h_ml_p_flk = f%XH_ML(jl)
265  h_b1_p_flk = f%XH_B1(jl)
266 
267 !------------------------------------------------------------------------------
268 ! Set the rate of snow accumulation
269 !------------------------------------------------------------------------------
270 
271  dmsnowdt_flk = dmsnowdt_in(jl)
272 
273 !------------------------------------------------------------------------------
274 ! Compute solar radiation fluxes (positive downward)
275 !------------------------------------------------------------------------------
276 
277  i_atm_flk = i_atm_in(jl)
278  CALL flake_radflux ( f%XWATER_DEPTH(jl), albedo(jl), opticpar_water(jl), &
279  opticpar_ice(jl), opticpar_snow(jl) )
280 
281 !------------------------------------------------------------------------------
282 ! Compute long-wave radiation fluxes (positive downward)
283 ! lwd-lwu = emis*(lwd-sigma*ts**4)
284 !------------------------------------------------------------------------------
285 !
286  q_w_flk = f%XEMIS(jl)*q_atm_lw_in(jl) - sfcflx_lwradwsfc(f%XEMIS(jl),f%XTS(jl))
287 !
288  q_atm_lw_up(jl) = q_atm_lw_in(jl) - q_w_flk
289 !
290 !------------------------------------------------------------------------------
291 ! Compute the surface friction velocity and fluxes of sensible and latent heat
292 !------------------------------------------------------------------------------
293 
294  IF (f%CFLK_FLUX=='FLAKE') THEN
295  !
296  q_momentum(jl) = - rho_a(jl) * ustar(jl)**2
297  !
298  CALL sfcflx_momsenlat ( height_u_in(jl), height_tq_in(jl), f%XWATER_FETCH(jl), &
299  u_a_in(jl), t_a_in(jl), q_a_in(jl), f%XTS(jl), &
300  p_a_in(jl), h_ice_p_flk, q_momentum(jl), &
301  q_sensible(jl), q_latent(jl), q_watvap(jl), &
302  ri(jl), f%XZ0(jl), z0t(jl), qsat(jl), &
303  q_latenti(jl), q_sublim(jl) )
304  f%XZ0(jl)= z0u_sf
305  z0t(jl)=z0t_sf
306  ! recomputes the future wind speed and associated momentum flux
307  ! in the case wind speed is implicited (V. Masson, Meteo-France)
308  ! 1st step : drag coefficient
309  ! It is retrieved assumed a relationship between momentum flux
310  ! and previous time-step wind : Q_mom = - rho_a * Cd_a * U_a_in**2
311  !
312  cd_a(jl) = - q_momentum(jl) / rho_a(jl) / zwind(jl)**2
313  ! 2nd step : friction velocity (for air) computed with future wind speed
314  ! (the latter computed using implicit coefficients)
315  ustar2 = 0.0
316  zvmod = u_a_in(jl)
317  IF(himplicit_wind=='OLD')THEN
318  ! old implicitation
319  ustar2 = (cd_a(jl)*u_a_in(jl)*ppew_b_coef(jl))/ &
320  (1.0-rho_a(jl)*cd_a(jl)*u_a_in(jl)*ppew_a_coef(jl))
321  ELSE
322  ! new implicitation
323  ustar2 = (cd_a(jl)*u_a_in(jl)*(2.*ppew_b_coef(jl)-u_a_in(jl)))/ &
324  (1.0-2.0*rho_a(jl)*cd_a(jl)*u_a_in(jl)*ppew_a_coef(jl))
325  zvmod = rho_a(jl)*ppew_a_coef(jl)*ustar2 + ppew_b_coef(jl)
326  zvmod = max(0.0,zvmod)
327  IF(ppew_a_coef(jl)/= 0.)THEN
328  ustar2 = max((zvmod-ppew_b_coef(jl))/(rho_a(jl)*ppew_a_coef(jl)),0.0)
329  ENDIF
330  ENDIF
331  ustar(jl) =sqrt(ustar2)
332  ! 3rd step : momentum flux computed with the future wind speed
333  q_momentum(jl) = - rho_a(jl) * ustar2
334 
335  END IF
336  u_star_w_flk = sqrt(-q_momentum(jl)/tpl_rho_w_r)
337 
338 !------------------------------------------------------------------------------
339 ! Compute heat fluxes Q_snow_flk, Q_ice_flk, Q_w_flk
340 !------------------------------------------------------------------------------
341 
342  q_w_flk = q_w_flk - q_sensible(jl) - q_latent(jl) ! Add sensible and latent heat fluxes
343  ! (notice the signs)
344  IF(h_ice_p_flk.GE.h_ice_min_flk) THEN ! Ice exists
345  IF(h_snow_p_flk.GE.h_snow_min_flk) THEN ! There is snow above the ice
346  q_snow_flk = q_w_flk
347  q_ice_flk = 0.
348  q_w_flk = 0.
349  ELSE ! No snow above the ice
350  q_snow_flk = 0.
351  q_ice_flk = q_w_flk
352  q_w_flk = 0.
353  END IF
354  ELSE ! No ice-snow cover
355  q_snow_flk = 0.
356  q_ice_flk = 0.
357  END IF
358 
359 !------------------------------------------------------------------------------
360 ! Advance FLake variables
361 ! Time splitting parameter for *very large time steps*
362 ! -----------------------------------------------------------------------------
363 !
364  indt = max(1,nint(del_time(jl)/ztimemax))
365  ztstep = del_time(jl)/REAL(indt)
366 
367  DO jdt=1,indt
368 !
369  t_snow_p_flk = f%XT_SNOW(jl)
370  t_ice_p_flk = f%XT_ICE(jl)
371  t_mnw_p_flk = f%XT_MNW(jl)
372  t_wml_p_flk = f%XT_WML(jl)
373  t_bot_p_flk = f%XT_BOT(jl)
374  t_b1_p_flk = f%XT_B1(jl)
375  c_t_p_flk = f%XCT(jl)
376  h_snow_p_flk = f%XH_SNOW(jl)
377  h_ice_p_flk = f%XH_ICE(jl)
378  h_ml_p_flk = f%XH_ML(jl)
379  h_b1_p_flk = f%XH_B1(jl)
380 !
381  CALL flake_driver ( f%XWATER_DEPTH(jl), f%XDEPTH_BS(jl), f%XT_BS(jl), f%XCORIO(jl), &
382  opticpar_water(jl)%extincoef_optic(1), &
383  ztstep, f%XTS(jl), t_sfc_n )
384 !
385 !------------------------------------------------------------------------------
386 ! Set output values
387 !------------------------------------------------------------------------------
388 !
389  f%XT_SNOW(jl) = t_snow_n_flk
390  f%XT_ICE(jl) = t_ice_n_flk
391  f%XT_MNW(jl) = t_mnw_n_flk
392  f%XT_WML(jl) = t_wml_n_flk
393  f%XT_BOT(jl) = t_bot_n_flk
394  f%XT_B1(jl) = t_b1_n_flk
395  f%XCT(jl) = c_t_n_flk
396  f%XH_SNOW(jl) = h_snow_n_flk
397  f%XH_ICE(jl) = h_ice_n_flk
398  f%XH_ML(jl) = h_ml_n_flk
399  f%XH_B1(jl) = h_b1_n_flk
400  f%XTS(jl) = t_sfc_n
401 !
402  ENDDO
403 !
404  pswe(jl) = f%XH_SNOW(jl)*flake_snowdensity(f%XH_SNOW(jl))
405 !
406 !------------------------------------------------------------------------------
407 ! Compute skin temperature in case of no ice nor snow
408 !------------------------------------------------------------------------------
409 !
410 ! Q_w_flk=LWD-LWU-(QH+QE) accounts for water phase (water, ice, snow)
411 ! (1-albedo)*I_atm_flk=SWD-SWU accounts for water phase (water, ice, snow)
412 !
413  IF (f%LSKINTEMP.AND.(f%XH_ICE(jl)<h_ice_min_flk).AND.(f%CFLK_FLUX=='FLAKE')) THEN
414 
415  zaux = (1.0-exp(-opticpar_water(jl)%extincoef_optic(1) * h_skinlayer_flk)) &
416  / opticpar_water(jl)%extincoef_optic(1)
417 
418  zcond = tpl_kappa_w
419 
420  zloc = ((1.0-albedo(jl))*i_atm_flk+q_w_flk)*h_skinlayer_flk-(1.0-albedo(jl))*i_atm_flk*zaux
421 
422  f%XTS(jl) = t_sfc_n + zloc / zcond
423 
424  ENDIF
425 !
426 ENDDO h_point_loop
427 !
428 IF (lhook) CALL dr_hook('FLAKE_INTERFACE',1,zhook_handle)
429 !
430 !------------------------------------------------------------------------------
431 ! End calculations
432 !==============================================================================
433 
434 END SUBROUTINE flake_interface
435 
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 function, dimension(size(pwind)) wind_threshold(PWIND, PUREF)
integer, parameter jprb
Definition: parkind1.F90:32
real function sfcflx_lwradwsfc(emis, pts)
logical lhook
Definition: yomhook.F90:15
type(opticpar_medium), parameter opticpar_ice_opaque
type(opticpar_medium), parameter opticpar_snow_opaque
subroutine flake_interface(F, KI, dMsnowdt_in, I_atm_in, Q_atm_lw_in, height_u_in, height_tq_in, U_a_in, T_a_in, q_a_in, P_a_in, del_time, albedo, Q_sensible, Q_latent, Q_momentum, z0t, Qsat, Ri, ustar, Cd_a, Q_watvap, Q_latenti, Q_sublim, Q_atm_lw_up, pswe, PPEW_A_COEF, PPEW_B_COEF, rho_a, HIMPLICIT_WIND)