source: LMDZ6/branches/Ocean_skin/libf/phylmd/ecrad/radiation_tripleclouds_lw.F90 @ 5407

Last change on this file since 5407 was 3908, checked in by idelkadi, 4 years ago

Online implementation of the radiative transfer code ECRAD in the LMDZ model.

  • Inclusion of the ecrad directory containing the sources of the ECRAD code
    • interface routine : radiation_scheme.F90
  • Adaptation of compilation scripts :
    • compilation under CPP key CPP_ECRAD
    • compilation with option "-rad ecard" or "-ecard true"
    • The "-rad old/rtm/ecran" build option will need to replace the "-rrtm true" and "-ecrad true" options in the future.
  • Runing LMDZ simulations with ecrad, you need :
    • logical key iflag_rrtm = 2 in physiq.def
    • namelist_ecrad (DefLists?)
    • the directory "data" containing the configuration files is temporarily placed in ../libfphylmd/ecrad/
  • Compilation and execution are tested in the 1D case. The repository under svn would allow to continue the implementation work: tests, verification of the results, ...
File size: 22.9 KB
Line 
1! radiation_tripleclouds_lw.F90 - Longwave "Tripleclouds" solver
2!
3! (C) Copyright 2016- 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! Modifications
16!   2017-04-28  R. Hogan  Receive emission/albedo rather than planck/emissivity
17!   2017-04-22  R. Hogan  Store surface fluxes at all g-points
18!   2017-10-23  R. Hogan  Renamed single-character variables
19!   2018-10-08  R. Hogan  Call calc_region_properties
20
21module radiation_tripleclouds_lw
22
23  public
24
25contains
26  ! Small routine for scaling cloud optical depth in the cloudy
27  ! regions
28#include "radiation_optical_depth_scaling.h"
29
30  ! This module contains just one subroutine, the longwave
31  ! "Tripleclouds" solver in which cloud inhomogeneity is treated by
32  ! dividing each model level into three regions, one clear and two
33  ! cloudy (with differing optical depth). This approach was described
34  ! by Shonk and Hogan (2008).
35
36  subroutine solver_tripleclouds_lw(nlev,istartcol,iendcol, &
37       &  config, cloud, &
38       &  od, ssa, g, od_cloud, ssa_cloud, g_cloud, planck_hl, &
39       &  emission, albedo, &
40       &  flux)
41
42    use parkind1, only           : jprb
43    use yomhook,  only           : lhook, dr_hook
44
45!    use radiation_io, only             : nulout
46    use radiation_config, only         : config_type, IPdfShapeGamma
47    use radiation_cloud, only          : cloud_type
48    use radiation_regions, only        : calc_region_properties
49    use radiation_overlap, only        : calc_overlap_matrices
50    use radiation_flux, only           : flux_type, &
51         &                               indexed_sum, add_indexed_sum
52    use radiation_matrix, only         : singlemat_x_vec
53    use radiation_two_stream, only     : calc_two_stream_gammas_lw, &
54         &                               calc_reflectance_transmittance_lw, &
55         &                               calc_no_scattering_transmittance_lw
56    use radiation_lw_derivatives, only : calc_lw_derivatives_region
57
58    implicit none
59
60    ! Inputs
61    integer, intent(in) :: nlev               ! number of model levels
62    integer, intent(in) :: istartcol, iendcol ! range of columns to process
63    type(config_type),        intent(in) :: config
64    type(cloud_type),         intent(in) :: cloud
65
66    ! Gas and aerosol optical depth of each layer at each longwave
67    ! g-point
68    real(jprb), intent(in), dimension(config%n_g_lw,nlev,istartcol:iendcol) :: od
69
70    ! Gas and aerosol single-scattering albedo and asymmetry factor,
71    ! only if longwave scattering by aerosols is to be represented
72    real(jprb), intent(in), &
73         &  dimension(config%n_g_lw_if_scattering,nlev,istartcol:iendcol) :: ssa, g
74
75    ! Cloud and precipitation optical depth of each layer in each
76    ! longwave band
77    real(jprb), intent(in) :: od_cloud(config%n_bands_lw,nlev,istartcol:iendcol)
78
79    ! Cloud and precipitation single-scattering albedo and asymmetry
80    ! factor, only if longwave scattering by clouds is to be
81    ! represented
82    real(jprb), intent(in), dimension(config%n_bands_lw_if_scattering, &
83         &                            nlev,istartcol:iendcol) :: ssa_cloud, g_cloud
84
85    ! Planck function (emitted flux from a black body) at half levels
86    ! and at the surface at each longwave g-point
87    real(jprb), intent(in), dimension(config%n_g_lw,nlev+1,istartcol:iendcol) :: planck_hl
88
89    ! Emission (Planck*emissivity) and albedo (1-emissivity) at the
90    ! surface at each longwave g-point
91    real(jprb), intent(in), dimension(config%n_g_lw, istartcol:iendcol) :: emission, albedo
92
93    ! Optical depth, single scattering albedo and asymmetry factor in
94    ! each g-point including gas, aerosol and clouds
95    real(jprb), dimension(config%n_g_lw) :: od_total, ssa_total, g_total
96
97    ! Modified optical depth after Tripleclouds scaling to represent
98    ! cloud inhomogeneity
99    real(jprb), dimension(config%n_g_lw) :: od_cloud_new
100
101    ! Output
102    type(flux_type), intent(inout):: flux
103
104    ! Local constants
105    integer, parameter :: nregions = 3
106
107    ! In a clear-sky layer this will be 1, otherwise equal to nregions
108    integer :: nreg
109
110    ! Local variables
111   
112    ! The area fractions of each region
113    real(jprb) :: region_fracs(1:nregions,nlev,istartcol:iendcol)
114
115    ! The scaling used for the optical depth in the cloudy regions
116    real(jprb) :: od_scaling(2:nregions,nlev,istartcol:iendcol)
117
118    ! Directional overlap matrices defined at all layer interfaces
119    ! including top-of-atmosphere and the surface
120    real(jprb), dimension(nregions,nregions,nlev+1, &
121         &                istartcol:iendcol) :: u_matrix, v_matrix
122
123    ! Two-stream variables
124    real(jprb), dimension(config%n_g_lw) :: gamma1, gamma2
125
126    ! Diffuse reflection and transmission matrices of each layer
127    real(jprb), dimension(config%n_g_lw, nregions, nlev) :: reflectance, transmittance
128
129    ! Emission by a layer into the upwelling or downwelling diffuse
130    ! streams
131    real(jprb), dimension(config%n_g_lw, nregions, nlev) &
132         &  :: Sup, Sdn
133
134    ! ...clear-sky equivalent
135    real(jprb), dimension(config%n_g_lw, nlev) &
136         &  :: Sup_clear, Sdn_clear
137
138    ! Total albedo of the atmosphere/surface just above a layer
139    ! interface with respect to downwelling diffuse radiation at that
140    ! interface, where level index = 1 corresponds to the
141    ! top-of-atmosphere
142    real(jprb), dimension(config%n_g_lw, nregions, nlev+1) :: total_albedo
143
144    ! Upwelling radiation just above a layer interface due to emission
145    ! below that interface, where level index = 1 corresponds to the
146    ! top-of-atmosphere
147    real(jprb), dimension(config%n_g_lw, nregions, nlev+1) :: total_source
148
149    ! ...equivalent values for clear-skies
150    real(jprb), dimension(config%n_g_lw, nlev+1) :: total_albedo_clear, total_source_clear
151
152    ! Total albedo and source of the atmosphere just below a layer interface
153    real(jprb), dimension(config%n_g_lw, nregions) &
154         &  :: total_albedo_below, total_source_below
155
156    ! Downwelling flux below and above an interface between
157    ! layers into a plane perpendicular to the direction of the sun
158    real(jprb), dimension(config%n_g_lw, nregions) &
159         &  :: flux_dn, flux_dn_below, flux_up
160
161    ! ...clear-sky equivalent (no distinction between "above/below")
162    real(jprb), dimension(config%n_g_lw) &
163         &  :: flux_dn_clear, flux_up_clear
164
165    ! Clear-sky equivalent, but actually its reciprocal to replace
166    ! some divisions by multiplications
167    real(jprb), dimension(config%n_g_lw, nregions) :: inv_denom
168
169    ! Identify clear-sky layers, with pseudo layers for outer space
170    ! and below the ground, both treated as single-region clear skies
171    logical :: is_clear_sky_layer(0:nlev+1)
172
173    integer :: jcol, jlev, jg, jreg, jreg2, ng
174
175    real(jprb) :: hook_handle
176
177    if (lhook) call dr_hook('radiation_tripleclouds_lw:solver_tripleclouds_lw',0,hook_handle)
178
179    ! --------------------------------------------------------
180    ! Section 1: Prepare general variables and arrays
181    ! --------------------------------------------------------
182    ! Copy array dimensions to local variables for convenience
183    ng   = config%n_g_lw
184
185    ! Compute the wavelength-independent region fractions and
186    ! optical-depth scalings
187    call calc_region_properties(nlev,nregions,istartcol,iendcol, &
188         &  config%i_cloud_pdf_shape == IPdfShapeGamma, &
189         &  cloud%fraction, cloud%fractional_std, region_fracs, &
190         &  od_scaling, config%cloud_fraction_threshold)
191
192    ! Compute wavelength-independent overlap matrices u_matrix and v_matrix
193    call calc_overlap_matrices(nlev,nregions,istartcol,iendcol, &
194         &  region_fracs, cloud%overlap_param, &
195         &  u_matrix, v_matrix, &
196         &  decorrelation_scaling=config%cloud_inhom_decorr_scaling, &
197         &  cloud_fraction_threshold=config%cloud_fraction_threshold, &
198         &  use_beta_overlap=config%use_beta_overlap, &
199         &  cloud_cover=flux%cloud_cover_lw)
200
201    ! Main loop over columns
202    do jcol = istartcol, iendcol
203      ! --------------------------------------------------------
204      ! Section 2: Prepare column-specific variables and arrays
205      ! --------------------------------------------------------
206
207      ! Define which layers contain cloud; assume that
208      ! cloud%crop_cloud_fraction has already been called
209      is_clear_sky_layer = .true.
210      do jlev = 1,nlev
211        if (cloud%fraction(jcol,jlev) > 0.0_jprb) then
212          is_clear_sky_layer(jlev) = .false.
213        end if
214      end do
215
216      ! --------------------------------------------------------
217      ! Section 3: Loop over layers to compute reflectance and transmittance
218      ! --------------------------------------------------------
219      ! In this section the reflectance, transmittance and sources
220      ! are computed for each layer
221      do jlev = 1,nlev ! Start at top-of-atmosphere
222
223        ! Array-wise assignments
224        gamma1 = 0.0_jprb
225        gamma2 = 0.0_jprb
226
227        nreg = nregions
228        if (is_clear_sky_layer(jlev)) then
229          nreg = 1
230          reflectance(:,2:,jlev)   = 0.0_jprb
231          transmittance(:,2:,jlev)   = 0.0_jprb
232          Sup(:,2:,jlev) = 0.0_jprb
233          Sdn(:,2:,jlev) = 0.0_jprb
234        end if
235        do jreg = 1,nreg
236          if (jreg == 1) then
237            ! Clear-sky calculation
238            if (.not. config%do_lw_aerosol_scattering) then
239              call calc_no_scattering_transmittance_lw(ng, od(:,jlev,jcol), &
240                   &  planck_hl(:,jlev,jcol), planck_hl(:,jlev+1, jcol), &
241                   &  transmittance(:,1,jlev), Sup(:,1,jlev), Sdn(:,1,jlev))
242              reflectance(:,1,jlev) = 0.0_jprb
243            else
244              call calc_two_stream_gammas_lw(ng, &
245                   &  ssa(:,jlev,jcol), g(:,jlev,jcol), gamma1, gamma2)
246              call calc_reflectance_transmittance_lw(ng, &
247                   &  od(:,jlev,jcol), gamma1, gamma2, &
248                   &  planck_hl(:,jlev,jcol), planck_hl(:,jlev+1,jcol), &
249                   &  reflectance(:,1,jlev), transmittance(:,1,jlev), &
250                   &  Sup(:,1,jlev), Sdn(:,1,jlev))
251            end if
252          else
253            ! Cloudy sky
254            ! Add scaled cloud optical depth to clear-sky value
255            od_cloud_new = od_cloud(config%i_band_from_reordered_g_lw,jlev,jcol) &
256                 &       * od_scaling(jreg,jlev,jcol)
257            od_total = od(:,jlev,jcol) + od_cloud_new
258
259            if (config%do_lw_cloud_scattering) then
260              ssa_total = 0.0_jprb
261              g_total   = 0.0_jprb             
262              if (config%do_lw_aerosol_scattering) then
263                where (od_total > 0.0_jprb)
264                  ssa_total = (ssa(:,jlev,jcol)*od(:,jlev,jcol) &
265                       &     + ssa_cloud(config%i_band_from_reordered_g_lw,jlev,jcol) &
266                       &     *  od_cloud_new) &
267                       &     / od_total
268                end where
269                where (ssa_total > 0.0_jprb .and. od_total > 0.0_jprb)
270                  g_total = (g(:,jlev,jcol)*ssa(:,jlev,jcol)*od(:,jlev,jcol) &
271                       &     +   g_cloud(config%i_band_from_reordered_g_lw,jlev,jcol) &
272                       &     * ssa_cloud(config%i_band_from_reordered_g_lw,jlev,jcol) &
273                       &     *  od_cloud_new) &
274                       &     / (ssa_total*od_total)
275                end where
276              else
277                where (od_total > 0.0_jprb)
278                  ssa_total = ssa_cloud(config%i_band_from_reordered_g_lw,jlev,jcol) &
279                       &     * od_cloud_new / od_total
280                end where
281                where (ssa_total > 0.0_jprb .and. od_total > 0.0_jprb)
282                  g_total = g_cloud(config%i_band_from_reordered_g_lw,jlev,jcol) &
283                       &     * ssa_cloud(config%i_band_from_reordered_g_lw,jlev,jcol) &
284                       &     *  od_cloud_new / (ssa_total*od_total)
285                end where
286              end if
287              call calc_two_stream_gammas_lw(ng, &
288                   &  ssa_total, g_total, gamma1, gamma2)
289              call calc_reflectance_transmittance_lw(ng, &
290                   &  od_total, gamma1, gamma2, &
291                   &  planck_hl(:,jlev,jcol), planck_hl(:,jlev+1,jcol), &
292                   &  reflectance(:,jreg,jlev), transmittance(:,jreg,jlev), &
293                   &  Sup(:,jreg,jlev), Sdn(:,jreg,jlev))
294            else
295              ! No-scattering case: use simpler functions for
296              ! transmission and emission
297              call calc_no_scattering_transmittance_lw(ng, od_total, &
298                   &  planck_hl(:,jlev,jcol), planck_hl(:,jlev+1, jcol), &
299                   &  transmittance(:,jreg,jlev), Sup(:,jreg,jlev), Sdn(:,jreg,jlev))
300              reflectance(:,jreg,jlev) = 0.0_jprb
301            end if
302          end if
303        end do
304
305        ! Copy over the clear-sky emission
306        Sup_clear(:,jlev) = Sup(:,1,jlev)
307        Sdn_clear(:,jlev) = Sdn(:,1,jlev)
308        if (.not. is_clear_sky_layer(jlev)) then
309          ! Emission is scaled by the size of each region
310          do jreg = 1,nregions
311            Sup(:,jreg,jlev) = region_fracs(jreg,jlev,jcol) * Sup(:,jreg,jlev)
312            Sdn(:,jreg,jlev) = region_fracs(jreg,jlev,jcol) * Sdn(:,jreg,jlev)
313          end do
314        end if
315
316      end do ! Loop over levels
317
318      ! --------------------------------------------------------
319      ! Section 4: Compute total sources albedos
320      ! --------------------------------------------------------
321
322      total_albedo(:,:,:) = 0.0_jprb
323      total_source(:,:,:) = 0.0_jprb
324
325      ! Calculate the upwelling radiation emitted by the surface, and
326      ! copy the surface albedo into total_albedo
327      do jreg = 1,nregions
328        do jg = 1,ng
329          ! region_fracs(jreg,nlev,jcol) is the fraction of each region in the
330          ! lowest model level
331          total_source(jg,jreg,nlev+1) = region_fracs(jreg,nlev,jcol)*emission(jg,jcol)
332          total_albedo(jg,jreg,nlev+1) = albedo(jg,jcol)
333        end do
334      end do
335      ! Equivalent surface values for computing clear-sky fluxes
336      if (config%do_clear) then
337        do jg = 1,ng
338          total_source_clear(jg,nlev+1) = emission(jg,jcol)
339        end do
340        ! In the case of surface albedo there is no dependence on
341        ! cloud fraction so we can copy the all-sky value
342        total_albedo_clear(1:ng,nlev+1) = total_albedo(1:ng,1,nlev+1)
343      end if
344
345      ! Work up from the surface computing the total albedo of the
346      ! atmosphere and the total upwelling due to emission below each
347      ! level below using the adding method
348      do jlev = nlev,1,-1
349
350        total_albedo_below        = 0.0_jprb
351
352        if (config%do_clear) then
353          ! For clear-skies there is no need to consider "above" and
354          ! "below" quantities since with no cloud overlap to worry
355          ! about, these are the same
356          inv_denom(:,1) = 1.0_jprb &
357               &  / (1.0_jprb - total_albedo_clear(:,jlev+1)*reflectance(:,1,jlev))
358          total_albedo_clear(:,jlev) = reflectance(:,1,jlev) &
359               &  + transmittance(:,1,jlev)*transmittance(:,1,jlev)*total_albedo_clear(:,jlev+1) &
360               &  * inv_denom(:,1)
361          total_source_clear(:,jlev) = Sup_clear(:,jlev) &
362               &  + transmittance(:,1,jlev)*(total_source_clear(:,jlev+1) &
363               &  + total_albedo_clear(:,jlev+1)*Sdn_clear(:,jlev)) &
364               &  * inv_denom(:,1)
365        end if
366
367        if (is_clear_sky_layer(jlev)) then
368          inv_denom(:,1) = 1.0_jprb &
369               &  / (1.0_jprb - total_albedo(:,1,jlev+1)*reflectance(:,1,jlev))
370          total_albedo_below = 0.0_jprb
371          total_albedo_below(:,1) = reflectance(:,1,jlev) &
372               &  + transmittance(:,1,jlev)*transmittance(:,1,jlev)*total_albedo(:,1,jlev+1) &
373               &  * inv_denom(:,1)
374          total_source_below = 0.0_jprb
375          total_source_below(:,1) = Sup(:,1,jlev) &
376               &  + transmittance(:,1,jlev)*(total_source(:,1,jlev+1) &
377               &  + total_albedo(:,1,jlev+1)*Sdn(:,1,jlev)) &
378               &  * inv_denom(:,1)
379        else
380          inv_denom = 1.0_jprb / (1.0_jprb - total_albedo(:,:,jlev+1)*reflectance(:,:,jlev))
381          total_albedo_below = reflectance(:,:,jlev) &
382               &  + transmittance(:,:,jlev)*transmittance(:,:,jlev)*total_albedo(:,:,jlev+1) &
383               &  * inv_denom
384          total_source_below = Sup(:,:,jlev) &
385               &  + transmittance(:,:,jlev)*(total_source(:,:,jlev+1) &
386               &  + total_albedo(:,:,jlev+1)*Sdn(:,:,jlev)) &
387               &  * inv_denom
388        end if
389
390        ! Account for cloud overlap when converting albedo below a
391        ! layer interface to the equivalent values just above
392        if (is_clear_sky_layer(jlev) .and. is_clear_sky_layer(jlev-1)) then
393          total_albedo(:,:,jlev) = total_albedo_below(:,:)
394          total_source(:,:,jlev) = total_source_below(:,:)
395        else
396          total_source(:,:,jlev) = singlemat_x_vec(ng,ng,nregions,&
397               &  u_matrix(:,:,jlev,jcol), total_source_below)
398          ! Use overlap matrix and exclude "anomalous" horizontal
399          ! transport described by Shonk & Hogan (2008).  Therefore,
400          ! the operation we perform is essentially diag(total_albedo)
401          ! = matmul(transpose(v_matrix), diag(total_albedo_below)).
402          do jreg = 1,nregions
403            do jreg2 = 1,nregions
404              total_albedo(:,jreg,jlev) &
405                   &  = total_albedo(:,jreg,jlev) &
406                   &  + total_albedo_below(:,jreg2) &
407                   &  * v_matrix(jreg2,jreg,jlev,jcol)
408
409            end do
410          end do
411
412        end if
413       
414      end do ! Reverse loop over levels
415
416      ! --------------------------------------------------------
417      ! Section 5: Compute fluxes
418      ! --------------------------------------------------------
419
420      ! Top-of-atmosphere fluxes into the regions of the top-most
421      ! layer, zero since we assume no diffuse downwelling
422      flux_dn = 0.0_jprb
423
424      if (config%do_clear) then
425        flux_dn_clear = 0.0_jprb
426      end if
427
428      ! Store the TOA broadband fluxes
429      flux%lw_up(jcol,1) = sum(total_source(:,:,1))
430      flux%lw_dn(jcol,1) = 0.0_jprb
431      if (config%do_clear) then
432        flux%lw_up_clear(jcol,1) = sum(total_source_clear(:,1))
433        flux%lw_dn_clear(jcol,1) = 0.0_jprb
434      end if
435
436      ! Save the spectral fluxes if required
437      if (config%do_save_spectral_flux) then
438        call indexed_sum(sum(total_source(:,:,1),2), &
439             &           config%i_spec_from_reordered_g_lw, &
440             &           flux%lw_up_band(:,jcol,1))
441        flux%lw_dn_band(:,jcol,1) = 0.0_jprb
442        if (config%do_clear) then
443          call indexed_sum(total_source_clear(:,1), &
444               &           config%i_spec_from_reordered_g_lw, &
445               &           flux%lw_up_clear_band(:,jcol,1))
446          flux%lw_dn_clear_band(:,jcol,1) = 0.0_jprb
447        end if
448      end if
449
450      ! Final loop back down through the atmosphere to compute fluxes
451      do jlev = 1,nlev
452        if (config%do_clear) then
453          flux_dn_clear = (transmittance(:,1,jlev)*flux_dn_clear &
454               &  + reflectance(:,1,jlev)*total_source_clear(:,jlev+1) + Sdn_clear(:,jlev) ) &
455               &  / (1.0_jprb - reflectance(:,1,jlev)*total_albedo_clear(:,jlev+1))
456          flux_up_clear = total_source_clear(:,jlev+1) &
457               &        + flux_dn_clear*total_albedo_clear(:,jlev+1)
458        end if
459
460        if (is_clear_sky_layer(jlev)) then
461          flux_dn(:,1) = (transmittance(:,1,jlev)*flux_dn(:,1) &
462               &       + reflectance(:,1,jlev)*total_source(:,1,jlev+1) + Sdn(:,1,jlev) ) &
463               &  / (1.0_jprb - reflectance(:,1,jlev)*total_albedo(:,1,jlev+1))
464          flux_dn(:,2:)  = 0.0_jprb
465          flux_up(:,1) = total_source(:,1,jlev+1) + flux_dn(:,1)*total_albedo(:,1,jlev+1)
466          flux_up(:,2:)  = 0.0_jprb
467        else
468          flux_dn = (transmittance(:,:,jlev)*flux_dn &
469               &     + reflectance(:,:,jlev)*total_source(:,:,jlev+1) + Sdn(:,:,jlev) ) &
470               &  / (1.0_jprb - reflectance(:,:,jlev)*total_albedo(:,:,jlev+1))
471          flux_up = total_source(:,:,jlev+1) + flux_dn*total_albedo(:,:,jlev+1)
472        end if
473
474        if (.not. (is_clear_sky_layer(jlev) &
475             &    .and. is_clear_sky_layer(jlev+1))) then
476          ! Account for overlap rules in translating fluxes just above
477          ! a layer interface to the values just below
478          flux_dn_below = singlemat_x_vec(ng,ng,nregions, &
479               &  v_matrix(:,:,jlev+1,jcol), flux_dn)
480          flux_dn = flux_dn_below
481        end if ! Otherwise the fluxes in each region are the same so
482               ! nothing to do
483
484        ! Store the broadband fluxes
485        flux%lw_up(jcol,jlev+1) = sum(sum(flux_up,1))
486        flux%lw_dn(jcol,jlev+1) = sum(sum(flux_dn,1))
487        if (config%do_clear) then
488          flux%lw_up_clear(jcol,jlev+1) = sum(flux_up_clear)
489          flux%lw_dn_clear(jcol,jlev+1) = sum(flux_dn_clear)
490        end if
491
492        ! Save the spectral fluxes if required
493        if (config%do_save_spectral_flux) then
494          call indexed_sum(sum(flux_up,2), &
495               &           config%i_spec_from_reordered_g_lw, &
496               &           flux%lw_up_band(:,jcol,jlev+1))
497          call indexed_sum(sum(flux_dn,2), &
498               &           config%i_spec_from_reordered_g_lw, &
499               &           flux%lw_dn_band(:,jcol,jlev+1))
500          if (config%do_clear) then
501            call indexed_sum(flux_up_clear, &
502                 &           config%i_spec_from_reordered_g_lw, &
503                 &           flux%lw_up_clear_band(:,jcol,jlev+1))
504            call indexed_sum(flux_dn_clear, &
505                 &           config%i_spec_from_reordered_g_lw, &
506                 &           flux%lw_dn_clear_band(:,jcol,jlev+1))
507          end if
508        end if
509
510      end do ! Final loop over levels
511     
512      ! Store surface spectral downwelling fluxes, which at this point
513      ! are at the surface
514      flux%lw_dn_surf_g(:,jcol) = sum(flux_dn,2)
515      if (config%do_clear) then
516        flux%lw_dn_surf_clear_g(:,jcol) = flux_dn_clear
517      end if
518
519      ! Compute the longwave derivatives needed by Hogan and Bozzo
520      ! (2015) approximate radiation update scheme
521      if (config%do_lw_derivatives) then
522        ! Note that at this point flux_up contains the spectral
523        ! fluxes into the regions of the lowest layer; we sum over
524        ! regions first to provide a simple spectral flux upwelling
525        ! from the surface
526        call calc_lw_derivatives_region(ng, nlev, nregions, jcol, transmittance, &
527             &  u_matrix(:,:,:,jcol), sum(flux_up,2), flux%lw_derivatives)
528      end if
529
530    end do ! Loop over columns
531
532    if (lhook) call dr_hook('radiation_tripleclouds_lw:solver_tripleclouds_lw',1,hook_handle)
533
534  end subroutine solver_tripleclouds_lw
535
536end module radiation_tripleclouds_lw
Note: See TracBrowser for help on using the repository browser.