GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: phylmd/Ocean_skin/sens_heat_rain_m.F90 Lines: 10 10 100.0 %
Date: 2023-06-30 12:51:15 Branches: 0 0 - %

Line Branch Exec Source
1
module sens_heat_rain_m
2
3
  implicit none
4
5
contains
6
7
#ifdef IN_LMDZ
8
280418
  real function sens_heat_rain(rain, t, q, rhoa, xlv, t_int, p)
9
#else
10
  elemental real function sens_heat_rain(rain, t, q, rhoa, xlv, t_int, p)
11
#endif
12
13
    ! Computes heat flux due to rainfall, in W m-2, positive
14
    ! upward.
15
16
    ! If in LMDZ, do not declare this function as elemental because
17
    ! YOMCST.h contains an OpenMP directive, and that only works in
18
    ! OpenMP 5.0.
19
20
    use const, only: cpa, cpw, rgas
21
#ifndef IN_LMDZ
22
    use const, only: eps_w
23
#endif
24
    use esat_m, only: esat
25
26
#ifdef IN_LMDZ
27
    include "YOMCST.h"
28
    ! for eps_w
29
#endif
30
31
    real, intent(in):: rain ! rain mass flux, in kg m-2 s-1
32
    real, intent(in):: t ! air temperature at 10 m, in K
33
    real, intent(in):: q ! specific humidity at 10 m
34
    real, intent(in):: rhoa ! density of moist air  (kg / m3)
35
    real, intent(in):: xlv ! latent heat of evaporation (J / kg)
36
    real, intent(in):: t_int ! interface temperature, in K
37
    real, intent(in):: p ! surface pressure, in Pa
38
39
    ! Local:
40
41
    real es ! saturation pressure of wator vapor, in Pa
42
    real alfac ! wet bulb factor
43
    real dwat ! water vapour diffusivity
44
    real dtmp ! heat diffusivity
45
    real q_int ! specific (saturation) humidity at ocean interface
46
    real t_celsius ! air temperature at 10 m, in Celsius degrees
47
48
    real wetc
49
    ! derivative of saturated mass fraction of water vapor with
50
    ! respect to temperature, at constant total pressure
51
52
    !---------------------------------------------------------------------
53
54
280418
    es = esat(t_int, p) * 0.98 ! reduced for salinity, Kraus 1972 page 46
55
280418
    q_int = eps_w * (es / (p - (1. - eps_w) * es))
56
280418
    wetc = eps_w * xlv * q_int / (rgas * t_int**2)
57
280418
    dwat = 2.11e-5 * (t / 273.15)**1.94
58
280418
    t_celsius = t - 273.15
59
    dtmp = (1. + 3.309e-3 * t_celsius - 1.44e-6 * t_celsius**2) * 0.02411 &
60
280418
         / (rhoa * cpa)
61
62
    ! Gosnell 1995 k0991, equation (11):
63
280418
    alfac =  1. / (1. + (wetc * xlv * dwat) / (cpa * dtmp))
64
65
    ! Gosnell 1995 k0991, equation (12):
66
280418
    sens_heat_rain =  rain * alfac * cpw * (t_int - t + (q_int - q) * xlv / cpa)
67
68
280418
  end function sens_heat_rain
69
70
end module sens_heat_rain_m