GFS Physics Documentation
radlw_main.f
Go to the documentation of this file.
1 
4 
5 !!!!! ============================================================== !!!!!
6 !!!!! lw-rrtm3 radiation package description !!!!!
7 !!!!! ============================================================== !!!!!
8 ! !
9 ! this package includes ncep's modifications of the rrtm-lw radiation !
10 ! code from aer inc. !
11 ! !
12 ! the lw-rrtm3 package includes these parts: !
13 ! !
14 ! 'radlw_rrtm3_param.f' !
15 ! 'radlw_rrtm3_datatb.f' !
16 ! 'radlw_rrtm3_main.f' !
17 ! !
18 ! the 'radlw_rrtm3_param.f' contains: !
19 ! !
20 ! 'module_radlw_parameters' -- band parameters set up !
21 ! !
22 ! the 'radlw_rrtm3_datatb.f' contains: !
23 ! !
24 ! 'module_radlw_avplank' -- plank flux data !
25 ! 'module_radlw_ref' -- reference temperature and pressure !
26 ! 'module_radlw_cldprlw' -- cloud property coefficients !
27 ! 'module_radlw_kgbnn' -- absorption coeffients for 16 !
28 ! bands, where nn = 01-16 !
29 ! !
30 ! the 'radlw_rrtm3_main.f' contains: !
31 ! !
32 ! 'module_radlw_main' -- main lw radiation transfer !
33 ! !
34 ! in the main module 'module_radlw_main' there are only two !
35 ! externally callable subroutines: !
36 ! !
37 ! !
38 ! 'lwrad' -- main lw radiation routine !
39 ! inputs: !
40 ! (plyr,plvl,tlyr,tlvl,qlyr,olyr,gasvmr, !
41 ! clouds,icseed,aerosols,sfemis,sfgtmp, !
42 ! npts, nlay, nlp1, lprnt, !
43 ! outputs: !
44 ! hlwc,topflx,sfcflx, !
45 !! optional outputs: !
46 ! HLW0,HLWB,FLXPRF) !
47 ! !
48 ! 'rlwinit' -- initialization routine !
49 ! inputs: !
50 ! ( me ) !
51 ! outputs: !
52 ! (none) !
53 ! !
54 ! all the lw radiation subprograms become contained subprograms !
55 ! in module 'module_radlw_main' and many of them are not directly !
56 ! accessable from places outside the module. !
57 ! !
58 ! derived data type constructs used: !
59 ! !
60 ! 1. radiation flux at toa: (from module 'module_radlw_parameters') !
61 ! topflw_type - derived data type for toa rad fluxes !
62 ! upfxc total sky upward flux at toa !
63 ! upfx0 clear sky upward flux at toa !
64 ! !
65 ! 2. radiation flux at sfc: (from module 'module_radlw_parameters') !
66 ! sfcflw_type - derived data type for sfc rad fluxes !
67 ! upfxc total sky upward flux at sfc !
68 ! upfx0 clear sky upward flux at sfc !
69 ! dnfxc total sky downward flux at sfc !
70 ! dnfx0 clear sky downward flux at sfc !
71 ! !
72 ! 3. radiation flux profiles(from module 'module_radlw_parameters') !
73 ! proflw_type - derived data type for rad vertical prof !
74 ! upfxc level upward flux for total sky !
75 ! dnfxc level downward flux for total sky !
76 ! upfx0 level upward flux for clear sky !
77 ! dnfx0 level downward flux for clear sky !
78 ! !
79 ! external modules referenced: !
80 ! !
81 ! 'module physparam' !
82 ! 'module physcons' !
83 ! 'mersenne_twister' !
84 ! !
85 ! compilation sequence is: !
86 ! !
87 ! 'radlw_rrtm3_param.f' !
88 ! 'radlw_rrtm3_datatb.f' !
89 ! 'radlw_rrtm3_main.f' !
90 ! !
91 ! and all should be put in front of routines that use lw modules !
92 ! !
93 !==========================================================================!
94 ! !
95 ! the original aer's program declarations: !
96 ! !
97 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
98 ! |
99 ! Copyright 2002-2007, Atmospheric & Environmental Research, Inc. (AER). |
100 ! This software may be used, copied, or redistributed as long as it is |
101 ! not sold and this copyright notice is reproduced on each copy made. |
102 ! This model is provided as is without any express or implied warranties. |
103 ! (http://www.rtweb.aer.com/) |
104 ! |
105 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
106 ! !
107 ! ************************************************************************ !
108 ! !
109 ! rrtmg_lw !
110 ! !
111 ! !
112 ! a rapid radiative transfer model !
113 ! for the longwave region !
114 ! for application to general circulation models !
115 ! !
116 ! !
117 ! atmospheric and environmental research, inc. !
118 ! 131 hartwell avenue !
119 ! lexington, ma 02421 !
120 ! !
121 ! eli j. mlawer !
122 ! jennifer s. delamere !
123 ! michael j. iacono !
124 ! shepard a. clough !
125 ! !
126 ! !
127 ! email: miacono@aer.com !
128 ! email: emlawer@aer.com !
129 ! email: jdelamer@aer.com !
130 ! !
131 ! the authors wish to acknowledge the contributions of the !
132 ! following people: steven j. taubman, karen cady-pereira, !
133 ! patrick d. brown, ronald e. farren, luke chen, robert bergstrom. !
134 ! !
135 ! ************************************************************************ !
136 ! !
137 ! references: !
138 ! (rrtm_lw/rrtmg_lw): !
139 ! clough, s.A., m.w. shephard, e.j. mlawer, j.s. delamere, !
140 ! m.j. iacono, k. cady-pereira, s. boukabara, and p.d. brown: !
141 ! atmospheric radiative transfer modeling: a summary of the aer !
142 ! codes, j. quant. spectrosc. radiat. transfer, 91, 233-244, 2005. !
143 ! !
144 ! mlawer, e.j., s.j. taubman, p.d. brown, m.j. iacono, and s.a. !
145 ! clough: radiative transfer for inhomogeneous atmospheres: rrtm, !
146 ! a validated correlated-k model for the longwave. j. geophys. res., !
147 ! 102, 16663-16682, 1997. !
148 ! !
149 ! (mcica): !
150 ! pincus, r., h. w. barker, and j.-j. morcrette: a fast, flexible, !
151 ! approximation technique for computing radiative transfer in !
152 ! inhomogeneous cloud fields, j. geophys. res., 108(d13), 4376, !
153 ! doi:10.1029/2002JD003322, 2003. !
154 ! !
155 ! ************************************************************************ !
156 ! !
157 ! aer's revision history: !
158 ! this version of rrtmg_lw has been modified from rrtm_lw to use a !
159 ! reduced set of g-points for application to gcms. !
160 ! !
161 ! -- original version (derived from rrtm_lw), reduction of g-points, !
162 ! other revisions for use with gcms. !
163 ! 1999: m. j. iacono, aer, inc. !
164 ! -- adapted for use with ncar/cam3. !
165 ! may 2004: m. j. iacono, aer, inc. !
166 ! -- revised to add mcica capability. !
167 ! nov 2005: m. j. iacono, aer, inc. !
168 ! -- conversion to f90 formatting for consistency with rrtmg_sw. !
169 ! feb 2007: m. j. iacono, aer, inc. !
170 ! -- modifications to formatting to use assumed-shape arrays. !
171 ! aug 2007: m. j. iacono, aer, inc. !
172 ! !
173 ! ************************************************************************ !
174 ! !
175 ! ncep modifications history log: !
176 ! !
177 ! nov 1999, ken campana -- received the original code from !
178 ! aer (1998 ncar ccm version), updated to link up with !
179 ! ncep mrf model !
180 ! jun 2000, ken campana -- added option to switch random and !
181 ! maximum/random cloud overlap !
182 ! 2001, shrinivas moorthi -- further updates for mrf model !
183 ! may 2001, yu-tai hou -- updated on trace gases and cloud !
184 ! property based on rrtm_v3.0 codes. !
185 ! dec 2001, yu-tai hou -- rewritten code into fortran 90 std !
186 ! set ncep radiation structure standard that contains !
187 ! three plug-in compatable fortran program files: !
188 ! 'radlw_param.f', 'radlw_datatb.f', 'radlw_main.f' !
189 ! fixed bugs in subprograms taugb14, taugb2, etc. added !
190 ! out-of-bounds protections. (a detailed note of !
191 ! up_to_date modifications/corrections by ncep was sent !
192 ! to aer in 2002) !
193 ! jun 2004, yu-tai hou -- added mike iacono's apr 2004 !
194 ! modification of variable diffusivity angles. !
195 ! apr 2005, yu-tai hou -- minor modifications on module !
196 ! structures include rain/snow effect (this version of !
197 ! code was given back to aer in jun 2006) !
198 ! mar 2007, yu-tai hou -- added aerosol effect for ncep !
199 ! models using the generallized aerosol optical property!
200 ! scheme for gfs model. !
201 ! apr 2007, yu-tai hou -- added spectral band heating as an !
202 ! optional output to support the 500 km gfs model's !
203 ! upper stratospheric radiation calculations. and !
204 ! restructure optional outputs for easy access by !
205 ! different models. !
206 ! oct 2008, yu-tai hou -- modified to include new features !
207 ! from aer's newer release v4.4-v4.7, including the !
208 ! mcica sub-grid cloud option. add rain/snow optical !
209 ! properties support to cloudy sky calculations. !
210 ! correct errors in mcica cloud optical properties for !
211 ! ebert & curry scheme (ilwcice=1) that needs band !
212 ! index conversion. simplified and unified sw and lw !
213 ! sub-column cloud subroutines into one module by using !
214 ! optional parameters. !
215 ! mar 2009, yu-tai hou -- replaced the original random number!
216 ! generator coming from the original code with ncep w3 !
217 ! library to simplify the program and moved sub-column !
218 ! cloud subroutines inside the main module. added !
219 ! option of user provided permutation seeds that could !
220 ! be randomly generated from forecast time stamp. !
221 ! oct 2009, yu-tai hou -- modified subrtines "cldprop" and !
222 ! "rlwinit" according updats from aer's rrtmg_lw v4.8. !
223 ! nov 2009, yu-tai hou -- modified subrtine "taumol" according
224 ! updats from aer's rrtmg_lw version 4.82. notice the !
225 ! cloud ice/liquid are assumed as in-cloud quantities, !
226 ! not as grid averaged quantities. !
227 ! jun 2010, yu-tai hou -- optimized code to improve efficiency
228 ! apr 2012, b. ferrier and y. hou -- added conversion factor to fu's!
229 ! cloud-snow optical property scheme. !
230 ! nov 2012, yu-tai hou -- modified control parameters thru !
231 ! module 'physparam'. !
232 ! FEB 2017 A.Cheng - add odpth output, effective radius input !
233 ! !
234 ! !
235 !!!!! ============================================================== !!!!!
236 !!!!! end descriptions !!!!!
237 !!!!! ============================================================== !!!!!
238 
239 
279 !========================================!
280  module module_radlw_main !
281 !........................................!
282 !
283  use physparam, only : ilwrate, ilwrgas, ilwcliq, ilwcice, &
284  & isubclw, icldflg, iovrlw, ivflip, &
285  & kind_phys
286  use physcons, only : con_g, con_cp, con_avgd, con_amd, &
287  & con_amw, con_amo3
288  use mersenne_twister, only : random_setseed, random_number, &
289  & random_stat
290 
292 !
293  use module_radlw_avplank, only : totplnk
294  use module_radlw_ref, only : preflog, tref, chi_mls
295 !
296  implicit none
297 !
298  private
299 !
300 ! ... version tag and last revision date
301  character(40), parameter :: &
302  & VTAGLW='NCEP LW v5.1 Nov 2012 -RRTMG-LW v4.82 '
303 ! & VTAGLW='NCEP LW v5.0 Aug 2012 -RRTMG-LW v4.82 '
304 ! & VTAGLW='RRTMG-LW v4.82 Nov 2009 '
305 ! & VTAGLW='RRTMG-LW v4.8 Oct 2009 '
306 ! & VTAGLW='RRTMG-LW v4.71 Mar 2009 '
307 ! & VTAGLW='RRTMG-LW v4.4 Oct 2008 '
308 ! & VTAGLW='RRTM-LW v2.3g Mar 2007 '
309 ! & VTAGLW='RRTM-LW v2.3g Apr 2004 '
310 
311 ! --- constant values
312  real (kind=kind_phys), parameter :: eps = 1.0e-6
313  real (kind=kind_phys), parameter :: oneminus= 1.0-eps
314  real (kind=kind_phys), parameter :: cldmin = 1.0e-80
315  real (kind=kind_phys), parameter :: bpade = 1.0/0.278 ! pade approx constant
316  real (kind=kind_phys), parameter :: stpfac = 296.0/1013.0
317  real (kind=kind_phys), parameter :: wtdiff = 0.5 ! weight for radiance to flux conversion
318  real (kind=kind_phys), parameter :: tblint = ntbl ! lookup table conversion factor
319  real (kind=kind_phys), parameter :: f_zero = 0.0
320  real (kind=kind_phys), parameter :: f_one = 1.0
321 
322 ! ... atomic weights for conversion from mass to volume mixing ratios
323  real (kind=kind_phys), parameter :: amdw = con_amd/con_amw
324  real (kind=kind_phys), parameter :: amdo3 = con_amd/con_amo3
325 
326 ! ... band indices
327  integer, dimension(nbands) :: nspa, nspb
328 
329  data nspa / 1, 1, 9, 9, 9, 1, 9, 1, 9, 1, 1, 9, 9, 1, 9, 9 /
330  data nspb / 1, 1, 5, 5, 5, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0 /
331 
332 ! ... band wavenumber intervals
333 ! real (kind=kind_phys) :: wavenum1(nbands), wavenum2(nbands)
334 ! data wavenum1/ &
335 ! & 10., 350., 500., 630., 700., 820., 980., 1080., &
336 !err & 1180., 1390., 1480., 1800., 2080., 2250., 2390., 2600. /
337 ! & 1180., 1390., 1480., 1800., 2080., 2250., 2380., 2600. /
338 ! data wavenum2/ &
339 ! & 350., 500., 630., 700., 820., 980., 1080., 1180., &
340 !err & 1390., 1480., 1800., 2080., 2250., 2390., 2600., 3250. /
341 ! & 1390., 1480., 1800., 2080., 2250., 2380., 2600., 3250. /
342 ! real (kind=kind_phys) :: delwave(nbands)
343 ! data delwave / 340., 150., 130., 70., 120., 160., 100., 100., &
344 ! & 210., 90., 320., 280., 170., 130., 220., 650. /
345 
346 ! --- reset diffusivity angle for Bands 2-3 and 5-9 to vary (between 1.50
347 ! and 1.80) as a function of total column water vapor. the function
348 ! has been defined to minimize flux and cooling rate errors in these bands
349 ! over a wide range of precipitable water values.
350  real (kind=kind_phys), dimension(nbands) :: a0, a1, a2
351 
352  data a0 / 1.66, 1.55, 1.58, 1.66, 1.54, 1.454, 1.89, 1.33, &
353  & 1.668, 1.66, 1.66, 1.66, 1.66, 1.66, 1.66, 1.66 /
354  data a1 / 0.00, 0.25, 0.22, 0.00, 0.13, 0.446, -0.10, 0.40, &
355  & -0.006, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 /
356  data a2 / 0.00, -12.0, -11.7, 0.00, -0.72,-0.243, 0.19,-0.062, &
357  & 0.414, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 /
358 
359 !! --- logical flags for optional output fields
360 
361  logical :: lhlwb = .false.
362  logical :: lhlw0 = .false.
363  logical :: lflxprf= .false.
364 
365 ! --- those data will be set up only once by "rlwinit"
366 
367 ! ... fluxfac, heatfac are factors for fluxes (in w/m**2) and heating
368 ! rates (in k/day, or k/sec set by subroutine 'rlwinit')
369 ! semiss0 are default surface emissivity for each bands
370 
371  real (kind=kind_phys) :: fluxfac, heatfac, semiss0(nbands)
372  data semiss0(:) / nbands*1.0 /
373 
374  real (kind=kind_phys) :: tau_tbl(0:ntbl) !clr-sky opt dep (for cldy transfer)
375  real (kind=kind_phys) :: exp_tbl(0:ntbl) !transmittance lookup table
376  real (kind=kind_phys) :: tfn_tbl(0:ntbl) !tau transition function; i.e. the
377  !transition of planck func from mean lyr
378  !temp to lyr boundary temp as a func of
379  !opt dep. "linear in tau" method is used.
380 
381 ! --- the following variables are used for sub-column cloud scheme
382 
383  integer, parameter :: ipsdlw0 = ngptlw ! initial permutation seed
384 
385 ! --- public accessable subprograms
386 
387  public lwrad, rlwinit
388 
389 
390 ! ================
391  contains
392 ! ================
393 
455 ! --------------------------------
456  subroutine lwrad &
457  & ( plyr,plvl,tlyr,tlvl,qlyr,olyr,gasvmr, & ! --- inputs
458  & clouds,icseed,aerosols,sfemis,sfgtmp, &
459  & npts, nlay, nlp1, lprnt, &
460  & hlwc,topflx,sfcflx, & ! --- outputs
461  & hlw0,hlwb,flxprf & !! --- optional
462  & )
464 ! ==================== defination of variables ==================== !
465 ! !
466 ! input variables: !
467 ! plyr (npts,nlay) : layer mean pressures (mb) !
468 ! plvl (npts,nlp1) : interface pressures (mb) !
469 ! tlyr (npts,nlay) : layer mean temperature (k) !
470 ! tlvl (npts,nlp1) : interface temperatures (k) !
471 ! qlyr (npts,nlay) : layer specific humidity (gm/gm) *see inside !
472 ! olyr (npts,nlay) : layer ozone concentration (gm/gm) *see inside !
473 ! gasvmr(npts,nlay,:): atmospheric gases amount: !
474 ! (check module_radiation_gases for definition) !
475 ! gasvmr(:,:,1) - co2 volume mixing ratio !
476 ! gasvmr(:,:,2) - n2o volume mixing ratio !
477 ! gasvmr(:,:,3) - ch4 volume mixing ratio !
478 ! gasvmr(:,:,4) - o2 volume mixing ratio !
479 ! gasvmr(:,:,5) - co volume mixing ratio !
480 ! gasvmr(:,:,6) - cfc11 volume mixing ratio !
481 ! gasvmr(:,:,7) - cfc12 volume mixing ratio !
482 ! gasvmr(:,:,8) - cfc22 volume mixing ratio !
483 ! gasvmr(:,:,9) - ccl4 volume mixing ratio !
484 ! clouds(npts,nlay,:): layer cloud profiles: !
485 ! (check module_radiation_clouds for definition) !
486 ! --- for ilwcliq > 0 --- !
487 ! clouds(:,:,1) - layer total cloud fraction !
488 ! clouds(:,:,2) - layer in-cloud liq water path (g/m**2) !
489 ! clouds(:,:,3) - mean eff radius for liq cloud (micron) !
490 ! clouds(:,:,4) - layer in-cloud ice water path (g/m**2) !
491 ! clouds(:,:,5) - mean eff radius for ice cloud (micron) !
492 ! clouds(:,:,6) - layer rain drop water path (g/m**2) !
493 ! clouds(:,:,7) - mean eff radius for rain drop (micron) !
494 ! clouds(:,:,8) - layer snow flake water path (g/m**2) !
495 ! clouds(:,:,9) - mean eff radius for snow flake (micron) !
496 ! --- for ilwcliq = 0 --- !
497 ! clouds(:,:,1) - layer total cloud fraction !
498 ! clouds(:,:,2) - layer cloud optical depth !
499 ! clouds(:,:,3) - layer cloud single scattering albedo !
500 ! clouds(:,:,4) - layer cloud asymmetry factor !
501 ! icseed(npts) : auxiliary special cloud related array !
502 ! when module variable isubclw=2, it provides !
503 ! permutation seed for each column profile that !
504 ! are used for generating random numbers. !
505 ! when isubclw /=2, it will not be used. !
506 ! aerosols(npts,nlay,nbands,:) : aerosol optical properties !
507 ! (check module_radiation_aerosols for definition)!
508 ! (:,:,:,1) - optical depth !
509 ! (:,:,:,2) - single scattering albedo !
510 ! (:,:,:,3) - asymmetry parameter !
511 ! sfemis (npts) : surface emissivity !
512 ! sfgtmp (npts) : surface ground temperature (k) !
513 ! npts : total number of horizontal points !
514 ! nlay, nlp1 : total number of vertical layers, levels !
515 ! lprnt : cntl flag for diagnostic print out !
516 ! !
517 ! output variables: !
518 ! hlwc (npts,nlay): total sky heating rate (k/day or k/sec) !
519 ! topflx(npts) : radiation fluxes at top, component: !
520 ! (check module_radlw_paramters for definition) !
521 ! upfxc - total sky upward flux at top (w/m2) !
522 ! upfx0 - clear sky upward flux at top (w/m2) !
523 ! sfcflx(npts) : radiation fluxes at sfc, component: !
524 ! (check module_radlw_paramters for definition) !
525 ! upfxc - total sky upward flux at sfc (w/m2) !
526 ! upfx0 - clear sky upward flux at sfc (w/m2) !
527 ! dnfxc - total sky downward flux at sfc (w/m2) !
528 ! dnfx0 - clear sky downward flux at sfc (w/m2) !
529 ! !
530 !! optional output variables: !
531 ! hlwb(npts,nlay,nbands): spectral band total sky heating rates !
532 ! hlw0 (npts,nlay): clear sky heating rate (k/day or k/sec) !
533 ! flxprf(npts,nlp1): level radiative fluxes (w/m2), components: !
534 ! (check module_radlw_paramters for definition) !
535 ! upfxc - total sky upward flux !
536 ! dnfxc - total sky dnward flux !
537 ! upfx0 - clear sky upward flux !
538 ! dnfx0 - clear sky dnward flux !
539 ! !
540 ! external module variables: (in physparam) !
541 ! ilwrgas - control flag for rare gases (ch4,n2o,o2,cfcs, etc.) !
542 ! =0: do not include rare gases !
543 ! >0: include all rare gases !
544 ! ilwcliq - control flag for liq-cloud optical properties !
545 ! =0: input cloud optical depth, ignor ilwcice !
546 ! =1: input cld liqp & reliq, hu & stamnes (1993) !
547 ! =2: not used !
548 ! ilwcice - control flag for ice-cloud optical properties !
549 ! *** if ilwcliq==0, ilwcice is ignored !
550 ! =1: input cld icep & reice, ebert & curry (1997) !
551 ! =2: input cld icep & reice, streamer (1996) !
552 ! =3: input cld icep & reice, fu (1998) !
553 ! isubclw - sub-column cloud approximation control flag !
554 ! =0: no sub-col cld treatment, use grid-mean cld quantities !
555 ! =1: mcica sub-col, prescribed seeds to get random numbers !
556 ! =2: mcica sub-col, providing array icseed for random numbers!
557 ! iovrlw - cloud overlapping control flag !
558 ! =0: random overlapping clouds !
559 ! =1: maximum/random overlapping clouds !
560 ! =2: maximum overlap cloud (used for isubclw>0 only) !
561 ! ivflip - control flag for vertical index direction !
562 ! =0: vertical index from toa to surface !
563 ! =1: vertical index from surface to toa !
564 ! !
565 ! module parameters, control variables: !
566 ! nbands - number of longwave spectral bands !
567 ! maxgas - maximum number of absorbing gaseous !
568 ! maxxsec - maximum number of cross-sections !
569 ! ngptlw - total number of g-point subintervals !
570 ! ng## - number of g-points in band (##=1-16) !
571 ! ngb(ngptlw) - band indices for each g-point !
572 ! bpade - pade approximation constant (1/0.278) !
573 ! nspa,nspb(nbands)- number of lower/upper ref atm's per band !
574 ! delwave(nbands) - longwave band width (wavenumbers) !
575 ! ipsdlw0 - permutation seed for mcica sub-col clds !
576 ! !
577 ! major local variables: !
578 ! pavel (nlay) - layer pressures (mb) !
579 ! delp (nlay) - layer pressure thickness (mb) !
580 ! tavel (nlay) - layer temperatures (k) !
581 ! tz (0:nlay) - level (interface) temperatures (k) !
582 ! semiss (nbands) - surface emissivity for each band !
583 ! wx (nlay,maxxsec) - cross-section molecules concentration !
584 ! coldry (nlay) - dry air column amount !
585 ! (1.e-20*molecules/cm**2) !
586 ! cldfrc (0:nlp1) - layer cloud fraction !
587 ! taucld (nbands,nlay) - layer cloud optical depth for each band !
588 ! cldfmc (ngptlw,nlay) - layer cloud fraction for each g-point !
589 ! tauaer (nbands,nlay) - aerosol optical depths !
590 ! fracs (ngptlw,nlay) - planck fractions !
591 ! tautot (ngptlw,nlay) - total optical depths (gaseous+aerosols) !
592 ! colamt (nlay,maxgas) - column amounts of absorbing gases !
593 ! 1-maxgas are for watervapor, carbon !
594 ! dioxide, ozone, nitrous oxide, methane, !
595 ! oxigen, carbon monoxide, respectively !
596 ! (molecules/cm**2) !
597 ! pwvcm - column precipitable water vapor (cm) !
598 ! secdiff(nbands) - variable diffusivity angle defined as !
599 ! an exponential function of the column !
600 ! water amount in bands 2-3 and 5-9. !
601 ! this reduces the bias of several w/m2 in !
602 ! downward surface flux in high water !
603 ! profiles caused by using the constant !
604 ! diffusivity angle of 1.66. (mji) !
605 ! facij (nlay) - indicator of interpolation factors !
606 ! =0/1: indicate lower/higher temp & height !
607 ! selffac(nlay) - scale factor for self-continuum, equals !
608 ! (w.v. density)/(atm density at 296K,1013 mb) !
609 ! selffrac(nlay) - factor for temp interpolation of ref !
610 ! self-continuum data !
611 ! indself(nlay) - index of the lower two appropriate ref !
612 ! temp for the self-continuum interpolation !
613 ! forfac (nlay) - scale factor for w.v. foreign-continuum !
614 ! forfrac(nlay) - factor for temp interpolation of ref !
615 ! w.v. foreign-continuum data !
616 ! indfor (nlay) - index of the lower two appropriate ref !
617 ! temp for the foreign-continuum interp !
618 ! laytrop - tropopause layer index at which switch is !
619 ! made from one conbination kew species to !
620 ! another. !
621 ! jp(nlay),jt(nlay),jt1(nlay) !
622 ! - lookup table indexes !
623 ! totuflux(0:nlay) - total-sky upward longwave flux (w/m2) !
624 ! totdflux(0:nlay) - total-sky downward longwave flux (w/m2) !
625 ! htr(nlay) - total-sky heating rate (k/day or k/sec) !
626 ! totuclfl(0:nlay) - clear-sky upward longwave flux (w/m2) !
627 ! totdclfl(0:nlay) - clear-sky downward longwave flux (w/m2) !
628 ! htrcl(nlay) - clear-sky heating rate (k/day or k/sec) !
629 ! fnet (0:nlay) - net longwave flux (w/m2) !
630 ! fnetc (0:nlay) - clear-sky net longwave flux (w/m2) !
631 ! !
632 ! !
633 ! ====================== end of definitions =================== !
634 
635 ! --- inputs:
636  integer, intent(in) :: npts, nlay, nlp1
637  integer, intent(in) :: icseed(npts)
638 
639  logical, intent(in) :: lprnt
640 
641  real (kind=kind_phys), dimension(npts,nlp1), intent(in) :: plvl, &
642  & tlvl
643  real (kind=kind_phys), dimension(npts,nlay), intent(in) :: plyr, &
644  & tlyr, qlyr, olyr
645 
646  real (kind=kind_phys), dimension(npts,nlay,9), intent(in):: gasvmr
647  real (kind=kind_phys), dimension(npts,nlay,11) :: clouds
648 
649  real (kind=kind_phys), dimension(npts), intent(in) :: sfemis, &
650  & sfgtmp
651 
652  real (kind=kind_phys), dimension(npts,nlay,nbands,3),intent(in):: &
653  & aerosols
654 
655 ! --- outputs:
656  real (kind=kind_phys), dimension(npts,nlay), intent(out) :: hlwc
657 
658  type(topflw_type), dimension(npts), intent(out) :: topflx
659  type(sfcflw_type), dimension(npts), intent(out) :: sfcflx
660 
661 !! --- optional outputs:
662  real (kind=kind_phys), dimension(npts,nlay,nbands),optional, &
663  & intent(out) :: hlwb
664  real (kind=kind_phys), dimension(npts,nlay), optional, &
665  & intent(out) :: hlw0
666  type (proflw_type), dimension(npts,nlp1), optional, &
667  & intent(out) :: flxprf
668 
669 ! --- locals:
670  real (kind=kind_phys), dimension(0:nlp1) :: cldfrc
671 
672  real (kind=kind_phys), dimension(0:nlay) :: totuflux, totdflux, &
673  & totuclfl, totdclfl, tz
674 
675  real (kind=kind_phys), dimension(nlay) :: htr, htrcl
676 
677  real (kind=kind_phys), dimension(nlay) :: pavel, tavel, delp, &
678  & clwp, ciwp, relw, reiw, cda1, cda2, cda3, cda4, &
679  & coldry, colbrd, h2ovmr, o3vmr, fac00, fac01, fac10, fac11, &
680  & selffac, selffrac, forfac, forfrac, minorfrac, scaleminor, &
681  & scaleminorn2, temcol
682 
683  real (kind=kind_phys), dimension(nbands,0:nlay) :: pklev, pklay
684 
685  real (kind=kind_phys), dimension(nlay,nbands) :: htrb
686  real (kind=kind_phys), dimension(nbands,nlay) :: taucld, tauaer
687  real (kind=kind_phys), dimension(ngptlw,nlay) :: fracs, tautot, &
688  & cldfmc
689 
690  real (kind=kind_phys), dimension(nbands) :: semiss, secdiff
691 
692 ! --- column amount of absorbing gases:
693 ! (:,m) m = 1-h2o, 2-co2, 3-o3, 4-n2o, 5-ch4, 6-o2, 7-co
694  real (kind=kind_phys) :: colamt(nlay,maxgas)
695 
696 ! --- column cfc cross-section amounts:
697 ! (:,m) m = 1-ccl4, 2-cfc11, 3-cfc12, 4-cfc22
698  real (kind=kind_phys) :: wx(nlay,maxxsec)
699 
700 ! --- reference ratios of binary species parameter in lower atmosphere:
701 ! (:,m,:) m = 1-h2o/co2, 2-h2o/o3, 3-h2o/n2o, 4-h2o/ch4, 5-n2o/co2, 6-o3/co2
702  real (kind=kind_phys) :: rfrate(nlay,nrates,2)
703 
704  real (kind=kind_phys) :: tem0, tem1, tem2, pwvcm, summol, stemp
705 
706  integer, dimension(npts) :: ipseed
707  integer, dimension(nlay) :: jp, jt, jt1, indself, indfor, indminor
708  integer :: laytrop, iplon, i, j, k, k1
709  logical :: lcf1
710 
711 !
712 !===> ... begin here
713 !
714 
715 ! --- ... initialization
716 
717  lhlwb = present ( hlwb )
718  lhlw0 = present ( hlw0 )
719  lflxprf= present ( flxprf )
720 
721 
722  colamt(:,:) = f_zero
723 
726 
727  if ( isubclw == 1 ) then ! advance prescribed permutation seed
728  do i = 1, npts
729  ipseed(i) = ipsdlw0 + i
730  enddo
731  elseif ( isubclw == 2 ) then ! use input array of permutaion seeds
732  do i = 1, npts
733  ipseed(i) = icseed(i)
734  enddo
735  endif
736 
737 ! if ( lprnt ) then
738 ! print *,' In radlw, isubclw, ipsdlw0,ipseed =', &
739 ! & isubclw, ipsdlw0, ipseed
740 ! endif
741 
742 ! --- ... loop over horizontal npts profiles
743 
744  lab_do_iplon : do iplon = 1, npts
745 
747  if (sfemis(iplon) > eps .and. sfemis(iplon) <= 1.0) then ! input surface emissivity
748  do j = 1, nbands
749  semiss(j) = sfemis(iplon)
750  enddo
751  else ! use default values
752  do j = 1, nbands
753  semiss(j) = semiss0(j)
754  enddo
755  endif
756 
757  stemp = sfgtmp(iplon) ! surface ground temp
758 
760 ! the vertical index of internal array is from surface to top
761 
762 ! --- ... molecular amounts are input or converted to volume mixing ratio
763 ! and later then converted to molecular amount (molec/cm2) by the
764 ! dry air column coldry (in molec/cm2) which is calculated from the
765 ! layer pressure thickness (in mb), based on the hydrostatic equation
766 ! --- ... and includes a correction to account for h2o in the layer.
767 
768  if (ivflip == 0) then ! input from toa to sfc
769 
770  tem1 = 100.0 * con_g
771  tem2 = 1.0e-20 * 1.0e3 * con_avgd
772  tz(0) = tlvl(iplon,nlp1)
773 
774  do k = 1, nlay
775  k1 = nlp1 - k
776  pavel(k)= plyr(iplon,k1)
777  delp(k) = plvl(iplon,k1+1) - plvl(iplon,k1)
778  tavel(k)= tlyr(iplon,k1)
779  tz(k) = tlvl(iplon,k1)
780 
782 
783 !test use
784 ! h2ovmr(k)= max(f_zero,qlyr(iplon,k1)*amdw) ! input mass mixing ratio
785 ! h2ovmr(k)= max(f_zero,qlyr(iplon,k1)) ! input vol mixing ratio
786 ! o3vmr (k)= max(f_zero,olyr(iplon,k1)) ! input vol mixing ratio
787 !ncep model use
788  h2ovmr(k)= max(f_zero,qlyr(iplon,k1) &
789  & *amdw/(f_one-qlyr(iplon,k1))) ! input specific humidity
790  o3vmr(k)= max(f_zero,olyr(iplon,k1)*amdo3) ! input mass mixing ratio
791 
792 ! --- ... tem0 is the molecular weight of moist air
793  tem0 = (f_one - h2ovmr(k))*con_amd + h2ovmr(k)*con_amw
794  coldry(k) = tem2*delp(k) / (tem1*tem0*(f_one+h2ovmr(k)))
795  temcol(k) = 1.0e-12 * coldry(k)
796 
797  colamt(k,1) = max(f_zero, coldry(k)*h2ovmr(k)) ! h2o
798  colamt(k,2) = max(temcol(k), coldry(k)*gasvmr(iplon,k1,1)) ! co2
799  colamt(k,3) = max(temcol(k), coldry(k)*o3vmr(k)) ! o3
800  enddo
801 
805 
806  if (ilwrgas > 0) then
807  do k = 1, nlay
808  k1 = nlp1 - k
809  colamt(k,4)=max(temcol(k), coldry(k)*gasvmr(iplon,k1,2)) ! n2o
810  colamt(k,5)=max(temcol(k), coldry(k)*gasvmr(iplon,k1,3)) ! ch4
811  colamt(k,6)=max(f_zero, coldry(k)*gasvmr(iplon,k1,4)) ! o2
812  colamt(k,7)=max(f_zero, coldry(k)*gasvmr(iplon,k1,5)) ! co
813 
814  wx(k,1) = max( f_zero, coldry(k)*gasvmr(iplon,k1,9) ) ! ccl4
815  wx(k,2) = max( f_zero, coldry(k)*gasvmr(iplon,k1,6) ) ! cf11
816  wx(k,3) = max( f_zero, coldry(k)*gasvmr(iplon,k1,7) ) ! cf12
817  wx(k,4) = max( f_zero, coldry(k)*gasvmr(iplon,k1,8) ) ! cf22
818  enddo
819  else
820  do k = 1, nlay
821  colamt(k,4) = f_zero ! n2o
822  colamt(k,5) = f_zero ! ch4
823  colamt(k,6) = f_zero ! o2
824  colamt(k,7) = f_zero ! co
825 
826  wx(k,1) = f_zero
827  wx(k,2) = f_zero
828  wx(k,3) = f_zero
829  wx(k,4) = f_zero
830  enddo
831  endif
832 
834 
835  do k = 1, nlay
836  k1 = nlp1 - k
837  do j = 1, nbands
838  tauaer(j,k) = aerosols(iplon,k1,j,1) &
839  & * (f_one - aerosols(iplon,k1,j,2))
840  enddo
841  enddo
842 
844  if (ilwcliq > 0) then ! use prognostic cloud method
845  do k = 1, nlay
846  k1 = nlp1 - k
847  cldfrc(k)= clouds(iplon,k1,1)
848  clwp(k) = clouds(iplon,k1,2)
849  relw(k) = clouds(iplon,k1,3)
850  ciwp(k) = clouds(iplon,k1,4)
851  reiw(k) = clouds(iplon,k1,5)
852  cda1(k) = clouds(iplon,k1,6)
853  cda2(k) = clouds(iplon,k1,7)
854  cda3(k) = clouds(iplon,k1,8)
855  cda4(k) = clouds(iplon,k1,9)
856  enddo
857  else ! use diagnostic cloud method
858  do k = 1, nlay
859  k1 = nlp1 - k
860  cldfrc(k)= clouds(iplon,k1,1)
861  cda1(k) = clouds(iplon,k1,2)
862  enddo
863  endif ! end if_ilwcliq
864 
865  cldfrc(0) = f_one ! padding value only
866  cldfrc(nlp1) = f_zero ! padding value only
867 
869 
870  tem1 = f_zero
871  tem2 = f_zero
872  do k = 1, nlay
873  tem1 = tem1 + coldry(k) + colamt(k,1)
874  tem2 = tem2 + colamt(k,1)
875  enddo
876 
877  tem0 = 10.0 * tem2 / (amdw * tem1 * con_g)
878  pwvcm = tem0 * plvl(iplon,nlp1)
879 
880  else ! input from sfc to toa
881 
882  tem1 = 100.0 * con_g
883  tem2 = 1.0e-20 * 1.0e3 * con_avgd
884  tz(0) = tlvl(iplon,1)
885 
886  do k = 1, nlay
887  pavel(k)= plyr(iplon,k)
888  delp(k) = plvl(iplon,k) - plvl(iplon,k+1)
889  tavel(k)= tlyr(iplon,k)
890  tz(k) = tlvl(iplon,k+1)
891 
892 ! --- ... set absorber amount
893 !test use
894 ! h2ovmr(k)= max(f_zero,qlyr(iplon,k)*amdw) ! input mass mixing ratio
895 ! h2ovmr(k)= max(f_zero,qlyr(iplon,k)) ! input vol mixing ratio
896 ! o3vmr (k)= max(f_zero,olyr(iplon,k)) ! input vol mixing ratio
897 !ncep model use
898  h2ovmr(k)= max(f_zero,qlyr(iplon,k) &
899  & *amdw/(f_one-qlyr(iplon,k))) ! input specific humidity
900  o3vmr(k)= max(f_zero,olyr(iplon,k)*amdo3) ! input mass mixing ratio
901 
902 ! --- ... tem0 is the molecular weight of moist air
903  tem0 = (f_one - h2ovmr(k))*con_amd + h2ovmr(k)*con_amw
904  coldry(k) = tem2*delp(k) / (tem1*tem0*(f_one+h2ovmr(k)))
905  temcol(k) = 1.0e-12 * coldry(k)
906 
907  colamt(k,1) = max(f_zero, coldry(k)*h2ovmr(k)) ! h2o
908  colamt(k,2) = max(temcol(k), coldry(k)*gasvmr(iplon,k,1)) ! co2
909  colamt(k,3) = max(temcol(k), coldry(k)*o3vmr(k)) ! o3
910  enddo
911 
912 ! --- ... set up col amount for rare gases, convert from volume mixing ratio
913 ! to molec/cm2 based on coldry (scaled to 1.0e-20)
914 
915  if (ilwrgas > 0) then
916  do k = 1, nlay
917  colamt(k,4)=max(temcol(k), coldry(k)*gasvmr(iplon,k,2)) ! n2o
918  colamt(k,5)=max(temcol(k), coldry(k)*gasvmr(iplon,k,3)) ! ch4
919  colamt(k,6)=max(f_zero, coldry(k)*gasvmr(iplon,k,4)) ! o2
920  colamt(k,7)=max(f_zero, coldry(k)*gasvmr(iplon,k,5)) ! co
921 
922  wx(k,1) = max( f_zero, coldry(k)*gasvmr(iplon,k,9) ) ! ccl4
923  wx(k,2) = max( f_zero, coldry(k)*gasvmr(iplon,k,6) ) ! cf11
924  wx(k,3) = max( f_zero, coldry(k)*gasvmr(iplon,k,7) ) ! cf12
925  wx(k,4) = max( f_zero, coldry(k)*gasvmr(iplon,k,8) ) ! cf22
926  enddo
927  else
928  do k = 1, nlay
929  colamt(k,4) = f_zero ! n2o
930  colamt(k,5) = f_zero ! ch4
931  colamt(k,6) = f_zero ! o2
932  colamt(k,7) = f_zero ! co
933 
934  wx(k,1) = f_zero
935  wx(k,2) = f_zero
936  wx(k,3) = f_zero
937  wx(k,4) = f_zero
938  enddo
939  endif
940 
941 ! --- ... set aerosol optical properties
942 
943  do j = 1, nbands
944  do k = 1, nlay
945  tauaer(j,k) = aerosols(iplon,k,j,1) &
946  & * (f_one - aerosols(iplon,k,j,2))
947  enddo
948  enddo
949 
950  if (ilwcliq > 0) then ! use prognostic cloud method
951  do k = 1, nlay
952  cldfrc(k)= clouds(iplon,k,1)
953  clwp(k) = clouds(iplon,k,2)
954  relw(k) = clouds(iplon,k,3)
955  ciwp(k) = clouds(iplon,k,4)
956  reiw(k) = clouds(iplon,k,5)
957  cda1(k) = clouds(iplon,k,6)
958  cda2(k) = clouds(iplon,k,7)
959  cda3(k) = clouds(iplon,k,8)
960  cda4(k) = clouds(iplon,k,9)
961  enddo
962  else ! use diagnostic cloud method
963  do k = 1, nlay
964  cldfrc(k)= clouds(iplon,k,1)
965  cda1(k) = clouds(iplon,k,2)
966  enddo
967  endif ! end if_ilwcliq
968 
969  cldfrc(0) = f_one ! padding value only
970  cldfrc(nlp1) = f_zero ! padding value only
971 
972 ! --- ... compute precipitable water vapor for diffusivity angle adjustments
973 
974  tem1 = f_zero
975  tem2 = f_zero
976  do k = 1, nlay
977  tem1 = tem1 + coldry(k) + colamt(k,1)
978  tem2 = tem2 + colamt(k,1)
979  enddo
980 
981  tem0 = 10.0 * tem2 / (amdw * tem1 * con_g)
982  pwvcm = tem0 * plvl(iplon,1)
983 
984  endif ! if_ivflip
985 
987 
988  do k = 1, nlay
989  summol = f_zero
990  do i = 2, maxgas
991  summol = summol + colamt(k,i)
992  enddo
993  colbrd(k) = coldry(k) - summol
994  enddo
995 
997 
998  tem1 = 1.80
999  tem2 = 1.50
1000  do j = 1, nbands
1001  if (j==1 .or. j==4 .or. j==10) then
1002  secdiff(j) = 1.66
1003  else
1004  secdiff(j) = min( tem1, max( tem2, &
1005  & a0(j)+a1(j)*exp(a2(j)*pwvcm) ))
1006  endif
1007  enddo
1008 
1009 ! if (lprnt) then
1010 ! print *,' coldry',coldry
1011 ! print *,' wx(*,1) ',(wx(k,1),k=1,NLAY)
1012 ! print *,' wx(*,2) ',(wx(k,2),k=1,NLAY)
1013 ! print *,' wx(*,3) ',(wx(k,3),k=1,NLAY)
1014 ! print *,' wx(*,4) ',(wx(k,4),k=1,NLAY)
1015 ! print *,' iplon ',iplon
1016 ! print *,' pavel ',pavel
1017 ! print *,' delp ',delp
1018 ! print *,' tavel ',tavel
1019 ! print *,' tz ',tz
1020 ! print *,' h2ovmr ',h2ovmr
1021 ! print *,' o3vmr ',o3vmr
1022 ! endif
1023 
1026 
1027  lcf1 = .false.
1028  lab_do_k0 : do k = 1, nlay
1029  if ( cldfrc(k) > eps ) then
1030  lcf1 = .true.
1031  exit lab_do_k0
1032  endif
1033  enddo lab_do_k0
1034 
1035  if ( lcf1 ) then
1036 
1037  call cldprop &
1038 ! --- inputs:
1039  & ( cldfrc,clwp,relw,ciwp,reiw,cda1,cda2,cda3,cda4, &
1040  & nlay, nlp1, ipseed(iplon), &
1041 ! --- outputs:
1042  & cldfmc, taucld &
1043  & )
1044 
1045  else
1046  cldfmc = f_zero
1047  taucld = f_zero
1048  endif
1049  do k = 1, nlay
1050  clouds(iplon,k,11) = taucld(6,k) &
1051  & + taucld(7,k) + taucld(8,k)
1052  end do
1053 
1054 ! if (lprnt) then
1055 ! print *,' after cldprop'
1056 ! print *,' clwp',clwp
1057 ! print *,' ciwp',ciwp
1058 ! print *,' relw',relw
1059 ! print *,' reiw',reiw
1060 ! print *,' taucl',cda1
1061 ! print *,' cldfrac',cldfrc
1062 ! endif
1063 
1066  call setcoef &
1067 ! --- inputs:
1068  & ( pavel,tavel,tz,stemp,h2ovmr,colamt,coldry,colbrd, &
1069  & nlay, nlp1, &
1070 ! --- outputs:
1071  & laytrop,pklay,pklev,jp,jt,jt1, &
1072  & rfrate,fac00,fac01,fac10,fac11, &
1073  & selffac,selffrac,indself,forfac,forfrac,indfor, &
1074  & minorfrac,scaleminor,scaleminorn2,indminor &
1075  & )
1076 
1077 ! if (lprnt) then
1078 ! print *,'laytrop',laytrop
1079 ! print *,'colh2o',(colamt(k,1),k=1,NLAY)
1080 ! print *,'colco2',(colamt(k,2),k=1,NLAY)
1081 ! print *,'colo3', (colamt(k,3),k=1,NLAY)
1082 ! print *,'coln2o',(colamt(k,4),k=1,NLAY)
1083 ! print *,'colch4',(colamt(k,5),k=1,NLAY)
1084 ! print *,'fac00',fac00
1085 ! print *,'fac01',fac01
1086 ! print *,'fac10',fac10
1087 ! print *,'fac11',fac11
1088 ! print *,'jp',jp
1089 ! print *,'jt',jt
1090 ! print *,'jt1',jt1
1091 ! print *,'selffac',selffac
1092 ! print *,'selffrac',selffrac
1093 ! print *,'indself',indself
1094 ! print *,'forfac',forfac
1095 ! print *,'forfrac',forfrac
1096 ! print *,'indfor',indfor
1097 ! endif
1098 
1101 
1102  call taumol &
1103 ! --- inputs:
1104  & ( laytrop,pavel,coldry,colamt,colbrd,wx,tauaer, &
1105  & rfrate,fac00,fac01,fac10,fac11,jp,jt,jt1, &
1106  & selffac,selffrac,indself,forfac,forfrac,indfor, &
1107  & minorfrac,scaleminor,scaleminorn2,indminor, &
1108  & nlay, &
1109 ! --- outputs:
1110  & fracs, tautot &
1111  & )
1112 
1113 ! if (lprnt) then
1114 ! print *,' after taumol'
1115 ! do k = 1, nlay
1116 ! write(6,121) k
1117 !121 format(' k =',i3,5x,'FRACS')
1118 ! write(6,122) (fracs(j,k),j=1,ngptlw)
1119 !122 format(10e14.7)
1120 ! write(6,123) k
1121 !123 format(' k =',i3,5x,'TAUTOT')
1122 ! write(6,122) (tautot(j,k),j=1,ngptlw)
1123 ! enddo
1124 ! endif
1125 
1135 
1136  if (isubclw <= 0) then
1137 
1138  if (iovrlw <= 0) then
1139 
1140  call rtrn &
1141 ! --- inputs:
1142  & ( semiss,delp,cldfrc,taucld,tautot,pklay,pklev, &
1143  & fracs,secdiff,nlay,nlp1, &
1144 ! --- outputs:
1145  & totuflux,totdflux,htr, totuclfl,totdclfl,htrcl, htrb &
1146  & )
1147 
1148  else
1149 
1150  call rtrnmr &
1151 ! --- inputs:
1152  & ( semiss,delp,cldfrc,taucld,tautot,pklay,pklev, &
1153  & fracs,secdiff,nlay,nlp1, &
1154 ! --- outputs:
1155  & totuflux,totdflux,htr, totuclfl,totdclfl,htrcl, htrb &
1156  & )
1157 
1158  endif ! end if_iovrlw_block
1159 
1160  else
1161 
1162  call rtrnmc &
1163 ! --- inputs:
1164  & ( semiss,delp,cldfmc,taucld,tautot,pklay,pklev, &
1165  & fracs,secdiff,nlay,nlp1, &
1166 ! --- outputs:
1167  & totuflux,totdflux,htr, totuclfl,totdclfl,htrcl, htrb &
1168  & )
1169 
1170  endif ! end if_isubclw_block
1171 
1173 
1174  topflx(iplon)%upfxc = totuflux(nlay)
1175  topflx(iplon)%upfx0 = totuclfl(nlay)
1176 
1177  sfcflx(iplon)%upfxc = totuflux(0)
1178  sfcflx(iplon)%upfx0 = totuclfl(0)
1179  sfcflx(iplon)%dnfxc = totdflux(0)
1180  sfcflx(iplon)%dnfx0 = totdclfl(0)
1181 
1182  if (ivflip == 0) then ! output from toa to sfc
1183 
1184 !! --- ... optional fluxes
1185  if ( lflxprf ) then
1186  do k = 0, nlay
1187  k1 = nlp1 - k
1188  flxprf(iplon,k1)%upfxc = totuflux(k)
1189  flxprf(iplon,k1)%dnfxc = totdflux(k)
1190  flxprf(iplon,k1)%upfx0 = totuclfl(k)
1191  flxprf(iplon,k1)%dnfx0 = totdclfl(k)
1192  enddo
1193  endif
1194 
1195  do k = 1, nlay
1196  k1 = nlp1 - k
1197  hlwc(iplon,k1) = htr(k)
1198  enddo
1199 
1200 !! --- ... optional clear sky heating rate
1201  if ( lhlw0 ) then
1202  do k = 1, nlay
1203  k1 = nlp1 - k
1204  hlw0(iplon,k1) = htrcl(k)
1205  enddo
1206  endif
1207 
1208 !! --- ... optional spectral band heating rate
1209  if ( lhlwb ) then
1210  do j = 1, nbands
1211  do k = 1, nlay
1212  k1 = nlp1 - k
1213  hlwb(iplon,k1,j) = htrb(k,j)
1214  enddo
1215  enddo
1216  endif
1217 
1218  else ! output from sfc to toa
1219 
1220 !! --- ... optional fluxes
1221  if ( lflxprf ) then
1222  do k = 0, nlay
1223  flxprf(iplon,k+1)%upfxc = totuflux(k)
1224  flxprf(iplon,k+1)%dnfxc = totdflux(k)
1225  flxprf(iplon,k+1)%upfx0 = totuclfl(k)
1226  flxprf(iplon,k+1)%dnfx0 = totdclfl(k)
1227  enddo
1228  endif
1229 
1230  do k = 1, nlay
1231  hlwc(iplon,k) = htr(k)
1232  enddo
1233 
1234 !! --- ... optional clear sky heating rate
1235  if ( lhlw0 ) then
1236  do k = 1, nlay
1237  hlw0(iplon,k) = htrcl(k)
1238  enddo
1239  endif
1240 
1241 !! --- ... optional spectral band heating rate
1242  if ( lhlwb ) then
1243  do j = 1, nbands
1244  do k = 1, nlay
1245  hlwb(iplon,k,j) = htrb(k,j)
1246  enddo
1247  enddo
1248  endif
1249 
1250  endif ! if_ivflip
1251 
1252  enddo lab_do_iplon
1253 
1254 !...................................
1255  end subroutine lwrad
1256 !-----------------------------------
1258 
1259 
1260 
1266 !-----------------------------------
1267  subroutine rlwinit &
1268  & ( me ) ! --- inputs
1269 ! --- outputs: (none)
1270 
1271 ! =================== program usage description =================== !
1272 ! !
1273 ! purpose: initialize non-varying module variables, conversion factors,!
1274 ! and look-up tables. !
1275 ! !
1276 ! subprograms called: none !
1277 ! !
1278 ! ==================== defination of variables ==================== !
1279 ! !
1280 ! inputs: !
1281 ! me - print control for parallel process !
1282 ! !
1283 ! outputs: (none) !
1284 ! !
1285 ! external module variables: (in physparam) !
1286 ! ilwrate - heating rate unit selections !
1287 ! =1: output in k/day !
1288 ! =2: output in k/second !
1289 ! ilwrgas - control flag for rare gases (ch4,n2o,o2,cfcs, etc.) !
1290 ! =0: do not include rare gases !
1291 ! >0: include all rare gases !
1292 ! ilwcliq - liquid cloud optical properties contrl flag !
1293 ! =0: input cloud opt depth from diagnostic scheme !
1294 ! >0: input cwp,rew, and other cloud content parameters !
1295 ! isubclw - sub-column cloud approximation control flag !
1296 ! =0: no sub-col cld treatment, use grid-mean cld quantities !
1297 ! =1: mcica sub-col, prescribed seeds to get random numbers !
1298 ! =2: mcica sub-col, providing array icseed for random numbers!
1299 ! icldflg - cloud scheme control flag !
1300 ! =0: diagnostic scheme gives cloud tau, omiga, and g. !
1301 ! =1: prognostic scheme gives cloud liq/ice path, etc. !
1302 ! iovrlw - clouds vertical overlapping control flag !
1303 ! =0: random overlapping clouds !
1304 ! =1: maximum/random overlapping clouds !
1305 ! =2: maximum overlap cloud (isubcol>0 only) !
1306 ! !
1307 ! ******************************************************************* !
1308 ! original code description !
1309 ! !
1310 ! original version: michael j. iacono; july, 1998 !
1311 ! first revision for ncar ccm: september, 1998 !
1312 ! second revision for rrtm_v3.0: september, 2002 !
1313 ! !
1314 ! this subroutine performs calculations necessary for the initialization
1315 ! of the longwave model. lookup tables are computed for use in the lw !
1316 ! radiative transfer, and input absorption coefficient data for each !
1317 ! spectral band are reduced from 256 g-point intervals to 140. !
1318 ! !
1319 ! ******************************************************************* !
1320 ! !
1321 ! definitions: !
1322 ! arrays for 10000-point look-up tables: !
1323 ! tau_tbl - clear-sky optical depth (used in cloudy radiative transfer!
1324 ! exp_tbl - exponential lookup table for tansmittance !
1325 ! tfn_tbl - tau transition function; i.e. the transition of the Planck!
1326 ! function from that for the mean layer temperature to that !
1327 ! for the layer boundary temperature as a function of optical
1328 ! depth. the "linear in tau" method is used to make the table
1329 ! !
1330 ! ******************************************************************* !
1331 ! !
1332 ! ====================== end of description block ================= !
1333 
1334 ! --- inputs:
1335  integer, intent(in) :: me
1336 
1337 ! --- outputs: none
1338 
1339 ! --- locals:
1340  real (kind=kind_phys), parameter :: expeps = 1.e-20
1341 
1342  real (kind=kind_phys) :: tfn, pival, explimit
1343 
1344  integer :: i
1345 
1346 !
1347 !===> ... begin here
1348 !
1349  if ( iovrlw<0 .or. iovrlw>2 ) then
1350  print *,' *** Error in specification of cloud overlap flag', &
1351  & ' IOVRLW=',iovrlw,' in RLWINIT !!'
1352  stop
1353  elseif ( iovrlw==2 .and. isubclw==0 ) then
1354  if (me == 0) then
1355  print *,' *** IOVRLW=2 - maximum cloud overlap, is not yet', &
1356  & ' available for ISUBCLW=0 setting!!'
1357  print *,' The program uses maximum/random overlap', &
1358  & ' instead.'
1359  endif
1360 
1361  iovrlw = 1
1362  endif
1363 
1364  if (me == 0) then
1365  print *,' - Using AER Longwave Radiation, Version: ', vtaglw
1366 
1367  if (ilwrgas > 0) then
1368  print *,' --- Include rare gases N2O, CH4, O2, CFCs ', &
1369  & 'absorptions in LW'
1370  else
1371  print *,' --- Rare gases effect is NOT included in LW'
1372  endif
1373 
1374  if ( isubclw == 0 ) then
1375  print *,' --- Using standard grid average clouds, no ', &
1376  & 'sub-column clouds approximation applied'
1377  elseif ( isubclw == 1 ) then
1378  print *,' --- Using MCICA sub-colum clouds approximation ', &
1379  & 'with a prescribed sequence of permutaion seeds'
1380  elseif ( isubclw == 2 ) then
1381  print *,' --- Using MCICA sub-colum clouds approximation ', &
1382  & 'with provided input array of permutation seeds'
1383  else
1384  print *,' *** Error in specification of sub-column cloud ', &
1385  & ' control flag isubclw =',isubclw,' !!'
1386  stop
1387  endif
1388  endif
1389 
1390 ! --- ... check cloud flags for consistency
1391 
1392  if ((icldflg == 0 .and. ilwcliq /= 0) .or. &
1393  & (icldflg == 1 .and. ilwcliq == 0)) then
1394  print *,' *** Model cloud scheme inconsistent with LW', &
1395  & ' radiation cloud radiative property setup !!'
1396  stop
1397  endif
1398 
1399 ! --- ... setup default surface emissivity for each band here
1400 
1401  semiss0(:) = f_one
1402 
1403 ! --- ... setup constant factors for flux and heating rate
1404 ! the 1.0e-2 is to convert pressure from mb to N/m**2
1405 
1406  pival = 2.0 * asin(f_one)
1407  fluxfac = pival * 2.0d4
1408 ! fluxfac = 62831.85307179586 ! = 2 * pi * 1.0e4
1409 
1410  if (ilwrate == 1) then
1411 ! heatfac = 8.4391
1412 ! heatfac = con_g * 86400. * 1.0e-2 / con_cp ! (in k/day)
1413  heatfac = con_g * 864.0 / con_cp ! (in k/day)
1414  else
1415  heatfac = con_g * 1.0e-2 / con_cp ! (in k/second)
1416  endif
1417 
1418 ! --- ... compute lookup tables for transmittance, tau transition
1419 ! function, and clear sky tau (for the cloudy sky radiative
1420 ! transfer). tau is computed as a function of the tau
1421 ! transition function, transmittance is calculated as a
1422 ! function of tau, and the tau transition function is
1423 ! calculated using the linear in tau formulation at values of
1424 ! tau above 0.01. tf is approximated as tau/6 for tau < 0.01.
1425 ! all tables are computed at intervals of 0.001. the inverse
1426 ! of the constant used in the pade approximation to the tau
1427 ! transition function is set to b.
1428 
1429  tau_tbl(0) = f_zero
1430  exp_tbl(0) = f_one
1431  tfn_tbl(0) = f_zero
1432 
1433  tau_tbl(ntbl) = 1.e10
1434  exp_tbl(ntbl) = expeps
1435  tfn_tbl(ntbl) = f_one
1436 
1437  explimit = aint( -log(tiny(exp_tbl(0))) )
1438 
1439  do i = 1, ntbl-1
1440 !org tfn = float(i) / float(ntbl)
1441 !org tau_tbl(i) = bpade * tfn / (f_one - tfn)
1442  tfn = real(i, kind_phys) / real(ntbl-i, kind_phys)
1443  tau_tbl(i) = bpade * tfn
1444  if (tau_tbl(i) >= explimit) then
1445  exp_tbl(i) = expeps
1446  else
1447  exp_tbl(i) = exp( -tau_tbl(i) )
1448  endif
1449 
1450  if (tau_tbl(i) < 0.06) then
1451  tfn_tbl(i) = tau_tbl(i) / 6.0
1452  else
1453  tfn_tbl(i) = f_one - 2.0*( (f_one / tau_tbl(i)) &
1454  & - ( exp_tbl(i) / (f_one - exp_tbl(i)) ) )
1455  endif
1456  enddo
1457 
1458 !...................................
1459  end subroutine rlwinit
1460 !-----------------------------------
1461 
1462 
1491 ! ----------------------------
1492  subroutine cldprop &
1493  & ( cfrac,cliqp,reliq,cicep,reice,cdat1,cdat2,cdat3,cdat4, & ! --- inputs
1494  & nlay, nlp1, ipseed, &
1495  & cldfmc, taucld & ! --- outputs
1496  & )
1498 ! =================== program usage description =================== !
1499 ! !
1500 ! purpose: compute the cloud optical depth(s) for each cloudy layer !
1501 ! and g-point interval. !
1502 ! !
1503 ! subprograms called: none !
1504 ! !
1505 ! ==================== defination of variables ==================== !
1506 ! !
1507 ! inputs: -size- !
1508 ! cfrac - real, layer cloud fraction 0:nlp1 !
1509 ! ..... for ilwcliq > 0 (prognostic cloud sckeme) - - - !
1510 ! cliqp - real, layer in-cloud liq water path (g/m**2) nlay !
1511 ! reliq - real, mean eff radius for liq cloud (micron) nlay !
1512 ! cicep - real, layer in-cloud ice water path (g/m**2) nlay !
1513 ! reice - real, mean eff radius for ice cloud (micron) nlay !
1514 ! cdat1 - real, layer rain drop water path (g/m**2) nlay !
1515 ! cdat2 - real, effective radius for rain drop (microm) nlay !
1516 ! cdat3 - real, layer snow flake water path (g/m**2) nlay !
1517 ! cdat4 - real, effective radius for snow flakes (micron) nlay !
1518 ! ..... for ilwcliq = 0 (diagnostic cloud sckeme) - - - !
1519 ! cdat1 - real, input cloud optical depth nlay !
1520 ! cdat2 - real, layer cloud single scattering albedo nlay !
1521 ! cdat3 - real, layer cloud asymmetry factor nlay !
1522 ! cdat4 - real, optional use nlay !
1523 ! cliqp - not used nlay !
1524 ! reliq - not used nlay !
1525 ! cicep - not used nlay !
1526 ! reice - not used nlay !
1527 ! !
1528 ! nlay - integer, number of vertical layers 1 !
1529 ! nlp1 - integer, number of vertical levels 1 !
1530 ! ipseed- permutation seed for generating random numbers (isubclw>0) !
1531 ! !
1532 ! outputs: !
1533 ! cldfmc - real, cloud fraction for each sub-column ngptlw*nlay!
1534 ! taucld - real, cld opt depth for bands (non-mcica) nbands*nlay!
1535 ! !
1536 ! explanation of the method for each value of ilwcliq, and ilwcice. !
1537 ! set up in module "module_radlw_cntr_para" !
1538 ! !
1539 ! ilwcliq=0 : input cloud optical property (tau, ssa, asy). !
1540 ! (used for diagnostic cloud method) !
1541 ! ilwcliq>0 : input cloud liq/ice path and effective radius, also !
1542 ! require the user of 'ilwcice' to specify the method !
1543 ! used to compute aborption due to water/ice parts. !
1544 ! ................................................................... !
1545 ! !
1546 ! ilwcliq=1: the water droplet effective radius (microns) is input!
1547 ! and the opt depths due to water clouds are computed !
1548 ! as in hu and stamnes, j., clim., 6, 728-742, (1993). !
1549 ! the values for absorption coefficients appropriate for
1550 ! the spectral bands in rrtm have been obtained for a !
1551 ! range of effective radii by an averaging procedure !
1552 ! based on the work of j. pinto (private communication).
1553 ! linear interpolation is used to get the absorption !
1554 ! coefficients for the input effective radius. !
1555 ! !
1556 ! ilwcice=1: the cloud ice path (g/m2) and ice effective radius !
1557 ! (microns) are input and the optical depths due to ice!
1558 ! clouds are computed as in ebert and curry, jgr, 97, !
1559 ! 3831-3836 (1992). the spectral regions in this work !
1560 ! have been matched with the spectral bands in rrtm to !
1561 ! as great an extent as possible: !
1562 ! e&c 1 ib = 5 rrtm bands 9-16 !
1563 ! e&c 2 ib = 4 rrtm bands 6-8 !
1564 ! e&c 3 ib = 3 rrtm bands 3-5 !
1565 ! e&c 4 ib = 2 rrtm band 2 !
1566 ! e&c 5 ib = 1 rrtm band 1 !
1567 ! ilwcice=2: the cloud ice path (g/m2) and ice effective radius !
1568 ! (microns) are input and the optical depths due to ice!
1569 ! clouds are computed as in rt code, streamer v3.0 !
1570 ! (ref: key j., streamer user's guide, cooperative !
1571 ! institute for meteorological satellite studies, 2001,!
1572 ! 96 pp.) valid range of values for re are between 5.0 !
1573 ! and 131.0 micron. !
1574 ! ilwcice=3: the ice generalized effective size (dge) is input and!
1575 ! the optical properties, are calculated as in q. fu, !
1576 ! j. climate, (1998). q. fu provided high resolution !
1577 ! tales which were appropriately averaged for the bands!
1578 ! in rrtm_lw. linear interpolation is used to get the !
1579 ! coeff from the stored tables. valid range of values !
1580 ! for deg are between 5.0 and 140.0 micron. !
1581 ! !
1582 ! other cloud control module variables: !
1583 ! isubclw =0: standard cloud scheme, no sub-col cloud approximation !
1584 ! >0: mcica sub-col cloud scheme using ipseed as permutation!
1585 ! seed for generating rundom numbers !
1586 ! !
1587 ! ====================== end of description block ================= !
1588 !
1590 
1591 ! --- inputs:
1592  integer, intent(in) :: nlay, nlp1, ipseed
1593 
1594  real (kind=kind_phys), dimension(0:nlp1), intent(in) :: cfrac
1595  real (kind=kind_phys), dimension(nlay), intent(in) :: cliqp, &
1596  & reliq, cicep, reice, cdat1, cdat2, cdat3, cdat4
1597 
1598 ! --- outputs:
1599  real (kind=kind_phys), dimension(ngptlw,nlay),intent(out):: cldfmc
1600  real (kind=kind_phys), dimension(nbands,nlay),intent(out):: taucld
1601 
1602 ! --- locals:
1603  real (kind=kind_phys), dimension(nbands) :: tauliq, tauice
1604  real (kind=kind_phys), dimension(nlay) :: cldf
1605 
1606  real (kind=kind_phys) :: dgeice, factor, fint, tauran, tausnw, &
1607  & cldliq, refliq, cldice, refice
1608 
1609  logical :: lcloudy(ngptlw,nlay)
1610  integer :: ia, ib, ig, k, index
1611 
1612 !
1613 !===> ... begin here
1614 !
1615  do k = 1, nlay
1616  do ib = 1, nbands
1617  taucld(ib,k) = f_zero
1618  enddo
1619  enddo
1620 
1621  do k = 1, nlay
1622  do ig = 1, ngptlw
1623  cldfmc(ig,k) = f_zero
1624  enddo
1625  enddo
1626 
1633 
1634 ! --- ... compute cloud radiative properties for a cloudy column
1635 
1636  lab_if_ilwcliq : if (ilwcliq > 0) then
1637 
1638  lab_do_k : do k = 1, nlay
1639  lab_if_cld : if (cfrac(k) > cldmin) then
1640 
1641  tauran = absrain * cdat1(k) ! ncar formula
1642 !! tausnw = abssnow1 * cdat3(k) ! ncar formula
1643 ! --- if use fu's formula it needs to be normalized by snow density
1644 ! !not use snow density = 0.1 g/cm**3 = 0.1 g/(mu * m**2)
1645 ! use ice density = 0.9167 g/cm**3 = 0.9167 g/(mu * m**2)
1646 ! factor 1.5396=8/(3*sqrt(3)) converts reff to generalized ice particle size
1647 ! use newer factor value 1.0315
1648 ! 1/(0.9167*1.0315) = 1.05756
1649  if (cdat3(k)>f_zero .and. cdat4(k)>10.0_kind_phys) then
1650  tausnw = abssnow0*1.05756*cdat3(k)/cdat4(k) ! fu's formula
1651  else
1652  tausnw = f_zero
1653  endif
1654 
1655  cldliq = cliqp(k)
1656  cldice = cicep(k)
1657 ! refliq = max(2.5e0, min(60.0e0, reliq(k) ))
1658 ! refice = max(5.0e0, reice(k) )
1659  refliq = reliq(k)
1660  refice = reice(k)
1661 
1662 ! --- ... calculation of absorption coefficients due to water clouds.
1663 
1664  if ( cldliq <= f_zero ) then
1665  do ib = 1, nbands
1666  tauliq(ib) = f_zero
1667  enddo
1668  else
1669  if ( ilwcliq == 1 ) then
1670 
1671  factor = refliq - 1.5
1672  index = max( 1, min( 57, int( factor ) ))
1673  fint = factor - float(index)
1674 
1675  do ib = 1, nbands
1676  tauliq(ib) = max(f_zero, cldliq*(absliq1(index,ib) &
1677  & + fint*(absliq1(index+1,ib)-absliq1(index,ib)) ))
1678  enddo
1679  endif ! end if_ilwcliq_block
1680  endif ! end if_cldliq_block
1681 
1682 ! --- ... calculation of absorption coefficients due to ice clouds.
1683 
1684  if ( cldice <= f_zero ) then
1685  do ib = 1, nbands
1686  tauice(ib) = f_zero
1687  enddo
1688  else
1689 
1690 ! --- ... ebert and curry approach for all particle sizes though somewhat
1691 ! unjustified for large ice particles
1692 
1693  if ( ilwcice == 1 ) then
1694  refice = min(130.0, max(13.0, real(refice) ))
1695 
1696  do ib = 1, nbands
1697  ia = ipat(ib) ! eb_&_c band index for ice cloud coeff
1698  tauice(ib) = max(f_zero, cldice*(absice1(1,ia) &
1699  & + absice1(2,ia)/refice) )
1700  enddo
1701 
1702 ! --- ... streamer approach for ice effective radius between 5.0 and 131.0 microns
1703 ! and ebert and curry approach for ice eff radius greater than 131.0 microns.
1704 ! no smoothing between the transition of the two methods.
1705 
1706  elseif ( ilwcice == 2 ) then
1707 
1708  factor = (refice - 2.0) / 3.0
1709  index = max( 1, min( 42, int( factor ) ))
1710  fint = factor - float(index)
1711 
1712  do ib = 1, nbands
1713  tauice(ib) = max(f_zero, cldice*(absice2(index,ib) &
1714  & + fint*(absice2(index+1,ib) - absice2(index,ib)) ))
1715  enddo
1716 
1717 ! --- ... fu's approach for ice effective radius between 4.8 and 135 microns
1718 ! (generalized effective size from 5 to 140 microns)
1719 
1720  elseif ( ilwcice == 3 ) then
1721 
1722 ! dgeice = max(5.0, 1.5396*refice) ! v4.4 value
1723  dgeice = max(5.0, 1.0315*refice) ! v4.71 value
1724  factor = (dgeice - 2.0) / 3.0
1725  index = max( 1, min( 45, int( factor ) ))
1726  fint = factor - float(index)
1727 
1728  do ib = 1, nbands
1729  tauice(ib) = max(f_zero, cldice*(absice3(index,ib) &
1730  & + fint*(absice3(index+1,ib) - absice3(index,ib)) ))
1731  enddo
1732 
1733  endif ! end if_ilwcice_block
1734  endif ! end if_cldice_block
1735 
1736  do ib = 1, nbands
1737  taucld(ib,k) = tauice(ib) + tauliq(ib) + tauran + tausnw
1738  enddo
1739 
1740  endif lab_if_cld
1741  enddo lab_do_k
1742 
1743  else lab_if_ilwcliq
1744 
1745  do k = 1, nlay
1746  if (cfrac(k) > cldmin) then
1747  do ib = 1, nbands
1748  taucld(ib,k) = cdat1(k)
1749  enddo
1750  endif
1751  enddo
1752 
1753  endif lab_if_ilwcliq
1754 
1757 
1758  if ( isubclw > 0 ) then ! mcica sub-col clouds approx
1759  do k = 1, nlay
1760  if ( cfrac(k) < cldmin ) then
1761  cldf(k) = f_zero
1762  else
1763  cldf(k) = cfrac(k)
1764  endif
1765  enddo
1766 
1767 ! --- ... call sub-column cloud generator
1768 
1769  call mcica_subcol &
1770 ! --- inputs:
1771  & ( cldf, nlay, ipseed, &
1772 ! --- output:
1773  & lcloudy &
1774  & )
1775 
1776  do k = 1, nlay
1777  do ig = 1, ngptlw
1778  if ( lcloudy(ig,k) ) then
1779  cldfmc(ig,k) = f_one
1780  else
1781  cldfmc(ig,k) = f_zero
1782  endif
1783  enddo
1784  enddo
1785 
1786  endif ! end if_isubclw_block
1787 
1788  return
1789 ! ..................................
1790  end subroutine cldprop
1791 ! ----------------------------------
1793 
1799 ! ----------------------------------
1800  subroutine mcica_subcol &
1801  & ( cldf, nlay, ipseed, &! --- inputs
1802  & lcloudy & ! --- outputs
1803  & )
1805 ! ==================== defination of variables ==================== !
1806 ! !
1807 ! input variables: size !
1808 ! cldf - real, layer cloud fraction nlay !
1809 ! nlay - integer, number of model vertical layers 1 !
1810 ! ipseed - integer, permute seed for random num generator 1 !
1811 ! ** note : if the cloud generator is called multiple times, need !
1812 ! to permute the seed between each call; if between calls !
1813 ! for lw and sw, use values differ by the number of g-pts. !
1814 ! !
1815 ! output variables: !
1816 ! lcloudy - logical, sub-colum cloud profile flag array ngptlw*nlay!
1817 ! !
1818 ! other control flags from module variables: !
1819 ! iovrlw : control flag for cloud overlapping method !
1820 ! =0:random; =1:maximum/random: =2:maximum !
1821 ! !
1822 ! ===================== end of definitions ==================== !
1823 
1824  implicit none
1825 
1826 ! --- inputs:
1827  integer, intent(in) :: nlay, ipseed
1828 
1829  real (kind=kind_phys), dimension(nlay), intent(in) :: cldf
1830 
1831 ! --- outputs:
1832  logical, dimension(ngptlw,nlay), intent(out) :: lcloudy
1833 
1834 ! --- locals:
1835  real (kind=kind_phys) :: cdfunc(ngptlw,nlay), rand1d(ngptlw), &
1836  & rand2d(nlay*ngptlw), tem1
1837 
1838  type(random_stat) :: stat ! for thread safe random generator
1839 
1840  integer :: k, n, k1
1841 !
1842 !===> ... begin here
1843 !
1844 ! --- ... advance randum number generator by ipseed values
1845 
1846  call random_setseed &
1847 ! --- inputs:
1848  & ( ipseed, &
1849 ! --- outputs:
1850  & stat &
1851  & )
1852 
1853 ! --- ... sub-column set up according to overlapping assumption
1854 
1855  select case ( iovrlw )
1856 
1857  case( 0 ) ! random overlap, pick a random value at every level
1858 
1859  call random_number &
1860 ! --- inputs: ( none )
1861 ! --- outputs:
1862  & ( rand2d, stat )
1863 
1864  k1 = 0
1865  do n = 1, ngptlw
1866  do k = 1, nlay
1867  k1 = k1 + 1
1868  cdfunc(n,k) = rand2d(k1)
1869  enddo
1870  enddo
1871 
1872  case( 1 ) ! max-ran overlap
1873 
1874  call random_number &
1875 ! --- inputs: ( none )
1876 ! --- outputs:
1877  & ( rand2d, stat )
1878 
1879  k1 = 0
1880  do n = 1, ngptlw
1881  do k = 1, nlay
1882  k1 = k1 + 1
1883  cdfunc(n,k) = rand2d(k1)
1884  enddo
1885  enddo
1886 
1887 ! --- first pick a random number for bottom (or top) layer.
1888 ! then walk up the column: (aer's code)
1889 ! if layer below is cloudy, use the same rand num in the layer below
1890 ! if layer below is clear, use a new random number
1891 
1892 ! --- from bottom up
1893  do k = 2, nlay
1894  k1 = k - 1
1895  tem1 = f_one - cldf(k1)
1896 
1897  do n = 1, ngptlw
1898  if ( cdfunc(n,k1) > tem1 ) then
1899  cdfunc(n,k) = cdfunc(n,k1)
1900  else
1901  cdfunc(n,k) = cdfunc(n,k) * tem1
1902  endif
1903  enddo
1904  enddo
1905 
1906 ! --- or walk down the column: (if use original author's method)
1907 ! if layer above is cloudy, use the same rand num in the layer above
1908 ! if layer above is clear, use a new random number
1909 
1910 ! --- from top down
1911 ! do k = nlay-1, 1, -1
1912 ! k1 = k + 1
1913 ! tem1 = f_one - cldf(k1)
1914 
1915 ! do n = 1, ngptlw
1916 ! if ( cdfunc(n,k1) > tem1 ) then
1917 ! cdfunc(n,k) = cdfunc(n,k1)
1918 ! else
1919 ! cdfunc(n,k) = cdfunc(n,k) * tem1
1920 ! endif
1921 ! enddo
1922 ! enddo
1923 
1924  case( 2 ) ! maximum overlap, pick same random numebr at every level
1925 
1926  call random_number &
1927 ! --- inputs: ( none )
1928 ! --- outputs:
1929  & ( rand1d, stat )
1930 
1931  do n = 1, ngptlw
1932  tem1 = rand1d(n)
1933 
1934  do k = 1, nlay
1935  cdfunc(n,k) = tem1
1936  enddo
1937  enddo
1938 
1939  end select
1940 
1941 ! --- ... generate subcolumns for homogeneous clouds
1942 
1943  do k = 1, nlay
1944  tem1 = f_one - cldf(k)
1945 
1946  do n = 1, ngptlw
1947  lcloudy(n,k) = cdfunc(n,k) >= tem1
1948  enddo
1949  enddo
1950 
1951  return
1952 ! ..................................
1953  end subroutine mcica_subcol
1954 ! ----------------------------------
1955 
1995 ! ----------------------------------
1996  subroutine setcoef &
1997  & ( pavel,tavel,tz,stemp,h2ovmr,colamt,coldry,colbrd, & ! --- inputs:
1998  & nlay, nlp1, &
1999  & laytrop,pklay,pklev,jp,jt,jt1, & ! --- outputs:
2000  & rfrate,fac00,fac01,fac10,fac11, &
2001  & selffac,selffrac,indself,forfac,forfrac,indfor, &
2002  & minorfrac,scaleminor,scaleminorn2,indminor &
2003  & )
2005 ! =================== program usage description =================== !
2006 ! !
2007 ! purpose: compute various coefficients needed in radiative transfer !
2008 ! calculations. !
2009 ! !
2010 ! subprograms called: none !
2011 ! !
2012 ! ==================== defination of variables ==================== !
2013 ! !
2014 ! inputs: -size- !
2015 ! pavel - real, layer pressures (mb) nlay !
2016 ! tavel - real, layer temperatures (k) nlay !
2017 ! tz - real, level (interface) temperatures (k) 0:nlay !
2018 ! stemp - real, surface ground temperature (k) 1 !
2019 ! h2ovmr - real, layer w.v. volum mixing ratio (kg/kg) nlay !
2020 ! colamt - real, column amounts of absorbing gases nlay*maxgas!
2021 ! 2nd indices range: 1-maxgas, for watervapor, !
2022 ! carbon dioxide, ozone, nitrous oxide, methane, !
2023 ! oxigen, carbon monoxide,etc. (molecules/cm**2) !
2024 ! coldry - real, dry air column amount nlay !
2025 ! colbrd - real, column amount of broadening gases nlay !
2026 ! nlay/nlp1 - integer, total number of vertical layers, levels 1 !
2027 ! !
2028 ! outputs: !
2029 ! laytrop - integer, tropopause layer index (unitless) 1 !
2030 ! pklay - real, integrated planck func at lay temp nbands*0:nlay!
2031 ! pklev - real, integrated planck func at lev temp nbands*0:nlay!
2032 ! jp - real, indices of lower reference pressure nlay !
2033 ! jt, jt1 - real, indices of lower reference temperatures nlay !
2034 ! rfrate - real, ref ratios of binary species param nlay*nrates*2!
2035 ! (:,m,:)m=1-h2o/co2,2-h2o/o3,3-h2o/n2o,4-h2o/ch4,5-n2o/co2,6-o3/co2!
2036 ! (:,:,n)n=1,2: the rates of ref press at the 2 sides of the layer !
2037 ! facij - real, factors multiply the reference ks, nlay !
2038 ! i,j=0/1 for lower/higher of the 2 appropriate !
2039 ! temperatures and altitudes. !
2040 ! selffac - real, scale factor for w. v. self-continuum nlay !
2041 ! equals (w. v. density)/(atmospheric density !
2042 ! at 296k and 1013 mb) !
2043 ! selffrac - real, factor for temperature interpolation of nlay !
2044 ! reference w. v. self-continuum data !
2045 ! indself - integer, index of lower ref temp for selffac nlay !
2046 ! forfac - real, scale factor for w. v. foreign-continuum nlay !
2047 ! forfrac - real, factor for temperature interpolation of nlay !
2048 ! reference w.v. foreign-continuum data !
2049 ! indfor - integer, index of lower ref temp for forfac nlay !
2050 ! minorfrac - real, factor for minor gases nlay !
2051 ! scaleminor,scaleminorn2 !
2052 ! - real, scale factors for minor gases nlay !
2053 ! indminor - integer, index of lower ref temp for minor gases nlay !
2054 ! !
2055 ! ====================== end of definitions =================== !
2056 
2057 ! --- inputs:
2058  integer, intent(in) :: nlay, nlp1
2059 
2060  real (kind=kind_phys), dimension(nlay,maxgas),intent(in):: colamt
2061  real (kind=kind_phys), dimension(0:nlay), intent(in):: tz
2062 
2063  real (kind=kind_phys), dimension(nlay), intent(in) :: pavel, &
2064  & tavel, h2ovmr, coldry, colbrd
2065 
2066  real (kind=kind_phys), intent(in) :: stemp
2067 
2068 ! --- outputs:
2069  integer, dimension(nlay), intent(out) :: jp, jt, jt1, indself, &
2070  & indfor, indminor
2071 
2072  integer, intent(out) :: laytrop
2073 
2074  real (kind=kind_phys), dimension(nlay,nrates,2), intent(out) :: &
2075  & rfrate
2076  real (kind=kind_phys), dimension(nbands,0:nlay), intent(out) :: &
2077  & pklev, pklay
2078 
2079  real (kind=kind_phys), dimension(nlay), intent(out) :: &
2080  & fac00, fac01, fac10, fac11, selffac, selffrac, forfac, &
2081  & forfrac, minorfrac, scaleminor, scaleminorn2
2082 
2083 ! --- locals:
2084  real (kind=kind_phys) :: tlvlfr, tlyrfr, plog, fp, ft, ft1, &
2085  & tem1, tem2
2086 
2087  integer :: i, k, jp1, indlev, indlay
2088 !
2089 !===> ... begin here
2090 !
2091 ! --- ... calculate information needed by the radiative transfer routine
2092 ! that is specific to this atmosphere, especially some of the
2093 ! coefficients and indices needed to compute the optical depths
2094 ! by interpolating data from stored reference atmospheres.
2095 
2096  indlay = min(180, max(1, int(stemp-159.0) ))
2097  indlev = min(180, max(1, int(tz(0)-159.0) ))
2098  tlyrfr = stemp - int(stemp)
2099  tlvlfr = tz(0) - int(tz(0))
2100  do i = 1, nbands
2101  tem1 = totplnk(indlay+1,i) - totplnk(indlay,i)
2102  tem2 = totplnk(indlev+1,i) - totplnk(indlev,i)
2103  pklay(i,0) = delwave(i) * (totplnk(indlay,i) + tlyrfr*tem1)
2104  pklev(i,0) = delwave(i) * (totplnk(indlev,i) + tlvlfr*tem2)
2105  enddo
2106 
2107 ! --- ... begin layer loop
2108 ! calculate the integrated Planck functions for each band at the
2109 ! surface, level, and layer temperatures.
2110 
2111  laytrop = 0
2112 
2113  do k = 1, nlay
2114 
2115  indlay = min(180, max(1, int(tavel(k)-159.0) ))
2116  tlyrfr = tavel(k) - int(tavel(k))
2117 
2118  indlev = min(180, max(1, int(tz(k)-159.0) ))
2119  tlvlfr = tz(k) - int(tz(k))
2120 
2121 ! --- ... begin spectral band loop
2122 
2123  do i = 1, nbands
2124  pklay(i,k) = delwave(i) * (totplnk(indlay,i) + tlyrfr &
2125  & * (totplnk(indlay+1,i) - totplnk(indlay,i)) )
2126  pklev(i,k) = delwave(i) * (totplnk(indlev,i) + tlvlfr &
2127  & * (totplnk(indlev+1,i) - totplnk(indlev,i)) )
2128  enddo
2129 
2130 ! --- ... find the two reference pressures on either side of the
2131 ! layer pressure. store them in jp and jp1. store in fp the
2132 ! fraction of the difference (in ln(pressure)) between these
2133 ! two values that the layer pressure lies.
2134 
2135  plog = log(pavel(k))
2136  jp(k)= max(1, min(58, int(36.0 - 5.0*(plog+0.04)) ))
2137  jp1 = jp(k) + 1
2138 ! --- ... limit pressure extrapolation at the top
2139  fp = max(f_zero, min(f_one, 5.0*(preflog(jp(k))-plog) ))
2140 !org fp = 5.0 * (preflog(jp(k)) - plog)
2141 
2142 ! --- ... determine, for each reference pressure (jp and jp1), which
2143 ! reference temperature (these are different for each
2144 ! reference pressure) is nearest the layer temperature but does
2145 ! not exceed it. store these indices in jt and jt1, resp.
2146 ! store in ft (resp. ft1) the fraction of the way between jt
2147 ! (jt1) and the next highest reference temperature that the
2148 ! layer temperature falls.
2149 
2150  tem1 = (tavel(k)-tref(jp(k))) / 15.0
2151  tem2 = (tavel(k)-tref(jp1 )) / 15.0
2152  jt(k) = max(1, min(4, int(3.0 + tem1) ))
2153  jt1(k) = max(1, min(4, int(3.0 + tem2) ))
2154 ! --- ... restrict extrapolation ranges by limiting abs(det t) < 37.5 deg
2155  ft = max(-0.5, min(1.5, tem1 - float(jt(k) - 3) ))
2156  ft1 = max(-0.5, min(1.5, tem2 - float(jt1(k) - 3) ))
2157 !org ft = tem1 - float(jt (k) - 3)
2158 !org ft1 = tem2 - float(jt1(k) - 3)
2159 
2160 ! --- ... we have now isolated the layer ln pressure and temperature,
2161 ! between two reference pressures and two reference temperatures
2162 ! (for each reference pressure). we multiply the pressure
2163 ! fraction fp with the appropriate temperature fractions to get
2164 ! the factors that will be needed for the interpolation that yields
2165 ! the optical depths (performed in routines taugbn for band n)
2166 
2167  tem1 = f_one - fp
2168  fac10(k) = tem1 * ft
2169  fac00(k) = tem1 * (f_one - ft)
2170  fac11(k) = fp * ft1
2171  fac01(k) = fp * (f_one - ft1)
2172 
2173  forfac(k) = pavel(k)*stpfac / (tavel(k)*(1.0 + h2ovmr(k)))
2174  selffac(k) = h2ovmr(k) * forfac(k)
2175 
2176 ! --- ... set up factors needed to separately include the minor gases
2177 ! in the calculation of absorption coefficient
2178 
2179  scaleminor(k) = pavel(k) / tavel(k)
2180  scaleminorn2(k) = (pavel(k) / tavel(k)) &
2181  & * (colbrd(k)/(coldry(k) + colamt(k,1)))
2182  tem1 = (tavel(k) - 180.8) / 7.2
2183  indminor(k) = min(18, max(1, int(tem1)))
2184  minorfrac(k) = tem1 - float(indminor(k))
2185 
2186 ! --- ... if the pressure is less than ~100mb, perform a different
2187 ! set of species interpolations.
2188 
2189  if (plog > 4.56) then
2190 
2191  laytrop = laytrop + 1
2192 
2193  tem1 = (332.0 - tavel(k)) / 36.0
2194  indfor(k) = min(2, max(1, int(tem1)))
2195  forfrac(k) = tem1 - float(indfor(k))
2196 
2197 ! --- ... set up factors needed to separately include the water vapor
2198 ! self-continuum in the calculation of absorption coefficient.
2199 
2200  tem1 = (tavel(k) - 188.0) / 7.2
2201  indself(k) = min(9, max(1, int(tem1)-7))
2202  selffrac(k) = tem1 - float(indself(k) + 7)
2203 
2204 ! --- ... setup reference ratio to be used in calculation of binary
2205 ! species parameter in lower atmosphere.
2206 
2207  rfrate(k,1,1) = chi_mls(1,jp(k)) / chi_mls(2,jp(k))
2208  rfrate(k,1,2) = chi_mls(1,jp(k)+1) / chi_mls(2,jp(k)+1)
2209 
2210  rfrate(k,2,1) = chi_mls(1,jp(k)) / chi_mls(3,jp(k))
2211  rfrate(k,2,2) = chi_mls(1,jp(k)+1) / chi_mls(3,jp(k)+1)
2212 
2213  rfrate(k,3,1) = chi_mls(1,jp(k)) / chi_mls(4,jp(k))
2214  rfrate(k,3,2) = chi_mls(1,jp(k)+1) / chi_mls(4,jp(k)+1)
2215 
2216  rfrate(k,4,1) = chi_mls(1,jp(k)) / chi_mls(6,jp(k))
2217  rfrate(k,4,2) = chi_mls(1,jp(k)+1) / chi_mls(6,jp(k)+1)
2218 
2219  rfrate(k,5,1) = chi_mls(4,jp(k)) / chi_mls(2,jp(k))
2220  rfrate(k,5,2) = chi_mls(4,jp(k)+1) / chi_mls(2,jp(k)+1)
2221 
2222  else
2223 
2224  tem1 = (tavel(k) - 188.0) / 36.0
2225  indfor(k) = 3
2226  forfrac(k) = tem1 - f_one
2227 
2228  indself(k) = 0
2229  selffrac(k) = f_zero
2230 
2231 ! --- ... setup reference ratio to be used in calculation of binary
2232 ! species parameter in upper atmosphere.
2233 
2234  rfrate(k,1,1) = chi_mls(1,jp(k)) / chi_mls(2,jp(k))
2235  rfrate(k,1,2) = chi_mls(1,jp(k)+1) / chi_mls(2,jp(k)+1)
2236 
2237  rfrate(k,6,1) = chi_mls(3,jp(k)) / chi_mls(2,jp(k))
2238  rfrate(k,6,2) = chi_mls(3,jp(k)+1) / chi_mls(2,jp(k)+1)
2239 
2240  endif
2241 
2242 ! --- ... rescale selffac and forfac for use in taumol
2243 
2244  selffac(k) = colamt(k,1) * selffac(k)
2245  forfac(k) = colamt(k,1) * forfac(k)
2246 
2247  enddo ! end do_k layer loop
2248 
2249  return
2250 ! ..................................
2251  end subroutine setcoef
2252 ! ----------------------------------
2253 
2254 
2289 ! ----------------------------------
2290  subroutine rtrn &
2291  & ( semiss,delp,cldfrc,taucld,tautot,pklay,pklev, & ! --- inputs
2292  & fracs,secdif, nlay,nlp1, &
2293  & totuflux,totdflux,htr, totuclfl,totdclfl,htrcl, htrb & ! --- outputs
2294  & )
2296 ! =================== program usage description =================== !
2297 ! !
2298 ! purpose: compute the upward/downward radiative fluxes, and heating !
2299 ! rates for both clear or cloudy atmosphere. clouds are assumed as !
2300 ! randomly overlaping in a vertical colum. !
2301 ! !
2302 ! subprograms called: none !
2303 ! !
2304 ! ==================== defination of variables ==================== !
2305 ! !
2306 ! inputs: -size- !
2307 ! semiss - real, lw surface emissivity nbands!
2308 ! delp - real, layer pressure thickness (mb) nlay !
2309 ! cldfrc - real, layer cloud fraction 0:nlp1 !
2310 ! taucld - real, layer cloud opt depth nbands,nlay!
2311 ! tautot - real, total optical depth (gas+aerosols) ngptlw,nlay!
2312 ! pklay - real, integrated planck func at lay temp nbands*0:nlay!
2313 ! pklev - real, integrated planck func at lev temp nbands*0:nlay!
2314 ! fracs - real, planck fractions ngptlw,nlay!
2315 ! secdif - real, secant of diffusivity angle nbands!
2316 ! nlay - integer, number of vertical layers 1 !
2317 ! nlp1 - integer, number of vertical levels (interfaces) 1 !
2318 ! !
2319 ! outputs: !
2320 ! totuflux- real, total sky upward flux (w/m2) 0:nlay !
2321 ! totdflux- real, total sky downward flux (w/m2) 0:nlay !
2322 ! htr - real, total sky heating rate (k/sec or k/day) nlay !
2323 ! totuclfl- real, clear sky upward flux (w/m2) 0:nlay !
2324 ! totdclfl- real, clear sky downward flux (w/m2) 0:nlay !
2325 ! htrcl - real, clear sky heating rate (k/sec or k/day) nlay !
2326 ! htrb - real, spectral band lw heating rate (k/day) nlay*nbands!
2327 ! !
2328 ! module veriables: !
2329 ! ngb - integer, band index for each g-value ngptlw!
2330 ! fluxfac - real, conversion factor for fluxes (pi*2.e4) 1 !
2331 ! heatfac - real, conversion factor for heating rates (g/cp*1e-2) 1 !
2332 ! tblint - real, conversion factor for look-up tbl (float(ntbl) 1 !
2333 ! bpade - real, pade approx constant (1/0.278) 1 !
2334 ! wtdiff - real, weight for radiance to flux conversion 1 !
2335 ! ntbl - integer, dimension of look-up tables 1 !
2336 ! tau_tbl - real, clr-sky opt dep lookup table 0:ntbl !
2337 ! exp_tbl - real, transmittance lookup table 0:ntbl !
2338 ! tfn_tbl - real, tau transition function 0:ntbl !
2339 ! !
2340 ! local variables: !
2341 ! itgas - integer, index for gases contribution look-up table 1 !
2342 ! ittot - integer, index for gases plus clouds look-up table 1 !
2343 ! reflct - real, surface reflectance 1 !
2344 ! atrgas - real, gaseous absorptivity 1 !
2345 ! atrtot - real, gaseous and cloud absorptivity 1 !
2346 ! odcld - real, cloud optical depth 1 !
2347 ! efclrfr- real, effective clear sky fraction (1-efcldfr) nlay !
2348 ! odepth - real, optical depth of gaseous only 1 !
2349 ! odtot - real, optical depth of gas and cloud 1 !
2350 ! gasfac - real, gas-only pade factor, used for planck fn 1 !
2351 ! totfac - real, gas+cld pade factor, used for planck fn 1 !
2352 ! bbdgas - real, gas-only planck function for downward rt 1 !
2353 ! bbugas - real, gas-only planck function for upward rt 1 !
2354 ! bbdtot - real, gas and cloud planck function for downward rt 1 !
2355 ! bbutot - real, gas and cloud planck function for upward rt 1 !
2356 ! gassrcu- real, upwd source radiance due to gas only nlay!
2357 ! totsrcu- real, upwd source radiance due to gas+cld nlay!
2358 ! gassrcd- real, dnwd source radiance due to gas only 1 !
2359 ! totsrcd- real, dnwd source radiance due to gas+cld 1 !
2360 ! radtotu- real, spectrally summed total sky upwd radiance 1 !
2361 ! radclru- real, spectrally summed clear sky upwd radiance 1 !
2362 ! radtotd- real, spectrally summed total sky dnwd radiance 1 !
2363 ! radclrd- real, spectrally summed clear sky dnwd radiance 1 !
2364 ! toturad- real, total sky upward radiance by layer 0:nlay*nbands!
2365 ! clrurad- real, clear sky upward radiance by layer 0:nlay*nbands!
2366 ! totdrad- real, total sky downward radiance by layer 0:nlay*nbands!
2367 ! clrdrad- real, clear sky downward radiance by layer 0:nlay*nbands!
2368 ! fnet - real, net longwave flux (w/m2) 0:nlay !
2369 ! fnetc - real, clear sky net longwave flux (w/m2) 0:nlay !
2370 ! !
2371 ! !
2372 ! ******************************************************************* !
2373 ! original code description !
2374 ! !
2375 ! original version: e. j. mlawer, et al. rrtm_v3.0 !
2376 ! revision for gcms: michael j. iacono; october, 2002 !
2377 ! revision for f90: michael j. iacono; june, 2006 !
2378 ! !
2379 ! this program calculates the upward fluxes, downward fluxes, and !
2380 ! heating rates for an arbitrary clear or cloudy atmosphere. the input !
2381 ! to this program is the atmospheric profile, all Planck function !
2382 ! information, and the cloud fraction by layer. a variable diffusivity!
2383 ! angle (secdif) is used for the angle integration. bands 2-3 and 5-9 !
2384 ! use a value for secdif that varies from 1.50 to 1.80 as a function !
2385 ! of the column water vapor, and other bands use a value of 1.66. the !
2386 ! gaussian weight appropriate to this angle (wtdiff=0.5) is applied !
2387 ! here. note that use of the emissivity angle for the flux integration!
2388 ! can cause errors of 1 to 4 W/m2 within cloudy layers. !
2389 ! clouds are treated with a random cloud overlap method. !
2390 ! !
2391 ! ******************************************************************* !
2392 ! ====================== end of description block ================= !
2393 
2394 ! --- inputs:
2395  integer, intent(in) :: nlay, nlp1
2396 
2397  real (kind=kind_phys), dimension(0:nlp1), intent(in) :: cldfrc
2398  real (kind=kind_phys), dimension(nbands), intent(in) :: semiss, &
2399  & secdif
2400  real (kind=kind_phys), dimension(nlay), intent(in) :: delp
2401 
2402  real (kind=kind_phys), dimension(nbands,nlay),intent(in):: taucld
2403  real (kind=kind_phys), dimension(ngptlw,nlay),intent(in):: fracs, &
2404  & tautot
2405 
2406  real (kind=kind_phys), dimension(nbands,0:nlay), intent(in) :: &
2407  & pklev, pklay
2408 
2409 ! --- outputs:
2410  real (kind=kind_phys), dimension(nlay), intent(out) :: htr, htrcl
2411 
2412  real (kind=kind_phys), dimension(nlay,nbands),intent(out) :: htrb
2413 
2414  real (kind=kind_phys), dimension(0:nlay), intent(out) :: &
2415  & totuflux, totdflux, totuclfl, totdclfl
2416 
2417 ! --- locals:
2418  real (kind=kind_phys), parameter :: rec_6 = 0.166667
2419 
2420  real (kind=kind_phys), dimension(0:nlay,nbands) :: clrurad, &
2421  & clrdrad, toturad, totdrad
2422 
2423  real (kind=kind_phys), dimension(nlay) :: gassrcu, totsrcu, &
2424  & trngas, efclrfr, rfdelp
2425  real (kind=kind_phys), dimension(0:nlay) :: fnet, fnetc
2426 
2427  real (kind=kind_phys) :: totsrcd, gassrcd, tblind, odepth, odtot, &
2428  & odcld, atrtot, atrgas, reflct, totfac, gasfac, flxfac, &
2429  & plfrac, blay, bbdgas, bbdtot, bbugas, bbutot, dplnku, &
2430  & dplnkd, radtotu, radclru, radtotd, radclrd, rad0, &
2431  & clfr, trng, gasu
2432 
2433  integer :: ittot, itgas, ib, ig, k
2434 !
2435 !===> ... begin here
2436 !
2437  do ib = 1, nbands
2438  do k = 0, nlay
2439  toturad(k,ib) = f_zero
2440  totdrad(k,ib) = f_zero
2441  clrurad(k,ib) = f_zero
2442  clrdrad(k,ib) = f_zero
2443  enddo
2444  enddo
2445 
2446  do k = 0, nlay
2447  totuflux(k) = f_zero
2448  totdflux(k) = f_zero
2449  totuclfl(k) = f_zero
2450  totdclfl(k) = f_zero
2451  enddo
2452 
2453 ! --- ... loop over all g-points
2454 
2455  do ig = 1, ngptlw
2456  ib = ngb(ig)
2457 
2458  radtotd = f_zero
2459  radclrd = f_zero
2460 
2462 
2463  do k = nlay, 1, -1
2464 
2465 !!\n - clear sky, gases contribution
2466 
2467  odepth = max( f_zero, secdif(ib)*tautot(ig,k) )
2468  if (odepth <= 0.06) then
2469  atrgas = odepth - 0.5*odepth*odepth
2470  trng = f_one - atrgas
2471  gasfac = rec_6 * odepth
2472  else
2473  tblind = odepth / (bpade + odepth)
2474  itgas = tblint*tblind + 0.5
2475  trng = exp_tbl(itgas)
2476  atrgas = f_one - trng
2477  gasfac = tfn_tbl(itgas)
2478  odepth = tau_tbl(itgas)
2479  endif
2480 
2481  plfrac = fracs(ig,k)
2482  blay = pklay(ib,k)
2483 
2484  dplnku = pklev(ib,k ) - blay
2485  dplnkd = pklev(ib,k-1) - blay
2486  bbdgas = plfrac * (blay + dplnkd*gasfac)
2487  bbugas = plfrac * (blay + dplnku*gasfac)
2488  gassrcd= bbdgas * atrgas
2489  gassrcu(k)= bbugas * atrgas
2490  trngas(k) = trng
2491 
2492 !!\n - total sky, gases+clouds contribution
2493 
2494  clfr = cldfrc(k)
2495  if (clfr >= eps) then
2496 !!\n - cloudy layer
2497 
2498  odcld = secdif(ib) * taucld(ib,k)
2499  efclrfr(k) = f_one-(f_one - exp(-odcld))*clfr
2500  odtot = odepth + odcld
2501  if (odtot < 0.06) then
2502  totfac = rec_6 * odtot
2503  atrtot = odtot - 0.5*odtot*odtot
2504  else
2505  tblind = odtot / (bpade + odtot)
2506  ittot = tblint*tblind + 0.5
2507  totfac = tfn_tbl(ittot)
2508  atrtot = f_one - exp_tbl(ittot)
2509  endif
2510 
2511  bbdtot = plfrac * (blay + dplnkd*totfac)
2512  bbutot = plfrac * (blay + dplnku*totfac)
2513  totsrcd= bbdtot * atrtot
2514  totsrcu(k)= bbutot * atrtot
2515 
2516 ! --- ... total sky radiance
2517  radtotd = radtotd*trng*efclrfr(k) + gassrcd &
2518  & + clfr*(totsrcd - gassrcd)
2519  totdrad(k-1,ib) = totdrad(k-1,ib) + radtotd
2520 
2521 ! --- ... clear sky radiance
2522  radclrd = radclrd*trng + gassrcd
2523  clrdrad(k-1,ib) = clrdrad(k-1,ib) + radclrd
2524 
2525  else
2526 ! --- ... clear layer
2527 
2528 ! --- ... total sky radiance
2529  radtotd = radtotd*trng + gassrcd
2530  totdrad(k-1,ib) = totdrad(k-1,ib) + radtotd
2531 
2532 ! --- ... clear sky radiance
2533  radclrd = radclrd*trng + gassrcd
2534  clrdrad(k-1,ib) = clrdrad(k-1,ib) + radclrd
2535 
2536  endif ! end if_clfr_block
2537 
2538  enddo ! end do_k_loop
2539 
2543 
2544 ! note: spectral and Lambertian reflection are identical for the
2545 ! diffusivity angle flux integration used here.
2546 
2547  reflct = f_one - semiss(ib)
2548  rad0 = semiss(ib) * fracs(ig,1) * pklay(ib,0)
2549 
2551  radtotu = rad0 + reflct*radtotd
2552  toturad(0,ib) = toturad(0,ib) + radtotu
2553 
2555  radclru = rad0 + reflct*radclrd
2556  clrurad(0,ib) = clrurad(0,ib) + radclru
2557 
2559 
2560  do k = 1, nlay
2561  clfr = cldfrc(k)
2562  trng = trngas(k)
2563  gasu = gassrcu(k)
2564 
2565  if (clfr >= eps) then
2566 ! --- ... cloudy layer
2567 
2568 ! --- ... total sky radiance
2569  radtotu = radtotu*trng*efclrfr(k) + gasu &
2570  & + clfr*(totsrcu(k) - gasu)
2571  toturad(k,ib) = toturad(k,ib) + radtotu
2572 
2573 ! --- ... clear sky radiance
2574  radclru = radclru*trng + gasu
2575  clrurad(k,ib) = clrurad(k,ib) + radclru
2576 
2577  else
2578 ! --- ... clear layer
2579 
2580 ! --- ... total sky radiance
2581  radtotu = radtotu*trng + gasu
2582  toturad(k,ib) = toturad(k,ib) + radtotu
2583 
2584 ! --- ... clear sky radiance
2585  radclru = radclru*trng + gasu
2586  clrurad(k,ib) = clrurad(k,ib) + radclru
2587 
2588  endif ! end if_clfr_block
2589 
2590  enddo ! end do_k_loop
2591 
2592  enddo ! end do_ig_loop
2593 
2596 
2597  flxfac = wtdiff * fluxfac
2598 
2599  do k = 0, nlay
2600  do ib = 1, nbands
2601  totuflux(k) = totuflux(k) + toturad(k,ib)
2602  totdflux(k) = totdflux(k) + totdrad(k,ib)
2603  totuclfl(k) = totuclfl(k) + clrurad(k,ib)
2604  totdclfl(k) = totdclfl(k) + clrdrad(k,ib)
2605  enddo
2606 
2607  totuflux(k) = totuflux(k) * flxfac
2608  totdflux(k) = totdflux(k) * flxfac
2609  totuclfl(k) = totuclfl(k) * flxfac
2610  totdclfl(k) = totdclfl(k) * flxfac
2611  enddo
2612 
2613 ! --- ... calculate net fluxes and heating rates
2614  fnet(0) = totuflux(0) - totdflux(0)
2615 
2616  do k = 1, nlay
2617  rfdelp(k) = heatfac / delp(k)
2618  fnet(k) = totuflux(k) - totdflux(k)
2619  htr(k) = (fnet(k-1) - fnet(k)) * rfdelp(k)
2620  enddo
2621 
2622 !! --- ... optional clear sky heating rates
2623  if ( lhlw0 ) then
2624  fnetc(0) = totuclfl(0) - totdclfl(0)
2625 
2626  do k = 1, nlay
2627  fnetc(k) = totuclfl(k) - totdclfl(k)
2628  htrcl(k) = (fnetc(k-1) - fnetc(k)) * rfdelp(k)
2629  enddo
2630  endif
2631 
2632 !! --- ... optional spectral band heating rates
2633  if ( lhlwb ) then
2634  do ib = 1, nbands
2635  fnet(0) = (toturad(0,ib) - totdrad(0,ib)) * flxfac
2636 
2637  do k = 1, nlay
2638  fnet(k) = (toturad(k,ib) - totdrad(k,ib)) * flxfac
2639  htrb(k,ib) = (fnet(k-1) - fnet(k)) * rfdelp(k)
2640  enddo
2641  enddo
2642  endif
2643 
2644 ! ..................................
2645  end subroutine rtrn
2646 ! ----------------------------------
2647 
2648 
2672 ! ----------------------------------
2673  subroutine rtrnmr &
2674  & ( semiss,delp,cldfrc,taucld,tautot,pklay,pklev, &! --- inputs
2675  & fracs,secdif, nlay,nlp1, &
2676  & totuflux,totdflux,htr, totuclfl,totdclfl,htrcl, htrb & ! --- outputs:
2677  & )
2679 ! =================== program usage description =================== !
2680 ! !
2681 ! purpose: compute the upward/downward radiative fluxes, and heating !
2682 ! rates for both clear or cloudy atmosphere. clouds are assumed as in !
2683 ! maximum-randomly overlaping in a vertical colum. !
2684 ! !
2685 ! subprograms called: none !
2686 ! !
2687 ! ==================== defination of variables ==================== !
2688 ! !
2689 ! inputs: -size- !
2690 ! semiss - real, lw surface emissivity nbands!
2691 ! delp - real, layer pressure thickness (mb) nlay !
2692 ! cldfrc - real, layer cloud fraction 0:nlp1 !
2693 ! taucld - real, layer cloud opt depth nbands,nlay!
2694 ! tautot - real, total optical depth (gas+aerosols) ngptlw,nlay!
2695 ! pklay - real, integrated planck func at lay temp nbands*0:nlay!
2696 ! pklev - real, integrated planck func at lev temp nbands*0:nlay!
2697 ! fracs - real, planck fractions ngptlw,nlay!
2698 ! secdif - real, secant of diffusivity angle nbands!
2699 ! nlay - integer, number of vertical layers 1 !
2700 ! nlp1 - integer, number of vertical levels (interfaces) 1 !
2701 ! !
2702 ! outputs: !
2703 ! totuflux- real, total sky upward flux (w/m2) 0:nlay !
2704 ! totdflux- real, total sky downward flux (w/m2) 0:nlay !
2705 ! htr - real, total sky heating rate (k/sec or k/day) nlay !
2706 ! totuclfl- real, clear sky upward flux (w/m2) 0:nlay !
2707 ! totdclfl- real, clear sky downward flux (w/m2) 0:nlay !
2708 ! htrcl - real, clear sky heating rate (k/sec or k/day) nlay !
2709 ! htrb - real, spectral band lw heating rate (k/day) nlay*nbands!
2710 ! !
2711 ! module veriables: !
2712 ! ngb - integer, band index for each g-value ngptlw!
2713 ! fluxfac - real, conversion factor for fluxes (pi*2.e4) 1 !
2714 ! heatfac - real, conversion factor for heating rates (g/cp*1e-2) 1 !
2715 ! tblint - real, conversion factor for look-up tbl (float(ntbl) 1 !
2716 ! bpade - real, pade approx constant (1/0.278) 1 !
2717 ! wtdiff - real, weight for radiance to flux conversion 1 !
2718 ! ntbl - integer, dimension of look-up tables 1 !
2719 ! tau_tbl - real, clr-sky opt dep lookup table 0:ntbl !
2720 ! exp_tbl - real, transmittance lookup table 0:ntbl !
2721 ! tfn_tbl - real, tau transition function 0:ntbl !
2722 ! !
2723 ! local variables: !
2724 ! itgas - integer, index for gases contribution look-up table 1 !
2725 ! ittot - integer, index for gases plus clouds look-up table 1 !
2726 ! reflct - real, surface reflectance 1 !
2727 ! atrgas - real, gaseous absorptivity 1 !
2728 ! atrtot - real, gaseous and cloud absorptivity 1 !
2729 ! odcld - real, cloud optical depth 1 !
2730 ! odepth - real, optical depth of gaseous only 1 !
2731 ! odtot - real, optical depth of gas and cloud 1 !
2732 ! gasfac - real, gas-only pade factor, used for planck fn 1 !
2733 ! totfac - real, gas+cld pade factor, used for planck fn 1 !
2734 ! bbdgas - real, gas-only planck function for downward rt 1 !
2735 ! bbugas - real, gas-only planck function for upward rt 1 !
2736 ! bbdtot - real, gas and cloud planck function for downward rt 1 !
2737 ! bbutot - real, gas and cloud planck function for upward rt 1 !
2738 ! gassrcu- real, upwd source radiance due to gas only nlay!
2739 ! totsrcu- real, upwd source radiance due to gas + cld nlay!
2740 ! gassrcd- real, dnwd source radiance due to gas only 1 !
2741 ! totsrcd- real, dnwd source radiance due to gas + cld 1 !
2742 ! radtotu- real, spectrally summed total sky upwd radiance 1 !
2743 ! radclru- real, spectrally summed clear sky upwd radiance 1 !
2744 ! radtotd- real, spectrally summed total sky dnwd radiance 1 !
2745 ! radclrd- real, spectrally summed clear sky dnwd radiance 1 !
2746 ! toturad- real, total sky upward radiance by layer 0:nlay*nbands!
2747 ! clrurad- real, clear sky upward radiance by layer 0:nlay*nbands!
2748 ! totdrad- real, total sky downward radiance by layer 0:nlay*nbands!
2749 ! clrdrad- real, clear sky downward radiance by layer 0:nlay*nbands!
2750 ! fnet - real, net longwave flux (w/m2) 0:nlay !
2751 ! fnetc - real, clear sky net longwave flux (w/m2) 0:nlay !
2752 ! !
2753 ! !
2754 ! ******************************************************************* !
2755 ! original code description !
2756 ! !
2757 ! original version: e. j. mlawer, et al. rrtm_v3.0 !
2758 ! revision for gcms: michael j. iacono; october, 2002 !
2759 ! revision for f90: michael j. iacono; june, 2006 !
2760 ! !
2761 ! this program calculates the upward fluxes, downward fluxes, and !
2762 ! heating rates for an arbitrary clear or cloudy atmosphere. the input !
2763 ! to this program is the atmospheric profile, all Planck function !
2764 ! information, and the cloud fraction by layer. a variable diffusivity!
2765 ! angle (secdif) is used for the angle integration. bands 2-3 and 5-9 !
2766 ! use a value for secdif that varies from 1.50 to 1.80 as a function !
2767 ! of the column water vapor, and other bands use a value of 1.66. the !
2768 ! gaussian weight appropriate to this angle (wtdiff=0.5) is applied !
2769 ! here. note that use of the emissivity angle for the flux integration!
2770 ! can cause errors of 1 to 4 W/m2 within cloudy layers. !
2771 ! clouds are treated with a maximum-random cloud overlap method. !
2772 ! !
2773 ! ******************************************************************* !
2774 ! ====================== end of description block ================= !
2775 
2776 ! --- inputs:
2777  integer, intent(in) :: nlay, nlp1
2778 
2779  real (kind=kind_phys), dimension(0:nlp1), intent(in) :: cldfrc
2780  real (kind=kind_phys), dimension(nbands), intent(in) :: semiss, &
2781  & secdif
2782  real (kind=kind_phys), dimension(nlay), intent(in) :: delp
2783 
2784  real (kind=kind_phys), dimension(nbands,nlay),intent(in):: taucld
2785  real (kind=kind_phys), dimension(ngptlw,nlay),intent(in):: fracs, &
2786  & tautot
2787 
2788  real (kind=kind_phys), dimension(nbands,0:nlay), intent(in) :: &
2789  & pklev, pklay
2790 
2791 ! --- outputs:
2792  real (kind=kind_phys), dimension(nlay), intent(out) :: htr, htrcl
2793 
2794  real (kind=kind_phys), dimension(nlay,nbands),intent(out) :: htrb
2795 
2796  real (kind=kind_phys), dimension(0:nlay), intent(out) :: &
2797  & totuflux, totdflux, totuclfl, totdclfl
2798 
2799 ! --- locals:
2800  real (kind=kind_phys), parameter :: rec_6 = 0.166667
2801 
2802  real (kind=kind_phys), dimension(0:nlay,nbands) :: clrurad, &
2803  & clrdrad, toturad, totdrad
2804 
2805  real (kind=kind_phys), dimension(nlay) :: gassrcu, totsrcu, &
2806  & trngas, trntot, rfdelp
2807  real (kind=kind_phys), dimension(0:nlay) :: fnet, fnetc
2808 
2809  real (kind=kind_phys) :: totsrcd, gassrcd, tblind, odepth, odtot, &
2810  & odcld, atrtot, atrgas, reflct, totfac, gasfac, flxfac, &
2811  & plfrac, blay, bbdgas, bbdtot, bbugas, bbutot, dplnku, &
2812  & dplnkd, radtotu, radclru, radtotd, radclrd, rad0, rad, &
2813  & totradd, clrradd, totradu, clrradu, fmax, fmin, rat1, rat2,&
2814  & radmod, clfr, trng, trnt, gasu, totu
2815 
2816  integer :: ittot, itgas, ib, ig, k
2817 
2818 ! dimensions for cloud overlap adjustment
2819  real (kind=kind_phys), dimension(nlp1) :: faccld1u, faccld2u, &
2820  & facclr1u, facclr2u, faccmb1u, faccmb2u
2821  real (kind=kind_phys), dimension(0:nlay) :: faccld1d, faccld2d, &
2822  & facclr1d, facclr2d, faccmb1d, faccmb2d
2823 
2824  logical :: lstcldu(nlay), lstcldd(nlay)
2825 !
2826 !===> ... begin here
2827 !
2828  do k = 1, nlp1
2829  faccld1u(k) = f_zero
2830  faccld2u(k) = f_zero
2831  facclr1u(k) = f_zero
2832  facclr2u(k) = f_zero
2833  faccmb1u(k) = f_zero
2834  faccmb2u(k) = f_zero
2835  enddo
2836 
2837  lstcldu(1) = cldfrc(1) > eps
2838  rat1 = f_zero
2839  rat2 = f_zero
2840 
2841  do k = 1, nlay-1
2842 
2843  lstcldu(k+1) = cldfrc(k+1)>eps .and. cldfrc(k)<=eps
2844 
2845  if (cldfrc(k) > eps) then
2846 
2848 
2849  if (cldfrc(k+1) >= cldfrc(k)) then
2850  if (lstcldu(k)) then
2851  if (cldfrc(k) < f_one) then
2852  facclr2u(k+1) = (cldfrc(k+1) - cldfrc(k)) &
2853  & / (f_one - cldfrc(k))
2854  endif
2855  facclr2u(k) = f_zero
2856  faccld2u(k) = f_zero
2857  else
2858  fmax = max(cldfrc(k), cldfrc(k-1))
2859  if (cldfrc(k+1) > fmax) then
2860  facclr1u(k+1) = rat2
2861  facclr2u(k+1) = (cldfrc(k+1) - fmax)/(f_one - fmax)
2862  elseif (cldfrc(k+1) < fmax) then
2863  facclr1u(k+1) = (cldfrc(k+1) - cldfrc(k)) &
2864  & / (cldfrc(k-1) - cldfrc(k))
2865  else
2866  facclr1u(k+1) = rat2
2867  endif
2868  endif
2869 
2870  if (facclr1u(k+1)>f_zero .or. facclr2u(k+1)>f_zero) then
2871  rat1 = f_one
2872  rat2 = f_zero
2873  else
2874  rat1 = f_zero
2875  rat2 = f_zero
2876  endif
2877  else
2878  if (lstcldu(k)) then
2879  faccld2u(k+1) = (cldfrc(k) - cldfrc(k+1)) / cldfrc(k)
2880  facclr2u(k) = f_zero
2881  faccld2u(k) = f_zero
2882  else
2883  fmin = min(cldfrc(k), cldfrc(k-1))
2884  if (cldfrc(k+1) <= fmin) then
2885  faccld1u(k+1) = rat1
2886  faccld2u(k+1) = (fmin - cldfrc(k+1)) / fmin
2887  else
2888  faccld1u(k+1) = (cldfrc(k) - cldfrc(k+1)) &
2889  & / (cldfrc(k) - fmin)
2890  endif
2891  endif
2892 
2893  if (faccld1u(k+1)>f_zero .or. faccld2u(k+1)>f_zero) then
2894  rat1 = f_zero
2895  rat2 = f_one
2896  else
2897  rat1 = f_zero
2898  rat2 = f_zero
2899  endif
2900  endif
2901 
2902  faccmb1u(k+1) = facclr1u(k+1) * faccld2u(k) * cldfrc(k-1)
2903  faccmb2u(k+1) = faccld1u(k+1) * facclr2u(k) &
2904  & * (f_one - cldfrc(k-1))
2905  endif
2906 
2907  enddo
2908 
2909  do k = 0, nlay
2910  faccld1d(k) = f_zero
2911  faccld2d(k) = f_zero
2912  facclr1d(k) = f_zero
2913  facclr2d(k) = f_zero
2914  faccmb1d(k) = f_zero
2915  faccmb2d(k) = f_zero
2916  enddo
2917 
2918  lstcldd(nlay) = cldfrc(nlay) > eps
2919  rat1 = f_zero
2920  rat2 = f_zero
2921 
2922  do k = nlay, 2, -1
2923 
2924  lstcldd(k-1) = cldfrc(k-1) > eps .and. cldfrc(k)<=eps
2925 
2926  if (cldfrc(k) > eps) then
2927 
2928  if (cldfrc(k-1) >= cldfrc(k)) then
2929  if (lstcldd(k)) then
2930  if (cldfrc(k) < f_one) then
2931  facclr2d(k-1) = (cldfrc(k-1) - cldfrc(k)) &
2932  & / (f_one - cldfrc(k))
2933  endif
2934 
2935  facclr2d(k) = f_zero
2936  faccld2d(k) = f_zero
2937  else
2938  fmax = max(cldfrc(k), cldfrc(k+1))
2939 
2940  if (cldfrc(k-1) > fmax) then
2941  facclr1d(k-1) = rat2
2942  facclr2d(k-1) = (cldfrc(k-1) - fmax) / (f_one - fmax)
2943  elseif (cldfrc(k-1) < fmax) then
2944  facclr1d(k-1) = (cldfrc(k-1) - cldfrc(k)) &
2945  & / (cldfrc(k+1) - cldfrc(k))
2946  else
2947  facclr1d(k-1) = rat2
2948  endif
2949  endif
2950 
2951  if (facclr1d(k-1)>f_zero .or. facclr2d(k-1)>f_zero) then
2952  rat1 = f_one
2953  rat2 = f_zero
2954  else
2955  rat1 = f_zero
2956  rat2 = f_zero
2957  endif
2958  else
2959  if (lstcldd(k)) then
2960  faccld2d(k-1) = (cldfrc(k) - cldfrc(k-1)) / cldfrc(k)
2961  facclr2d(k) = f_zero
2962  faccld2d(k) = f_zero
2963  else
2964  fmin = min(cldfrc(k), cldfrc(k+1))
2965 
2966  if (cldfrc(k-1) <= fmin) then
2967  faccld1d(k-1) = rat1
2968  faccld2d(k-1) = (fmin - cldfrc(k-1)) / fmin
2969  else
2970  faccld1d(k-1) = (cldfrc(k) - cldfrc(k-1)) &
2971  & / (cldfrc(k) - fmin)
2972  endif
2973  endif
2974 
2975  if (faccld1d(k-1)>f_zero .or. faccld2d(k-1)>f_zero) then
2976  rat1 = f_zero
2977  rat2 = f_one
2978  else
2979  rat1 = f_zero
2980  rat2 = f_zero
2981  endif
2982  endif
2983 
2984  faccmb1d(k-1) = facclr1d(k-1) * faccld2d(k) * cldfrc(k+1)
2985  faccmb2d(k-1) = faccld1d(k-1) * facclr2d(k) &
2986  & * (f_one - cldfrc(k+1))
2987  endif
2988 
2989  enddo
2990 
2992 
2993  do ib = 1, nbands
2994  do k = 0, nlay
2995  toturad(k,ib) = f_zero
2996  totdrad(k,ib) = f_zero
2997  clrurad(k,ib) = f_zero
2998  clrdrad(k,ib) = f_zero
2999  enddo
3000  enddo
3001 
3002  do k = 0, nlay
3003  totuflux(k) = f_zero
3004  totdflux(k) = f_zero
3005  totuclfl(k) = f_zero
3006  totdclfl(k) = f_zero
3007  enddo
3008 
3009 ! --- ... loop over all g-points
3010 
3011  do ig = 1, ngptlw
3012  ib = ngb(ig)
3013 
3014  radtotd = f_zero
3015  radclrd = f_zero
3016 
3018 
3019  do k = nlay, 1, -1
3020 
3021 ! --- ... clear sky, gases contribution
3022 
3023  odepth = max( f_zero, secdif(ib)*tautot(ig,k) )
3024  if (odepth <= 0.06) then
3025  atrgas = odepth - 0.5*odepth*odepth
3026  trng = f_one - atrgas
3027  gasfac = rec_6 * odepth
3028  else
3029  tblind = odepth / (bpade + odepth)
3030  itgas = tblint*tblind + 0.5
3031  trng = exp_tbl(itgas)
3032  atrgas = f_one - trng
3033  gasfac = tfn_tbl(itgas)
3034  odepth = tau_tbl(itgas)
3035  endif
3036 
3037  plfrac = fracs(ig,k)
3038  blay = pklay(ib,k)
3039 
3040  dplnku = pklev(ib,k ) - blay
3041  dplnkd = pklev(ib,k-1) - blay
3042  bbdgas = plfrac * (blay + dplnkd*gasfac)
3043  bbugas = plfrac * (blay + dplnku*gasfac)
3044  gassrcd = bbdgas * atrgas
3045  gassrcu(k)= bbugas * atrgas
3046  trngas(k) = trng
3047 
3048 ! --- ... total sky, gases+clouds contribution
3049 
3050  clfr = cldfrc(k)
3051  if (lstcldd(k)) then
3052  totradd = clfr * radtotd
3053  clrradd = radtotd - totradd
3054  rad = f_zero
3055  endif
3056 
3057  if (clfr >= eps) then
3059 
3060  odcld = secdif(ib) * taucld(ib,k)
3061  odtot = odepth + odcld
3062  if (odtot < 0.06) then
3063  totfac = rec_6 * odtot
3064  atrtot = odtot - 0.5*odtot*odtot
3065  trnt = f_one - atrtot
3066  else
3067  tblind = odtot / (bpade + odtot)
3068  ittot = tblint*tblind + 0.5
3069  totfac = tfn_tbl(ittot)
3070  trnt = exp_tbl(ittot)
3071  atrtot = f_one - trnt
3072  endif
3073 
3074  bbdtot = plfrac * (blay + dplnkd*totfac)
3075  bbutot = plfrac * (blay + dplnku*totfac)
3076  totsrcd = bbdtot * atrtot
3077  totsrcu(k)= bbutot * atrtot
3078  trntot(k) = trnt
3079 
3080  totradd = totradd*trnt + clfr*totsrcd
3081  clrradd = clrradd*trng + (f_one - clfr)*gassrcd
3082 
3084  radtotd = totradd + clrradd
3085  totdrad(k-1,ib) = totdrad(k-1,ib) + radtotd
3086 
3088  radclrd = radclrd*trng + gassrcd
3089  clrdrad(k-1,ib) = clrdrad(k-1,ib) + radclrd
3090 
3091  radmod = rad*(facclr1d(k-1)*trng + faccld1d(k-1)*trnt) &
3092  & - faccmb1d(k-1)*gassrcd + faccmb2d(k-1)*totsrcd
3093 
3094  rad = -radmod + facclr2d(k-1)*(clrradd + radmod) &
3095  & - faccld2d(k-1)*(totradd - radmod)
3096  totradd = totradd + rad
3097  clrradd = clrradd - rad
3098 
3099  else
3100 ! --- ... clear layer
3101 
3102 ! --- ... total sky radiance
3103  radtotd = radtotd*trng + gassrcd
3104  totdrad(k-1,ib) = totdrad(k-1,ib) + radtotd
3105 
3106 ! --- ... clear sky radiance
3107  radclrd = radclrd*trng + gassrcd
3108  clrdrad(k-1,ib) = clrdrad(k-1,ib) + radclrd
3109 
3110  endif ! end if_clfr_block
3111 
3112  enddo ! end do_k_loop
3113 
3117 
3118 ! note: spectral and Lambertian reflection are identical for the
3119 ! diffusivity angle flux integration used here.
3120 
3121  reflct = f_one - semiss(ib)
3122  rad0 = semiss(ib) * fracs(ig,1) * pklay(ib,0)
3123 
3125  radtotu = rad0 + reflct*radtotd
3126  toturad(0,ib) = toturad(0,ib) + radtotu
3127 
3129  radclru = rad0 + reflct*radclrd
3130  clrurad(0,ib) = clrurad(0,ib) + radclru
3131 
3133 
3134  do k = 1, nlay
3135 
3136  clfr = cldfrc(k)
3137  trng = trngas(k)
3138  gasu = gassrcu(k)
3139 
3140  if (lstcldu(k)) then
3141  totradu = clfr * radtotu
3142  clrradu = radtotu - totradu
3143  rad = f_zero
3144  endif
3145 
3146  if (clfr >= eps) then
3148 
3149  trnt = trntot(k)
3150  totu = totsrcu(k)
3151  totradu = totradu*trnt + clfr*totu
3152  clrradu = clrradu*trng + (f_one - clfr)*gasu
3153 
3155  radtotu = totradu + clrradu
3156  toturad(k,ib) = toturad(k,ib) + radtotu
3157 
3159  radclru = radclru*trng + gasu
3160  clrurad(k,ib) = clrurad(k,ib) + radclru
3161 
3162  radmod = rad*(facclr1u(k+1)*trng + faccld1u(k+1)*trnt) &
3163  & - faccmb1u(k+1)*gasu + faccmb2u(k+1)*totu
3164  rad = -radmod + facclr2u(k+1)*(clrradu + radmod) &
3165  & - faccld2u(k+1)*(totradu - radmod)
3166  totradu = totradu + rad
3167  clrradu = clrradu - rad
3168 
3169  else
3170 ! --- ... clear layer
3171 
3172 ! --- ... total sky radiance
3173  radtotu = radtotu*trng + gasu
3174  toturad(k,ib) = toturad(k,ib) + radtotu
3175 
3176 ! --- ... clear sky radiance
3177  radclru = radclru*trng + gasu
3178  clrurad(k,ib) = clrurad(k,ib) + radclru
3179 
3180  endif ! end if_clfr_block
3181 
3182  enddo ! end do_k_loop
3183 
3184  enddo ! end do_ig_loop
3185 
3188 
3189  flxfac = wtdiff * fluxfac
3190 
3191  do k = 0, nlay
3192  do ib = 1, nbands
3193  totuflux(k) = totuflux(k) + toturad(k,ib)
3194  totdflux(k) = totdflux(k) + totdrad(k,ib)
3195  totuclfl(k) = totuclfl(k) + clrurad(k,ib)
3196  totdclfl(k) = totdclfl(k) + clrdrad(k,ib)
3197  enddo
3198 
3199  totuflux(k) = totuflux(k) * flxfac
3200  totdflux(k) = totdflux(k) * flxfac
3201  totuclfl(k) = totuclfl(k) * flxfac
3202  totdclfl(k) = totdclfl(k) * flxfac
3203  enddo
3204 
3205 ! --- ... calculate net fluxes and heating rates
3206  fnet(0) = totuflux(0) - totdflux(0)
3207 
3208  do k = 1, nlay
3209  rfdelp(k) = heatfac / delp(k)
3210  fnet(k) = totuflux(k) - totdflux(k)
3211  htr(k) = (fnet(k-1) - fnet(k)) * rfdelp(k)
3212  enddo
3213 
3214 !! --- ... optional clear sky heating rates
3215  if ( lhlw0 ) then
3216  fnetc(0) = totuclfl(0) - totdclfl(0)
3217 
3218  do k = 1, nlay
3219  fnetc(k) = totuclfl(k) - totdclfl(k)
3220  htrcl(k) = (fnetc(k-1) - fnetc(k)) * rfdelp(k)
3221  enddo
3222  endif
3223 
3224 !! --- ... optional spectral band heating rates
3225  if ( lhlwb ) then
3226  do ib = 1, nbands
3227  fnet(0) = (toturad(0,ib) - totdrad(0,ib)) * flxfac
3228 
3229  do k = 1, nlay
3230  fnet(k) = (toturad(k,ib) - totdrad(k,ib)) * flxfac
3231  htrb(k,ib) = (fnet(k-1) - fnet(k)) * rfdelp(k)
3232  enddo
3233  enddo
3234  endif
3235 
3236 ! .................................
3237  end subroutine rtrnmr
3238 ! ---------------------------------
3240 
3241 
3265 ! ---------------------------------
3266  subroutine rtrnmc &
3267  & ( semiss,delp,cldfmc,taucld,tautot,pklay,pklev, & ! --- inputs:
3268  & fracs,secdif, nlay,nlp1, &
3269  & totuflux,totdflux,htr, totuclfl,totdclfl,htrcl, htrb & ! --- outputs:
3270  & )
3272 ! =================== program usage description =================== !
3273 ! !
3274 ! purpose: compute the upward/downward radiative fluxes, and heating !
3275 ! rates for both clear or cloudy atmosphere. clouds are treated with !
3276 ! the mcica stochastic approach. !
3277 ! !
3278 ! subprograms called: none !
3279 ! !
3280 ! ==================== defination of variables ==================== !
3281 ! !
3282 ! inputs: -size- !
3283 ! semiss - real, lw surface emissivity nbands!
3284 ! delp - real, layer pressure thickness (mb) nlay !
3285 ! cldfmc - real, layer cloud fraction (sub-column) ngptlw*nlay!
3286 ! taucld - real, layer cloud opt depth nbands*nlay!
3287 ! tautot - real, total optical depth (gas+aerosols) ngptlw*nlay!
3288 ! pklay - real, integrated planck func at lay temp nbands*0:nlay!
3289 ! pklev - real, integrated planck func at lev temp nbands*0:nlay!
3290 ! fracs - real, planck fractions ngptlw*nlay!
3291 ! secdif - real, secant of diffusivity angle nbands!
3292 ! nlay - integer, number of vertical layers 1 !
3293 ! nlp1 - integer, number of vertical levels (interfaces) 1 !
3294 ! !
3295 ! outputs: !
3296 ! totuflux- real, total sky upward flux (w/m2) 0:nlay !
3297 ! totdflux- real, total sky downward flux (w/m2) 0:nlay !
3298 ! htr - real, total sky heating rate (k/sec or k/day) nlay !
3299 ! totuclfl- real, clear sky upward flux (w/m2) 0:nlay !
3300 ! totdclfl- real, clear sky downward flux (w/m2) 0:nlay !
3301 ! htrcl - real, clear sky heating rate (k/sec or k/day) nlay !
3302 ! htrb - real, spectral band lw heating rate (k/day) nlay*nbands!
3303 ! !
3304 ! module veriables: !
3305 ! ngb - integer, band index for each g-value ngptlw!
3306 ! fluxfac - real, conversion factor for fluxes (pi*2.e4) 1 !
3307 ! heatfac - real, conversion factor for heating rates (g/cp*1e-2) 1 !
3308 ! tblint - real, conversion factor for look-up tbl (float(ntbl) 1 !
3309 ! bpade - real, pade approx constant (1/0.278) 1 !
3310 ! wtdiff - real, weight for radiance to flux conversion 1 !
3311 ! ntbl - integer, dimension of look-up tables 1 !
3312 ! tau_tbl - real, clr-sky opt dep lookup table 0:ntbl !
3313 ! exp_tbl - real, transmittance lookup table 0:ntbl !
3314 ! tfn_tbl - real, tau transition function 0:ntbl !
3315 ! !
3316 ! local variables: !
3317 ! itgas - integer, index for gases contribution look-up table 1 !
3318 ! ittot - integer, index for gases plus clouds look-up table 1 !
3319 ! reflct - real, surface reflectance 1 !
3320 ! atrgas - real, gaseous absorptivity 1 !
3321 ! atrtot - real, gaseous and cloud absorptivity 1 !
3322 ! odcld - real, cloud optical depth 1 !
3323 ! efclrfr- real, effective clear sky fraction (1-efcldfr) nlay!
3324 ! odepth - real, optical depth of gaseous only 1 !
3325 ! odtot - real, optical depth of gas and cloud 1 !
3326 ! gasfac - real, gas-only pade factor, used for planck function 1 !
3327 ! totfac - real, gas and cloud pade factor, used for planck fn 1 !
3328 ! bbdgas - real, gas-only planck function for downward rt 1 !
3329 ! bbugas - real, gas-only planck function for upward rt 1 !
3330 ! bbdtot - real, gas and cloud planck function for downward rt 1 !
3331 ! bbutot - real, gas and cloud planck function for upward rt 1 !
3332 ! gassrcu- real, upwd source radiance due to gas nlay!
3333 ! totsrcu- real, upwd source radiance due to gas+cld nlay!
3334 ! gassrcd- real, dnwd source radiance due to gas 1 !
3335 ! totsrcd- real, dnwd source radiance due to gas+cld 1 !
3336 ! radtotu- real, spectrally summed total sky upwd radiance 1 !
3337 ! radclru- real, spectrally summed clear sky upwd radiance 1 !
3338 ! radtotd- real, spectrally summed total sky dnwd radiance 1 !
3339 ! radclrd- real, spectrally summed clear sky dnwd radiance 1 !
3340 ! toturad- real, total sky upward radiance by layer 0:nlay*nbands!
3341 ! clrurad- real, clear sky upward radiance by layer 0:nlay*nbands!
3342 ! totdrad- real, total sky downward radiance by layer 0:nlay*nbands!
3343 ! clrdrad- real, clear sky downward radiance by layer 0:nlay*nbands!
3344 ! fnet - real, net longwave flux (w/m2) 0:nlay !
3345 ! fnetc - real, clear sky net longwave flux (w/m2) 0:nlay !
3346 ! !
3347 ! !
3348 ! ******************************************************************* !
3349 ! original code description !
3350 ! !
3351 ! original version: e. j. mlawer, et al. rrtm_v3.0 !
3352 ! revision for gcms: michael j. iacono; october, 2002 !
3353 ! revision for f90: michael j. iacono; june, 2006 !
3354 ! !
3355 ! this program calculates the upward fluxes, downward fluxes, and !
3356 ! heating rates for an arbitrary clear or cloudy atmosphere. the input !
3357 ! to this program is the atmospheric profile, all Planck function !
3358 ! information, and the cloud fraction by layer. a variable diffusivity!
3359 ! angle (secdif) is used for the angle integration. bands 2-3 and 5-9 !
3360 ! use a value for secdif that varies from 1.50 to 1.80 as a function !
3361 ! of the column water vapor, and other bands use a value of 1.66. the !
3362 ! gaussian weight appropriate to this angle (wtdiff=0.5) is applied !
3363 ! here. note that use of the emissivity angle for the flux integration!
3364 ! can cause errors of 1 to 4 W/m2 within cloudy layers. !
3365 ! clouds are treated with the mcica stochastic approach and !
3366 ! maximum-random cloud overlap. !
3367 ! !
3368 ! ******************************************************************* !
3369 ! ====================== end of description block ================= !
3370 
3371 ! --- inputs:
3372  integer, intent(in) :: nlay, nlp1
3373 
3374  real (kind=kind_phys), dimension(nbands), intent(in) :: semiss, &
3375  & secdif
3376  real (kind=kind_phys), dimension(nlay), intent(in) :: delp
3377 
3378  real (kind=kind_phys), dimension(nbands,nlay),intent(in):: taucld
3379  real (kind=kind_phys), dimension(ngptlw,nlay),intent(in):: fracs, &
3380  & tautot, cldfmc
3381 
3382  real (kind=kind_phys), dimension(nbands,0:nlay), intent(in) :: &
3383  & pklev, pklay
3384 
3385 ! --- outputs:
3386  real (kind=kind_phys), dimension(nlay), intent(out) :: htr, htrcl
3387 
3388  real (kind=kind_phys), dimension(nlay,nbands),intent(out) :: htrb
3389 
3390  real (kind=kind_phys), dimension(0:nlay), intent(out) :: &
3391  & totuflux, totdflux, totuclfl, totdclfl
3392 
3393 ! --- locals:
3394  real (kind=kind_phys), parameter :: rec_6 = 0.166667
3395 
3396  real (kind=kind_phys), dimension(0:nlay,nbands) :: clrurad, &
3397  & clrdrad, toturad, totdrad
3398 
3399  real (kind=kind_phys), dimension(nlay) :: gassrcu, totsrcu, &
3400  & trngas, efclrfr, rfdelp
3401  real (kind=kind_phys), dimension(0:nlay) :: fnet, fnetc
3402 
3403  real (kind=kind_phys) :: totsrcd, gassrcd, tblind, odepth, odtot, &
3404  & odcld, atrtot, atrgas, reflct, totfac, gasfac, flxfac, &
3405  & plfrac, blay, bbdgas, bbdtot, bbugas, bbutot, dplnku, &
3406  & dplnkd, radtotu, radclru, radtotd, radclrd, rad0, &
3407  & clfm, trng, gasu
3408 
3409  integer :: ittot, itgas, ib, ig, k
3410 !
3411 !===> ... begin here
3412 !
3413  do ib = 1, nbands
3414  do k = 0, nlay
3415  toturad(k,ib) = f_zero
3416  totdrad(k,ib) = f_zero
3417  clrurad(k,ib) = f_zero
3418  clrdrad(k,ib) = f_zero
3419  enddo
3420  enddo
3421 
3422  do k = 0, nlay
3423  totuflux(k) = f_zero
3424  totdflux(k) = f_zero
3425  totuclfl(k) = f_zero
3426  totdclfl(k) = f_zero
3427  enddo
3428 
3429 ! --- ... loop over all g-points
3430 
3431  do ig = 1, ngptlw
3432  ib = ngb(ig)
3433 
3434  radtotd = f_zero
3435  radclrd = f_zero
3436 
3443 
3444  do k = nlay, 1, -1
3445 
3446 ! --- ... clear sky, gases contribution
3447 
3448  odepth = max( f_zero, secdif(ib)*tautot(ig,k) )
3449  if (odepth <= 0.06) then
3450  atrgas = odepth - 0.5*odepth*odepth
3451  trng = f_one - atrgas
3452  gasfac = rec_6 * odepth
3453  else
3454  tblind = odepth / (bpade + odepth)
3455  itgas = tblint*tblind + 0.5
3456  trng = exp_tbl(itgas)
3457  atrgas = f_one - trng
3458  gasfac = tfn_tbl(itgas)
3459  odepth = tau_tbl(itgas)
3460  endif
3461 
3462  plfrac = fracs(ig,k)
3463  blay = pklay(ib,k)
3464 
3465  dplnku = pklev(ib,k ) - blay
3466  dplnkd = pklev(ib,k-1) - blay
3467  bbdgas = plfrac * (blay + dplnkd*gasfac)
3468  bbugas = plfrac * (blay + dplnku*gasfac)
3469  gassrcd= bbdgas * atrgas
3470  gassrcu(k)= bbugas * atrgas
3471  trngas(k) = trng
3472 
3473 ! --- ... total sky, gases+clouds contribution
3474 
3475  clfm = cldfmc(ig,k)
3476  if (clfm >= eps) then
3477 ! --- ... cloudy layer
3478 
3479  odcld = secdif(ib) * taucld(ib,k)
3480  efclrfr(k) = f_one - (f_one - exp(-odcld))*clfm
3481  odtot = odepth + odcld
3482  if (odtot < 0.06) then
3483  totfac = rec_6 * odtot
3484  atrtot = odtot - 0.5*odtot*odtot
3485  else
3486  tblind = odtot / (bpade + odtot)
3487  ittot = tblint*tblind + 0.5
3488  totfac = tfn_tbl(ittot)
3489  atrtot = f_one - exp_tbl(ittot)
3490  endif
3491 
3492  bbdtot = plfrac * (blay + dplnkd*totfac)
3493  bbutot = plfrac * (blay + dplnku*totfac)
3494  totsrcd= bbdtot * atrtot
3495  totsrcu(k)= bbutot * atrtot
3496 
3497 ! --- ... total sky radiance
3498  radtotd = radtotd*trng*efclrfr(k) + gassrcd &
3499  & + clfm*(totsrcd - gassrcd)
3500  totdrad(k-1,ib) = totdrad(k-1,ib) + radtotd
3501 
3502 ! --- ... clear sky radiance
3503  radclrd = radclrd*trng + gassrcd
3504  clrdrad(k-1,ib) = clrdrad(k-1,ib) + radclrd
3505 
3506  else
3507 ! --- ... clear layer
3508 
3509 ! --- ... total sky radiance
3510  radtotd = radtotd*trng + gassrcd
3511  totdrad(k-1,ib) = totdrad(k-1,ib) + radtotd
3512 
3513 ! --- ... clear sky radiance
3514  radclrd = radclrd*trng + gassrcd
3515  clrdrad(k-1,ib) = clrdrad(k-1,ib) + radclrd
3516 
3517  endif ! end if_clfm_block
3518 
3519  enddo ! end do_k_loop
3520 
3524 
3525 ! note: spectral and Lambertian reflection are identical for the
3526 ! diffusivity angle flux integration used here.
3527 
3528  reflct = f_one - semiss(ib)
3529  rad0 = semiss(ib) * fracs(ig,1) * pklay(ib,0)
3530 
3532  radtotu = rad0 + reflct*radtotd
3533  toturad(0,ib) = toturad(0,ib) + radtotu
3534 
3536  radclru = rad0 + reflct*radclrd
3537  clrurad(0,ib) = clrurad(0,ib) + radclru
3538 
3542 
3543 ! toturad holds summed radiance for total sky stream
3544 ! clrurad holds summed radiance for clear sky stream
3545 
3546  do k = 1, nlay
3547  clfm = cldfmc(ig,k)
3548  trng = trngas(k)
3549  gasu = gassrcu(k)
3550 
3551  if (clfm > eps) then
3552 ! --- ... cloudy layer
3553 
3554 ! --- ... total sky radiance
3555  radtotu = radtotu*trng*efclrfr(k) + gasu &
3556  & + clfm*(totsrcu(k) - gasu)
3557  toturad(k,ib) = toturad(k,ib) + radtotu
3558 
3559 ! --- ... clear sky radiance
3560  radclru = radclru*trng + gasu
3561  clrurad(k,ib) = clrurad(k,ib) + radclru
3562 
3563  else
3564 ! --- ... clear layer
3565 
3566 ! --- ... total sky radiance
3567  radtotu = radtotu*trng + gasu
3568  toturad(k,ib) = toturad(k,ib) + radtotu
3569 
3570 ! --- ... clear sky radiance
3571  radclru = radclru*trng + gasu
3572  clrurad(k,ib) = clrurad(k,ib) + radclru
3573 
3574  endif ! end if_clfm_block
3575 
3576  enddo ! end do_k_loop
3577 
3578  enddo ! end do_ig_loop
3579 
3582 
3583  flxfac = wtdiff * fluxfac
3584 
3585  do k = 0, nlay
3586  do ib = 1, nbands
3587  totuflux(k) = totuflux(k) + toturad(k,ib)
3588  totdflux(k) = totdflux(k) + totdrad(k,ib)
3589  totuclfl(k) = totuclfl(k) + clrurad(k,ib)
3590  totdclfl(k) = totdclfl(k) + clrdrad(k,ib)
3591  enddo
3592 
3593  totuflux(k) = totuflux(k) * flxfac
3594  totdflux(k) = totdflux(k) * flxfac
3595  totuclfl(k) = totuclfl(k) * flxfac
3596  totdclfl(k) = totdclfl(k) * flxfac
3597  enddo
3598 
3599 ! --- ... calculate net fluxes and heating rates
3600  fnet(0) = totuflux(0) - totdflux(0)
3601 
3602  do k = 1, nlay
3603  rfdelp(k) = heatfac / delp(k)
3604  fnet(k) = totuflux(k) - totdflux(k)
3605  htr(k) = (fnet(k-1) - fnet(k)) * rfdelp(k)
3606  enddo
3607 
3608 !! --- ... optional clear sky heating rates
3609  if ( lhlw0 ) then
3610  fnetc(0) = totuclfl(0) - totdclfl(0)
3611 
3612  do k = 1, nlay
3613  fnetc(k) = totuclfl(k) - totdclfl(k)
3614  htrcl(k) = (fnetc(k-1) - fnetc(k)) * rfdelp(k)
3615  enddo
3616  endif
3617 
3618 !! --- ... optional spectral band heating rates
3619  if ( lhlwb ) then
3620  do ib = 1, nbands
3621  fnet(0) = (toturad(0,ib) - totdrad(0,ib)) * flxfac
3622 
3623  do k = 1, nlay
3624  fnet(k) = (toturad(k,ib) - totdrad(k,ib)) * flxfac
3625  htrb(k,ib) = (fnet(k-1) - fnet(k)) * rfdelp(k)
3626  enddo
3627  enddo
3628  endif
3629 
3630 ! ..................................
3631  end subroutine rtrnmc
3632 ! ----------------------------------
3634 
3679 ! ----------------------------------
3680  subroutine taumol &
3681  & ( laytrop,pavel,coldry,colamt,colbrd,wx,tauaer, & ! --- inputs
3682  & rfrate,fac00,fac01,fac10,fac11,jp,jt,jt1, &
3683  & selffac,selffrac,indself,forfac,forfrac,indfor, &
3684  & minorfrac,scaleminor,scaleminorn2,indminor, &
3685  & nlay, &
3686  & fracs, tautot & ! --- outputs
3687  & )
3689 ! ************ original subprogram description *************** !
3690 ! !
3691 ! optical depths developed for the !
3692 ! !
3693 ! rapid radiative transfer model (rrtm) !
3694 ! !
3695 ! atmospheric and environmental research, inc. !
3696 ! 131 hartwell avenue !
3697 ! lexington, ma 02421 !
3698 ! !
3699 ! eli j. mlawer !
3700 ! jennifer delamere !
3701 ! steven j. taubman !
3702 ! shepard a. clough !
3703 ! !
3704 ! email: mlawer@aer.com !
3705 ! email: jdelamer@aer.com !
3706 ! !
3707 ! the authors wish to acknowledge the contributions of the !
3708 ! following people: karen cady-pereira, patrick d. brown, !
3709 ! michael j. iacono, ronald e. farren, luke chen, !
3710 ! robert bergstrom. !
3711 ! !
3712 ! revision for g-point reduction: michael j. iacono; aer, inc. !
3713 ! !
3714 ! taumol !
3715 ! !
3716 ! this file contains the subroutines taugbn (where n goes from !
3717 ! 1 to 16). taugbn calculates the optical depths and planck !
3718 ! fractions per g-value and layer for band n. !
3719 ! !
3720 ! ******************************************************************* !
3721 ! ================== program usage description ================== !
3722 ! !
3723 ! call taumol !
3724 ! inputs: !
3725 ! ( laytrop,pavel,coldry,colamt,colbrd,wx,tauaer, !
3726 ! rfrate,fac00,fac01,fac10,fac11,jp,jt,jt1, !
3727 ! selffac,selffrac,indself,forfac,forfrac,indfor, !
3728 ! minorfrac,scaleminor,scaleminorn2,indminor, !
3729 ! nlay, !
3730 ! outputs: !
3731 ! fracs, tautot ) !
3732 ! !
3733 ! subprograms called: taugb## (## = 01 -16) !
3734 ! !
3735 ! !
3736 ! ==================== defination of variables ==================== !
3737 ! !
3738 ! inputs: size !
3739 ! laytrop - integer, tropopause layer index (unitless) 1 !
3740 ! layer at which switch is made for key species !
3741 ! pavel - real, layer pressures (mb) nlay !
3742 ! coldry - real, column amount for dry air (mol/cm2) nlay !
3743 ! colamt - real, column amounts of h2o, co2, o3, n2o, ch4, !
3744 ! o2, co (mol/cm**2) nlay*maxgas!
3745 ! colbrd - real, column amount of broadening gases nlay !
3746 ! wx - real, cross-section amounts(mol/cm2) nlay*maxxsec!
3747 ! tauaer - real, aerosol optical depth nbands*nlay !
3748 ! rfrate - real, reference ratios of binary species parameter !
3749 ! (:,m,:)m=1-h2o/co2,2-h2o/o3,3-h2o/n2o,4-h2o/ch4,5-n2o/co2,6-o3/co2!
3750 ! (:,:,n)n=1,2: the rates of ref press at the 2 sides of the layer !
3751 ! nlay*nrates*2!
3752 ! facij - real, factors multiply the reference ks, i,j of 0/1 !
3753 ! for lower/higher of the 2 appropriate temperatures !
3754 ! and altitudes nlay !
3755 ! jp - real, index of lower reference pressure nlay !
3756 ! jt, jt1 - real, indices of lower reference temperatures nlay !
3757 ! for pressure levels jp and jp+1, respectively !
3758 ! selffac - real, scale factor for water vapor self-continuum !
3759 ! equals (water vapor density)/(atmospheric density !
3760 ! at 296k and 1013 mb) nlay !
3761 ! selffrac - real, factor for temperature interpolation of !
3762 ! reference water vapor self-continuum data nlay !
3763 ! indself - integer, index of lower reference temperature for !
3764 ! the self-continuum interpolation nlay !
3765 ! forfac - real, scale factor for w. v. foreign-continuum nlay !
3766 ! forfrac - real, factor for temperature interpolation of !
3767 ! reference w.v. foreign-continuum data nlay !
3768 ! indfor - integer, index of lower reference temperature for !
3769 ! the foreign-continuum interpolation nlay !
3770 ! minorfrac - real, factor for minor gases nlay !
3771 ! scaleminor,scaleminorn2 !
3772 ! - real, scale factors for minor gases nlay !
3773 ! indminor - integer, index of lower reference temperature for !
3774 ! minor gases nlay !
3775 ! nlay - integer, total number of layers 1 !
3776 ! !
3777 ! outputs: !
3778 ! fracs - real, planck fractions ngptlw,nlay!
3779 ! tautot - real, total optical depth (gas+aerosols) ngptlw,nlay!
3780 ! !
3781 ! internal variables: !
3782 ! ng## - integer, number of g-values in band ## (##=01-16) 1 !
3783 ! nspa - integer, for lower atmosphere, the number of ref !
3784 ! atmos, each has different relative amounts of the !
3785 ! key species for the band nbands!
3786 ! nspb - integer, same but for upper atmosphere nbands!
3787 ! absa - real, k-values for lower ref atmospheres (no w.v. !
3788 ! self-continuum) (cm**2/molecule) nspa(##)*5*13*ng##!
3789 ! absb - real, k-values for high ref atmospheres (all sources) !
3790 ! (cm**2/molecule) nspb(##)*5*13:59*ng##!
3791 ! ka_m'mgas'- real, k-values for low ref atmospheres minor species !
3792 ! (cm**2/molecule) mmn##*ng##!
3793 ! kb_m'mgas'- real, k-values for high ref atmospheres minor species !
3794 ! (cm**2/molecule) mmn##*ng##!
3795 ! selfref - real, k-values for w.v. self-continuum for ref atmos !
3796 ! used below laytrop (cm**2/mol) 10*ng##!
3797 ! forref - real, k-values for w.v. foreign-continuum for ref atmos
3798 ! used below/above laytrop (cm**2/mol) 4*ng##!
3799 ! !
3800 ! ****************************************************************** !
3801 
3802 ! --- inputs:
3803  integer, intent(in) :: nlay, laytrop
3804 
3805  integer, dimension(nlay), intent(in) :: jp, jt, jt1, indself, &
3806  & indfor, indminor
3807 
3808  real (kind=kind_phys), dimension(nlay), intent(in) :: pavel, &
3809  & coldry, colbrd, fac00, fac01, fac10, fac11, selffac, &
3810  & selffrac, forfac, forfrac, minorfrac, scaleminor, &
3811  & scaleminorn2
3812 
3813  real (kind=kind_phys), dimension(nlay,maxgas), intent(in):: colamt
3814  real (kind=kind_phys), dimension(nlay,maxxsec),intent(in):: wx
3815 
3816  real (kind=kind_phys), dimension(nbands,nlay), intent(in):: tauaer
3817 
3818  real (kind=kind_phys), dimension(nlay,nrates,2), intent(in) :: &
3819  & rfrate
3820 
3821 ! --- outputs:
3822  real (kind=kind_phys), dimension(ngptlw,nlay), intent(out) :: &
3823  & fracs, tautot
3824 
3825 ! --- locals
3826  real (kind=kind_phys), dimension(ngptlw,nlay) :: taug
3827 
3828  integer :: ib, ig, k
3829 !
3830 !===> ... begin here
3831 !
3832  call taugb01
3833  call taugb02
3834  call taugb03
3835  call taugb04
3836  call taugb05
3837  call taugb06
3838  call taugb07
3839  call taugb08
3840  call taugb09
3841  call taugb10
3842  call taugb11
3843  call taugb12
3844  call taugb13
3845  call taugb14
3846  call taugb15
3847  call taugb16
3848 
3849 ! --- combine gaseous and aerosol optical depths
3850 
3851  do ig = 1, ngptlw
3852  ib = ngb(ig)
3853 
3854  do k = 1, nlay
3855  tautot(ig,k) = taug(ig,k) + tauaer(ib,k)
3856  enddo
3857  enddo
3858 
3859 ! =================
3860  contains
3861 ! =================
3862 
3865 ! ----------------------------------
3866  subroutine taugb01
3867 ! ..................................
3868 
3869 ! ------------------------------------------------------------------ !
3870 ! written by eli j. mlawer, atmospheric & environmental research. !
3871 ! revised by michael j. iacono, atmospheric & environmental research. !
3872 ! !
3873 ! band 1: 10-350 cm-1 (low key - h2o; low minor - n2) !
3874 ! (high key - h2o; high minor - n2) !
3875 ! !
3876 ! compute the optical depth by interpolating in ln(pressure) and !
3877 ! temperature. below laytrop, the water vapor self-continuum and !
3878 ! foreign continuum is interpolated (in temperature) separately. !
3879 ! ------------------------------------------------------------------ !
3880 
3881  use module_radlw_kgb01
3882 
3883 ! --- locals:
3884  integer :: k, ind0, ind0p, ind1, ind1p, inds, indsp, indf, indfp, &
3885  & indm, indmp, ig
3886 
3887  real (kind=kind_phys) :: pp, corradj, scalen2, tauself, taufor, &
3888  & taun2
3889 !
3890 !===> ... begin here
3891 !
3892 ! --- minor gas mapping levels:
3893 ! lower - n2, p = 142.5490 mbar, t = 215.70 k
3894 ! upper - n2, p = 142.5490 mbar, t = 215.70 k
3895 
3896 ! --- ... lower atmosphere loop
3897 
3898  do k = 1, laytrop
3899  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(1) + 1
3900  ind1 = ( jp(k) *5 + (jt1(k)-1)) * nspa(1) + 1
3901  inds = indself(k)
3902  indf = indfor(k)
3903  indm = indminor(k)
3904 
3905  ind0p = ind0 + 1
3906  ind1p = ind1 + 1
3907  indsp = inds + 1
3908  indfp = indf + 1
3909  indmp = indm + 1
3910 
3911  pp = pavel(k)
3912  scalen2 = colbrd(k) * scaleminorn2(k)
3913  if (pp < 250.0) then
3914  corradj = f_one - 0.15 * (250.0-pp) / 154.4
3915  else
3916  corradj = f_one
3917  endif
3918 
3919  do ig = 1, ng01
3920  tauself = selffac(k) * (selfref(ig,inds) + selffrac(k) &
3921  & * (selfref(ig,indsp) - selfref(ig,inds)))
3922  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
3923  & * (forref(ig,indfp) - forref(ig,indf)))
3924  taun2 = scalen2 * (ka_mn2(ig,indm) + minorfrac(k) &
3925  & * (ka_mn2(ig,indmp) - ka_mn2(ig,indm)))
3926 
3927  taug(ig,k) = corradj * (colamt(k,1) &
3928  & * (fac00(k)*absa(ig,ind0) + fac10(k)*absa(ig,ind0p) &
3929  & + fac01(k)*absa(ig,ind1) + fac11(k)*absa(ig,ind1p)) &
3930  & + tauself + taufor + taun2)
3931 
3932  fracs(ig,k) = fracrefa(ig)
3933  enddo
3934  enddo
3935 
3936 ! --- ... upper atmosphere loop
3937 
3938  do k = laytrop+1, nlay
3939  ind0 = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(1) + 1
3940  ind1 = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(1) + 1
3941  indf = indfor(k)
3942  indm = indminor(k)
3943 
3944  ind0p = ind0 + 1
3945  ind1p = ind1 + 1
3946  indfp = indf + 1
3947  indmp = indm + 1
3948 
3949  scalen2 = colbrd(k) * scaleminorn2(k)
3950  corradj = f_one - 0.15 * (pavel(k) / 95.6)
3951 
3952  do ig = 1, ng01
3953  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
3954  & * (forref(ig,indfp) - forref(ig,indf)))
3955  taun2 = scalen2 * (kb_mn2(ig,indm) + minorfrac(k) &
3956  & * (kb_mn2(ig,indmp) - kb_mn2(ig,indm)))
3957 
3958  taug(ig,k) = corradj * (colamt(k,1) &
3959  & * (fac00(k)*absb(ig,ind0) + fac10(k)*absb(ig,ind0p) &
3960  & + fac01(k)*absb(ig,ind1) + fac11(k)*absb(ig,ind1p)) &
3961  & + taufor + taun2)
3962 
3963  fracs(ig,k) = fracrefb(ig)
3964  enddo
3965  enddo
3966 
3967 ! ..................................
3968  end subroutine taugb01
3969 ! ----------------------------------
3970 
3972 ! ----------------------------------
3973  subroutine taugb02
3974 ! ..................................
3975 
3976 ! ------------------------------------------------------------------ !
3977 ! band 2: 350-500 cm-1 (low key - h2o; high key - h2o) !
3978 ! ------------------------------------------------------------------ !
3979 
3980  use module_radlw_kgb02
3981 
3982 ! --- locals:
3983  integer :: k, ind0, ind0p, ind1, ind1p, inds, indsp, indf, indfp, &
3984  & ig
3985 
3986  real (kind=kind_phys) :: corradj, tauself, taufor
3987 !
3988 !===> ... begin here
3989 !
3990 ! --- ... lower atmosphere loop
3991 
3992  do k = 1, laytrop
3993  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(2) + 1
3994  ind1 = ( jp(k) *5 + (jt1(k)-1)) * nspa(2) + 1
3995  inds = indself(k)
3996  indf = indfor(k)
3997 
3998  ind0p = ind0 + 1
3999  ind1p = ind1 + 1
4000  indsp = inds + 1
4001  indfp = indf + 1
4002 
4003  corradj = f_one - 0.05 * (pavel(k) - 100.0) / 900.0
4004 
4005  do ig = 1, ng02
4006  tauself = selffac(k) * (selfref(ig,inds) + selffrac(k) &
4007  & * (selfref(ig,indsp) - selfref(ig,inds)))
4008  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
4009  & * (forref(ig,indfp) - forref(ig,indf)))
4010 
4011  taug(ns02+ig,k) = corradj * (colamt(k,1) &
4012  & * (fac00(k)*absa(ig,ind0) + fac10(k)*absa(ig,ind0p) &
4013  & + fac01(k)*absa(ig,ind1) + fac11(k)*absa(ig,ind1p)) &
4014  & + tauself + taufor)
4015 
4016  fracs(ns02+ig,k) = fracrefa(ig)
4017  enddo
4018  enddo
4019 
4020 ! --- ... upper atmosphere loop
4021 
4022  do k = laytrop+1, nlay
4023  ind0 = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(2) + 1
4024  ind1 = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(2) + 1
4025  indf = indfor(k)
4026 
4027  ind0p = ind0 + 1
4028  ind1p = ind1 + 1
4029  indfp = indf + 1
4030 
4031  do ig = 1, ng02
4032  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
4033  & * (forref(ig,indfp) - forref(ig,indf)))
4034 
4035  taug(ns02+ig,k) = colamt(k,1) &
4036  & * (fac00(k)*absb(ig,ind0) + fac10(k)*absb(ig,ind0p) &
4037  & + fac01(k)*absb(ig,ind1) + fac11(k)*absb(ig,ind1p)) &
4038  & + taufor
4039 
4040  fracs(ns02+ig,k) = fracrefb(ig)
4041  enddo
4042  enddo
4043 
4044 ! ..................................
4045  end subroutine taugb02
4046 ! ----------------------------------
4047 
4050 ! ----------------------------------
4051  subroutine taugb03
4052 ! ..................................
4053 
4054 ! ------------------------------------------------------------------ !
4055 ! band 3: 500-630 cm-1 (low key - h2o,co2; low minor - n2o) !
4056 ! (high key - h2o,co2; high minor - n2o) !
4057 ! ------------------------------------------------------------------ !
4058 
4059  use module_radlw_kgb03
4060 
4061 ! --- locals:
4062  integer :: k, ind0, ind1, inds, indsp, indf, indfp, indm, indmp, &
4063  & id000, id010, id100, id110, id200, id210, jmn2o, jmn2op, &
4064  & id001, id011, id101, id111, id201, id211, jpl, jplp, &
4065  & ig, js, js1
4066 
4067  real (kind=kind_phys) :: absn2o, ratn2o, adjfac, adjcoln2o, &
4068  & speccomb, specparm, specmult, fs, &
4069  & speccomb1, specparm1, specmult1, fs1, &
4070  & speccomb_mn2o, specparm_mn2o, specmult_mn2o, fmn2o, &
4071  & speccomb_planck,specparm_planck,specmult_planck,fpl, &
4072  & refrat_planck_a, refrat_planck_b, refrat_m_a, refrat_m_b, &
4073  & fac000, fac100, fac200, fac010, fac110, fac210, &
4074  & fac001, fac101, fac201, fac011, fac111, fac211, &
4075  & tau_major, tau_major1, tauself, taufor, n2om1, n2om2, &
4076  & p, p4, fk0, fk1, fk2
4077 !
4078 !===> ... begin here
4079 !
4080 ! --- ... minor gas mapping levels:
4081 ! lower - n2o, p = 706.272 mbar, t = 278.94 k
4082 ! upper - n2o, p = 95.58 mbar, t = 215.7 k
4083 
4084  refrat_planck_a = chi_mls(1,9)/chi_mls(2,9) ! P = 212.725 mb
4085  refrat_planck_b = chi_mls(1,13)/chi_mls(2,13) ! P = 95.58 mb
4086  refrat_m_a = chi_mls(1,3)/chi_mls(2,3) ! P = 706.270 mb
4087  refrat_m_b = chi_mls(1,13)/chi_mls(2,13) ! P = 95.58 mb
4088 
4089 ! --- ... lower atmosphere loop
4090 
4091  do k = 1, laytrop
4092  speccomb = colamt(k,1) + rfrate(k,1,1)*colamt(k,2)
4093  specparm = colamt(k,1) / speccomb
4094  specmult = 8.0 * min(specparm, oneminus)
4095  js = 1 + int(specmult)
4096  fs = mod(specmult, f_one)
4097  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(3) + js
4098 
4099  speccomb1 = colamt(k,1) + rfrate(k,1,2)*colamt(k,2)
4100  specparm1 = colamt(k,1) / speccomb1
4101  specmult1 = 8.0 * min(specparm1, oneminus)
4102  js1 = 1 + int(specmult1)
4103  fs1 = mod(specmult1, f_one)
4104  ind1 = (jp(k)*5 + (jt1(k)-1)) * nspa(3) + js1
4105 
4106  speccomb_mn2o = colamt(k,1) + refrat_m_a*colamt(k,2)
4107  specparm_mn2o = colamt(k,1) / speccomb_mn2o
4108  specmult_mn2o = 8.0 * min(specparm_mn2o, oneminus)
4109  jmn2o = 1 + int(specmult_mn2o)
4110  fmn2o = mod(specmult_mn2o, f_one)
4111 
4112  speccomb_planck = colamt(k,1) + refrat_planck_a*colamt(k,2)
4113  specparm_planck = colamt(k,1) / speccomb_planck
4114  specmult_planck = 8.0 * min(specparm_planck, oneminus)
4115  jpl = 1 + int(specmult_planck)
4116  fpl = mod(specmult_planck, f_one)
4117 
4118  inds = indself(k)
4119  indf = indfor(k)
4120  indm = indminor(k)
4121  indsp = inds + 1
4122  indfp = indf + 1
4123  indmp = indm + 1
4124  jmn2op= jmn2o+ 1
4125  jplp = jpl + 1
4126 
4127 ! --- ... in atmospheres where the amount of n2O is too great to be considered
4128 ! a minor species, adjust the column amount of n2O by an empirical factor
4129 ! to obtain the proper contribution.
4130 
4131  p = coldry(k) * chi_mls(4,jp(k)+1)
4132  ratn2o = colamt(k,4) / p
4133  if (ratn2o > 1.5) then
4134  adjfac = 0.5 + (ratn2o - 0.5)**0.65
4135  adjcoln2o = adjfac * p
4136  else
4137  adjcoln2o = colamt(k,4)
4138  endif
4139 
4140  if (specparm < 0.125) then
4141  p = fs - f_one
4142  p4 = p**4
4143  fk0 = p4
4144  fk1 = f_one - p - 2.0*p4
4145  fk2 = p + p4
4146  id000 = ind0
4147  id010 = ind0 + 9
4148  id100 = ind0 + 1
4149  id110 = ind0 +10
4150  id200 = ind0 + 2
4151  id210 = ind0 +11
4152  else if (specparm > 0.875) then
4153  p = -fs
4154  p4 = p**4
4155  fk0 = p4
4156  fk1 = f_one - p - 2.0*p4
4157  fk2 = p + p4
4158  id000 = ind0 + 1
4159  id010 = ind0 +10
4160  id100 = ind0
4161  id110 = ind0 + 9
4162  id200 = ind0 - 1
4163  id210 = ind0 + 8
4164  else
4165  fk0 = f_one - fs
4166  fk1 = fs
4167  fk2 = f_zero
4168  id000 = ind0
4169  id010 = ind0 + 9
4170  id100 = ind0 + 1
4171  id110 = ind0 +10
4172  id200 = ind0
4173  id210 = ind0
4174  endif
4175 
4176  fac000 = fk0*fac00(k)
4177  fac100 = fk1*fac00(k)
4178  fac200 = fk2*fac00(k)
4179  fac010 = fk0*fac10(k)
4180  fac110 = fk1*fac10(k)
4181  fac210 = fk2*fac10(k)
4182 
4183  if (specparm1 < 0.125) then
4184  p = fs1 - f_one
4185  p4 = p**4
4186  fk0 = p4
4187  fk1 = f_one - p - 2.0*p4
4188  fk2 = p + p4
4189  id001 = ind1
4190  id011 = ind1 + 9
4191  id101 = ind1 + 1
4192  id111 = ind1 +10
4193  id201 = ind1 + 2
4194  id211 = ind1 +11
4195  elseif (specparm1 > 0.875) then
4196  p = -fs1
4197  p4 = p**4
4198  fk0 = p4
4199  fk1 = f_one - p - 2.0*p4
4200  fk2 = p + p4
4201  id001 = ind1 + 1
4202  id011 = ind1 +10
4203  id101 = ind1
4204  id111 = ind1 + 9
4205  id201 = ind1 - 1
4206  id211 = ind1 + 8
4207  else
4208  fk0 = f_one - fs1
4209  fk1 = fs1
4210  fk2 = f_zero
4211  id001 = ind1
4212  id011 = ind1 + 9
4213  id101 = ind1 + 1
4214  id111 = ind1 +10
4215  id201 = ind1
4216  id211 = ind1
4217  endif
4218 
4219  fac001 = fk0*fac01(k)
4220  fac101 = fk1*fac01(k)
4221  fac201 = fk2*fac01(k)
4222  fac011 = fk0*fac11(k)
4223  fac111 = fk1*fac11(k)
4224  fac211 = fk2*fac11(k)
4225 
4226  do ig = 1, ng03
4227  tauself = selffac(k)* (selfref(ig,inds) + selffrac(k) &
4228  & * (selfref(ig,indsp) - selfref(ig,inds)))
4229  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
4230  & * (forref(ig,indfp) - forref(ig,indf)))
4231  n2om1 = ka_mn2o(ig,jmn2o,indm) + fmn2o &
4232  & * (ka_mn2o(ig,jmn2op,indm) - ka_mn2o(ig,jmn2o,indm))
4233  n2om2 = ka_mn2o(ig,jmn2o,indmp) + fmn2o &
4234  & * (ka_mn2o(ig,jmn2op,indmp) - ka_mn2o(ig,jmn2o,indmp))
4235  absn2o = n2om1 + minorfrac(k) * (n2om2 - n2om1)
4236 
4237  tau_major = speccomb &
4238  & * (fac000*absa(ig,id000) + fac010*absa(ig,id010) &
4239  & + fac100*absa(ig,id100) + fac110*absa(ig,id110) &
4240  & + fac200*absa(ig,id200) + fac210*absa(ig,id210))
4241 
4242  tau_major1 = speccomb1 &
4243  & * (fac001*absa(ig,id001) + fac011*absa(ig,id011) &
4244  & + fac101*absa(ig,id101) + fac111*absa(ig,id111) &
4245  & + fac201*absa(ig,id201) + fac211*absa(ig,id211))
4246 
4247  taug(ns03+ig,k) = tau_major + tau_major1 &
4248  & + tauself + taufor + adjcoln2o*absn2o
4249 
4250  fracs(ns03+ig,k) = fracrefa(ig,jpl) + fpl &
4251  & * (fracrefa(ig,jplp) - fracrefa(ig,jpl))
4252  enddo ! end do_k_loop
4253  enddo ! end do_ig_loop
4254 
4255 ! --- ... upper atmosphere loop
4256 
4257  do k = laytrop+1, nlay
4258  speccomb = colamt(k,1) + rfrate(k,1,1)*colamt(k,2)
4259  specparm = colamt(k,1) / speccomb
4260  specmult = 4.0 * min(specparm, oneminus)
4261  js = 1 + int(specmult)
4262  fs = mod(specmult, f_one)
4263  ind0 = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(3) + js
4264 
4265  speccomb1 = colamt(k,1) + rfrate(k,1,2)*colamt(k,2)
4266  specparm1 = colamt(k,1) / speccomb1
4267  specmult1 = 4.0 * min(specparm1, oneminus)
4268  js1 = 1 + int(specmult1)
4269  fs1 = mod(specmult1, f_one)
4270  ind1 = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(3) + js1
4271 
4272  speccomb_mn2o = colamt(k,1) + refrat_m_b*colamt(k,2)
4273  specparm_mn2o = colamt(k,1) / speccomb_mn2o
4274  specmult_mn2o = 4.0 * min(specparm_mn2o, oneminus)
4275  jmn2o = 1 + int(specmult_mn2o)
4276  fmn2o = mod(specmult_mn2o, f_one)
4277 
4278  speccomb_planck = colamt(k,1) + refrat_planck_b*colamt(k,2)
4279  specparm_planck = colamt(k,1) / speccomb_planck
4280  specmult_planck = 4.0 * min(specparm_planck, oneminus)
4281  jpl = 1 + int(specmult_planck)
4282  fpl = mod(specmult_planck, f_one)
4283 
4284  indf = indfor(k)
4285  indm = indminor(k)
4286  indfp = indf + 1
4287  indmp = indm + 1
4288  jmn2op= jmn2o+ 1
4289  jplp = jpl + 1
4290 
4291  id000 = ind0
4292  id010 = ind0 + 5
4293  id100 = ind0 + 1
4294  id110 = ind0 + 6
4295  id001 = ind1
4296  id011 = ind1 + 5
4297  id101 = ind1 + 1
4298  id111 = ind1 + 6
4299 
4300 ! --- ... in atmospheres where the amount of n2o is too great to be considered
4301 ! a minor species, adjust the column amount of N2O by an empirical factor
4302 ! to obtain the proper contribution.
4303 
4304  p = coldry(k) * chi_mls(4,jp(k)+1)
4305  ratn2o = colamt(k,4) / p
4306  if (ratn2o > 1.5) then
4307  adjfac = 0.5 + (ratn2o - 0.5)**0.65
4308  adjcoln2o = adjfac * p
4309  else
4310  adjcoln2o = colamt(k,4)
4311  endif
4312 
4313  fk0 = f_one - fs
4314  fk1 = fs
4315  fac000 = fk0*fac00(k)
4316  fac010 = fk0*fac10(k)
4317  fac100 = fk1*fac00(k)
4318  fac110 = fk1*fac10(k)
4319 
4320  fk0 = f_one - fs1
4321  fk1 = fs1
4322  fac001 = fk0*fac01(k)
4323  fac011 = fk0*fac11(k)
4324  fac101 = fk1*fac01(k)
4325  fac111 = fk1*fac11(k)
4326 
4327  do ig = 1, ng03
4328  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
4329  & * (forref(ig,indfp) - forref(ig,indf)))
4330  n2om1 = kb_mn2o(ig,jmn2o,indm) + fmn2o &
4331  & * (kb_mn2o(ig,jmn2op,indm) - kb_mn2o(ig,jmn2o,indm))
4332  n2om2 = kb_mn2o(ig,jmn2o,indmp) + fmn2o &
4333  & * (kb_mn2o(ig,jmn2op,indmp) - kb_mn2o(ig,jmn2o,indmp))
4334  absn2o = n2om1 + minorfrac(k) * (n2om2 - n2om1)
4335 
4336  tau_major = speccomb &
4337  & * (fac000*absb(ig,id000) + fac010*absb(ig,id010) &
4338  & + fac100*absb(ig,id100) + fac110*absb(ig,id110))
4339 
4340  tau_major1 = speccomb1 &
4341  & * (fac001*absb(ig,id001) + fac011*absb(ig,id011) &
4342  & + fac101*absb(ig,id101) + fac111*absb(ig,id111))
4343 
4344  taug(ns03+ig,k) = tau_major + tau_major1 &
4345  & + taufor + adjcoln2o*absn2o
4346 
4347  fracs(ns03+ig,k) = fracrefb(ig,jpl) + fpl &
4348  & * (fracrefb(ig,jplp) - fracrefb(ig,jpl))
4349  enddo
4350  enddo
4351 
4352 ! ..................................
4353  end subroutine taugb03
4354 ! ----------------------------------
4355 
4357 ! ----------------------------------
4358  subroutine taugb04
4359 ! ..................................
4360 
4361 ! ------------------------------------------------------------------ !
4362 ! band 4: 630-700 cm-1 (low key - h2o,co2; high key - o3,co2) !
4363 ! ------------------------------------------------------------------ !
4364 
4365  use module_radlw_kgb04
4366 
4367 ! --- locals:
4368  integer :: k, ind0, ind1, inds, indsp, indf, indfp, jpl, jplp, &
4369  & id000, id010, id100, id110, id200, id210, ig, js, js1, &
4370  & id001, id011, id101, id111, id201, id211
4371 
4372  real (kind=kind_phys) :: tauself, taufor, p, p4, fk0, fk1, fk2, &
4373  & speccomb, specparm, specmult, fs, &
4374  & speccomb1, specparm1, specmult1, fs1, &
4375  & speccomb_planck,specparm_planck,specmult_planck,fpl, &
4376  & fac000, fac100, fac200, fac010, fac110, fac210, &
4377  & fac001, fac101, fac201, fac011, fac111, fac211, &
4378  & refrat_planck_a, refrat_planck_b, tau_major, tau_major1
4379 !
4380 !===> ... begin here
4381 !
4382  refrat_planck_a = chi_mls(1,11)/chi_mls(2,11) ! P = 142.5940 mb
4383  refrat_planck_b = chi_mls(3,13)/chi_mls(2,13) ! P = 95.58350 mb
4384 
4385 ! --- ... lower atmosphere loop
4386 
4387  do k = 1, laytrop
4388  speccomb = colamt(k,1) + rfrate(k,1,1)*colamt(k,2)
4389  specparm = colamt(k,1) / speccomb
4390  specmult = 8.0 * min(specparm, oneminus)
4391  js = 1 + int(specmult)
4392  fs = mod(specmult, f_one)
4393  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(4) + js
4394 
4395  speccomb1 = colamt(k,1) + rfrate(k,1,2)*colamt(k,2)
4396  specparm1 = colamt(k,1) / speccomb1
4397  specmult1 = 8.0 * min(specparm1, oneminus)
4398  js1 = 1 + int(specmult1)
4399  fs1 = mod(specmult1, f_one)
4400  ind1 = ( jp(k)*5 + (jt1(k)-1)) * nspa(4) + js1
4401 
4402  speccomb_planck = colamt(k,1) + refrat_planck_a*colamt(k,2)
4403  specparm_planck = colamt(k,1) / speccomb_planck
4404  specmult_planck = 8.0 * min(specparm_planck, oneminus)
4405  jpl = 1 + int(specmult_planck)
4406  fpl = mod(specmult_planck, 1.0)
4407 
4408  inds = indself(k)
4409  indf = indfor(k)
4410  indsp = inds + 1
4411  indfp = indf + 1
4412  jplp = jpl + 1
4413 
4414  if (specparm < 0.125) then
4415  p = fs - f_one
4416  p4 = p**4
4417  fk0 = p4
4418  fk1 = f_one - p - 2.0*p4
4419  fk2 = p + p4
4420  id000 = ind0
4421  id010 = ind0 + 9
4422  id100 = ind0 + 1
4423  id110 = ind0 +10
4424  id200 = ind0 + 2
4425  id210 = ind0 +11
4426  elseif (specparm > 0.875) then
4427  p = -fs
4428  p4 = p**4
4429  fk0 = p4
4430  fk1 = f_one - p - 2.0*p4
4431  fk2 = p + p4
4432  id000 = ind0 + 1
4433  id010 = ind0 +10
4434  id100 = ind0
4435  id110 = ind0 + 9
4436  id200 = ind0 - 1
4437  id210 = ind0 + 8
4438  else
4439  fk0 = f_one - fs
4440  fk1 = fs
4441  fk2 = f_zero
4442  id000 = ind0
4443  id010 = ind0 + 9
4444  id100 = ind0 + 1
4445  id110 = ind0 +10
4446  id200 = ind0
4447  id210 = ind0
4448  endif
4449 
4450  fac000 = fk0*fac00(k)
4451  fac100 = fk1*fac00(k)
4452  fac200 = fk2*fac00(k)
4453  fac010 = fk0*fac10(k)
4454  fac110 = fk1*fac10(k)
4455  fac210 = fk2*fac10(k)
4456 
4457  if (specparm1 < 0.125) then
4458  p = fs1 - f_one
4459  p4 = p**4
4460  fk0 = p4
4461  fk1 = f_one - p - 2.0*p4
4462  fk2 = p + p4
4463  id001 = ind1
4464  id011 = ind1 + 9
4465  id101 = ind1 + 1
4466  id111 = ind1 +10
4467  id201 = ind1 + 2
4468  id211 = ind1 +11
4469  elseif (specparm1 > 0.875) then
4470  p = -fs1
4471  p4 = p**4
4472  fk0 = p4
4473  fk1 = f_one - p - 2.0*p4
4474  fk2 = p + p4
4475  id001 = ind1 + 1
4476  id011 = ind1 +10
4477  id101 = ind1
4478  id111 = ind1 + 9
4479  id201 = ind1 - 1
4480  id211 = ind1 + 8
4481  else
4482  fk0 = f_one - fs1
4483  fk1 = fs1
4484  fk2 = f_zero
4485  id001 = ind1
4486  id011 = ind1 + 9
4487  id101 = ind1 + 1
4488  id111 = ind1 +10
4489  id201 = ind1
4490  id211 = ind1
4491  endif
4492 
4493  fac001 = fk0*fac01(k)
4494  fac101 = fk1*fac01(k)
4495  fac201 = fk2*fac01(k)
4496  fac011 = fk0*fac11(k)
4497  fac111 = fk1*fac11(k)
4498  fac211 = fk2*fac11(k)
4499 
4500  do ig = 1, ng04
4501  tauself = selffac(k)* (selfref(ig,inds) + selffrac(k) &
4502  & * (selfref(ig,indsp) - selfref(ig,inds)))
4503  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
4504  & * (forref(ig,indfp) - forref(ig,indf)))
4505 
4506  tau_major = speccomb &
4507  & * (fac000*absa(ig,id000) + fac010*absa(ig,id010) &
4508  & + fac100*absa(ig,id100) + fac110*absa(ig,id110) &
4509  & + fac200*absa(ig,id200) + fac210*absa(ig,id210))
4510 
4511  tau_major1 = speccomb1 &
4512  & * (fac001*absa(ig,id001) + fac011*absa(ig,id011) &
4513  & + fac101*absa(ig,id101) + fac111*absa(ig,id111) &
4514  & + fac201*absa(ig,id201) + fac211*absa(ig,id211))
4515 
4516  taug(ns04+ig,k) = tau_major + tau_major1 + tauself + taufor
4517 
4518  fracs(ns04+ig,k) = fracrefa(ig,jpl) + fpl &
4519  & * (fracrefa(ig,jplp) - fracrefa(ig,jpl))
4520  enddo ! end do_k_loop
4521  enddo ! end do_ig_loop
4522 
4523 ! --- ... upper atmosphere loop
4524 
4525  do k = laytrop+1, nlay
4526  speccomb = colamt(k,3) + rfrate(k,6,1)*colamt(k,2)
4527  specparm = colamt(k,3) / speccomb
4528  specmult = 4.0 * min(specparm, oneminus)
4529  js = 1 + int(specmult)
4530  fs = mod(specmult, f_one)
4531  ind0 = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(4) + js
4532 
4533  speccomb1 = colamt(k,3) + rfrate(k,6,2)*colamt(k,2)
4534  specparm1 = colamt(k,3) / speccomb1
4535  specmult1 = 4.0 * min(specparm1, oneminus)
4536  js1 = 1 + int(specmult1)
4537  fs1 = mod(specmult1, f_one)
4538  ind1 = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(4) + js1
4539 
4540  speccomb_planck = colamt(k,3) + refrat_planck_b*colamt(k,2)
4541  specparm_planck = colamt(k,3) / speccomb_planck
4542  specmult_planck = 4.0 * min(specparm_planck, oneminus)
4543  jpl = 1 + int(specmult_planck)
4544  fpl = mod(specmult_planck, f_one)
4545  jplp = jpl + 1
4546 
4547  id000 = ind0
4548  id010 = ind0 + 5
4549  id100 = ind0 + 1
4550  id110 = ind0 + 6
4551  id001 = ind1
4552  id011 = ind1 + 5
4553  id101 = ind1 + 1
4554  id111 = ind1 + 6
4555 
4556  fk0 = f_one - fs
4557  fk1 = fs
4558  fac000 = fk0*fac00(k)
4559  fac010 = fk0*fac10(k)
4560  fac100 = fk1*fac00(k)
4561  fac110 = fk1*fac10(k)
4562 
4563  fk0 = f_one - fs1
4564  fk1 = fs1
4565  fac001 = fk0*fac01(k)
4566  fac011 = fk0*fac11(k)
4567  fac101 = fk1*fac01(k)
4568  fac111 = fk1*fac11(k)
4569 
4570  do ig = 1, ng04
4571  tau_major = speccomb &
4572  & * (fac000*absb(ig,id000) + fac010*absb(ig,id010) &
4573  & + fac100*absb(ig,id100) + fac110*absb(ig,id110))
4574  tau_major1 = speccomb1 &
4575  & * (fac001*absb(ig,id001) + fac011*absb(ig,id011) &
4576  & + fac101*absb(ig,id101) + fac111*absb(ig,id111))
4577 
4578  taug(ns04+ig,k) = tau_major + tau_major1
4579 
4580  fracs(ns04+ig,k) = fracrefb(ig,jpl) + fpl &
4581  & * (fracrefb(ig,jplp) - fracrefb(ig,jpl))
4582  enddo
4583 
4584 ! --- ... empirical modification to code to improve stratospheric cooling rates
4585 ! for co2. revised to apply weighting for g-point reduction in this band.
4586 
4587  taug(ns04+ 8,k) = taug(ns04+ 8,k) * 0.92
4588  taug(ns04+ 9,k) = taug(ns04+ 9,k) * 0.88
4589  taug(ns04+10,k) = taug(ns04+10,k) * 1.07
4590  taug(ns04+11,k) = taug(ns04+11,k) * 1.1
4591  taug(ns04+12,k) = taug(ns04+12,k) * 0.99
4592  taug(ns04+13,k) = taug(ns04+13,k) * 0.88
4593  taug(ns04+14,k) = taug(ns04+14,k) * 0.943
4594  enddo
4595 
4596 ! ..................................
4597  end subroutine taugb04
4598 ! ----------------------------------
4599 
4602 ! ----------------------------------
4603  subroutine taugb05
4604 ! ..................................
4605 
4606 ! ------------------------------------------------------------------ !
4607 ! band 5: 700-820 cm-1 (low key - h2o,co2; low minor - o3, ccl4) !
4608 ! (high key - o3,co2) !
4609 ! ------------------------------------------------------------------ !
4610 
4611  use module_radlw_kgb05
4612 
4613 ! --- locals:
4614  integer :: k, ind0, ind1, inds, indsp, indf, indfp, indm, indmp, &
4615  & id000, id010, id100, id110, id200, id210, jmo3, jmo3p, &
4616  & id001, id011, id101, id111, id201, id211, jpl, jplp, &
4617  & ig, js, js1
4618 
4619  real (kind=kind_phys) :: tauself, taufor, o3m1, o3m2, abso3, &
4620  & speccomb, specparm, specmult, fs, &
4621  & speccomb1, specparm1, specmult1, fs1, &
4622  & speccomb_mo3, specparm_mo3, specmult_mo3, fmo3, &
4623  & speccomb_planck,specparm_planck,specmult_planck,fpl, &
4624  & refrat_planck_a, refrat_planck_b, refrat_m_a, &
4625  & fac000, fac100, fac200, fac010, fac110, fac210, &
4626  & fac001, fac101, fac201, fac011, fac111, fac211, &
4627  & p0, p40, fk00, fk10, fk20, p1, p41, fk01, fk11, fk21
4628 !
4629 !===> ... begin here
4630 !
4631 ! --- ... minor gas mapping level :
4632 ! lower - o3, p = 317.34 mbar, t = 240.77 k
4633 ! lower - ccl4
4634 
4635 ! --- ... calculate reference ratio to be used in calculation of Planck
4636 ! fraction in lower/upper atmosphere.
4637 
4638  refrat_planck_a = chi_mls(1,5)/chi_mls(2,5) ! P = 473.420 mb
4639  refrat_planck_b = chi_mls(3,43)/chi_mls(2,43) ! P = 0.2369 mb
4640  refrat_m_a = chi_mls(1,7)/chi_mls(2,7) ! P = 317.348 mb
4641 
4642 ! --- ... lower atmosphere loop
4643 
4644  do k = 1, laytrop
4645  speccomb = colamt(k,1) + rfrate(k,1,1)*colamt(k,2)
4646  specparm = colamt(k,1) / speccomb
4647  specmult = 8.0 * min(specparm, oneminus)
4648  js = 1 + int(specmult)
4649  fs = mod(specmult, f_one)
4650  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(5) + js
4651 
4652  speccomb1 = colamt(k,1) + rfrate(k,1,2)*colamt(k,2)
4653  specparm1 = colamt(k,1) / speccomb1
4654  specmult1 = 8.0 * min(specparm1, oneminus)
4655  js1 = 1 + int(specmult1)
4656  fs1 = mod(specmult1, f_one)
4657  ind1 = (jp(k)*5 + (jt1(k)-1)) * nspa(5) + js1
4658 
4659  speccomb_mo3 = colamt(k,1) + refrat_m_a*colamt(k,2)
4660  specparm_mo3 = colamt(k,1) / speccomb_mo3
4661  specmult_mo3 = 8.0 * min(specparm_mo3, oneminus)
4662  jmo3 = 1 + int(specmult_mo3)
4663  fmo3 = mod(specmult_mo3, f_one)
4664 
4665  speccomb_planck = colamt(k,1) + refrat_planck_a*colamt(k,2)
4666  specparm_planck = colamt(k,1) / speccomb_planck
4667  specmult_planck = 8.0 * min(specparm_planck, oneminus)
4668  jpl = 1 + int(specmult_planck)
4669  fpl = mod(specmult_planck, f_one)
4670 
4671  inds = indself(k)
4672  indf = indfor(k)
4673  indm = indminor(k)
4674  indsp = inds + 1
4675  indfp = indf + 1
4676  indmp = indm + 1
4677  jplp = jpl + 1
4678  jmo3p = jmo3 + 1
4679 
4680  if (specparm < 0.125) then
4681  p0 = fs - f_one
4682  p40 = p0**4
4683  fk00 = p40
4684  fk10 = f_one - p0 - 2.0*p40
4685  fk20 = p0 + p40
4686 
4687  id000 = ind0
4688  id010 = ind0 + 9
4689  id100 = ind0 + 1
4690  id110 = ind0 +10
4691  id200 = ind0 + 2
4692  id210 = ind0 +11
4693  elseif (specparm > 0.875) then
4694  p0 = -fs
4695  p40 = p0**4
4696  fk00 = p40
4697  fk10 = f_one - p0 - 2.0*p40
4698  fk20 = p0 + p40
4699 
4700  id000 = ind0 + 1
4701  id010 = ind0 +10
4702  id100 = ind0
4703  id110 = ind0 + 9
4704  id200 = ind0 - 1
4705  id210 = ind0 + 8
4706  else
4707  fk00 = f_one - fs
4708  fk10 = fs
4709  fk20 = f_zero
4710 
4711  id000 = ind0
4712  id010 = ind0 + 9
4713  id100 = ind0 + 1
4714  id110 = ind0 +10
4715  id200 = ind0
4716  id210 = ind0
4717  endif
4718 
4719  fac000 = fk00 * fac00(k)
4720  fac100 = fk10 * fac00(k)
4721  fac200 = fk20 * fac00(k)
4722  fac010 = fk00 * fac10(k)
4723  fac110 = fk10 * fac10(k)
4724  fac210 = fk20 * fac10(k)
4725 
4726  if (specparm1 < 0.125) then
4727  p1 = fs1 - f_one
4728  p41 = p1**4
4729  fk01 = p41
4730  fk11 = f_one - p1 - 2.0*p41
4731  fk21 = p1 + p41
4732 
4733  id001 = ind1
4734  id011 = ind1 + 9
4735  id101 = ind1 + 1
4736  id111 = ind1 +10
4737  id201 = ind1 + 2
4738  id211 = ind1 +11
4739  elseif (specparm1 > 0.875) then
4740  p1 = -fs1
4741  p41 = p1**4
4742  fk01 = p41
4743  fk11 = f_one - p1 - 2.0*p41
4744  fk21 = p1 + p41
4745 
4746  id001 = ind1 + 1
4747  id011 = ind1 +10
4748  id101 = ind1
4749  id111 = ind1 + 9
4750  id201 = ind1 - 1
4751  id211 = ind1 + 8
4752  else
4753  fk01 = f_one - fs1
4754  fk11 = fs1
4755  fk21 = f_zero
4756 
4757  id001 = ind1
4758  id011 = ind1 + 9
4759  id101 = ind1 + 1
4760  id111 = ind1 +10
4761  id201 = ind1
4762  id211 = ind1
4763  endif
4764 
4765  fac001 = fk01 * fac01(k)
4766  fac101 = fk11 * fac01(k)
4767  fac201 = fk21 * fac01(k)
4768  fac011 = fk01 * fac11(k)
4769  fac111 = fk11 * fac11(k)
4770  fac211 = fk21 * fac11(k)
4771 
4772  do ig = 1, ng05
4773  tauself = selffac(k) * (selfref(ig,inds) + selffrac(k) &
4774  & * (selfref(ig,indsp) - selfref(ig,inds)))
4775  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
4776  & * (forref(ig,indfp) - forref(ig,indf)))
4777  o3m1 = ka_mo3(ig,jmo3,indm) + fmo3 &
4778  & * (ka_mo3(ig,jmo3p,indm) - ka_mo3(ig,jmo3,indm))
4779  o3m2 = ka_mo3(ig,jmo3,indmp) + fmo3 &
4780  & * (ka_mo3(ig,jmo3p,indmp) - ka_mo3(ig,jmo3,indmp))
4781  abso3 = o3m1 + minorfrac(k)*(o3m2 - o3m1)
4782 
4783  taug(ns05+ig,k) = speccomb &
4784  & * (fac000*absa(ig,id000) + fac010*absa(ig,id010) &
4785  & + fac100*absa(ig,id100) + fac110*absa(ig,id110) &
4786  & + fac200*absa(ig,id200) + fac210*absa(ig,id210)) &
4787  & + speccomb1 &
4788  & * (fac001*absa(ig,id001) + fac011*absa(ig,id011) &
4789  & + fac101*absa(ig,id101) + fac111*absa(ig,id111) &
4790  & + fac201*absa(ig,id201) + fac211*absa(ig,id211)) &
4791  & + tauself + taufor+abso3*colamt(k,3)+wx(k,1)*ccl4(ig)
4792 
4793  fracs(ns05+ig,k) = fracrefa(ig,jpl) + fpl &
4794  & * (fracrefa(ig,jplp) - fracrefa(ig,jpl))
4795  enddo
4796  enddo
4797 
4798 ! --- ... upper atmosphere loop
4799 
4800  do k = laytrop+1, nlay
4801  speccomb = colamt(k,3) + rfrate(k,6,1)*colamt(k,2)
4802  specparm = colamt(k,3) / speccomb
4803  specmult = 4.0 * min(specparm, oneminus)
4804  js = 1 + int(specmult)
4805  fs = mod(specmult, f_one)
4806  ind0 = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(5) + js
4807 
4808  speccomb1 = colamt(k,3) + rfrate(k,6,2)*colamt(k,2)
4809  specparm1 = colamt(k,3) / speccomb1
4810  specmult1 = 4.0 * min(specparm1, oneminus)
4811  js1 = 1 + int(specmult1)
4812  fs1 = mod(specmult1, f_one)
4813  ind1 = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(5) + js1
4814 
4815  speccomb_planck = colamt(k,3) + refrat_planck_b*colamt(k,2)
4816  specparm_planck = colamt(k,3) / speccomb_planck
4817  specmult_planck = 4.0 * min(specparm_planck, oneminus)
4818  jpl = 1 + int(specmult_planck)
4819  fpl = mod(specmult_planck, f_one)
4820  jplp= jpl + 1
4821 
4822  id000 = ind0
4823  id010 = ind0 + 5
4824  id100 = ind0 + 1
4825  id110 = ind0 + 6
4826  id001 = ind1
4827  id011 = ind1 + 5
4828  id101 = ind1 + 1
4829  id111 = ind1 + 6
4830 
4831  fk00 = f_one - fs
4832  fk10 = fs
4833 
4834  fk01 = f_one - fs1
4835  fk11 = fs1
4836 
4837  fac000 = fk00 * fac00(k)
4838  fac010 = fk00 * fac10(k)
4839  fac100 = fk10 * fac00(k)
4840  fac110 = fk10 * fac10(k)
4841 
4842  fac001 = fk01 * fac01(k)
4843  fac011 = fk01 * fac11(k)
4844  fac101 = fk11 * fac01(k)
4845  fac111 = fk11 * fac11(k)
4846 
4847  do ig = 1, ng05
4848  taug(ns05+ig,k) = speccomb &
4849  & * (fac000*absb(ig,id000) + fac010*absb(ig,id010) &
4850  & + fac100*absb(ig,id100) + fac110*absb(ig,id110)) &
4851  & + speccomb1 &
4852  & * (fac001*absb(ig,id001) + fac011*absb(ig,id011) &
4853  & + fac101*absb(ig,id101) + fac111*absb(ig,id111)) &
4854  & + wx(k,1) * ccl4(ig)
4855 
4856  fracs(ns05+ig,k) = fracrefb(ig,jpl) + fpl &
4857  & * (fracrefb(ig,jplp) - fracrefb(ig,jpl))
4858  enddo
4859  enddo
4860 
4861 ! ..................................
4862  end subroutine taugb05
4863 ! ----------------------------------
4864 
4867 ! ----------------------------------
4868  subroutine taugb06
4869 ! ..................................
4870 
4871 ! ------------------------------------------------------------------ !
4872 ! band 6: 820-980 cm-1 (low key - h2o; low minor - co2) !
4873 ! (high key - none; high minor - cfc11, cfc12)
4874 ! ------------------------------------------------------------------ !
4875 
4876  use module_radlw_kgb06
4877 
4878 ! --- locals:
4879  integer :: k, ind0, ind0p, ind1, ind1p, inds, indsp, indf, indfp, &
4880  & indm, indmp, ig
4881 
4882  real (kind=kind_phys) :: ratco2, adjfac, adjcolco2, tauself, &
4883  & taufor, absco2, temp
4884 !
4885 !===> ... begin here
4886 !
4887 ! --- ... minor gas mapping level:
4888 ! lower - co2, p = 706.2720 mb, t = 294.2 k
4889 ! upper - cfc11, cfc12
4890 
4891 ! --- ... lower atmosphere loop
4892 
4893  do k = 1, laytrop
4894  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(6) + 1
4895  ind1 = ( jp(k) *5 + (jt1(k)-1)) * nspa(6) + 1
4896 
4897  inds = indself(k)
4898  indf = indfor(k)
4899  indm = indminor(k)
4900  indsp = inds + 1
4901  indfp = indf + 1
4902  indmp = indm + 1
4903  ind0p = ind0 + 1
4904  ind1p = ind1 + 1
4905 
4906 ! --- ... in atmospheres where the amount of co2 is too great to be considered
4907 ! a minor species, adjust the column amount of co2 by an empirical factor
4908 ! to obtain the proper contribution.
4909 
4910  temp = coldry(k) * chi_mls(2,jp(k)+1)
4911  ratco2 = colamt(k,2) / temp
4912  if (ratco2 > 3.0) then
4913  adjfac = 2.0 + (ratco2-2.0)**0.77
4914  adjcolco2 = adjfac * temp
4915  else
4916  adjcolco2 = colamt(k,2)
4917  endif
4918 
4919  do ig = 1, ng06
4920  tauself = selffac(k) * (selfref(ig,inds) + selffrac(k) &
4921  & * (selfref(ig,indsp) - selfref(ig,inds)))
4922  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
4923  & * (forref(ig,indfp) - forref(ig,indf)))
4924  absco2 = ka_mco2(ig,indm) + minorfrac(k) &
4925  & * (ka_mco2(ig,indmp) - ka_mco2(ig,indm))
4926 
4927  taug(ns06+ig,k) = colamt(k,1) &
4928  & * (fac00(k)*absa(ig,ind0) + fac10(k)*absa(ig,ind0p) &
4929  & + fac01(k)*absa(ig,ind1) + fac11(k)*absa(ig,ind1p)) &
4930  & + tauself + taufor + adjcolco2*absco2 &
4931  & + wx(k,2)*cfc11adj(ig) + wx(k,3)*cfc12(ig)
4932 
4933  fracs(ns06+ig,k) = fracrefa(ig)
4934  enddo
4935  enddo
4936 
4937 ! --- ... upper atmosphere loop
4938 ! nothing important goes on above laytrop in this band.
4939 
4940  do k = laytrop+1, nlay
4941  do ig = 1, ng06
4942  taug(ns06+ig,k) = wx(k,2)*cfc11adj(ig) + wx(k,3)*cfc12(ig)
4943 
4944  fracs(ns06+ig,k) = fracrefa(ig)
4945  enddo
4946  enddo
4947 
4948 ! ..................................
4949  end subroutine taugb06
4950 ! ----------------------------------
4951 
4954 ! ----------------------------------
4955  subroutine taugb07
4956 ! ..................................
4957 
4958 ! ------------------------------------------------------------------ !
4959 ! band 7: 980-1080 cm-1 (low key - h2o,o3; low minor - co2) !
4960 ! (high key - o3; high minor - co2) !
4961 ! ------------------------------------------------------------------ !
4962 
4963  use module_radlw_kgb07
4964 
4965 ! --- locals:
4966  integer :: k, ind0, ind0p, ind1, ind1p, inds, indsp, indf, indfp, &
4967  & id000, id010, id100, id110, id200, id210, indm, indmp, &
4968  & id001, id011, id101, id111, id201, id211, jmco2, jmco2p, &
4969  & jpl, jplp, ig, js, js1
4970 
4971  real (kind=kind_phys) :: tauself, taufor, co2m1, co2m2, absco2, &
4972  & speccomb, specparm, specmult, fs, &
4973  & speccomb1, specparm1, specmult1, fs1, &
4974  & speccomb_mco2, specparm_mco2, specmult_mco2, fmco2, &
4975  & speccomb_planck,specparm_planck,specmult_planck,fpl, &
4976  & refrat_planck_a, refrat_m_a, ratco2, adjfac, adjcolco2, &
4977  & fac000, fac100, fac200, fac010, fac110, fac210, &
4978  & fac001, fac101, fac201, fac011, fac111, fac211, &
4979  & p0, p40, fk00, fk10, fk20, p1, p41, fk01, fk11, fk21, temp
4980 !
4981 !===> ... begin here
4982 !
4983 ! --- ... minor gas mapping level :
4984 ! lower - co2, p = 706.2620 mbar, t= 278.94 k
4985 ! upper - co2, p = 12.9350 mbar, t = 234.01 k
4986 
4987 ! --- ... calculate reference ratio to be used in calculation of Planck
4988 ! fraction in lower atmosphere.
4989 
4990  refrat_planck_a = chi_mls(1,3)/chi_mls(3,3) ! P = 706.2620 mb
4991  refrat_m_a = chi_mls(1,3)/chi_mls(3,3) ! P = 706.2720 mb
4992 
4993 ! --- ... lower atmosphere loop
4994 
4995  do k = 1, laytrop
4996  speccomb = colamt(k,1) + rfrate(k,2,1)*colamt(k,3)
4997  specparm = colamt(k,1) / speccomb
4998  specmult = 8.0 * min(specparm, oneminus)
4999  js = 1 + int(specmult)
5000  fs = mod(specmult, f_one)
5001  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(7) + js
5002 
5003  speccomb1 = colamt(k,1) + rfrate(k,2,2)*colamt(k,3)
5004  specparm1 = colamt(k,1) / speccomb1
5005  specmult1 = 8.0 * min(specparm1, oneminus)
5006  js1 = 1 + int(specmult1)
5007  fs1 = mod(specmult1, f_one)
5008  ind1 = (jp(k)*5 + (jt1(k)-1)) * nspa(7) + js1
5009 
5010  speccomb_mco2 = colamt(k,1) + refrat_m_a*colamt(k,3)
5011  specparm_mco2 = colamt(k,1) / speccomb_mco2
5012  specmult_mco2 = 8.0 * min(specparm_mco2, oneminus)
5013  jmco2 = 1 + int(specmult_mco2)
5014  fmco2 = mod(specmult_mco2, f_one)
5015 
5016  speccomb_planck = colamt(k,1) + refrat_planck_a*colamt(k,3)
5017  specparm_planck = colamt(k,1) / speccomb_planck
5018  specmult_planck = 8.0 * min(specparm_planck, oneminus)
5019  jpl = 1 + int(specmult_planck)
5020  fpl = mod(specmult_planck, f_one)
5021 
5022  inds = indself(k)
5023  indf = indfor(k)
5024  indm = indminor(k)
5025  indsp = inds + 1
5026  indfp = indf + 1
5027  indmp = indm + 1
5028  jplp = jpl + 1
5029  jmco2p= jmco2+ 1
5030  ind0p = ind0 + 1
5031  ind1p = ind1 + 1
5032 
5033 ! --- ... in atmospheres where the amount of CO2 is too great to be considered
5034 ! a minor species, adjust the column amount of CO2 by an empirical factor
5035 ! to obtain the proper contribution.
5036 
5037  temp = coldry(k) * chi_mls(2,jp(k)+1)
5038  ratco2 = colamt(k,2) / temp
5039  if (ratco2 > 3.0) then
5040  adjfac = 3.0 + (ratco2-3.0)**0.79
5041  adjcolco2 = adjfac * temp
5042  else
5043  adjcolco2 = colamt(k,2)
5044  endif
5045 
5046  if (specparm < 0.125) then
5047  p0 = fs - f_one
5048  p40 = p0**4
5049  fk00 = p40
5050  fk10 = f_one - p0 - 2.0*p40
5051  fk20 = p0 + p40
5052 
5053  id000 = ind0
5054  id010 = ind0 + 9
5055  id100 = ind0 + 1
5056  id110 = ind0 +10
5057  id200 = ind0 + 2
5058  id210 = ind0 +11
5059  elseif (specparm > 0.875) then
5060  p0 = -fs
5061  p40 = p0**4
5062  fk00 = p40
5063  fk10 = f_one - p0 - 2.0*p40
5064  fk20 = p0 + p40
5065 
5066  id000 = ind0 + 1
5067  id010 = ind0 +10
5068  id100 = ind0
5069  id110 = ind0 + 9
5070  id200 = ind0 - 1
5071  id210 = ind0 + 8
5072  else
5073  fk00 = f_one - fs
5074  fk10 = fs
5075  fk20 = f_zero
5076 
5077  id000 = ind0
5078  id010 = ind0 + 9
5079  id100 = ind0 + 1
5080  id110 = ind0 +10
5081  id200 = ind0
5082  id210 = ind0
5083  endif
5084 
5085  fac000 = fk00 * fac00(k)
5086  fac100 = fk10 * fac00(k)
5087  fac200 = fk20 * fac00(k)
5088  fac010 = fk00 * fac10(k)
5089  fac110 = fk10 * fac10(k)
5090  fac210 = fk20 * fac10(k)
5091 
5092  if (specparm1 < 0.125) then
5093  p1 = fs1 - f_one
5094  p41 = p1**4
5095  fk01 = p41
5096  fk11 = f_one - p1 - 2.0*p41
5097  fk21 = p1 + p41
5098 
5099  id001 = ind1
5100  id011 = ind1 + 9
5101  id101 = ind1 + 1
5102  id111 = ind1 +10
5103  id201 = ind1 + 2
5104  id211 = ind1 +11
5105  elseif (specparm1 > 0.875) then
5106  p1 = -fs1
5107  p41 = p1**4
5108  fk01 = p41
5109  fk11 = f_one - p1 - 2.0*p41
5110  fk21 = p1 + p41
5111 
5112  id001 = ind1 + 1
5113  id011 = ind1 +10
5114  id101 = ind1
5115  id111 = ind1 + 9
5116  id201 = ind1 - 1
5117  id211 = ind1 + 8
5118  else
5119  fk01 = f_one - fs1
5120  fk11 = fs1
5121  fk21 = f_zero
5122 
5123  id001 = ind1
5124  id011 = ind1 + 9
5125  id101 = ind1 + 1
5126  id111 = ind1 +10
5127  id201 = ind1
5128  id211 = ind1
5129  endif
5130 
5131  fac001 = fk01 * fac01(k)
5132  fac101 = fk11 * fac01(k)
5133  fac201 = fk21 * fac01(k)
5134  fac011 = fk01 * fac11(k)
5135  fac111 = fk11 * fac11(k)
5136  fac211 = fk21 * fac11(k)
5137 
5138  do ig = 1, ng07
5139  tauself = selffac(k)* (selfref(ig,inds) + selffrac(k) &
5140  & * (selfref(ig,indsp) - selfref(ig,inds)))
5141  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
5142  & * (forref(ig,indfp) - forref(ig,indf)))
5143  co2m1 = ka_mco2(ig,jmco2,indm) + fmco2 &
5144  & * (ka_mco2(ig,jmco2p,indm) - ka_mco2(ig,jmco2,indm))
5145  co2m2 = ka_mco2(ig,jmco2,indmp) + fmco2 &
5146  & * (ka_mco2(ig,jmco2p,indmp) - ka_mco2(ig,jmco2,indmp))
5147  absco2 = co2m1 + minorfrac(k) * (co2m2 - co2m1)
5148 
5149  taug(ns07+ig,k) = speccomb &
5150  & * (fac000*absa(ig,id000) + fac010*absa(ig,id010) &
5151  & + fac100*absa(ig,id100) + fac110*absa(ig,id110) &
5152  & + fac200*absa(ig,id200) + fac210*absa(ig,id210)) &
5153  & + speccomb1 &
5154  & * (fac001*absa(ig,id001) + fac011*absa(ig,id011) &
5155  & + fac101*absa(ig,id101) + fac111*absa(ig,id111) &
5156  & + fac201*absa(ig,id201) + fac211*absa(ig,id211)) &
5157  & + tauself + taufor + adjcolco2*absco2
5158 
5159  fracs(ns07+ig,k) = fracrefa(ig,jpl) + fpl &
5160  & * (fracrefa(ig,jplp) - fracrefa(ig,jpl))
5161  enddo
5162  enddo
5163 
5164 ! --- ... upper atmosphere loop
5165 
5166 ! --- ... in atmospheres where the amount of co2 is too great to be considered
5167 ! a minor species, adjust the column amount of co2 by an empirical factor
5168 ! to obtain the proper contribution.
5169 
5170  do k = laytrop+1, nlay
5171  temp = coldry(k) * chi_mls(2,jp(k)+1)
5172  ratco2 = colamt(k,2) / temp
5173  if (ratco2 > 3.0) then
5174  adjfac = 2.0 + (ratco2-2.0)**0.79
5175  adjcolco2 = adjfac * temp
5176  else
5177  adjcolco2 = colamt(k,2)
5178  endif
5179 
5180  ind0 = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(7) + 1
5181  ind1 = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(7) + 1
5182 
5183  indm = indminor(k)
5184  indmp = indm + 1
5185  ind0p = ind0 + 1
5186  ind1p = ind1 + 1
5187 
5188  do ig = 1, ng07
5189  absco2 = kb_mco2(ig,indm) + minorfrac(k) &
5190  & * (kb_mco2(ig,indmp) - kb_mco2(ig,indm))
5191 
5192  taug(ns07+ig,k) = colamt(k,3) &
5193  & * (fac00(k)*absb(ig,ind0) + fac10(k)*absb(ig,ind0p) &
5194  & + fac01(k)*absb(ig,ind1) + fac11(k)*absb(ig,ind1p)) &
5195  & + adjcolco2 * absco2
5196 
5197  fracs(ns07+ig,k) = fracrefb(ig)
5198  enddo
5199 
5200 ! --- ... empirical modification to code to improve stratospheric cooling rates
5201 ! for o3. revised to apply weighting for g-point reduction in this band.
5202 
5203  taug(ns07+ 6,k) = taug(ns07+ 6,k) * 0.92
5204  taug(ns07+ 7,k) = taug(ns07+ 7,k) * 0.88
5205  taug(ns07+ 8,k) = taug(ns07+ 8,k) * 1.07
5206  taug(ns07+ 9,k) = taug(ns07+ 9,k) * 1.1
5207  taug(ns07+10,k) = taug(ns07+10,k) * 0.99
5208  taug(ns07+11,k) = taug(ns07+11,k) * 0.855
5209  enddo
5210 
5211 ! ..................................
5212  end subroutine taugb07
5213 ! ----------------------------------
5214 
5217 ! ----------------------------------
5218  subroutine taugb08
5219 ! ..................................
5220 
5221 ! ------------------------------------------------------------------ !
5222 ! band 8: 1080-1180 cm-1 (low key - h2o; low minor - co2,o3,n2o) !
5223 ! (high key - o3; high minor - co2, n2o) !
5224 ! ------------------------------------------------------------------ !
5225 
5226  use module_radlw_kgb08
5227 
5228 ! --- locals:
5229  integer :: k, ind0, ind0p, ind1, ind1p, inds, indsp, indf, indfp, &
5230  & indm, indmp, ig
5231 
5232  real (kind=kind_phys) :: tauself, taufor, absco2, abso3, absn2o, &
5233  & ratco2, adjfac, adjcolco2, temp
5234 !
5235 !===> ... begin here
5236 !
5237 ! --- ... minor gas mapping level:
5238 ! lower - co2, p = 1053.63 mb, t = 294.2 k
5239 ! lower - o3, p = 317.348 mb, t = 240.77 k
5240 ! lower - n2o, p = 706.2720 mb, t= 278.94 k
5241 ! lower - cfc12,cfc11
5242 ! upper - co2, p = 35.1632 mb, t = 223.28 k
5243 ! upper - n2o, p = 8.716e-2 mb, t = 226.03 k
5244 
5245 ! --- ... lower atmosphere loop
5246 
5247  do k = 1, laytrop
5248  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(8) + 1
5249  ind1 = ( jp(k) *5 + (jt1(k)-1)) * nspa(8) + 1
5250 
5251  inds = indself(k)
5252  indf = indfor(k)
5253  indm = indminor(k)
5254  ind0p = ind0 + 1
5255  ind1p = ind1 + 1
5256  indsp = inds + 1
5257  indfp = indf + 1
5258  indmp = indm + 1
5259 
5260 ! --- ... in atmospheres where the amount of co2 is too great to be considered
5261 ! a minor species, adjust the column amount of co2 by an empirical factor
5262 ! to obtain the proper contribution.
5263 
5264  temp = coldry(k) * chi_mls(2,jp(k)+1)
5265  ratco2 = colamt(k,2) / temp
5266  if (ratco2 > 3.0) then
5267  adjfac = 2.0 + (ratco2-2.0)**0.65
5268  adjcolco2 = adjfac * temp
5269  else
5270  adjcolco2 = colamt(k,2)
5271  endif
5272 
5273  do ig = 1, ng08
5274  tauself = selffac(k) * (selfref(ig,inds) + selffrac(k) &
5275  & * (selfref(ig,indsp) - selfref(ig,inds)))
5276  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
5277  & * (forref(ig,indfp) - forref(ig,indf)))
5278  absco2 = (ka_mco2(ig,indm) + minorfrac(k) &
5279  & * (ka_mco2(ig,indmp) - ka_mco2(ig,indm)))
5280  abso3 = (ka_mo3(ig,indm) + minorfrac(k) &
5281  & * (ka_mo3(ig,indmp) - ka_mo3(ig,indm)))
5282  absn2o = (ka_mn2o(ig,indm) + minorfrac(k) &
5283  & * (ka_mn2o(ig,indmp) - ka_mn2o(ig,indm)))
5284 
5285  taug(ns08+ig,k) = colamt(k,1) &
5286  & * (fac00(k)*absa(ig,ind0) + fac10(k)*absa(ig,ind0p) &
5287  & + fac01(k)*absa(ig,ind1) + fac11(k)*absa(ig,ind1p)) &
5288  & + tauself+taufor + adjcolco2*absco2 &
5289  & + colamt(k,3)*abso3 + colamt(k,4)*absn2o &
5290  & + wx(k,3)*cfc12(ig) + wx(k,4)*cfc22adj(ig)
5291 
5292  fracs(ns08+ig,k) = fracrefa(ig)
5293  enddo
5294  enddo
5295 
5296 ! --- ... upper atmosphere loop
5297 
5298  do k = laytrop+1, nlay
5299  ind0 = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(8) + 1
5300  ind1 = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(8) + 1
5301 
5302  indm = indminor(k)
5303  ind0p = ind0 + 1
5304  ind1p = ind1 + 1
5305  indmp = indm + 1
5306 
5307 ! --- ... in atmospheres where the amount of co2 is too great to be considered
5308 ! a minor species, adjust the column amount of co2 by an empirical factor
5309 ! to obtain the proper contribution.
5310 
5311  temp = coldry(k) * chi_mls(2,jp(k)+1)
5312  ratco2 = colamt(k,2) / temp
5313  if (ratco2 > 3.0) then
5314  adjfac = 2.0 + (ratco2-2.0)**0.65
5315  adjcolco2 = adjfac * temp
5316  else
5317  adjcolco2 = colamt(k,2)
5318  endif
5319 
5320  do ig = 1, ng08
5321  absco2 = (kb_mco2(ig,indm) + minorfrac(k) &
5322  & * (kb_mco2(ig,indmp) - kb_mco2(ig,indm)))
5323  absn2o = (kb_mn2o(ig,indm) + minorfrac(k) &
5324  & * (kb_mn2o(ig,indmp) - kb_mn2o(ig,indm)))
5325 
5326  taug(ns08+ig,k) = colamt(k,3) &
5327  & * (fac00(k)*absb(ig,ind0) + fac10(k)*absb(ig,ind0p) &
5328  & + fac01(k)*absb(ig,ind1) + fac11(k)*absb(ig,ind1p)) &
5329  & + adjcolco2*absco2 + colamt(k,4)*absn2o &
5330  & + wx(k,3)*cfc12(ig) + wx(k,4)*cfc22adj(ig)
5331 
5332  fracs(ns08+ig,k) = fracrefb(ig)
5333  enddo
5334  enddo
5335 
5336 ! ..................................
5337  end subroutine taugb08
5338 ! ----------------------------------
5339 
5342 ! ----------------------------------
5343  subroutine taugb09
5344 ! ..................................
5345 
5346 ! ------------------------------------------------------------------ !
5347 ! band 9: 1180-1390 cm-1 (low key - h2o,ch4; low minor - n2o) !
5348 ! (high key - ch4; high minor - n2o) !
5349 ! ------------------------------------------------------------------ !
5350 
5351  use module_radlw_kgb09
5352 
5353 ! --- locals:
5354  integer :: k, ind0, ind0p, ind1, ind1p, inds, indsp, indf, indfp, &
5355  & id000, id010, id100, id110, id200, id210, indm, indmp, &
5356  & id001, id011, id101, id111, id201, id211, jmn2o, jmn2op, &
5357  & jpl, jplp, ig, js, js1
5358 
5359  real (kind=kind_phys) :: tauself, taufor, n2om1, n2om2, absn2o, &
5360  & speccomb, specparm, specmult, fs, &
5361  & speccomb1, specparm1, specmult1, fs1, &
5362  & speccomb_mn2o, specparm_mn2o, specmult_mn2o, fmn2o, &
5363  & speccomb_planck,specparm_planck,specmult_planck,fpl, &
5364  & refrat_planck_a, refrat_m_a, ratn2o, adjfac, adjcoln2o, &
5365  & fac000, fac100, fac200, fac010, fac110, fac210, &
5366  & fac001, fac101, fac201, fac011, fac111, fac211, &
5367  & p0, p40, fk00, fk10, fk20, p1, p41, fk01, fk11, fk21, temp
5368 !
5369 !===> ... begin here
5370 !
5371 ! --- ... minor gas mapping level :
5372 ! lower - n2o, p = 706.272 mbar, t = 278.94 k
5373 ! upper - n2o, p = 95.58 mbar, t = 215.7 k
5374 
5375 ! --- ... calculate reference ratio to be used in calculation of Planck
5376 ! fraction in lower/upper atmosphere.
5377 
5378  refrat_planck_a = chi_mls(1,9)/chi_mls(6,9) ! P = 212 mb
5379  refrat_m_a = chi_mls(1,3)/chi_mls(6,3) ! P = 706.272 mb
5380 
5381 ! --- ... lower atmosphere loop
5382 
5383  do k = 1, laytrop
5384  speccomb = colamt(k,1) + rfrate(k,4,1)*colamt(k,5)
5385  specparm = colamt(k,1) / speccomb
5386  specmult = 8.0 * min(specparm, oneminus)
5387  js = 1 + int(specmult)
5388  fs = mod(specmult, f_one)
5389  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(9) + js
5390 
5391  speccomb1 = colamt(k,1) + rfrate(k,4,2)*colamt(k,5)
5392  specparm1 = colamt(k,1) / speccomb1
5393  specmult1 = 8.0 * min(specparm1, oneminus)
5394  js1 = 1 + int(specmult1)
5395  fs1 = mod(specmult1, f_one)
5396  ind1 = (jp(k)*5 + (jt1(k)-1)) * nspa(9) + js1
5397 
5398  speccomb_mn2o = colamt(k,1) + refrat_m_a*colamt(k,5)
5399  specparm_mn2o = colamt(k,1) / speccomb_mn2o
5400  specmult_mn2o = 8.0 * min(specparm_mn2o, oneminus)
5401  jmn2o = 1 + int(specmult_mn2o)
5402  fmn2o = mod(specmult_mn2o, f_one)
5403 
5404  speccomb_planck = colamt(k,1) + refrat_planck_a*colamt(k,5)
5405  specparm_planck = colamt(k,1) / speccomb_planck
5406  specmult_planck = 8.0 * min(specparm_planck, oneminus)
5407  jpl = 1 + int(specmult_planck)
5408  fpl = mod(specmult_planck, f_one)
5409 
5410  inds = indself(k)
5411  indf = indfor(k)
5412  indm = indminor(k)
5413  indsp = inds + 1
5414  indfp = indf + 1
5415  indmp = indm + 1
5416  jplp = jpl + 1
5417  jmn2op= jmn2o+ 1
5418 
5419 ! --- ... in atmospheres where the amount of n2o is too great to be considered
5420 ! a minor species, adjust the column amount of n2o by an empirical factor
5421 ! to obtain the proper contribution.
5422 
5423  temp = coldry(k) * chi_mls(4,jp(k)+1)
5424  ratn2o = colamt(k,4) / temp
5425  if (ratn2o > 1.5) then
5426  adjfac = 0.5 + (ratn2o-0.5)**0.65
5427  adjcoln2o = adjfac * temp
5428  else
5429  adjcoln2o = colamt(k,4)
5430  endif
5431 
5432  if (specparm < 0.125) then
5433  p0 = fs - f_one
5434  p40 = p0**4
5435  fk00 = p40
5436  fk10 = f_one - p0 - 2.0*p40
5437  fk20 = p0 + p40
5438 
5439  id000 = ind0
5440  id010 = ind0 + 9
5441  id100 = ind0 + 1
5442  id110 = ind0 +10
5443  id200 = ind0 + 2
5444  id210 = ind0 +11
5445  elseif (specparm > 0.875) then
5446  p0 = -fs
5447  p40 = p0**4
5448  fk00 = p40
5449  fk10 = f_one - p0 - 2.0*p40
5450  fk20 = p0 + p40
5451 
5452  id000 = ind0 + 1
5453  id010 = ind0 +10
5454  id100 = ind0
5455  id110 = ind0 + 9
5456  id200 = ind0 - 1
5457  id210 = ind0 + 8
5458  else
5459  fk00 = f_one - fs
5460  fk10 = fs
5461  fk20 = f_zero
5462 
5463  id000 = ind0
5464  id010 = ind0 + 9
5465  id100 = ind0 + 1
5466  id110 = ind0 +10
5467  id200 = ind0
5468  id210 = ind0
5469  endif
5470 
5471  fac000 = fk00 * fac00(k)
5472  fac100 = fk10 * fac00(k)
5473  fac200 = fk20 * fac00(k)
5474  fac010 = fk00 * fac10(k)
5475  fac110 = fk10 * fac10(k)
5476  fac210 = fk20 * fac10(k)
5477 
5478  if (specparm1 < 0.125) then
5479  p1 = fs1 - f_one
5480  p41 = p1**4
5481  fk01 = p41
5482  fk11 = f_one - p1 - 2.0*p41
5483  fk21 = p1 + p41
5484 
5485  id001 = ind1
5486  id011 = ind1 + 9
5487  id101 = ind1 + 1
5488  id111 = ind1 +10
5489  id201 = ind1 + 2
5490  id211 = ind1 +11
5491  elseif (specparm1 > 0.875) then
5492  p1 = -fs1
5493  p41 = p1**4
5494  fk01 = p41
5495  fk11 = f_one - p1 - 2.0*p41
5496  fk21 = p1 + p41
5497 
5498  id001 = ind1 + 1
5499  id011 = ind1 +10
5500  id101 = ind1
5501  id111 = ind1 + 9
5502  id201 = ind1 - 1
5503  id211 = ind1 + 8
5504  else
5505  fk01 = f_one - fs1
5506  fk11 = fs1
5507  fk21 = f_zero
5508 
5509  id001 = ind1
5510  id011 = ind1 + 9
5511  id101 = ind1 + 1
5512  id111 = ind1 +10
5513  id201 = ind1
5514  id211 = ind1
5515  endif
5516 
5517  fac001 = fk01 * fac01(k)
5518  fac101 = fk11 * fac01(k)
5519  fac201 = fk21 * fac01(k)
5520  fac011 = fk01 * fac11(k)
5521  fac111 = fk11 * fac11(k)
5522  fac211 = fk21 * fac11(k)
5523 
5524  do ig = 1, ng09
5525  tauself = selffac(k)* (selfref(ig,inds) + selffrac(k) &
5526  & * (selfref(ig,indsp) - selfref(ig,inds)))
5527  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
5528  & * (forref(ig,indfp) - forref(ig,indf)))
5529  n2om1 = ka_mn2o(ig,jmn2o,indm) + fmn2o &
5530  & * (ka_mn2o(ig,jmn2op,indm) - ka_mn2o(ig,jmn2o,indm))
5531  n2om2 = ka_mn2o(ig,jmn2o,indmp) + fmn2o &
5532  & * (ka_mn2o(ig,jmn2op,indmp) - ka_mn2o(ig,jmn2o,indmp))
5533  absn2o = n2om1 + minorfrac(k) * (n2om2 - n2om1)
5534 
5535  taug(ns09+ig,k) = speccomb &
5536  & * (fac000*absa(ig,id000) + fac010*absa(ig,id010) &
5537  & + fac100*absa(ig,id100) + fac110*absa(ig,id110) &
5538  & + fac200*absa(ig,id200) + fac210*absa(ig,id210)) &
5539  & + speccomb1 &
5540  & * (fac001*absa(ig,id001) + fac011*absa(ig,id011) &
5541  & + fac101*absa(ig,id101) + fac111*absa(ig,id111) &
5542  & + fac201*absa(ig,id201) + fac211*absa(ig,id211)) &
5543  & + tauself + taufor + adjcoln2o*absn2o
5544 
5545  fracs(ns09+ig,k) = fracrefa(ig,jpl) + fpl &
5546  & * (fracrefa(ig,jplp) - fracrefa(ig,jpl))
5547  enddo
5548  enddo
5549 
5550 ! --- ... upper atmosphere loop
5551 
5552  do k = laytrop+1, nlay
5553  ind0 = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(9) + 1
5554  ind1 = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(9) + 1
5555 
5556  indm = indminor(k)
5557  ind0p = ind0 + 1
5558  ind1p = ind1 + 1
5559  indmp = indm + 1
5560 
5561 ! --- ... in atmospheres where the amount of n2o is too great to be considered
5562 ! a minor species, adjust the column amount of n2o by an empirical factor
5563 ! to obtain the proper contribution.
5564 
5565  temp = coldry(k) * chi_mls(4,jp(k)+1)
5566  ratn2o = colamt(k,4) / temp
5567  if (ratn2o > 1.5) then
5568  adjfac = 0.5 + (ratn2o - 0.5)**0.65
5569  adjcoln2o = adjfac * temp
5570  else
5571  adjcoln2o = colamt(k,4)
5572  endif
5573 
5574  do ig = 1, ng09
5575  absn2o = kb_mn2o(ig,indm) + minorfrac(k) &
5576  & * (kb_mn2o(ig,indmp) - kb_mn2o(ig,indm))
5577 
5578  taug(ns09+ig,k) = colamt(k,5) &
5579  & * (fac00(k)*absb(ig,ind0) + fac10(k)*absb(ig,ind0p) &
5580  & + fac01(k)*absb(ig,ind1) + fac11(k)*absb(ig,ind1p)) &
5581  & + adjcoln2o*absn2o
5582 
5583  fracs(ns09+ig,k) = fracrefb(ig)
5584  enddo
5585  enddo
5586 
5587 ! ..................................
5588  end subroutine taugb09
5589 ! ----------------------------------
5590 
5592 ! ----------------------------------
5593  subroutine taugb10
5594 ! ..................................
5595 
5596 ! ------------------------------------------------------------------ !
5597 ! band 10: 1390-1480 cm-1 (low key - h2o; high key - h2o) !
5598 ! ------------------------------------------------------------------ !
5599 
5600  use module_radlw_kgb10
5601 
5602 ! --- locals:
5603  integer :: k, ind0, ind0p, ind1, ind1p, inds, indsp, indf, indfp, &
5604  & ig
5605 
5606  real (kind=kind_phys) :: tauself, taufor
5607 !
5608 !===> ... begin here
5609 !
5610 ! --- ... lower atmosphere loop
5611 
5612  do k = 1, laytrop
5613  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(10) + 1
5614  ind1 = ( jp(k) *5 + (jt1(k)-1)) * nspa(10) + 1
5615 
5616  inds = indself(k)
5617  indf = indfor(k)
5618  ind0p = ind0 + 1
5619  ind1p = ind1 + 1
5620  indsp = inds + 1
5621  indfp = indf + 1
5622 
5623  do ig = 1, ng10
5624  tauself = selffac(k) * (selfref(ig,inds) + selffrac(k) &
5625  & * (selfref(ig,indsp) - selfref(ig,inds)))
5626  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
5627  & * (forref(ig,indfp) - forref(ig,indf)))
5628 
5629  taug(ns10+ig,k) = colamt(k,1) &
5630  & * (fac00(k)*absa(ig,ind0) + fac10(k)*absa(ig,ind0p) &
5631  & + fac01(k)*absa(ig,ind1) + fac11(k)*absa(ig,ind1p)) &
5632  & + tauself + taufor
5633 
5634  fracs(ns10+ig,k) = fracrefa(ig)
5635  enddo
5636  enddo
5637 
5638 ! --- ... upper atmosphere loop
5639 
5640  do k = laytrop+1, nlay
5641  ind0 = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(10) + 1
5642  ind1 = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(10) + 1
5643 
5644  indf = indfor(k)
5645  ind0p = ind0 + 1
5646  ind1p = ind1 + 1
5647  indfp = indf + 1
5648 
5649  do ig = 1, ng10
5650  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
5651  & * (forref(ig,indfp) - forref(ig,indf)))
5652 
5653  taug(ns10+ig,k) = colamt(k,1) &
5654  & * (fac00(k)*absb(ig,ind0) + fac10(k)*absb(ig,ind0p) &
5655  & + fac01(k)*absb(ig,ind1) + fac11(k)*absb(ig,ind1p)) &
5656  & + taufor
5657 
5658  fracs(ns10+ig,k) = fracrefb(ig)
5659  enddo
5660  enddo
5661 
5662 ! ..................................
5663  end subroutine taugb10
5664 ! ----------------------------------
5665 
5668 ! ----------------------------------
5669  subroutine taugb11
5670 ! ..................................
5671 
5672 ! ------------------------------------------------------------------ !
5673 ! band 11: 1480-1800 cm-1 (low - h2o; low minor - o2) !
5674 ! (high key - h2o; high minor - o2) !
5675 ! ------------------------------------------------------------------ !
5676 
5677  use module_radlw_kgb11
5678 
5679 ! --- locals:
5680  integer :: k, ind0, ind0p, ind1, ind1p, inds, indsp, indf, indfp, &
5681  & indm, indmp, ig
5682 
5683  real (kind=kind_phys) :: scaleo2, tauself, taufor, tauo2
5684 !
5685 !===> ... begin here
5686 !
5687 ! --- ... minor gas mapping level :
5688 ! lower - o2, p = 706.2720 mbar, t = 278.94 k
5689 ! upper - o2, p = 4.758820 mbarm t = 250.85 k
5690 
5691 ! --- ... lower atmosphere loop
5692 
5693  do k = 1, laytrop
5694  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(11) + 1
5695  ind1 = ( jp(k) *5 + (jt1(k)-1)) * nspa(11) + 1
5696 
5697  inds = indself(k)
5698  indf = indfor(k)
5699  indm = indminor(k)
5700  ind0p = ind0 + 1
5701  ind1p = ind1 + 1
5702  indsp = inds + 1
5703  indfp = indf + 1
5704  indmp = indm + 1
5705 
5706  scaleo2 = colamt(k,6) * scaleminor(k)
5707 
5708  do ig = 1, ng11
5709  tauself = selffac(k) * (selfref(ig,inds) + selffrac(k) &
5710  & * (selfref(ig,indsp) - selfref(ig,inds)))
5711  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
5712  & * (forref(ig,indfp) - forref(ig,indf)))
5713  tauo2 = scaleo2 * (ka_mo2(ig,indm) + minorfrac(k) &
5714  & * (ka_mo2(ig,indmp) - ka_mo2(ig,indm)))
5715 
5716  taug(ns11+ig,k) = colamt(k,1) &
5717  & * (fac00(k)*absa(ig,ind0) + fac10(k)*absa(ig,ind0p) &
5718  & + fac01(k)*absa(ig,ind1) + fac11(k)*absa(ig,ind1p)) &
5719  & + tauself + taufor + tauo2
5720 
5721  fracs(ns11+ig,k) = fracrefa(ig)
5722  enddo
5723  enddo
5724 
5725 ! --- ... upper atmosphere loop
5726 
5727  do k = laytrop+1, nlay
5728  ind0 = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(11) + 1
5729  ind1 = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(11) + 1
5730 
5731  indf = indfor(k)
5732  indm = indminor(k)
5733  ind0p = ind0 + 1
5734  ind1p = ind1 + 1
5735  indfp = indf + 1
5736  indmp = indm + 1
5737 
5738  scaleo2 = colamt(k,6) * scaleminor(k)
5739 
5740  do ig = 1, ng11
5741  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
5742  & * (forref(ig,indfp) - forref(ig,indf)))
5743  tauo2 = scaleo2 * (kb_mo2(ig,indm) + minorfrac(k) &
5744  & * (kb_mo2(ig,indmp) - kb_mo2(ig,indm)))
5745 
5746  taug(ns11+ig,k) = colamt(k,1) &
5747  & * (fac00(k)*absb(ig,ind0) + fac10(k)*absb(ig,ind0p) &
5748  & + fac01(k)*absb(ig,ind1) + fac11(k)*absb(ig,ind1p)) &
5749  & + taufor + tauo2
5750 
5751  fracs(ns11+ig,k) = fracrefb(ig)
5752  enddo
5753  enddo
5754 
5755 ! ..................................
5756  end subroutine taugb11
5757 ! ----------------------------------
5758 
5760 ! ----------------------------------
5761  subroutine taugb12
5762 ! ..................................
5763 
5764 ! ------------------------------------------------------------------ !
5765 ! band 12: 1800-2080 cm-1 (low - h2o,co2; high - nothing) !
5766 ! ------------------------------------------------------------------ !
5767 
5768  use module_radlw_kgb12
5769 
5770 ! --- locals:
5771  integer :: k, ind0, ind1, inds, indsp, indf, indfp, jpl, jplp, &
5772  & id000, id010, id100, id110, id200, id210, ig, js, js1, &
5773  & id001, id011, id101, id111, id201, id211
5774 
5775  real (kind=kind_phys) :: tauself, taufor, refrat_planck_a, &
5776  & speccomb, specparm, specmult, fs, &
5777  & speccomb1, specparm1, specmult1, fs1, &
5778  & speccomb_planck,specparm_planck,specmult_planck,fpl, &
5779  & fac000, fac100, fac200, fac010, fac110, fac210, &
5780  & fac001, fac101, fac201, fac011, fac111, fac211, &
5781  & p0, p40, fk00, fk10, fk20, p1, p41, fk01, fk11, fk21
5782 !
5783 !===> ... begin here
5784 !
5785 ! --- ... calculate reference ratio to be used in calculation of Planck
5786 ! fraction in lower/upper atmosphere.
5787 
5788  refrat_planck_a = chi_mls(1,10)/chi_mls(2,10) ! P = 174.164 mb
5789 
5790 ! --- ... lower atmosphere loop
5791 
5792  do k = 1, laytrop
5793  speccomb = colamt(k,1) + rfrate(k,1,1)*colamt(k,2)
5794  specparm = colamt(k,1) / speccomb
5795  specmult = 8.0 * min(specparm, oneminus)
5796  js = 1 + int(specmult)
5797  fs = mod(specmult, f_one)
5798  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(12) + js
5799 
5800  speccomb1 = colamt(k,1) + rfrate(k,1,2)*colamt(k,2)
5801  specparm1 = colamt(k,1) / speccomb1
5802  specmult1 = 8.0 * min(specparm1, oneminus)
5803  js1 = 1 + int(specmult1)
5804  fs1 = mod(specmult1, f_one)
5805  ind1 = (jp(k)*5 + (jt1(k)-1)) * nspa(12) + js1
5806 
5807  speccomb_planck = colamt(k,1) + refrat_planck_a*colamt(k,2)
5808  specparm_planck = colamt(k,1) / speccomb_planck
5809  if (specparm_planck >= oneminus) specparm_planck=oneminus
5810  specmult_planck = 8.0 * specparm_planck
5811  jpl = 1 + int(specmult_planck)
5812  fpl = mod(specmult_planck, f_one)
5813 
5814  inds = indself(k)
5815  indf = indfor(k)
5816  indsp = inds + 1
5817  indfp = indf + 1
5818  jplp = jpl + 1
5819 
5820  if (specparm < 0.125) then
5821  p0 = fs - f_one
5822  p40 = p0**4
5823  fk00 = p40
5824  fk10 = f_one - p0 - 2.0*p40
5825  fk20 = p0 + p40
5826 
5827  id000 = ind0
5828  id010 = ind0 + 9
5829  id100 = ind0 + 1
5830  id110 = ind0 +10
5831  id200 = ind0 + 2
5832  id210 = ind0 +11
5833  elseif (specparm > 0.875) then
5834  p0 = -fs
5835  p40 = p0**4
5836  fk00 = p40
5837  fk10 = f_one - p0 - 2.0*p40
5838  fk20 = p0 + p40
5839 
5840  id000 = ind0 + 1
5841  id010 = ind0 +10
5842  id100 = ind0
5843  id110 = ind0 + 9
5844  id200 = ind0 - 1
5845  id210 = ind0 + 8
5846  else
5847  fk00 = f_one - fs
5848  fk10 = fs
5849  fk20 = f_zero
5850 
5851  id000 = ind0
5852  id010 = ind0 + 9
5853  id100 = ind0 + 1
5854  id110 = ind0 +10
5855  id200 = ind0
5856  id210 = ind0
5857  endif
5858 
5859  fac000 = fk00 * fac00(k)
5860  fac100 = fk10 * fac00(k)
5861  fac200 = fk20 * fac00(k)
5862  fac010 = fk00 * fac10(k)
5863  fac110 = fk10 * fac10(k)
5864  fac210 = fk20 * fac10(k)
5865 
5866  if (specparm1 < 0.125) then
5867  p1 = fs1 - f_one
5868  p41 = p1**4
5869  fk01 = p41
5870  fk11 = f_one - p1 - 2.0*p41
5871  fk21 = p1 + p41
5872 
5873  id001 = ind1
5874  id011 = ind1 + 9
5875  id101 = ind1 + 1
5876  id111 = ind1 +10
5877  id201 = ind1 + 2
5878  id211 = ind1 +11
5879  elseif (specparm1 > 0.875) then
5880  p1 = -fs1
5881  p41 = p1**4
5882  fk01 = p41
5883  fk11 = f_one - p1 - 2.0*p41
5884  fk21 = p1 + p41
5885 
5886  id001 = ind1 + 1
5887  id011 = ind1 +10
5888  id101 = ind1
5889  id111 = ind1 + 9
5890  id201 = ind1 - 1
5891  id211 = ind1 + 8
5892  else
5893  fk01 = f_one - fs1
5894  fk11 = fs1
5895  fk21 = f_zero
5896 
5897  id001 = ind1
5898  id011 = ind1 + 9
5899  id101 = ind1 + 1
5900  id111 = ind1 +10
5901  id201 = ind1
5902  id211 = ind1
5903  endif
5904 
5905  fac001 = fk01 * fac01(k)
5906  fac101 = fk11 * fac01(k)
5907  fac201 = fk21 * fac01(k)
5908  fac011 = fk01 * fac11(k)
5909  fac111 = fk11 * fac11(k)
5910  fac211 = fk21 * fac11(k)
5911 
5912  do ig = 1, ng12
5913  tauself = selffac(k)* (selfref(ig,inds) + selffrac(k) &
5914  & * (selfref(ig,indsp) - selfref(ig,inds)))
5915  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
5916  & * (forref(ig,indfp) - forref(ig,indf)))
5917 
5918  taug(ns12+ig,k) = speccomb &
5919  & * (fac000*absa(ig,id000) + fac010*absa(ig,id010) &
5920  & + fac100*absa(ig,id100) + fac110*absa(ig,id110) &
5921  & + fac200*absa(ig,id200) + fac210*absa(ig,id210)) &
5922  & + speccomb1 &
5923  & * (fac001*absa(ig,id001) + fac011*absa(ig,id011) &
5924  & + fac101*absa(ig,id101) + fac111*absa(ig,id111) &
5925  & + fac201*absa(ig,id201) + fac211*absa(ig,id211)) &
5926  & + tauself + taufor
5927 
5928  fracs(ns12+ig,k) = fracrefa(ig,jpl) + fpl &
5929  & *(fracrefa(ig,jplp) - fracrefa(ig,jpl))
5930  enddo
5931  enddo
5932 
5933 ! --- ... upper atmosphere loop
5934 
5935  do k = laytrop+1, nlay
5936  do ig = 1, ng12
5937  taug(ns12+ig,k) = f_zero
5938  fracs(ns12+ig,k) = f_zero
5939  enddo
5940  enddo
5941 
5942 ! ..................................
5943  end subroutine taugb12
5944 ! ----------------------------------
5945 
5947 ! ----------------------------------
5948  subroutine taugb13
5949 ! ..................................
5950 
5951 ! ------------------------------------------------------------------ !
5952 ! band 13: 2080-2250 cm-1 (low key-h2o,n2o; high minor-o3 minor) !
5953 ! ------------------------------------------------------------------ !
5954 
5955  use module_radlw_kgb13
5956 
5957 ! --- locals:
5958  integer :: k, ind0, ind1, inds, indsp, indf, indfp, indm, indmp, &
5959  & id000, id010, id100, id110, id200, id210, jmco2, jpl, &
5960  & id001, id011, id101, id111, id201, id211, jmco2p, jplp, &
5961  & jmco, jmcop, ig, js, js1
5962 
5963  real (kind=kind_phys) :: tauself, taufor, co2m1, co2m2, absco2, &
5964  & speccomb, specparm, specmult, fs, &
5965  & speccomb1, specparm1, specmult1, fs1, &
5966  & speccomb_mco2, specparm_mco2, specmult_mco2, fmco2, &
5967  & speccomb_mco, specparm_mco, specmult_mco, fmco, &
5968  & speccomb_planck,specparm_planck,specmult_planck,fpl, &
5969  & refrat_planck_a, refrat_m_a, refrat_m_a3, ratco2, &
5970  & adjfac, adjcolco2, com1, com2, absco, abso3, &
5971  & fac000, fac100, fac200, fac010, fac110, fac210, &
5972  & fac001, fac101, fac201, fac011, fac111, fac211, &
5973  & p0, p40, fk00, fk10, fk20, p1, p41, fk01, fk11, fk21, temp
5974 !
5975 !===> ... begin here
5976 !
5977 ! --- ... minor gas mapping levels :
5978 ! lower - co2, p = 1053.63 mb, t = 294.2 k
5979 ! lower - co, p = 706 mb, t = 278.94 k
5980 ! upper - o3, p = 95.5835 mb, t = 215.7 k
5981 
5982 ! --- ... calculate reference ratio to be used in calculation of Planck
5983 ! fraction in lower/upper atmosphere.
5984 
5985  refrat_planck_a = chi_mls(1,5)/chi_mls(4,5) ! P = 473.420 mb (Level 5)
5986  refrat_m_a = chi_mls(1,1)/chi_mls(4,1) ! P = 1053. (Level 1)
5987  refrat_m_a3 = chi_mls(1,3)/chi_mls(4,3) ! P = 706. (Level 3)
5988 
5989 ! --- ... lower atmosphere loop
5990 
5991  do k = 1, laytrop
5992  speccomb = colamt(k,1) + rfrate(k,3,1)*colamt(k,4)
5993  specparm = colamt(k,1) / speccomb
5994  specmult = 8.0 * min(specparm, oneminus)
5995  js = 1 + int(specmult)
5996  fs = mod(specmult, f_one)
5997  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(13) + js
5998 
5999  speccomb1 = colamt(k,1) + rfrate(k,3,2)*colamt(k,4)
6000  specparm1 = colamt(k,1) / speccomb1
6001  specmult1 = 8.0 * min(specparm1, oneminus)
6002  js1 = 1 + int(specmult1)
6003  fs1 = mod(specmult1, f_one)
6004  ind1 = (jp(k)*5 + (jt1(k)-1)) * nspa(13) + js1
6005 
6006  speccomb_mco2 = colamt(k,1) + refrat_m_a*colamt(k,4)
6007  specparm_mco2 = colamt(k,1) / speccomb_mco2
6008  specmult_mco2 = 8.0 * min(specparm_mco2, oneminus)
6009  jmco2 = 1 + int(specmult_mco2)
6010  fmco2 = mod(specmult_mco2, f_one)
6011 
6012 ! --- ... in atmospheres where the amount of co2 is too great to be considered
6013 ! a minor species, adjust the column amount of co2 by an empirical factor
6014 ! to obtain the proper contribution.
6015 
6016  speccomb_mco = colamt(k,1) + refrat_m_a3*colamt(k,4)
6017  specparm_mco = colamt(k,1) / speccomb_mco
6018  specmult_mco = 8.0 * min(specparm_mco, oneminus)
6019  jmco = 1 + int(specmult_mco)
6020  fmco = mod(specmult_mco, f_one)
6021 
6022  speccomb_planck = colamt(k,1) + refrat_planck_a*colamt(k,4)
6023  specparm_planck = colamt(k,1) / speccomb_planck
6024  specmult_planck = 8.0 * min(specparm_planck, oneminus)
6025  jpl = 1 + int(specmult_planck)
6026  fpl = mod(specmult_planck, f_one)
6027 
6028  inds = indself(k)
6029  indf = indfor(k)
6030  indm = indminor(k)
6031  indsp = inds + 1
6032  indfp = indf + 1
6033  indmp = indm + 1
6034  jplp = jpl + 1
6035  jmco2p= jmco2+ 1
6036  jmcop = jmco + 1
6037 
6038 ! --- ... in atmospheres where the amount of co2 is too great to be considered
6039 ! a minor species, adjust the column amount of co2 by an empirical factor
6040 ! to obtain the proper contribution.
6041 
6042  temp = coldry(k) * 3.55e-4
6043  ratco2 = colamt(k,2) / temp
6044  if (ratco2 > 3.0) then
6045  adjfac = 2.0 + (ratco2-2.0)**0.68
6046  adjcolco2 = adjfac * temp
6047  else
6048  adjcolco2 = colamt(k,2)
6049  endif
6050 
6051  if (specparm < 0.125) then
6052  p0 = fs - f_one
6053  p40 = p0**4
6054  fk00 = p40
6055  fk10 = f_one - p0 - 2.0*p40
6056  fk20 = p0 + p40
6057 
6058  id000 = ind0
6059  id010 = ind0 + 9
6060  id100 = ind0 + 1
6061  id110 = ind0 +10
6062  id200 = ind0 + 2
6063  id210 = ind0 +11
6064  elseif (specparm > 0.875) then
6065  p0 = -fs
6066  p40 = p0**4
6067  fk00 = p40
6068  fk10 = f_one - p0 - 2.0*p40
6069  fk20 = p0 + p40
6070 
6071  id000 = ind0 + 1
6072  id010 = ind0 +10
6073  id100 = ind0
6074  id110 = ind0 + 9
6075  id200 = ind0 - 1
6076  id210 = ind0 + 8
6077  else
6078  fk00 = f_one - fs
6079  fk10 = fs
6080  fk20 = f_zero
6081 
6082  id000 = ind0
6083  id010 = ind0 + 9
6084  id100 = ind0 + 1
6085  id110 = ind0 +10
6086  id200 = ind0
6087  id210 = ind0
6088  endif
6089 
6090  fac000 = fk00 * fac00(k)
6091  fac100 = fk10 * fac00(k)
6092  fac200 = fk20 * fac00(k)
6093  fac010 = fk00 * fac10(k)
6094  fac110 = fk10 * fac10(k)
6095  fac210 = fk20 * fac10(k)
6096 
6097  if (specparm1 < 0.125) then
6098  p1 = fs1 - f_one
6099  p41 = p1**4
6100  fk01 = p41
6101  fk11 = f_one - p1 - 2.0*p41
6102  fk21 = p1 + p41
6103 
6104  id001 = ind1
6105  id011 = ind1 + 9
6106  id101 = ind1 + 1
6107  id111 = ind1 +10
6108  id201 = ind1 + 2
6109  id211 = ind1 +11
6110  elseif (specparm1 > 0.875) then
6111  p1 = -fs1
6112  p41 = p1**4
6113  fk01 = p41
6114  fk11 = f_one - p1 - 2.0*p41
6115  fk21 = p1 + p41
6116 
6117  id001 = ind1 + 1
6118  id011 = ind1 +10
6119  id101 = ind1
6120  id111 = ind1 + 9
6121  id201 = ind1 - 1
6122  id211 = ind1 + 8
6123  else
6124  fk01 = f_one - fs1
6125  fk11 = fs1
6126  fk21 = f_zero
6127 
6128  id001 = ind1
6129  id011 = ind1 + 9
6130  id101 = ind1 + 1
6131  id111 = ind1 +10
6132  id201 = ind1
6133  id211 = ind1
6134  endif
6135 
6136  fac001 = fk01 * fac01(k)
6137  fac101 = fk11 * fac01(k)
6138  fac201 = fk21 * fac01(k)
6139  fac011 = fk01 * fac11(k)
6140  fac111 = fk11 * fac11(k)
6141  fac211 = fk21 * fac11(k)
6142 
6143  do ig = 1, ng13
6144  tauself = selffac(k)* (selfref(ig,inds) + selffrac(k) &
6145  & * (selfref(ig,indsp) - selfref(ig,inds)))
6146  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
6147  & * (forref(ig,indfp) - forref(ig,indf)))
6148  co2m1 = ka_mco2(ig,jmco2,indm) + fmco2 &
6149  & * (ka_mco2(ig,jmco2p,indm) - ka_mco2(ig,jmco2,indm))
6150  co2m2 = ka_mco2(ig,jmco2,indmp) + fmco2 &
6151  & * (ka_mco2(ig,jmco2p,indmp) - ka_mco2(ig,jmco2,indmp))
6152  absco2 = co2m1 + minorfrac(k) * (co2m2 - co2m1)
6153  com1 = ka_mco(ig,jmco,indm) + fmco &
6154  & * (ka_mco(ig,jmcop,indm) - ka_mco(ig,jmco,indm))
6155  com2 = ka_mco(ig,jmco,indmp) + fmco &
6156  & * (ka_mco(ig,jmcop,indmp) - ka_mco(ig,jmco,indmp))
6157  absco = com1 + minorfrac(k) * (com2 - com1)
6158 
6159  taug(ns13+ig,k) = speccomb &
6160  & * (fac000*absa(ig,id000) + fac010*absa(ig,id010) &
6161  & + fac100*absa(ig,id100) + fac110*absa(ig,id110) &
6162  & + fac200*absa(ig,id200) + fac210*absa(ig,id210)) &
6163  & + speccomb1 &
6164  & * (fac001*absa(ig,id001) + fac011*absa(ig,id011) &
6165  & + fac101*absa(ig,id101) + fac111*absa(ig,id111) &
6166  & + fac201*absa(ig,id201) + fac211*absa(ig,id211)) &
6167  & + tauself + taufor + adjcolco2*absco2 &
6168  & + colamt(k,7)*absco
6169 
6170  fracs(ns13+ig,k) = fracrefa(ig,jpl) + fpl &
6171  & * (fracrefa(ig,jplp) - fracrefa(ig,jpl))
6172  enddo
6173  enddo
6174 
6175 ! --- ... upper atmosphere loop
6176 
6177  do k = laytrop+1, nlay
6178  indm = indminor(k)
6179  indmp = indm + 1
6180 
6181  do ig = 1, ng13
6182  abso3 = kb_mo3(ig,indm) + minorfrac(k) &
6183  & * (kb_mo3(ig,indmp) - kb_mo3(ig,indm))
6184 
6185  taug(ns13+ig,k) = colamt(k,3)*abso3
6186 
6187  fracs(ns13+ig,k) = fracrefb(ig)
6188  enddo
6189  enddo
6190 
6191 ! ..................................
6192  end subroutine taugb13
6193 ! ----------------------------------
6194 
6196 ! ----------------------------------
6197  subroutine taugb14
6198 ! ..................................
6199 
6200 ! ------------------------------------------------------------------ !
6201 ! band 14: 2250-2380 cm-1 (low - co2; high - co2) !
6202 ! ------------------------------------------------------------------ !
6203 
6204  use module_radlw_kgb14
6205 
6206 ! --- locals:
6207  integer :: k, ind0, ind0p, ind1, ind1p, inds, indsp, indf, indfp, &
6208  & ig
6209 
6210  real (kind=kind_phys) :: tauself, taufor
6211 !
6212 !===> ... begin here
6213 !
6214 ! --- ... lower atmosphere loop
6215 
6216  do k = 1, laytrop
6217  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(14) + 1
6218  ind1 = ( jp(k) *5 + (jt1(k)-1)) * nspa(14) + 1
6219 
6220  inds = indself(k)
6221  indf = indfor(k)
6222  ind0p = ind0 + 1
6223  ind1p = ind1 + 1
6224  indsp = inds + 1
6225  indfp = indf + 1
6226 
6227  do ig = 1, ng14
6228  tauself = selffac(k) * (selfref(ig,inds) + selffrac(k) &
6229  & * (selfref(ig,indsp) - selfref(ig,inds)))
6230  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
6231  & * (forref(ig,indfp) - forref(ig,indf)))
6232 
6233  taug(ns14+ig,k) = colamt(k,2) &
6234  & * (fac00(k)*absa(ig,ind0) + fac10(k)*absa(ig,ind0p) &
6235  & + fac01(k)*absa(ig,ind1) + fac11(k)*absa(ig,ind1p)) &
6236  & + tauself + taufor
6237 
6238  fracs(ns14+ig,k) = fracrefa(ig)
6239  enddo
6240  enddo
6241 
6242 ! --- ... upper atmosphere loop
6243 
6244  do k = laytrop+1, nlay
6245  ind0 = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(14) + 1
6246  ind1 = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(14) + 1
6247 
6248  ind0p = ind0 + 1
6249  ind1p = ind1 + 1
6250 
6251  do ig = 1, ng14
6252  taug(ns14+ig,k) = colamt(k,2) &
6253  & * (fac00(k)*absb(ig,ind0) + fac10(k)*absb(ig,ind0p) &
6254  & + fac01(k)*absb(ig,ind1) + fac11(k)*absb(ig,ind1p))
6255 
6256  fracs(ns14+ig,k) = fracrefb(ig)
6257  enddo
6258  enddo
6259 
6260 ! ..................................
6261  end subroutine taugb14
6262 ! ----------------------------------
6263 
6266 ! ----------------------------------
6267  subroutine taugb15
6268 ! ..................................
6269 
6270 ! ------------------------------------------------------------------ !
6271 ! band 15: 2380-2600 cm-1 (low - n2o,co2; low minor - n2) !
6272 ! (high - nothing) !
6273 ! ------------------------------------------------------------------ !
6274 
6275  use module_radlw_kgb15
6276 
6277 ! --- locals:
6278  integer :: k, ind0, ind1, inds, indsp, indf, indfp, indm, indmp, &
6279  & id000, id010, id100, id110, id200, id210, jpl, jplp, &
6280  & id001, id011, id101, id111, id201, id211, jmn2, jmn2p, &
6281  & ig, js, js1
6282 
6283  real (kind=kind_phys) :: scalen2, tauself, taufor, &
6284  & speccomb, specparm, specmult, fs, &
6285  & speccomb1, specparm1, specmult1, fs1, &
6286  & speccomb_mn2, specparm_mn2, specmult_mn2, fmn2, &
6287  & speccomb_planck,specparm_planck,specmult_planck,fpl, &
6288  & refrat_planck_a, refrat_m_a, n2m1, n2m2, taun2, &
6289  & fac000, fac100, fac200, fac010, fac110, fac210, &
6290  & fac001, fac101, fac201, fac011, fac111, fac211, &
6291  & p0, p40, fk00, fk10, fk20, p1, p41, fk01, fk11, fk21
6292 !
6293 !===> ... begin here
6294 !
6295 ! --- ... minor gas mapping level :
6296 ! lower - nitrogen continuum, P = 1053., T = 294.
6297 
6298 ! --- ... calculate reference ratio to be used in calculation of Planck
6299 ! fraction in lower atmosphere.
6300 
6301  refrat_planck_a = chi_mls(4,1)/chi_mls(2,1) ! P = 1053. mb (Level 1)
6302  refrat_m_a = chi_mls(4,1)/chi_mls(2,1) ! P = 1053. mb
6303 
6304 ! --- ... lower atmosphere loop
6305 
6306  do k = 1, laytrop
6307  speccomb = colamt(k,4) + rfrate(k,5,1)*colamt(k,2)
6308  specparm = colamt(k,4) / speccomb
6309  specmult = 8.0 * min(specparm, oneminus)
6310  js = 1 + int(specmult)
6311  fs = mod(specmult, f_one)
6312  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(15) + js
6313 
6314  speccomb1 = colamt(k,4) + rfrate(k,5,2)*colamt(k,2)
6315  specparm1 = colamt(k,4) / speccomb1
6316  specmult1 = 8.0 * min(specparm1, oneminus)
6317  js1 = 1 + int(specmult1)
6318  fs1 = mod(specmult1, f_one)
6319  ind1 = (jp(k)*5 + (jt1(k)-1)) * nspa(15) + js1
6320 
6321  speccomb_mn2 = colamt(k,4) + refrat_m_a*colamt(k,2)
6322  specparm_mn2 = colamt(k,4) / speccomb_mn2
6323  specmult_mn2 = 8.0 * min(specparm_mn2, oneminus)
6324  jmn2 = 1 + int(specmult_mn2)
6325  fmn2 = mod(specmult_mn2, f_one)
6326 
6327  speccomb_planck = colamt(k,4) + refrat_planck_a*colamt(k,2)
6328  specparm_planck = colamt(k,4) / speccomb_planck
6329  specmult_planck = 8.0 * min(specparm_planck, oneminus)
6330  jpl = 1 + int(specmult_planck)
6331  fpl = mod(specmult_planck, f_one)
6332 
6333  scalen2 = colbrd(k) * scaleminor(k)
6334 
6335  inds = indself(k)
6336  indf = indfor(k)
6337  indm = indminor(k)
6338  indsp = inds + 1
6339  indfp = indf + 1
6340  indmp = indm + 1
6341  jplp = jpl + 1
6342  jmn2p = jmn2 + 1
6343 
6344  if (specparm < 0.125) then
6345  p0 = fs - f_one
6346  p40 = p0**4
6347  fk00 = p40
6348  fk10 = f_one - p0 - 2.0*p40
6349  fk20 = p0 + p40
6350 
6351  id000 = ind0
6352  id010 = ind0 + 9
6353  id100 = ind0 + 1
6354  id110 = ind0 +10
6355  id200 = ind0 + 2
6356  id210 = ind0 +11
6357  elseif (specparm > 0.875) then
6358  p0 = -fs
6359  p40 = p0**4
6360  fk00 = p40
6361  fk10 = f_one - p0 - 2.0*p40
6362  fk20 = p0 + p40
6363 
6364  id000 = ind0 + 1
6365  id010 = ind0 +10
6366  id100 = ind0
6367  id110 = ind0 + 9
6368  id200 = ind0 - 1
6369  id210 = ind0 + 8
6370  else
6371  fk00 = f_one - fs
6372  fk10 = fs
6373  fk20 = f_zero
6374 
6375  id000 = ind0
6376  id010 = ind0 + 9
6377  id100 = ind0 + 1
6378  id110 = ind0 +10
6379  id200 = ind0
6380  id210 = ind0
6381  endif
6382 
6383  fac000 = fk00 * fac00(k)
6384  fac100 = fk10 * fac00(k)
6385  fac200 = fk20 * fac00(k)
6386  fac010 = fk00 * fac10(k)
6387  fac110 = fk10 * fac10(k)
6388  fac210 = fk20 * fac10(k)
6389 
6390  if (specparm1 < 0.125) then
6391  p1 = fs1 - f_one
6392  p41 = p1**4
6393  fk01 = p41
6394  fk11 = f_one - p1 - 2.0*p41
6395  fk21 = p1 + p41
6396 
6397  id001 = ind1
6398  id011 = ind1 + 9
6399  id101 = ind1 + 1
6400  id111 = ind1 +10
6401  id201 = ind1 + 2
6402  id211 = ind1 +11
6403  elseif (specparm1 > 0.875) then
6404  p1 = -fs1
6405  p41 = p1**4
6406  fk01 = p41
6407  fk11 = f_one - p1 - 2.0*p41
6408  fk21 = p1 + p41
6409 
6410  id001 = ind1 + 1
6411  id011 = ind1 +10
6412  id101 = ind1
6413  id111 = ind1 + 9
6414  id201 = ind1 - 1
6415  id211 = ind1 + 8
6416  else
6417  fk01 = f_one - fs1
6418  fk11 = fs1
6419  fk21 = f_zero
6420 
6421  id001 = ind1
6422  id011 = ind1 + 9
6423  id101 = ind1 + 1
6424  id111 = ind1 +10
6425  id201 = ind1
6426  id211 = ind1
6427  endif
6428 
6429  fac001 = fk01 * fac01(k)
6430  fac101 = fk11 * fac01(k)
6431  fac201 = fk21 * fac01(k)
6432  fac011 = fk01 * fac11(k)
6433  fac111 = fk11 * fac11(k)
6434  fac211 = fk21 * fac11(k)
6435 
6436  do ig = 1, ng15
6437  tauself = selffac(k)* (selfref(ig,inds) + selffrac(k) &
6438  & * (selfref(ig,indsp) - selfref(ig,inds)))
6439  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
6440  & * (forref(ig,indfp) - forref(ig,indf)))
6441  n2m1 = ka_mn2(ig,jmn2,indm) + fmn2 &
6442  & * (ka_mn2(ig,jmn2p,indm) - ka_mn2(ig,jmn2,indm))
6443  n2m2 = ka_mn2(ig,jmn2,indmp) + fmn2 &
6444  & * (ka_mn2(ig,jmn2p,indmp) - ka_mn2(ig,jmn2,indmp))
6445  taun2 = scalen2 * (n2m1 + minorfrac(k) * (n2m2 - n2m1))
6446 
6447  taug(ns15+ig,k) = speccomb &
6448  & * (fac000*absa(ig,id000) + fac010*absa(ig,id010) &
6449  & + fac100*absa(ig,id100) + fac110*absa(ig,id110) &
6450  & + fac200*absa(ig,id200) + fac210*absa(ig,id210)) &
6451  & + speccomb1 &
6452  & * (fac001*absa(ig,id001) + fac011*absa(ig,id011) &
6453  & + fac101*absa(ig,id101) + fac111*absa(ig,id111) &
6454  & + fac201*absa(ig,id201) + fac211*absa(ig,id211)) &
6455  & + tauself + taufor + taun2
6456 
6457  fracs(ns15+ig,k) = fracrefa(ig,jpl) + fpl &
6458  & * (fracrefa(ig,jplp) - fracrefa(ig,jpl))
6459  enddo
6460  enddo
6461 
6462 ! --- ... upper atmosphere loop
6463 
6464  do k = laytrop+1, nlay
6465  do ig = 1, ng15
6466  taug(ns15+ig,k) = f_zero
6467 
6468  fracs(ns15+ig,k) = f_zero
6469  enddo
6470  enddo
6471 
6472 ! ..................................
6473  end subroutine taugb15
6474 ! ----------------------------------
6475 
6477 ! ----------------------------------
6478  subroutine taugb16
6479 ! ..................................
6480 
6481 ! ------------------------------------------------------------------ !
6482 ! band 16: 2600-3250 cm-1 (low key- h2o,ch4; high key - ch4) !
6483 ! ------------------------------------------------------------------ !
6484 
6485  use module_radlw_kgb16
6486 
6487 ! --- locals:
6488  integer :: k, ind0, ind0p, ind1, ind1p, inds, indsp, indf, indfp, &
6489  & id000, id010, id100, id110, id200, id210, jpl, jplp, &
6490  & id001, id011, id101, id111, id201, id211, ig, js, js1
6491 
6492  real (kind=kind_phys) :: tauself, taufor, refrat_planck_a, &
6493  & speccomb, specparm, specmult, fs, &
6494  & speccomb1, specparm1, specmult1, fs1, &
6495  & speccomb_planck,specparm_planck,specmult_planck,fpl, &
6496  & fac000, fac100, fac200, fac010, fac110, fac210, &
6497  & fac001, fac101, fac201, fac011, fac111, fac211, &
6498  & p0, p40, fk00, fk10, fk20, p1, p41, fk01, fk11, fk21
6499 !
6500 !===> ... begin here
6501 !
6502 ! --- ... calculate reference ratio to be used in calculation of Planck
6503 ! fraction in lower atmosphere.
6504 
6505  refrat_planck_a = chi_mls(1,6)/chi_mls(6,6) ! P = 387. mb (Level 6)
6506 
6507 ! --- ... lower atmosphere loop
6508 
6509  do k = 1, laytrop
6510  speccomb = colamt(k,1) + rfrate(k,4,1)*colamt(k,5)
6511  specparm = colamt(k,1) / speccomb
6512  specmult = 8.0 * min(specparm, oneminus)
6513  js = 1 + int(specmult)
6514  fs = mod(specmult, f_one)
6515  ind0 = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(16) + js
6516 
6517  speccomb1 = colamt(k,1) + rfrate(k,4,2)*colamt(k,5)
6518  specparm1 = colamt(k,1) / speccomb1
6519  specmult1 = 8.0 * min(specparm1, oneminus)
6520  js1 = 1 + int(specmult1)
6521  fs1 = mod(specmult1, f_one)
6522  ind1 = (jp(k)*5 + (jt1(k)-1)) * nspa(16) + js1
6523 
6524  speccomb_planck = colamt(k,1) + refrat_planck_a*colamt(k,5)
6525  specparm_planck = colamt(k,1) / speccomb_planck
6526  specmult_planck = 8.0 * min(specparm_planck, oneminus)
6527  jpl = 1 + int(specmult_planck)
6528  fpl = mod(specmult_planck, f_one)
6529 
6530  inds = indself(k)
6531  indf = indfor(k)
6532  indsp = inds + 1
6533  indfp = indf + 1
6534  jplp = jpl + 1
6535 
6536  if (specparm < 0.125) then
6537  p0 = fs - f_one
6538  p40 = p0**4
6539  fk00 = p40
6540  fk10 = f_one - p0 - 2.0*p40
6541  fk20 = p0 + p40
6542 
6543  id000 = ind0
6544  id010 = ind0 + 9
6545  id100 = ind0 + 1
6546  id110 = ind0 +10
6547  id200 = ind0 + 2
6548  id210 = ind0 +11
6549  elseif (specparm > 0.875) then
6550  p0 = -fs
6551  p40 = p0**4
6552  fk00 = p40
6553  fk10 = f_one - p0 - 2.0*p40
6554  fk20 = p0 + p40
6555 
6556  id000 = ind0 + 1
6557  id010 = ind0 +10
6558  id100 = ind0
6559  id110 = ind0 + 9
6560  id200 = ind0 - 1
6561  id210 = ind0 + 8
6562  else
6563  fk00 = f_one - fs
6564  fk10 = fs
6565  fk20 = f_zero
6566 
6567  id000 = ind0
6568  id010 = ind0 + 9
6569  id100 = ind0 + 1
6570  id110 = ind0 +10
6571  id200 = ind0
6572  id210 = ind0
6573  endif
6574 
6575  fac000 = fk00 * fac00(k)
6576  fac100 = fk10 * fac00(k)
6577  fac200 = fk20 * fac00(k)
6578  fac010 = fk00 * fac10(k)
6579  fac110 = fk10 * fac10(k)
6580  fac210 = fk20 * fac10(k)
6581 
6582  if (specparm1 < 0.125) then
6583  p1 = fs1 - f_one
6584  p41 = p1**4
6585  fk01 = p41
6586  fk11 = f_one - p1 - 2.0*p41
6587  fk21 = p1 + p41
6588 
6589  id001 = ind1
6590  id011 = ind1 + 9
6591  id101 = ind1 + 1
6592  id111 = ind1 +10
6593  id201 = ind1 + 2
6594  id211 = ind1 +11
6595  elseif (specparm1 > 0.875) then
6596  p1 = -fs1
6597  p41 = p1**4
6598  fk01 = p41
6599  fk11 = f_one - p1 - 2.0*p41
6600  fk21 = p1 + p41
6601 
6602  id001 = ind1 + 1
6603  id011 = ind1 +10
6604  id101 = ind1
6605  id111 = ind1 + 9
6606  id201 = ind1 - 1
6607  id211 = ind1 + 8
6608  else
6609  fk01 = f_one - fs1
6610  fk11 = fs1
6611  fk21 = f_zero
6612 
6613  id001 = ind1
6614  id011 = ind1 + 9
6615  id101 = ind1 + 1
6616  id111 = ind1 +10
6617  id201 = ind1
6618  id211 = ind1
6619  endif
6620 
6621  fac001 = fk01 * fac01(k)
6622  fac101 = fk11 * fac01(k)
6623  fac201 = fk21 * fac01(k)
6624  fac011 = fk01 * fac11(k)
6625  fac111 = fk11 * fac11(k)
6626  fac211 = fk21 * fac11(k)
6627 
6628  do ig = 1, ng16
6629  tauself = selffac(k)* (selfref(ig,inds) + selffrac(k) &
6630  & * (selfref(ig,indsp) - selfref(ig,inds)))
6631  taufor = forfac(k) * (forref(ig,indf) + forfrac(k) &
6632  & * (forref(ig,indfp) - forref(ig,indf)))
6633 
6634  taug(ns16+ig,k) = speccomb &
6635  & * (fac000*absa(ig,id000) + fac010*absa(ig,id010) &
6636  & + fac100*absa(ig,id100) + fac110*absa(ig,id110) &
6637  & + fac200*absa(ig,id200) + fac210*absa(ig,id210)) &
6638  & + speccomb1 &
6639  & * (fac001*absa(ig,id001) + fac011*absa(ig,id011) &
6640  & + fac101*absa(ig,id101) + fac111*absa(ig,id111) &
6641  & + fac201*absa(ig,id201) + fac211*absa(ig,id211)) &
6642  & + tauself + taufor
6643 
6644  fracs(ns16+ig,k) = fracrefa(ig,jpl) + fpl &
6645  & * (fracrefa(ig,jplp) - fracrefa(ig,jpl))
6646  enddo
6647  enddo
6648 
6649 ! --- ... upper atmosphere loop
6650 
6651  do k = laytrop+1, nlay
6652  ind0 = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(16) + 1
6653  ind1 = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(16) + 1
6654 
6655  ind0p = ind0 + 1
6656  ind1p = ind1 + 1
6657 
6658  do ig = 1, ng16
6659  taug(ns16+ig,k) = colamt(k,5) &
6660  & * (fac00(k)*absb(ig,ind0) + fac10(k)*absb(ig,ind0p) &
6661  & + fac01(k)*absb(ig,ind1) + fac11(k)*absb(ig,ind1p))
6662 
6663  fracs(ns16+ig,k) = fracrefb(ig)
6664  enddo
6665  enddo
6666 
6667 ! ..................................
6668  end subroutine taugb16
6669 ! ----------------------------------
6670 
6671 ! ..................................
6672  end subroutine taumol
6673 !-----------------------------------
6674 
6675 
6676 !
6677 !........................................!
6678  end module module_radlw_main !
6679 !========================================!
6680 
6681 !! @}
real(kind=kind_phys), dimension(ng09, mmn09), public kb_mn2o
the array kb_mxxx contains the absorption coefficient for a minor species at the NG09=12 chosen g-val...
real(kind=kind_phys), dimension(ng08, mmc08), public ka_mco2
minor gas mapping level:lower - co2, p = 1053.63 mb, t = 294.2 k
This module sets up absorption coefficients for band 12: 1800-2080 cm-1 (low - h2o, co2; high - /)
real(kind=kind_phys), dimension(ng09), public fracrefb
planck fraction mapping level : p 3.20e-2 mb, t = 197.92 k
integer, parameter ngptlw
num of total g-points
Definition: radlw_param.f:113
Define type construct for radiation fluxes at surface.
Definition: radlw_param.f:84
real(kind=kind_phys), dimension(ng07, msb07), public absb
the array absb(NG07,235) = kb(NG07,5,13:59) contains absorption coefs at the NG07=12 chosen g-values ...
real(kind=kind_phys), dimension(ng15, msa15), public absa
the array absa(NG15,585) = ka(NG15,9,5,13) contains absorption coefs at the NG15=2 g-intervals for a ...
real(kind=kind_phys), dimension(ng05, mbf05), public fracrefb
planck fraction mapping level : p = 0.2369280 mbar, t = 253.60 k
subroutine taugb10
Band 10: 1390-1480 cm-1 (low key - h2o; high key - h2o)
Definition: radlw_main.f:5594
real(kind=kind_phys), dimension(ng04, msf04), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(ng15, msf15), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(ng06, msa06), public absa
the array absa(NG06,65) = ka(NG06,5,13) contains absorption coefs at the NG06=8 g-intervals for a ran...
real(kind=kind_phys), dimension(ng08, mmc08), public ka_mo3
minor gas mapping level:lower - o3, p = 317.348 mb, t = 240.77 k
real(kind=kind_phys), dimension(ng08, msb08), public absb
the array absb(NG08,235) = kb(NG08,5,13:59) contains absorption coefs at the NG08=8 chosen g-values f...
subroutine, public lwrad(plyr, plvl, tlyr, tlvl, qlyr, olyr, gasvmr, clouds, icseed, aerosols, sfemis, sfgtmp, npts, nlay, nlp1, lprnt, hlwc, topflx, sfcflx, HLW0, HLWB, FLXPRF)
This subroutine is the main LW radiation routine.
Definition: radlw_main.f:463
real(kind=kind_phys), dimension(ng09, maf09), public fracrefa
planck fractions mapping level : p=212.7250 mb, t = 223.06 k
This module sets up absorption coefficients for band 15: 2380-2600 cm-1 (low - n2o, co2; high - /)
real(kind=kind_phys), dimension(ng04, msa04), public absa
the array absa(NG04,585) = ka(NG04,9,5,13) contains absorption coefs at the NG04=14 g-intervals for a...
real(kind=kind_phys), dimension(ng01, msf01), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(58, nbands) absliq1
Hu and Stamnes method . the liquid water absorption coefficients are listed for a range of effective...
Definition: radlw_datatb.f:966
real(kind=kind_phys), dimension(ng10, msa10), public absa
the array absa(NG10,65) = ka(NG10,5,13) contains absorption coefs at the NG10=6 chosen g-values for a...
real(kind=kind_phys), dimension(ng03, maf03), public fracrefa
planck fraction mapping level: p=212.7250 mbar, t = 223.06 k
real(kind=kind_phys), dimension(ng11, msa11), public absa
the array absa(NG11,65) = ka(NG11,5,13) contains absorption coefs at the NG11=8 chosen g-values for a...
real(kind=kind_phys), dimension(ng13, msf13), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(ng09, msa09), public absa
the array absa(NG09,585) = ka(NG09,9,5,13) contains absorption coefs at the NG09=12 g-intervals for a...
This module sets up absorption coefficients for band 06: 820-980 cm-1 (low - h2o; high - /) ...
real(kind=kind_phys), dimension(ng16, maf16), public fracrefa
planck fraction mapping level: p = 387.6100 mbar, t = 250.17 k
real(kind=kind_phys), dimension(ng14), public fracrefa
planck fraction mapping level : p = 142.5940 mb, t = 215.70 k
real(kind=kind_phys), dimension(ng07), public fracrefb
planck data fraction mapping level : p=95.58 mbar, t= 215.70 k
real(kind=kind_phys), dimension(ng10), public fracrefb
planck fraction mapping level : p = 95.58350 mb, t = 215.70 k
real(kind=kind_phys), dimension(ng13), public fracrefb
planck fraction mapping level : p=4.758820 mb, t = 250.85 k
real(kind=kind_phys), dimension(ng09, mfr09), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
subroutine rtrnmc(semiss, delp, cldfmc, taucld, tautot, pklay, pklev, fracs, secdif, nlay, nlp1, totuflux, totdflux, htr, totuclfl, totdclfl, htrcl, htrb)
This subroutine computes the upward/downward radiative fluxes, and heating rates for both clear or cl...
Definition: radlw_main.f:3271
real(kind=kind_phys), dimension(ng05), public ccl4
minor gas (o3, ccl4) mapping level : p = 317.34 mbar, t = 240.77 k
subroutine taugb15
Band 15: 2380-2600 cm-1 (low - n2o,co2; low minor - n2) (high - nothing)
Definition: radlw_main.f:6268
real(kind=kind_phys), dimension(43, nbands) absice2
for iflagice =2, absice2 are the ice water absorption coefficients used for streamer method...
real(kind=kind_phys), dimension(ng04, msb04), public absb
the array absb(NG04,1175) = kb(NG04,5,5,13:59) contains absorption coefs at the NG04=14 g-intervals f...
real(kind=kind_phys), dimension(ng08, mfr08), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
real(kind=kind_phys), dimension(ng14, mfr14), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
integer, parameter maxxsec
num of halocarbon gasees
Definition: radlw_param.f:119
This module sets up absorption coefficients for band 09: 1180-1390 cm-1 (low - h2o, ch4; high - ch4)
real(kind=kind_phys), dimension(ng08), public cfc22adj
original cfc22 is multiplied by 1.485 to account for the 780-850 cm-1 and 1290-1335 cm-1 bands...
subroutine taumol(laytrop, pavel, coldry, colamt, colbrd, wx, tauaer, rfrate, fac00, fac01, fac10, fac11, jp, jt, jt1, selffac, selffrac, indself, forfac, forfrac, indfor, minorfrac, scaleminor, scaleminorn2, indminor, nlay, fracs, tautot)
This subroutine contains optical depths developed for the rapid radiative transfer model...
Definition: radlw_main.f:3688
This module sets up absorption coefficients for band 11: 1480-1800 cm-1 (low - h2o; high - h2o) ...
real(kind=kind_phys), dimension(ng01, msb01), public absb
the array absb(NG01,235) = kb(NG01,5,13:59) contains absorption coefs at the NG01=10 chosen g-values ...
real(kind=kind_phys), dimension(ng05, mfr05), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
real(kind=kind_phys), dimension(ng09, maf09, mmn09), public ka_mn2o
the array ka_mxxx contains the absorption coefficient for a minor species at the 16 chosen g-values f...
real(kind=kind_phys), dimension(ng01), public fracrefb
planck fraction mapping level: p = 212.7250 mbar, t = 223.06 k these planck fractions were calculated...
real(kind=kind_phys), dimension(ng16, msf16), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(ng08), public cfc12
minor gas mapping level:lower - cfc12
real(kind=kind_phys), dimension(ng03, mbf03), public fracrefb
planck fraction mapping level: p = 95.8 mbar, t = 215.7 k
real(kind=kind_phys), dimension(ng08, msa08), public absa
the array absa(NG08,65) = ka(NG08,5,13) contains absorption coefs at the NG08=8 g-intervals for a ran...
real(kind=kind_phys), dimension(ng02, msa02), public absa
the array absa(NG02,65) = ka(NG02,5,13) contains absorption coefs at the NG02=12 chosen g-values for ...
This module sets up absorption coefficients for band 02: 250-500 cm-1 (low - h2o; high - h2o) ...
subroutine taugb16
Band 16: 2600-3250 cm-1 (low key- h2o,ch4; high key - ch4)
Definition: radlw_main.f:6479
real(kind=kind_phys), parameter absrain
absrain is the rain drop absorption coefficient .
Definition: radlw_datatb.f:945
real(kind=kind_phys), dimension(ng11, mfr11), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
Define type construct for optional radiation flux profiles.
Definition: radlw_param.f:97
real(kind=kind_phys), dimension(ng14, msa14), public absa
the array absa(NG14,65) = ka(NG14,5,13) contains absorption coefs at the NG14=2 chosen g-values for a...
real(kind=kind_phys), dimension(ng09, msb09), public absb
the array absb(NG09,235) = kb(NG09,5,13:59) contains absorption coefs at the NG09=12 chosen g-values ...
real(kind=kind_phys), dimension(ng06, mmc06), public ka_mco2
the array kao_mxx contains the absorption coefficient for a minor species at the NG06=8 chosen g-valu...
real(kind=kind_phys), dimension(ng11, msb11), public absb
the array absb(NG11,235) = kb(NG11,5,13:59) contains absorption coefs at the NG11=8 chosen g-values f...
integer, dimension(nbands) ipat
ipat is bands index for ebert&curry ice cloud (for iflagice=1)
Definition: radlw_datatb.f:939
This module sets up absorption coefficients for band 05: 700-820 cm-1 (low - h2o, co2; high - co2...
subroutine taugb13
Band 13: 2080-2250 cm-1 (low key-h2o,n2o; high minor-o3 minor)
Definition: radlw_main.f:5949
real(kind=kind_phys), dimension(ng14), public fracrefb
planck fraction mapping level : p = 4.758820mb, t = 250.85 k
real(kind=kind_phys), dimension(ng04, mbf04), public fracrefb
planck fraction mapping level : p = 95.58350 mb, t = 215.70 k
real(kind=kind_phys), dimension(ng02), public fracrefa
planck fraction mapping level: p = 1053.630 mbar, t = 294.2 k
real(kind=kind_phys), dimension(ng03, mbf03, mmn03), public kb_mn2o
the array kb_mxxx contains the absorption coefficient for a minor species at the NG03=16 chosen g-val...
real(kind=kind_phys), parameter abssnow0
abssnow0 is the snow flake absorption coefficient (micron), fu coeff
Definition: radlw_datatb.f:948
real(kind=kind_phys), dimension(ng08, mmc08), public kb_mco2
minor gas mapping level:upper - co2, p = 35.1632 mb, t = 223.28 k
real(kind=kind_phys), dimension(ng01, msa01), public absa
the array absa(NG01,65) = ka(NG01,5,13) contains absorption coefs at the NG01=10 chosen g-values for ...
real(kind=kind_phys), dimension(ng07, maf07, mmc07), public ka_mco2
the array ka_mxxx contains the absorption coefficient for a minor species at the NG07=12 chosen g-val...
real(kind=kind_phys), dimension(ng12, msf12), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(ng03, msb03), public absb
the array absb(NG03,1175) = kb(NG03,5,5,13:59) contains absorption coefs at the NG03=16 g-intervals f...
real(kind=kind_phys), dimension(ng08), public fracrefb
planck fraction mapping level : p=95.5835 mb, t= 215.7 k
real(kind=kind_phys), dimension(ng02), public fracrefb
planck fraction mapping level: p = 3.206e-2 mb, t = 197.92 k
real(kind=kind_phys), dimension(ng11, mmo11), public ka_mo2
the array ka_mxx contains the absorption coefficient for a minor species at the NG11=8 chosen g-value...
real(kind=kind_phys), dimension(ng12, mfr12), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
This module contains reference temperature and pressure.
Definition: radlw_datatb.f:750
subroutine taugb08
Band 8: 1080-1180 cm-1 (low key - h2o; low minor - co2,o3,n2o) (high key - o3; high minor - co2...
Definition: radlw_main.f:5219
real(kind=kind_phys), dimension(nplnk, nbands), public totplnk
plank flux data
Definition: radlw_datatb.f:78
real(kind=kind_phys), dimension(ng15, mfr15), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
This module sets up absorption coefficients for band 14: 2250-2380 cm-1 (low - co2; high - co2) ...
real(kind=kind_phys), dimension(ng06), public fracrefa
planck fraction mapping level : p = 473.4280 mb, t = 259.83 k
subroutine rtrn(semiss, delp, cldfrc, taucld, tautot, pklay, pklev, fracs, secdif, nlay, nlp1, totuflux, totdflux, htr, totuclfl, totdclfl, htrcl, htrb)
This subroutine computes the upward/downward radiative fluxes, and heating rates for both clear or cl...
Definition: radlw_main.f:2295
real(kind=kind_phys), dimension(ng14, msf14), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(ng02, msb02), public absb
the array absb(NG02,235) = kb(NG02,5,13:59) contains absorption coefs at the NG02=12 chosen g-values ...
real(kind=kind_phys), dimension(46, nbands) absice3
for iflagice = 3, absice3 are the ice water absorption coefficients used for fu parameterization. particle size 5 - 140 micron in increments of 3 microns. units = m2/g. hexagonal ice particle parameterization absorption units (abs coef/iwc):
real(kind=kind_phys), dimension(ng05, msf05), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(ng06), public cfc11adj
lower - co2, p = 706.2720 mb, t = 294.2 k upper - cfc11, cfc12 original cfc11 is multiplied by 1...
subroutine taugb12
Band 12: 1800-2080 cm-1 (low - h2o,co2; high - nothing)
Definition: radlw_main.f:5762
real(kind=kind_phys), dimension(ng11), public fracrefb
planck fraction mapping level : p=0.353 mb, t = 262.11 k
This module sets up absorption coefficients for band 01: 10-250 cm-1 (low - h2o; high - h2o) ...
real(kind=kind_phys), dimension(ng05, maf05), public fracrefa
planck fraction mapping level : p = 473.42 mb, t = 259.83 k
real(kind=kind_phys), dimension(ng08, msf08), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(ng13, msa13), public absa
the array absa(NG13,585) = ka(NG13,9,5,13) contains absorption coefs at the NG13=4 g-intervals for a ...
integer, parameter ntbl
lookup table dimension
Definition: radlw_param.f:115
real(kind=kind_phys), dimension(ng02, msf02), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(ng15, maf15, mmn15), public ka_mn2
the array ka_mxx contains the absorption coefficient for a minor species at the NG15=2 chosen g-value...
real(kind=kind_phys), dimension(ng01), public fracrefa
planck fraction mapping level: p = 212.7250 mbar, t = 223.06 k
real(kind=kind_phys), dimension(ng07, mmc07), public kb_mco2
the array kb_mxxx contains absorption coefficient for a minor species at the NG07=12 chosen g-values ...
real(kind=kind_phys), dimension(ng16, mfr16), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
This module sets up absorption coefficients for band 08: 1080-1180 cm-1 (low - h2o; high - o3) ...
real(kind=kind_phys), dimension(ng04, maf04), public fracrefa
planck fraction mapping level: p=212.7250 mbar, t = 223.06 k
real(kind=kind_phys), dimension(ng05, msa05), public absa
the array absa(NG05,585) = ka(NG05,9,5,13) contains absorption coefs at the NG05=16 g-intervals for a...
real(kind=kind_phys), dimension(ng13, mfr13), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
This module sets up absorption coefficients for band 10: 1390-1480 cm-1 (low - h2o; high - h2o) ...
real(kind=kind_phys), dimension(ng09, msf09), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(ng07, maf07), public fracrefa
planck fraction mapping level : p = 706.27 mb, t = 278.94 k
real(kind=kind_phys), dimension(ng08), public fracrefa
planck fraction mapping level : p=473.4280 mb, t = 259.83 k
real(kind=kind_phys), dimension(ng03, msa03), public absa
the array absa(NG03,585) = ka(NG03,9,5,13) contains absorption coefs at the NG03=16 g-intervals for a...
real(kind=kind_phys), dimension(ng10, msf10), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
subroutine taugb04
Band 4: 630-700 cm-1 (low key - h2o,co2; high key - o3,co2)
Definition: radlw_main.f:4359
real(kind=kind_phys), dimension(ng06, mfr06), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
real(kind=kind_phys), dimension(ng08, mmc08), public kb_mn2o
minor gas mapping level:upper - n2o, p = 8.716e-2 mb, t = 226.03 k
This module contains LW band parameters set up.
Definition: radlw_param.f:64
Define type construct for radiation fluxes at toa.
Definition: radlw_param.f:75
real(kind=kind_phys), dimension(ng01, mfr01), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
real(kind=kind_phys), dimension(ng07, msf07), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
subroutine cldprop(cfrac, cliqp, reliq, cicep, reice, cdat1, cdat2, cdat3, cdat4, nlay, nlp1, ipseed, cldfmc, taucld)
This subroutine computes the cloud optical depth(s) for each cloudy layer and g-point interval...
Definition: radlw_main.f:1497
This module sets up absorption coefficients for band 13: 2080-2250 cm-1 (low - h2o, n2o; high - /)
real(kind=kind_phys), dimension(ng11, msf11), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
subroutine, public rlwinit(me)
This subroutine performs calculations necessary for the initialization of the longwave model...
Definition: radlw_main.f:1269
subroutine taugb07
Band 7: 980-1080 cm-1 (low key - h2o,o3; low minor - co2) (high key - o3; high minor - co2) ...
Definition: radlw_main.f:4956
real(kind=kind_phys), dimension(ng13, maf13, mmo13), public ka_mco2
the array ka_mxxx contains the absorption coefficient for a minor species at the NG13=4 chosen g-valu...
integer, parameter nrates
num of ref rates of binary species
Definition: radlw_param.f:121
real(kind=kind_phys), dimension(ng16, msa16), public absa
the array absa(NG16,585) = ka(NG16,9,5,13) contains absorption coefs at the NG16=2 g-intervals for a ...
This module sets up absorption coefficients for band 04: 630-700 cm-1 (low - h2o, co2; high - co2...
subroutine mcica_subcol(cldf, nlay, ipseed, lcloudy)
This suroutine computes sub-colum cloud profile flag array.
Definition: radlw_main.f:1804
real(kind=kind_phys), dimension(2, 5) absice1
for iflagice = 1, absice1 are the ice water absorption coefficients used for ebert and curry method ...
subroutine rtrnmr(semiss, delp, cldfrc, taucld, tautot, pklay, pklev, fracs, secdif, nlay, nlp1, totuflux, totdflux, htr, totuclfl, totdclfl, htrcl, htrb)
This subroutine computes the upward/downward radiative fluxes, and heating rates for both clear or cl...
Definition: radlw_main.f:2678
real(kind=kind_phys), dimension(ng10), public fracrefa
planck fraction mapping level : p = 212.7250, t = 223.06 k
subroutine taugb09
Band 9: 1180-1390 cm-1 (low key - h2o,ch4; low minor - n2o) (high key - ch4; high minor - n2o) ...
Definition: radlw_main.f:5344
real(kind=kind_phys), dimension(ng14, msb14), public absb
the array absb(NG14,235) = kb(NG14,5,13:59) contains absorption coefs at the NG14=2 chosen g-values f...
real(kind=kind_phys), dimension(ng12, msa12), public absa
the array absa(NG12,585) = ka(NG12,9,5,13) contains absorption coefs at the NG12=8 g-intervals for a ...
real(kind=kind_phys), dimension(ng08, mmc08), public ka_mn2o
minor gas mapping level:lower - n2o, p = 706.2720 mb, t= 278.94 k
subroutine taugb11
Band 11: 1480-1800 cm-1 (low - h2o; low minor - o2) (high key - h2o; high minor - o2) ...
Definition: radlw_main.f:5670
real(kind=kind_phys), dimension(ng07, msa07), public absa
the array absa(NG07,585) = ka(NG07,9,5,13) contains absorption coefs at the NG07=12 g-intervals for a...
subroutine taugb02
Band 2: 350-500 cm-1 (low key - h2o; high key - h2o)
Definition: radlw_main.f:3974
This module sets up absorption coefficients for band 07: 980-1080 cm-1 (low - h2o, o3; high - o3)
real(kind=kind_phys), dimension(ng03, msf03), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
subroutine taugb03
Band 3: 500-630 cm-1 (low key - h2o,co2; low minor - n2o); (high key - h2o,co2; high minor - n2o) ...
Definition: radlw_main.f:4052
subroutine taugb14
Band 14: 2250-2380 cm-1 (low - co2; high - co2)
Definition: radlw_main.f:6198
real(kind=kind_phys), dimension(ng16, msb16), public absb
the array absb(NG16,235) = kb(NG16,5,13:59) contains absorption coefs at the NG16=2 chosen g-values f...
subroutine taugb05
Band 5: 700-820 cm-1 (low key - h2o,co2; low minor - o3, ccl4) (high key - o3,co2) ...
Definition: radlw_main.f:4604
real(kind=kind_phys), dimension(ng10, mfr10), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
real(kind=kind_phys), dimension(ng16), public fracrefb
planck fraction mapping level : p=95.58350 mb, t = 215.70 k
real(kind=kind_phys), dimension(ng05, msb05), public absb
the array absb(NG05,1175) = kb(NG05,5,5,13:59) contains absorption coefs at the NG05=16 g-intervals f...
real(kind=kind_phys), dimension(ng11), public fracrefa
planck fraction mapping level : p=1053.63 mb, t= 294.2 k
This module sets up absorption coefficients for band 16: 2600-3000 cm-1 (low - h2o, ch4; high - /)
real(kind=kind_phys), dimension(ng02, mfr02), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
real(kind=kind_phys), dimension(ng15, maf15), public fracrefa
planck fraction mapping level : p = 1053. mb, t = 294.2 k
real(kind=kind_phys), dimension(ng06, msf06), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
subroutine setcoef(pavel, tavel, tz, stemp, h2ovmr, colamt, coldry, colbrd, nlay, nlp1, laytrop, pklay, pklev, jp, jt, jt1, rfrate, fac00, fac01, fac10, fac11, selffac, selffrac, indself, forfac, forfrac, indfor, minorfrac, scaleminor, scaleminorn2, indminor)
This subroutine computes various coefficients needed in radiative transfer calculations.
Definition: radlw_main.f:2004
subroutine taugb06
Band 6: 820-980 cm-1 (low key - h2o; low minor - co2) (high key - none; high minor - cfc11...
Definition: radlw_main.f:4869
This module contains cloud property coefficients.
Definition: radlw_datatb.f:928
integer, parameter maxgas
max num of absorbing gases
Definition: radlw_param.f:117
This module sets up absorption coefficients for band 03: 500-630 cm-1 (low - h2o, co2; high - h2o...
subroutine taugb01
band 1: 10-350 cm-1 (low key - h2o; low minor - n2); (high key - h2o; high minor - n2) ...
Definition: radlw_main.f:3867
real(kind=kind_phys), dimension(ng13, maf13), public fracrefa
planck fraction mapping level : p=473.4280 mb, t = 259.83 k
real(kind=kind_phys), dimension(ng12, maf12), public fracrefa
planck fraction mapping level : p = 174.1640 mbar, t= 215.78 k
This module contains plank flux data.
Definition: radlw_datatb.f:67
real(kind=kind_phys), dimension(ng03, mfr03), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
real(kind=kind_phys), dimension(ng11, mmo11), public kb_mo2
the array kb_mxx contains the absorption coefficient for a minor species at the NG11=8 chosen g-value...
integer, parameter nbands
num of total spectral bands
Definition: radlw_param.f:111
real(kind=kind_phys), dimension(ng03, maf03, mmn03), public ka_mn2o
the array ka_mxxx(NG03,9,19) contains the absorption coefficient for a minor species at the NG03=16 c...
integer, dimension(ngptlw) ngb
band indices for each g-point
Definition: radlw_param.f:142
real(kind=kind_phys), dimension(ng04, mfr04), public forref
the array forref contains the coefficient of the water vapor foreign-continuum (including the energy ...
real(kind=kind_phys), dimension(ng10, msb10), public absb
the array absb(NG10,235) = kb(NG10,5,13:59) contains absorption coefs at the NG10=6 chosen g-values f...