source: LMDZ6/trunk/libf/phylmd/ecrad/radiation/radiation_delta_eddington.h @ 4948

Last change on this file since 4948 was 4773, checked in by idelkadi, 11 months ago
  • Update of Ecrad in LMDZ The same organization of the Ecrad offline version is retained in order to facilitate the updating of Ecrad in LMDZ and the comparison between online and offline results. version 1.6.1 of Ecrad (https://github.com/lguez/ecrad.git)
  • Implementation of the double call of Ecrad in LMDZ


File size: 4.5 KB
Line 
1! radiation_delta_eddington.h - Delta-Eddington scaling -*- f90 -*-
2!
3! (C) Copyright 2015- ECMWF.
4!
5! This software is licensed under the terms of the Apache Licence Version 2.0
6! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
7!
8! In applying this licence, ECMWF does not waive the privileges and immunities
9! granted to it by virtue of its status as an intergovernmental organisation
10! nor does it submit to any jurisdiction.
11!
12! Author:  Robin Hogan
13! Email:   r.j.hogan@ecmwf.int
14!
15! This file is intended to be included inside a module to ensure that
16! these simple functions may be inlined
17
18!---------------------------------------------------------------------
19! Perform in-place delta-Eddington scaling of the phase function
20elemental subroutine delta_eddington(od, ssa, g)
21
22  use parkind1, only : jprb
23 
24  ! Total optical depth, single scattering albedo and asymmetry
25  ! factor
26  real(jprb), intent(inout) :: od, ssa, g
27 
28  ! Fraction of the phase function deemed to be in the forward lobe
29  ! and therefore treated as if it is not scattered at all
30  real(jprb) :: f
31 
32  f   = g*g
33  od  = od * (1.0_jprb - ssa*f)
34  ssa = ssa * (1.0_jprb - f) / (1.0_jprb - ssa*f)
35  g   = g / (1.0_jprb + g)
36 
37end subroutine delta_eddington
38
39
40!---------------------------------------------------------------------
41! Perform in-place delta-Eddington scaling of the phase function, but
42! using extensive variables (i.e. the scattering optical depth,
43! scat_od, rather than the single-scattering albedo, and the
44! scattering-optical-depth-multiplied-by-asymmetry-factor, scat_od_g,
45! rather than the asymmetry factor.
46elemental subroutine delta_eddington_extensive(od, scat_od, scat_od_g)
47
48  use parkind1, only : jprb
49
50  ! Total optical depth, scattering optical depth and asymmetry factor
51  ! multiplied by the scattering optical depth
52  real(jprb), intent(inout) :: od, scat_od, scat_od_g
53
54  ! Fraction of the phase function deemed to be in the forward lobe
55  ! and therefore treated as if it is not scattered at all
56  real(jprb) :: f, g
57
58  if (scat_od > 0.0_jprb) then
59    g = scat_od_g / scat_od
60  else
61    g = 0.0
62  end if
63
64  f         = g*g
65  od        = od - scat_od * f
66  scat_od   = scat_od * (1.0_jprb - f)
67  scat_od_g = scat_od * g / (1.0_jprb + g)
68 
69end subroutine delta_eddington_extensive
70
71
72!---------------------------------------------------------------------
73! Array version of delta_eddington_extensive, more likely to vectorize
74 subroutine delta_eddington_extensive_vec(ng, od, scat_od, scat_od_g)
75
76  use parkind1, only : jprb
77
78  ! Total optical depth, scattering optical depth and asymmetry factor
79  ! multiplied by the scattering optical depth
80  integer,                   intent(in)    :: ng
81  real(jprb), dimension(ng), intent(inout) :: od, scat_od, scat_od_g
82
83  ! Fraction of the phase function deemed to be in the forward lobe
84  ! and therefore treated as if it is not scattered at all
85  real(jprb) :: f, g
86  integer :: j
87
88  do j = 1,ng
89    g            = scat_od_g(j) / max(scat_od(j), 1.0e-24)
90    f            = g*g
91    od(j)        = od(j) - scat_od(j) * f
92    scat_od(j)   = scat_od(j) * (1.0_jprb - f)
93    scat_od_g(j) = scat_od(j) * g / (1.0_jprb + g)
94  end do
95 
96end subroutine delta_eddington_extensive_vec
97
98
99!---------------------------------------------------------------------
100! Perform in-place delta-Eddington scaling of the phase function,
101! using the scattering optical depth rather than the single scattering
102! albedo
103elemental subroutine delta_eddington_scat_od(od, scat_od, g)
104
105  use parkind1, only : jprb
106 
107  ! Total optical depth, scattering optical depth and asymmetry factor
108  real(jprb), intent(inout) :: od, scat_od, g
109
110  ! Fraction of the phase function deemed to be in the forward lobe
111  ! and therefore treated as if it is not scattered at all
112  real(jprb) :: f
113
114  f       = g*g
115  od      = od - scat_od * f
116  scat_od = scat_od * (1.0_jprb - f)
117  g       = g / (1.0_jprb + g)
118
119end subroutine delta_eddington_scat_od
120
121
122!---------------------------------------------------------------------
123! Revert delta-Eddington-scaled quantities in-place, back to their
124! original state
125elemental subroutine revert_delta_eddington(od, ssa, g)
126
127  use parkind1, only : jprb
128 
129  ! Total optical depth, single scattering albedo and asymmetry
130  ! factor
131  real(jprb), intent(inout) :: od, ssa, g
132 
133  ! Fraction of the phase function deemed to be in the forward lobe
134  ! and therefore treated as if it is not scattered at all
135  real(jprb) :: f
136 
137  g   = g / (1.0_jprb - g)
138  f   = g*g
139  ssa = ssa / (1.0_jprb - f + f*ssa);
140  od  = od / (1.0_jprb - ssa*f)
141 
142end subroutine revert_delta_eddington
Note: See TracBrowser for help on using the repository browser.