GFS Operational Physics Documentation  gsm/branches/DTC/phys-doc-all phys-doc-all R82971
radsw_main.f
Go to the documentation of this file.
1 
4 
5 ! ============================================================== !!!!!
6 ! sw-rrtm3 radiation package description !!!!!
7 ! ============================================================== !!!!!
8 ! !
9 ! this package includes ncep's modifications of the rrtm-sw radiation !
10 ! code from aer inc. !
11 ! !
12 ! the sw-rrtm3 package includes these parts: !
13 ! !
14 ! 'radsw_rrtm3_param.f' !
15 ! 'radsw_rrtm3_datatb.f' !
16 ! 'radsw_rrtm3_main.f' !
17 ! !
18 ! the 'radsw_rrtm3_param.f' contains: !
19 ! !
20 ! 'module_radsw_parameters' -- band parameters set up !
21 ! !
22 ! the 'radsw_rrtm3_datatb.f' contains: !
23 ! !
24 ! 'module_radsw_ref' -- reference temperature and pressure !
25 ! 'module_radsw_cldprtb' -- cloud property coefficients table !
26 ! 'module_radsw_sflux' -- spectral distribution of solar flux !
27 ! 'module_radsw_kgbnn' -- absorption coeffients for 14 !
28 ! bands, where nn = 16-29 !
29 ! !
30 ! the 'radsw_rrtm3_main.f' contains: !
31 ! !
32 ! 'module_radsw_main' -- main sw radiation transfer !
33 ! !
34 ! in the main module 'module_radsw_main' there are only two !
35 ! externally callable subroutines: !
36 ! !
37 ! 'swrad' -- main sw radiation routine !
38 ! inputs: !
39 ! (plyr,plvl,tlyr,tlvl,qlyr,olyr,gasvmr, !
40 ! clouds,icseed,aerosols,sfcalb, !
41 ! cosz,solcon,NDAY,idxday, !
42 ! npts, nlay, nlp1, lprnt, !
43 ! outputs: !
44 ! hswc,topflx,sfcflx, !
45 !! optional outputs: !
46 ! HSW0,HSWB,FLXPRF,FDNCMP) !
47 ! ) !
48 ! !
49 ! 'rswinit' -- initialization routine !
50 ! inputs: !
51 ! ( me ) !
52 ! outputs: !
53 ! (none) !
54 ! !
55 ! all the sw radiation subprograms become contained subprograms !
56 ! in module 'module_radsw_main' and many of them are not directly !
57 ! accessable from places outside the module. !
58 ! !
59 ! derived data type constructs used: !
60 ! !
61 ! 1. radiation flux at toa: (from module 'module_radsw_parameters') !
62 ! topfsw_type - derived data type for toa rad fluxes !
63 ! upfxc total sky upward flux at toa !
64 ! dnfxc total sky downward flux at toa !
65 ! upfx0 clear sky upward flux at toa !
66 ! !
67 ! 2. radiation flux at sfc: (from module 'module_radsw_parameters') !
68 ! sfcfsw_type - derived data type for sfc rad fluxes !
69 ! upfxc total sky upward flux at sfc !
70 ! dnfxc total sky downward flux at sfc !
71 ! upfx0 clear sky upward flux at sfc !
72 ! dnfx0 clear sky downward flux at sfc !
73 ! !
74 ! 3. radiation flux profiles(from module 'module_radsw_parameters') !
75 ! profsw_type - derived data type for rad vertical prof !
76 ! upfxc level upward flux for total sky !
77 ! dnfxc level downward flux for total sky !
78 ! upfx0 level upward flux for clear sky !
79 ! dnfx0 level downward flux for clear sky !
80 ! !
81 ! 4. surface component fluxes(from module 'module_radsw_parameters' !
82 ! cmpfsw_type - derived data type for component sfc flux !
83 ! uvbfc total sky downward uv-b flux at sfc !
84 ! uvbf0 clear sky downward uv-b flux at sfc !
85 ! nirbm surface downward nir direct beam flux !
86 ! nirdf surface downward nir diffused flux !
87 ! visbm surface downward uv+vis direct beam flx !
88 ! visdf surface downward uv+vis diffused flux !
89 ! !
90 ! external modules referenced: !
91 ! !
92 ! 'module physparam' !
93 ! 'module physcons' !
94 ! 'mersenne_twister' !
95 ! !
96 ! compilation sequence is: !
97 ! !
98 ! 'radsw_rrtm3_param.f' !
99 ! 'radsw_rrtm3_datatb.f' !
100 ! 'radsw_rrtm3_main.f' !
101 ! !
102 ! and all should be put in front of routines that use sw modules !
103 ! !
104 !==========================================================================!
105 ! !
106 ! the original program declarations: !
107 ! !
108 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
109 ! !
110 ! Copyright 2002-2007, Atmospheric & Environmental Research, Inc. (AER). !
111 ! This software may be used, copied, or redistributed as long as it is !
112 ! not sold and this copyright notice is reproduced on each copy made. !
113 ! This model is provided as is without any express or implied warranties. !
114 ! (http://www.rtweb.aer.com/) !
115 ! !
116 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
117 ! !
118 ! ************************************************************************ !
119 ! !
120 ! rrtmg_sw !
121 ! !
122 ! !
123 ! a rapid radiative transfer model !
124 ! for the solar spectral region !
125 ! atmospheric and environmental research, inc. !
126 ! 131 hartwell avenue !
127 ! lexington, ma 02421 !
128 ! !
129 ! eli j. mlawer !
130 ! jennifer s. delamere !
131 ! michael j. iacono !
132 ! shepard a. clough !
133 ! !
134 ! !
135 ! email: miacono@aer.com !
136 ! email: emlawer@aer.com !
137 ! email: jdelamer@aer.com !
138 ! !
139 ! the authors wish to acknowledge the contributions of the !
140 ! following people: steven j. taubman, patrick d. brown, !
141 ! ronald e. farren, luke chen, robert bergstrom. !
142 ! !
143 ! ************************************************************************ !
144 ! !
145 ! references: !
146 ! (rrtm_sw/rrtmg_sw): !
147 ! clough, s.a., m.w. shephard, e.j. mlawer, j.s. delamere, !
148 ! m.j. iacono, k. cady-pereira, s. boukabara, and p.d. brown: !
149 ! atmospheric radiative transfer modeling: a summary of the aer !
150 ! codes, j. quant. spectrosc. radiat. transfer, 91, 233-244, 2005. !
151 ! !
152 ! (mcica): !
153 ! pincus, r., h. w. barker, and j.-j. morcrette: a fast, flexible, !
154 ! approximation technique for computing radiative transfer in !
155 ! inhomogeneous cloud fields, j. geophys. res., 108(d13), 4376, !
156 ! doi:10.1029/2002jd003322, 2003. !
157 ! !
158 ! ************************************************************************ !
159 ! !
160 ! aer's revision history: !
161 ! this version of rrtmg_sw has been modified from rrtm_sw to use a !
162 ! reduced set of g-point intervals and a two-stream model for !
163 ! application to gcms. !
164 ! !
165 ! -- original version (derived from rrtm_sw) !
166 ! 2002: aer. inc. !
167 ! -- conversion to f90 formatting; addition of 2-stream radiative transfer!
168 ! feb 2003: j.-j. morcrette, ecmwf !
169 ! -- additional modifications for gcm application !
170 ! aug 2003: m. j. iacono, aer inc. !
171 ! -- total number of g-points reduced from 224 to 112. original !
172 ! set of 224 can be restored by exchanging code in module parrrsw.f90 !
173 ! and in file rrtmg_sw_init.f90. !
174 ! apr 2004: m. j. iacono, aer, inc. !
175 ! -- modifications to include output for direct and diffuse !
176 ! downward fluxes. there are output as "true" fluxes without !
177 ! any delta scaling applied. code can be commented to exclude !
178 ! this calculation in source file rrtmg_sw_spcvrt.f90. !
179 ! jan 2005: e. j. mlawer, m. j. iacono, aer, inc. !
180 ! -- revised to add mcica capability. !
181 ! nov 2005: m. j. iacono, aer, inc. !
182 ! -- reformatted for consistency with rrtmg_lw. !
183 ! feb 2007: m. j. iacono, aer, inc. !
184 ! -- modifications to formatting to use assumed-shape arrays. !
185 ! aug 2007: m. j. iacono, aer, inc. !
186 ! !
187 ! ************************************************************************ !
188 ! !
189 ! ncep modifications history log: !
190 ! !
191 ! sep 2003, yu-tai hou -- received aer's rrtm-sw gcm version !
192 ! code (v224) !
193 ! nov 2003, yu-tai hou -- corrected errors in direct/diffuse !
194 ! surface alabedo components. !
195 ! jan 2004, yu-tai hou -- modified code into standard modular!
196 ! f9x code for ncep models. the original three cloud !
197 ! control flags are simplified into two: iflagliq and !
198 ! iflagice. combined the org subr sw_224 and setcoef !
199 ! into radsw (the main program); put all kgb##together !
200 ! and reformat into a separated data module; combine !
201 ! reftra and vrtqdr as swflux; optimized taumol and all !
202 ! taubgs to form a contained subroutines. !
203 ! jun 2004, yu-tai hou -- modified code based on aer's faster!
204 ! version rrtmg_sw (v2.0) with 112 g-points. !
205 ! mar 2005, yu-tai hou -- modified to aer v2.3, correct cloud!
206 ! scaling error, total sky properties are delta scaled !
207 ! after combining clear and cloudy parts. the testing !
208 ! criterion of ssa is saved before scaling. added cloud !
209 ! layer rain and snow contributions. all cloud water !
210 ! partical contents are treated the same way as other !
211 ! atmos particles. !
212 ! apr 2005, yu-tai hou -- modified on module structures (this!
213 ! version of code was given back to aer in jun 2006) !
214 ! nov 2006, yu-tai hou -- modified code to include the !
215 ! generallized aerosol optical property scheme for gcms.!
216 ! apr 2007, yu-tai hou -- added spectral band heating as an !
217 ! optional output to support the 500km model's upper !
218 ! stratospheric radiation calculations. restructure !
219 ! optional outputs for easy access by different models. !
220 ! oct 2008, yu-tai hou -- modified to include new features !
221 ! from aer's newer release v3.5-v3.61, including mcica !
222 ! sub-grid cloud option and true direct/diffuse fluxes !
223 ! without delta scaling. added rain/snow opt properties !
224 ! support to cloudy sky calculations. simplified and !
225 ! unified sw and lw sub-column cloud subroutines into !
226 ! one module by using optional parameters. !
227 ! mar 2009, yu-tai hou -- replaced the original random number!
228 ! generator coming with the original code with ncep w3 !
229 ! library to simplify the program and moved sub-column !
230 ! cloud subroutines inside the main module. added !
231 ! option of user provided permutation seeds that could !
232 ! be randomly generated from forecast time stamp. !
233 ! mar 2009, yu-tai hou -- replaced random number generator !
234 ! programs coming from the original code with the ncep !
235 ! w3 library to simplify the program and moved sub-col !
236 ! cloud subroutines inside the main module. added !
237 ! option of user provided permutation seeds that could !
238 ! be randomly generated from forecast time stamp. !
239 ! nov 2009, yu-tai hou -- updated to aer v3.7-v3.8 version. !
240 ! notice the input cloud ice/liquid are assumed as !
241 ! in-cloud quantities, not grid average quantities. !
242 ! aug 2010, yu-tai hou -- uptimized code to improve efficiency
243 ! splited subroutine spcvrt into two subs, spcvrc and !
244 ! spcvrm, to handling non-mcica and mcica type of calls.!
245 ! apr 2012, b. ferrier and y. hou -- added conversion factor to fu's!
246 ! cloud-snow optical property scheme. !
247 ! jul 2012, s. moorthi and Y. hou -- eliminated the pointer array !
248 ! in subr 'spcvrt' for multi-threading issue running !
249 ! under intel's fortran compiler. !
250 ! nov 2012, yu-tai hou -- modified control parameters thru !
251 ! module 'physparam'. !
252 ! jun 2013, yu-tai hou -- moving band 9 surface treatment !
253 ! back as in the rrtm2 version, spliting surface flux !
254 ! into two spectral regions (vis & nir), instead of !
255 ! designated it in nir region only. !
256 ! may 2016 yu-tai hou --reverting swflux name back to vrtqdr!
257 ! !
258 !!!!! ============================================================== !!!!!
259 !!!!! end descriptions !!!!!
260 !!!!! ============================================================== !!!!!
261 
262 
405 !========================================!
406  module module_radsw_main !
407 !........................................!
408 !
409  use physparam, only : iswrate, iswrgas, iswcliq, iswcice, &
410  & isubcsw, icldflg, iovrsw, ivflip, &
411  & iswmode, kind_phys
412  use physcons, only : con_g, con_cp, con_avgd, con_amd, &
413  & con_amw, con_amo3
414 
416  use mersenne_twister, only : random_setseed, random_number, &
417  & random_stat
418  use module_radsw_ref, only : preflog, tref
420 !
421  implicit none
422 !
423  private
424 !
425 ! --- version tag and last revision date
426  character(40), parameter :: &
427  & VTAGSW='NCEP SW v5.1 Nov 2012 -RRTMG-SW v3.8 '
428 ! & VTAGSW='NCEP SW v5.0 Aug 2012 -RRTMG-SW v3.8 '
429 ! & VTAGSW='RRTMG-SW v3.8 Nov 2009'
430 ! & VTAGSW='RRTMG-SW v3.7 Nov 2009'
431 ! & VTAGSW='RRTMG-SW v3.61 Oct 2008'
432 ! & VTAGSW='RRTMG-SW v3.5 Oct 2008'
433 ! & VTAGSW='RRTM-SW 112v2.3 Apr 2007'
434 ! & VTAGSW='RRTM-SW 112v2.3 Mar 2005'
435 ! & VTAGSW='RRTM-SW 112v2.0 Jul 2004'
436 
438 
439  real (kind=kind_phys), parameter :: eps = 1.0e-6
440  real (kind=kind_phys), parameter :: oneminus= 1.0 - eps
442  real (kind=kind_phys), parameter :: bpade = 1.0/0.278
443  real (kind=kind_phys), parameter :: stpfac = 296.0/1013.0
444  real (kind=kind_phys), parameter :: ftiny = 1.0e-12
446  real (kind=kind_phys), parameter :: s0 = 1368.22
447 
448  real (kind=kind_phys), parameter :: f_zero = 0.0
449  real (kind=kind_phys), parameter :: f_one = 1.0
450 
452  real (kind=kind_phys), parameter :: amdw = con_amd/con_amw
453  real (kind=kind_phys), parameter :: amdo3 = con_amd/con_amo3
454 
456  integer, dimension(nblow:nbhgh) :: nspa, nspb
458  integer, dimension(nblow:nbhgh) :: idxsfc
460  integer, dimension(nblow:nbhgh) :: idxebc
461 
462  data nspa(:) / 9, 9, 9, 9, 1, 9, 9, 1, 9, 1, 0, 1, 9, 1 /
463  data nspb(:) / 1, 5, 1, 1, 1, 5, 1, 0, 1, 0, 0, 1, 5, 1 /
464 
465 ! data idxsfc(:) / 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1 / ! band index for sfc flux
466  data idxsfc(:) / 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 1 / ! band index for sfc flux
467  data idxebc(:) / 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 1, 5 / ! band index for cld prop
468 
469 ! --- band wavenumber intervals
470 ! real (kind=kind_phys), dimension(nblow:nbhgh):: wavenum1,wavenum2
471 ! data wavenum1(:) / &
472 ! & 2600.0, 3250.0, 4000.0, 4650.0, 5150.0, 6150.0, 7700.0, &
473 ! & 8050.0,12850.0,16000.0,22650.0,29000.0,38000.0, 820.0 /
474 ! data wavenum2(:) / &
475 ! 3250.0, 4000.0, 4650.0, 5150.0, 6150.0, 7700.0, 8050.0, &
476 ! & 12850.0,16000.0,22650.0,29000.0,38000.0,50000.0, 2600.0 /
477 ! real (kind=kind_phys), dimension(nblow:nbhgh) :: delwave
478 ! data delwave(:) / &
479 ! & 650.0, 750.0, 650.0, 500.0, 1000.0, 1550.0, 350.0, &
480 ! & 4800.0, 3150.0, 6650.0, 6350.0, 9000.0,12000.0, 1780.0 /
481 
483  integer, parameter :: nuvb = 27
484 
486  logical :: lhswb = .false.
487  logical :: lhsw0 = .false.
488  logical :: lflxprf= .false.
489  logical :: lfdncmp= .false.
490 
491 
493  real (kind=kind_phys) :: exp_tbl(0:ntbmx)
494 
495 
498  real (kind=kind_phys) :: heatfac
499 
500 
502  integer, parameter :: ipsdsw0 = 1
503 
504 ! --- public accessable subprograms
505 
506  public swrad, rswinit
507 
508 
509 ! =================
510  contains
511 ! =================
512 
583 !-----------------------------------
584  subroutine swrad &
585  & ( plyr,plvl,tlyr,tlvl,qlyr,olyr,gasvmr, & ! --- inputs
586  & clouds,icseed,aerosols,sfcalb, &
587  & cosz,solcon,nday,idxday, &
588  & npts, nlay, nlp1, lprnt, &
589  & hswc,topflx,sfcflx, & ! --- outputs
590  & hsw0,hswb,flxprf,fdncmp & ! --- optional
591  & )
593 ! ==================== defination of variables ==================== !
594 ! !
595 ! input variables: !
596 ! plyr (npts,nlay) : model layer mean pressure in mb !
597 ! plvl (npts,nlp1) : model level pressure in mb !
598 ! tlyr (npts,nlay) : model layer mean temperature in k !
599 ! tlvl (npts,nlp1) : model level temperature in k (not in use) !
600 ! qlyr (npts,nlay) : layer specific humidity in gm/gm *see inside !
601 ! olyr (npts,nlay) : layer ozone concentration in gm/gm !
602 ! gasvmr(npts,nlay,:): atmospheric constent gases: !
603 ! (check module_radiation_gases for definition) !
604 ! gasvmr(:,:,1) - co2 volume mixing ratio !
605 ! gasvmr(:,:,2) - n2o volume mixing ratio !
606 ! gasvmr(:,:,3) - ch4 volume mixing ratio !
607 ! gasvmr(:,:,4) - o2 volume mixing ratio !
608 ! gasvmr(:,:,5) - co volume mixing ratio (not used) !
609 ! gasvmr(:,:,6) - cfc11 volume mixing ratio (not used) !
610 ! gasvmr(:,:,7) - cfc12 volume mixing ratio (not used) !
611 ! gasvmr(:,:,8) - cfc22 volume mixing ratio (not used) !
612 ! gasvmr(:,:,9) - ccl4 volume mixing ratio (not used) !
613 ! clouds(npts,nlay,:): cloud profile !
614 ! (check module_radiation_clouds for definition) !
615 ! --- for iswcliq > 0 --- !
616 ! clouds(:,:,1) - layer total cloud fraction !
617 ! clouds(:,:,2) - layer in-cloud liq water path (g/m**2) !
618 ! clouds(:,:,3) - mean eff radius for liq cloud (micron) !
619 ! clouds(:,:,4) - layer in-cloud ice water path (g/m**2) !
620 ! clouds(:,:,5) - mean eff radius for ice cloud (micron) !
621 ! clouds(:,:,6) - layer rain drop water path (g/m**2) !
622 ! clouds(:,:,7) - mean eff radius for rain drop (micron) !
623 ! clouds(:,:,8) - layer snow flake water path (g/m**2) !
624 ! clouds(:,:,9) - mean eff radius for snow flake (micron) !
625 ! --- for iswcliq = 0 --- !
626 ! clouds(:,:,1) - layer total cloud fraction !
627 ! clouds(:,:,2) - layer cloud optical depth !
628 ! clouds(:,:,3) - layer cloud single scattering albedo !
629 ! clouds(:,:,4) - layer cloud asymmetry factor !
630 ! icseed(npts) : auxiliary special cloud related array !
631 ! when module variable isubcsw=2, it provides !
632 ! permutation seed for each column profile that !
633 ! are used for generating random numbers. !
634 ! when isubcsw /=2, it will not be used. !
635 ! aerosols(npts,nlay,nbdsw,:) : aerosol optical properties !
636 ! (check module_radiation_aerosols for definition) !
637 ! (:,:,:,1) - optical depth !
638 ! (:,:,:,2) - single scattering albedo !
639 ! (:,:,:,3) - asymmetry parameter !
640 ! sfcalb(npts, : ) : surface albedo in fraction !
641 ! (check module_radiation_surface for definition) !
642 ! ( :, 1 ) - near ir direct beam albedo !
643 ! ( :, 2 ) - near ir diffused albedo !
644 ! ( :, 3 ) - uv+vis direct beam albedo !
645 ! ( :, 4 ) - uv+vis diffused albedo !
646 ! cosz (npts) : cosine of solar zenith angle !
647 ! solcon : solar constant (w/m**2) !
648 ! NDAY : num of daytime points !
649 ! idxday(npts) : index array for daytime points !
650 ! npts : number of horizontal points !
651 ! nlay,nlp1 : vertical layer/lavel numbers !
652 ! lprnt : logical check print flag !
653 ! !
654 ! output variables: !
655 ! hswc (npts,nlay): total sky heating rates (k/sec or k/day) !
656 ! topflx(npts) : radiation fluxes at toa (w/m**2), components: !
657 ! (check module_radsw_parameters for definition) !
658 ! upfxc - total sky upward flux at toa !
659 ! dnflx - total sky downward flux at toa !
660 ! upfx0 - clear sky upward flux at toa !
661 ! sfcflx(npts) : radiation fluxes at sfc (w/m**2), components: !
662 ! (check module_radsw_parameters for definition) !
663 ! upfxc - total sky upward flux at sfc !
664 ! dnfxc - total sky downward flux at sfc !
665 ! upfx0 - clear sky upward flux at sfc !
666 ! dnfx0 - clear sky downward flux at sfc !
667 ! !
668 !!optional outputs variables: !
669 ! hswb(npts,nlay,nbdsw): spectral band total sky heating rates !
670 ! hsw0 (npts,nlay): clear sky heating rates (k/sec or k/day) !
671 ! flxprf(npts,nlp1): level radiation fluxes (w/m**2), components: !
672 ! (check module_radsw_parameters for definition) !
673 ! dnfxc - total sky downward flux at interface !
674 ! upfxc - total sky upward flux at interface !
675 ! dnfx0 - clear sky downward flux at interface !
676 ! upfx0 - clear sky upward flux at interface !
677 ! fdncmp(npts) : component surface downward fluxes (w/m**2): !
678 ! (check module_radsw_parameters for definition) !
679 ! uvbfc - total sky downward uv-b flux at sfc !
680 ! uvbf0 - clear sky downward uv-b flux at sfc !
681 ! nirbm - downward surface nir direct beam flux !
682 ! nirdf - downward surface nir diffused flux !
683 ! visbm - downward surface uv+vis direct beam flux !
684 ! visdf - downward surface uv+vis diffused flux !
685 ! !
686 ! external module variables: (in physparam) !
687 ! iswrgas - control flag for rare gases (ch4,n2o,o2, etc.) !
688 ! =0: do not include rare gases !
689 ! >0: include all rare gases !
690 ! iswcliq - control flag for liq-cloud optical properties !
691 ! =0: input cloud optical depth, fixed ssa, asy !
692 ! =1: use hu and stamnes(1993) method for liq cld !
693 ! =2: not used !
694 ! iswcice - control flag for ice-cloud optical properties !
695 ! *** if iswcliq==0, iswcice is ignored !
696 ! =1: use ebert and curry (1992) scheme for ice clouds !
697 ! =2: use streamer v3.0 (2001) method for ice clouds !
698 ! =3: use fu's method (1996) for ice clouds !
699 ! iswmode - control flag for 2-stream transfer scheme !
700 ! =1; delta-eddington (joseph et al., 1976) !
701 ! =2: pifm (zdunkowski et al., 1980) !
702 ! =3: discrete ordinates (liou, 1973) !
703 ! isubcsw - sub-column cloud approximation control flag !
704 ! =0: no sub-col cld treatment, use grid-mean cld quantities !
705 ! =1: mcica sub-col, prescribed seeds to get random numbers !
706 ! =2: mcica sub-col, providing array icseed for random numbers!
707 ! iovrsw - cloud overlapping control flag !
708 ! =0: random overlapping clouds !
709 ! =1: maximum/random overlapping clouds !
710 ! =2: maximum overlap cloud !
711 ! ivflip - control flg for direction of vertical index !
712 ! =0: index from toa to surface !
713 ! =1: index from surface to toa !
714 ! !
715 ! module parameters, control variables: !
716 ! nblow,nbhgh - lower and upper limits of spectral bands !
717 ! maxgas - maximum number of absorbing gaseous !
718 ! ngptsw - total number of g-point subintervals !
719 ! ng## - number of g-points in band (##=16-29) !
720 ! ngb(ngptsw) - band indices for each g-point !
721 ! bpade - pade approximation constant (1/0.278) !
722 ! nspa,nspb(nblow:nbhgh) !
723 ! - number of lower/upper ref atm's per band !
724 ! ipsdsw0 - permutation seed for mcica sub-col clds !
725 ! !
726 ! major local variables: !
727 ! pavel (nlay) - layer pressures (mb) !
728 ! delp (nlay) - layer pressure thickness (mb) !
729 ! tavel (nlay) - layer temperatures (k) !
730 ! coldry (nlay) - dry air column amount !
731 ! (1.e-20*molecules/cm**2) !
732 ! cldfrc (nlay) - layer cloud fraction (norm by tot cld) !
733 ! cldfmc (nlay,ngptsw) - layer cloud fraction for g-point !
734 ! taucw (nlay,nbdsw) - cloud optical depth !
735 ! ssacw (nlay,nbdsw) - cloud single scattering albedo (weighted) !
736 ! asycw (nlay,nbdsw) - cloud asymmetry factor (weighted) !
737 ! tauaer (nlay,nbdsw) - aerosol optical depths !
738 ! ssaaer (nlay,nbdsw) - aerosol single scattering albedo !
739 ! asyaer (nlay,nbdsw) - aerosol asymmetry factor !
740 ! colamt (nlay,maxgas) - column amounts of absorbing gases !
741 ! 1 to maxgas are for h2o, co2, o3, n2o, !
742 ! ch4, o2, co, respectively (mol/cm**2) !
743 ! facij (nlay) - indicator of interpolation factors !
744 ! =0/1: indicate lower/higher temp & height !
745 ! selffac(nlay) - scale factor for self-continuum, equals !
746 ! (w.v. density)/(atm density at 296K,1013 mb) !
747 ! selffrac(nlay) - factor for temp interpolation of ref !
748 ! self-continuum data !
749 ! indself(nlay) - index of the lower two appropriate ref !
750 ! temp for the self-continuum interpolation !
751 ! forfac (nlay) - scale factor for w.v. foreign-continuum !
752 ! forfrac(nlay) - factor for temp interpolation of ref !
753 ! w.v. foreign-continuum data !
754 ! indfor (nlay) - index of the lower two appropriate ref !
755 ! temp for the foreign-continuum interp !
756 ! laytrop - layer at which switch is made from one !
757 ! combination of key species to another !
758 ! jp(nlay),jt(nlay),jt1(nlay) !
759 ! - lookup table indexes !
760 ! flxucb(nlp1,nbdsw) - spectral bnd total-sky upward flx (w/m2) !
761 ! flxdcb(nlp1,nbdsw) - spectral bnd total-sky downward flx (w/m2)!
762 ! flxu0b(nlp1,nbdsw) - spectral bnd clear-sky upward flx (w/m2) !
763 ! flxd0b(nlp1,nbdsw) - spectral b d clear-sky downward flx (w/m2)!
764 ! !
765 ! !
766 ! ===================== end of definitions ==================== !
767 
768 ! --- inputs:
769  integer, intent(in) :: npts, nlay, nlp1, NDAY
770 
771  integer, dimension(:), intent(in) :: idxday, icseed
772 
773  logical, intent(in) :: lprnt
774 
775  real (kind=kind_phys), dimension(npts,nlp1), intent(in) :: &
776  & plvl, tlvl
777  real (kind=kind_phys), dimension(npts,nlay), intent(in) :: &
778  & plyr, tlyr, qlyr, olyr
779  real (kind=kind_phys), dimension(npts,4), intent(in) :: sfcalb
780 
781  real (kind=kind_phys), dimension(npts,nlay,9),intent(in):: gasvmr
782  real (kind=kind_phys), dimension(npts,nlay,9),intent(in):: clouds
783  real (kind=kind_phys), dimension(npts,nlay,nbdsw,3),intent(in):: &
784  & aerosols
785 
786  real (kind=kind_phys), intent(in) :: cosz(npts), solcon
787 
788 ! --- outputs:
789  real (kind=kind_phys), dimension(npts,nlay), intent(out) :: hswc
790 
791  type(topfsw_type), dimension(npts), intent(out) :: topflx
792  type(sfcfsw_type), dimension(npts), intent(out) :: sfcflx
793 
794 !! --- optional outputs:
795  real (kind=kind_phys), dimension(npts,nlay,nbdsw), optional, &
796  & intent(out) :: hswb
797 
798  real (kind=kind_phys), dimension(npts,nlay), optional, &
799  & intent(out) :: hsw0
800  type (profsw_type), dimension(npts,nlp1), optional, &
801  & intent(out) :: flxprf
802  type (cmpfsw_type), dimension(npts), optional, &
803  & intent(out) :: fdncmp
804 
805 ! --- locals:
806  real (kind=kind_phys), dimension(nlay,ngptsw) :: cldfmc, &
807  & taug, taur
808  real (kind=kind_phys), dimension(nlp1,nbdsw):: fxupc, fxdnc, &
809  & fxup0, fxdn0
810 
811  real (kind=kind_phys), dimension(nlay,nbdsw) :: &
812  & tauae, ssaae, asyae, taucw, ssacw, asycw
813 
814  real (kind=kind_phys), dimension(ngptsw) :: sfluxzen
815 
816  real (kind=kind_phys), dimension(nlay) :: cldfrc, delp, &
817  & pavel, tavel, coldry, colmol, h2ovmr, o3vmr, temcol, &
818  & cliqp, reliq, cicep, reice, cdat1, cdat2, cdat3, cdat4, &
819  & cfrac, fac00, fac01, fac10, fac11, forfac, forfrac, &
820  & selffac, selffrac, rfdelp
821 
822  real (kind=kind_phys), dimension(nlp1) :: fnet, flxdc, flxuc, &
823  & flxd0, flxu0
824 
825  real (kind=kind_phys), dimension(2) :: albbm, albdf, sfbmc, &
826  & sfbm0, sfdfc, sfdf0
827 
828  real (kind=kind_phys) :: cosz1, sntz1, tem0, tem1, tem2, s0fac, &
829  & ssolar, zcf0, zcf1, ftoau0, ftoauc, ftoadc, &
830  & fsfcu0, fsfcuc, fsfcd0, fsfcdc, suvbfc, suvbf0
831 
832 ! --- column amount of absorbing gases:
833 ! (:,m) m = 1-h2o, 2-co2, 3-o3, 4-n2o, 5-ch4, 6-o2, 7-co
834  real (kind=kind_phys) :: colamt(nlay,maxgas)
835 
836  integer, dimension(npts) :: ipseed
837  integer, dimension(nlay) :: indfor, indself, jp, jt, jt1
838 
839  integer :: i, ib, ipt, j1, k, kk, laytrop, mb
840 !
841 !===> ... begin here
842 !
843 
844  lhswb = present ( hswb )
845  lhsw0 = present ( hsw0 )
846  lflxprf= present ( flxprf )
847  lfdncmp= present ( fdncmp )
848 
850 ! *** s0, the solar constant at toa in w/m**2, is hard-coded with
851 ! each spectra band, the total flux is about 1368.22 w/m**2.
852 
853  s0fac = solcon / s0
854 
856 
857  hswc(:,:) = f_zero
858  topflx = topfsw_type( f_zero, f_zero, f_zero )
859  sfcflx = sfcfsw_type( f_zero, f_zero, f_zero, f_zero )
860 
861 !! --- ... initial optional outputs
862  if ( lflxprf ) then
863  flxprf = profsw_type( f_zero, f_zero, f_zero, f_zero )
864  endif
865 
866  if ( lfdncmp ) then
867  fdncmp = cmpfsw_type(f_zero,f_zero,f_zero,f_zero,f_zero,f_zero)
868  endif
869 
870  if ( lhsw0 ) then
871  hsw0(:,:) = f_zero
872  endif
873 
874  if ( lhswb ) then
875  hswb(:,:,:) = f_zero
876  endif
877 
880 
881  if ( isubcsw == 1 ) then ! advance prescribed permutation seed
882  do i = 1, npts
883  ipseed(i) = ipsdsw0 + i
884  enddo
885  elseif ( isubcsw == 2 ) then ! use input array of permutaion seeds
886  do i = 1, npts
887  ipseed(i) = icseed(i)
888  enddo
889  endif
890 
891  if ( lprnt ) then
892  write(0,*)' In radsw, isubcsw, ipsdsw0,ipseed =', &
893  & isubcsw, ipsdsw0, ipseed
894  endif
895 
896 ! --- ... loop over each daytime grid point
897 
898  lab_do_ipt : do ipt = 1, nday
899 
900  j1 = idxday(ipt)
901 
902  cosz1 = cosz(j1)
903  sntz1 = f_one / cosz(j1)
904  ssolar = s0fac * cosz(j1)
905 
907  albbm(1) = sfcalb(j1,1)
908  albdf(1) = sfcalb(j1,2)
909  albbm(2) = sfcalb(j1,3)
910  albdf(2) = sfcalb(j1,4)
911 
913 ! the vertical index of internal array is from surface to top
914 
915  if (ivflip == 0) then ! input from toa to sfc
916 
917  tem1 = 100.0 * con_g
918  tem2 = 1.0e-20 * 1.0e3 * con_avgd
919 
920  do k = 1, nlay
921  kk = nlp1 - k
922  pavel(k) = plyr(j1,kk)
923  tavel(k) = tlyr(j1,kk)
924  delp(k) = plvl(j1,kk+1) - plvl(j1,kk)
930 
931 !test use
932 ! h2ovmr(k)= max(f_zero,qlyr(j1,kk)*amdw) ! input mass mixing ratio
933 ! h2ovmr(k)= max(f_zero,qlyr(j1,kk)) ! input vol mixing ratio
934 ! o3vmr (k)= max(f_zero,olyr(j1,kk)) ! input vol mixing ratio
935 !ncep model use
936  h2ovmr(k)= max(f_zero,qlyr(j1,kk)*amdw/(f_one-qlyr(j1,kk))) ! input specific humidity
937  o3vmr(k)= max(f_zero,olyr(j1,kk)*amdo3) ! input mass mixing ratio
938 
939  tem0 = (f_one - h2ovmr(k))*con_amd + h2ovmr(k)*con_amw
940  coldry(k) = tem2 * delp(k) / (tem1*tem0*(f_one + h2ovmr(k)))
941  temcol(k) = 1.0e-12 * coldry(k)
942 
943  colamt(k,1) = max(f_zero, coldry(k)*h2ovmr(k)) ! h2o
944  colamt(k,2) = max(temcol(k), coldry(k)*gasvmr(j1,kk,1)) ! co2
945  colamt(k,3) = max(f_zero, coldry(k)*o3vmr(k)) ! o3
946  colmol(k) = coldry(k) + colamt(k,1)
947  enddo
948 
949 ! --- ... set up gas column amount, convert from volume mixing ratio
950 ! to molec/cm2 based on coldry (scaled to 1.0e-20)
951 
952  if (iswrgas > 0) then
953  do k = 1, nlay
954  kk = nlp1 - k
955  colamt(k,4) = max(temcol(k), coldry(k)*gasvmr(j1,kk,2)) ! n2o
956  colamt(k,5) = max(temcol(k), coldry(k)*gasvmr(j1,kk,3)) ! ch4
957  colamt(k,6) = max(temcol(k), coldry(k)*gasvmr(j1,kk,4)) ! o2
958 ! colamt(k,7) = max(temcol(k), coldry(k)*gasvmr(j1,kk,5)) ! co - notused
959  enddo
960  else
961  do k = 1, nlay
962  colamt(k,4) = temcol(k) ! n2o
963  colamt(k,5) = temcol(k) ! ch4
964  colamt(k,6) = temcol(k) ! o2
965 ! colamt(k,7) = temcol(k) ! co - notused
966  enddo
967  endif
968 
970 
971  do k = 1, nlay
972  kk = nlp1 - k
973  do ib = 1, nbdsw
974  tauae(k,ib) = aerosols(j1,kk,ib,1)
975  ssaae(k,ib) = aerosols(j1,kk,ib,2)
976  asyae(k,ib) = aerosols(j1,kk,ib,3)
977  enddo
978  enddo
979 
981  if (iswcliq > 0) then ! use prognostic cloud method
982  do k = 1, nlay
983  kk = nlp1 - k
984  cfrac(k) = clouds(j1,kk,1) ! cloud fraction
985  cliqp(k) = clouds(j1,kk,2) ! cloud liq path
986  reliq(k) = clouds(j1,kk,3) ! liq partical effctive radius
987  cicep(k) = clouds(j1,kk,4) ! cloud ice path
988  reice(k) = clouds(j1,kk,5) ! ice partical effctive radius
989  cdat1(k) = clouds(j1,kk,6) ! cloud rain drop path
990  cdat2(k) = clouds(j1,kk,7) ! rain partical effctive radius
991  cdat3(k) = clouds(j1,kk,8) ! cloud snow path
992  cdat4(k) = clouds(j1,kk,9) ! snow partical effctive radius
993  enddo
994  else ! use diagnostic cloud method
995  do k = 1, nlay
996  kk = nlp1 - k
997  cfrac(k) = clouds(j1,kk,1) ! cloud fraction
998  cdat1(k) = clouds(j1,kk,2) ! cloud optical depth
999  cdat2(k) = clouds(j1,kk,3) ! cloud single scattering albedo
1000  cdat3(k) = clouds(j1,kk,4) ! cloud asymmetry factor
1001  enddo
1002  endif ! end if_iswcliq
1003 
1004  else ! input from sfc to toa
1005 
1006  tem1 = 100.0 * con_g
1007  tem2 = 1.0e-20 * 1.0e3 * con_avgd
1008 
1009  do k = 1, nlay
1010  pavel(k) = plyr(j1,k)
1011  tavel(k) = tlyr(j1,k)
1012  delp(k) = plvl(j1,k) - plvl(j1,k+1)
1013 
1014 ! --- ... set absorber amount
1015 !test use
1016 ! h2ovmr(k)= max(f_zero,qlyr(j1,k)*amdw) ! input mass mixing ratio
1017 ! h2ovmr(k)= max(f_zero,qlyr(j1,k)) ! input vol mixing ratio
1018 ! o3vmr (k)= max(f_zero,olyr(j1,k)) ! input vol mixing ratio
1019 !ncep model use
1020  h2ovmr(k)= max(f_zero,qlyr(j1,k)*amdw/(f_one-qlyr(j1,k))) ! input specific humidity
1021  o3vmr(k)= max(f_zero,olyr(j1,k)*amdo3) ! input mass mixing ratio
1022 
1023  tem0 = (f_one - h2ovmr(k))*con_amd + h2ovmr(k)*con_amw
1024  coldry(k) = tem2 * delp(k) / (tem1*tem0*(f_one + h2ovmr(k)))
1025  temcol(k) = 1.0e-12 * coldry(k)
1026 
1027  colamt(k,1) = max(f_zero, coldry(k)*h2ovmr(k)) ! h2o
1028  colamt(k,2) = max(temcol(k), coldry(k)*gasvmr(j1,k,1)) ! co2
1029  colamt(k,3) = max(f_zero, coldry(k)*o3vmr(k)) ! o3
1030  colmol(k) = coldry(k) + colamt(k,1)
1031  enddo
1032 
1033 
1034  if (lprnt) then
1035  if (ipt == 1) then
1036  write(0,*)' pavel=',pavel
1037  write(0,*)' tavel=',tavel
1038  write(0,*)' delp=',delp
1039  write(0,*)' h2ovmr=',h2ovmr*1000
1040  write(0,*)' o3vmr=',o3vmr*1000000
1041  endif
1042  endif
1043 
1044 ! --- ... set up gas column amount, convert from volume mixing ratio
1045 ! to molec/cm2 based on coldry (scaled to 1.0e-20)
1046 
1047  if (iswrgas > 0) then
1048  do k = 1, nlay
1049  colamt(k,4) = max(temcol(k), coldry(k)*gasvmr(j1,k,2)) ! n2o
1050  colamt(k,5) = max(temcol(k), coldry(k)*gasvmr(j1,k,3)) ! ch4
1051  colamt(k,6) = max(temcol(k), coldry(k)*gasvmr(j1,k,4)) ! o2
1052 ! colamt(k,7) = max(temcol(k), coldry(k)*gasvmr(j1,k,5)) ! co - notused
1053  enddo
1054  else
1055  do k = 1, nlay
1056  colamt(k,4) = temcol(k) ! n2o
1057  colamt(k,5) = temcol(k) ! ch4
1058  colamt(k,6) = temcol(k) ! o2
1059 ! colamt(k,7) = temcol(k) ! co - notused
1060  enddo
1061  endif
1062 
1063 ! --- ... set aerosol optical properties
1064 
1065  do ib = 1, nbdsw
1066  do k = 1, nlay
1067  tauae(k,ib) = aerosols(j1,k,ib,1)
1068  ssaae(k,ib) = aerosols(j1,k,ib,2)
1069  asyae(k,ib) = aerosols(j1,k,ib,3)
1070  enddo
1071  enddo
1072 
1073  if (iswcliq > 0) then ! use prognostic cloud method
1074  do k = 1, nlay
1075  cfrac(k) = clouds(j1,k,1) ! cloud fraction
1076  cliqp(k) = clouds(j1,k,2) ! cloud liq path
1077  reliq(k) = clouds(j1,k,3) ! liq partical effctive radius
1078  cicep(k) = clouds(j1,k,4) ! cloud ice path
1079  reice(k) = clouds(j1,k,5) ! ice partical effctive radius
1080  cdat1(k) = clouds(j1,k,6) ! cloud rain drop path
1081  cdat2(k) = clouds(j1,k,7) ! rain partical effctive radius
1082  cdat3(k) = clouds(j1,k,8) ! cloud snow path
1083  cdat4(k) = clouds(j1,k,9) ! snow partical effctive radius
1084  enddo
1085  else ! use diagnostic cloud method
1086  do k = 1, nlay
1087  cfrac(k) = clouds(j1,k,1) ! cloud fraction
1088  cdat1(k) = clouds(j1,k,2) ! cloud optical depth
1089  cdat2(k) = clouds(j1,k,3) ! cloud single scattering albedo
1090  cdat3(k) = clouds(j1,k,4) ! cloud asymmetry factor
1091  enddo
1092  endif ! end if_iswcliq
1093 
1094  endif ! if_ivflip
1095 
1100 
1101  zcf0 = f_one
1102  zcf1 = f_one
1103  if (iovrsw == 0) then ! random overlapping
1104  do k = 1, nlay
1105  zcf0 = zcf0 * (f_one - cfrac(k))
1106  enddo
1107  else if (iovrsw == 1) then ! max/ran overlapping
1108  do k = 1, nlay
1109  if (cfrac(k) > ftiny) then ! cloudy layer
1110  zcf1 = min( zcf1, f_one-cfrac(k) )
1111  elseif (zcf1 < f_one) then ! clear layer
1112  zcf0 = zcf0 * zcf1
1113  zcf1 = f_one
1114  endif
1115  enddo
1116  zcf0 = zcf0 * zcf1
1117  else if (iovrsw == 2) then ! maximum overlapping
1118  do k = 1, nlay
1119  zcf0 = min( zcf0, f_one-cfrac(k) )
1120  enddo
1121  endif
1122 
1123  if (zcf0 <= ftiny) zcf0 = f_zero
1124  if (zcf0 > oneminus) zcf0 = f_one
1125  zcf1 = f_one - zcf0
1126 
1129 
1130  if (zcf1 > f_zero) then ! cloudy sky column
1131 
1132  call cldprop &
1133 ! --- inputs:
1134  & ( cfrac,cliqp,reliq,cicep,reice,cdat1,cdat2,cdat3,cdat4, &
1135  & zcf1, nlay, ipseed(j1), &
1136 ! --- outputs:
1137  & taucw, ssacw, asycw, cldfrc, cldfmc &
1138  & )
1139 
1140  else ! clear sky column
1141  cldfrc(:) = f_zero
1142  cldfmc(:,:)= f_zero
1143  do i = 1, nbdsw
1144  do k = 1, nlay
1145  taucw(k,i) = f_zero
1146  ssacw(k,i) = f_zero
1147  asycw(k,i) = f_zero
1148  enddo
1149  enddo
1150  endif ! end if_zcf1_block
1151 
1154  call setcoef &
1155 ! --- inputs:
1156  & ( pavel,tavel,h2ovmr, nlay,nlp1, &
1157 ! --- outputs:
1158  & laytrop,jp,jt,jt1,fac00,fac01,fac10,fac11, &
1159  & selffac,selffrac,indself,forfac,forfrac,indfor &
1160  & )
1161 
1164  call taumol &
1165 ! --- inputs:
1166  & ( colamt,colmol,fac00,fac01,fac10,fac11,jp,jt,jt1,laytrop, &
1167  & forfac,forfrac,indfor,selffac,selffrac,indself, nlay, &
1168 ! --- outputs:
1169  & sfluxzen, taug, taur &
1170  & )
1171 
1177 
1178  if ( isubcsw <= 0 ) then ! use standard cloud scheme
1179 
1180  call spcvrtc &
1181 ! --- inputs:
1182  & ( ssolar,cosz1,sntz1,albbm,albdf,sfluxzen,cldfrc, &
1183  & zcf1,zcf0,taug,taur,tauae,ssaae,asyae,taucw,ssacw,asycw, &
1184  & nlay, nlp1, &
1185 ! --- outputs:
1186  & fxupc,fxdnc,fxup0,fxdn0, &
1187  & ftoauc,ftoau0,ftoadc,fsfcuc,fsfcu0,fsfcdc,fsfcd0, &
1188  & sfbmc,sfdfc,sfbm0,sfdf0,suvbfc,suvbf0 &
1189  & )
1190 
1191  else ! use mcica cloud scheme
1192 
1193  call spcvrtm &
1194 ! --- inputs:
1195  & ( ssolar,cosz1,sntz1,albbm,albdf,sfluxzen,cldfmc, &
1196  & zcf1,zcf0,taug,taur,tauae,ssaae,asyae,taucw,ssacw,asycw, &
1197  & nlay, nlp1, &
1198 ! --- outputs:
1199  & fxupc,fxdnc,fxup0,fxdn0, &
1200  & ftoauc,ftoau0,ftoadc,fsfcuc,fsfcu0,fsfcdc,fsfcd0, &
1201  & sfbmc,sfdfc,sfbm0,sfdf0,suvbfc,suvbf0 &
1202  & )
1203 
1204  endif
1205 
1207 ! --- ... sum up total spectral fluxes for total-sky
1208 
1209  do k = 1, nlp1
1210  flxuc(k) = f_zero
1211  flxdc(k) = f_zero
1212 
1213  do ib = 1, nbdsw
1214  flxuc(k) = flxuc(k) + fxupc(k,ib)
1215  flxdc(k) = flxdc(k) + fxdnc(k,ib)
1216  enddo
1217  enddo
1218 
1219 !! --- ... optional clear sky fluxes
1220 
1221  if ( lhsw0 .or. lflxprf ) then
1222  do k = 1, nlp1
1223  flxu0(k) = f_zero
1224  flxd0(k) = f_zero
1225 
1226  do ib = 1, nbdsw
1227  flxu0(k) = flxu0(k) + fxup0(k,ib)
1228  flxd0(k) = flxd0(k) + fxdn0(k,ib)
1229  enddo
1230  enddo
1231  endif
1232 
1233 ! --- ... prepare for final outputs
1234 
1235  do k = 1, nlay
1236  rfdelp(k) = heatfac / delp(k)
1237  enddo
1238 
1239  if ( lfdncmp ) then
1240 !! --- ... optional uv-b surface downward flux
1241  fdncmp(j1)%uvbf0 = suvbf0
1242  fdncmp(j1)%uvbfc = suvbfc
1243 
1244 !! --- ... optional beam and diffuse sfc fluxes
1245  fdncmp(j1)%nirbm = sfbmc(1)
1246  fdncmp(j1)%nirdf = sfdfc(1)
1247  fdncmp(j1)%visbm = sfbmc(2)
1248  fdncmp(j1)%visdf = sfdfc(2)
1249  endif ! end if_lfdncmp
1250 
1251 ! --- ... toa and sfc fluxes
1252 
1253  topflx(j1)%upfxc = ftoauc
1254  topflx(j1)%dnfxc = ftoadc
1255  topflx(j1)%upfx0 = ftoau0
1256 
1257  sfcflx(j1)%upfxc = fsfcuc
1258  sfcflx(j1)%dnfxc = fsfcdc
1259  sfcflx(j1)%upfx0 = fsfcu0
1260  sfcflx(j1)%dnfx0 = fsfcd0
1261 
1262  if (ivflip == 0) then ! output from toa to sfc
1263 
1264 ! --- ... compute heating rates
1265 
1266  fnet(1) = flxdc(1) - flxuc(1)
1267 
1268  do k = 2, nlp1
1269  kk = nlp1 - k + 1
1270  fnet(k) = flxdc(k) - flxuc(k)
1271  hswc(j1,kk) = (fnet(k)-fnet(k-1)) * rfdelp(k-1)
1272  enddo
1273 
1274 !! --- ... optional flux profiles
1275 
1276  if ( lflxprf ) then
1277  do k = 1, nlp1
1278  kk = nlp1 - k + 1
1279  flxprf(j1,kk)%upfxc = flxuc(k)
1280  flxprf(j1,kk)%dnfxc = flxdc(k)
1281  flxprf(j1,kk)%upfx0 = flxu0(k)
1282  flxprf(j1,kk)%dnfx0 = flxd0(k)
1283  enddo
1284  endif
1285 
1286 !! --- ... optional clear sky heating rates
1287 
1288  if ( lhsw0 ) then
1289  fnet(1) = flxd0(1) - flxu0(1)
1290 
1291  do k = 2, nlp1
1292  kk = nlp1 - k + 1
1293  fnet(k) = flxd0(k) - flxu0(k)
1294  hsw0(j1,kk) = (fnet(k)-fnet(k-1)) * rfdelp(k-1)
1295  enddo
1296  endif
1297 
1298 !! --- ... optional spectral band heating rates
1299 
1300  if ( lhswb ) then
1301  do mb = 1, nbdsw
1302  fnet(1) = fxdnc(1,mb) - fxupc(1,mb)
1303 
1304  do k = 2, nlp1
1305  kk = nlp1 - k + 1
1306  fnet(k) = fxdnc(k,mb) - fxupc(k,mb)
1307  hswb(j1,kk,mb) = (fnet(k) - fnet(k-1)) * rfdelp(k-1)
1308  enddo
1309  enddo
1310  endif
1311 
1312  else ! output from sfc to toa
1313 
1314 ! --- ... compute heating rates
1315 
1316  fnet(1) = flxdc(1) - flxuc(1)
1317 
1318  do k = 2, nlp1
1319  fnet(k) = flxdc(k) - flxuc(k)
1320  hswc(j1,k-1) = (fnet(k)-fnet(k-1)) * rfdelp(k-1)
1321  enddo
1322 
1323 !! --- ... optional flux profiles
1324 
1325  if ( lflxprf ) then
1326  do k = 1, nlp1
1327  flxprf(j1,k)%upfxc = flxuc(k)
1328  flxprf(j1,k)%dnfxc = flxdc(k)
1329  flxprf(j1,k)%upfx0 = flxu0(k)
1330  flxprf(j1,k)%dnfx0 = flxd0(k)
1331  enddo
1332  endif
1333 
1334 !! --- ... optional clear sky heating rates
1335 
1336  if ( lhsw0 ) then
1337  fnet(1) = flxd0(1) - flxu0(1)
1338 
1339  do k = 2, nlp1
1340  fnet(k) = flxd0(k) - flxu0(k)
1341  hsw0(j1,k-1) = (fnet(k)-fnet(k-1)) * rfdelp(k-1)
1342  enddo
1343  endif
1344 
1345 !! --- ... optional spectral band heating rates
1346 
1347  if ( lhswb ) then
1348  do mb = 1, nbdsw
1349  fnet(1) = fxdnc(1,mb) - fxupc(1,mb)
1350 
1351  do k = 1, nlay
1352  fnet(k+1) = fxdnc(k+1,mb) - fxupc(k+1,mb)
1353  hswb(j1,k,mb) = (fnet(k+1) - fnet(k)) * rfdelp(k)
1354  enddo
1355  enddo
1356  endif
1357 
1358  endif ! if_ivflip
1359 
1360  enddo lab_do_ipt
1361 
1362  return
1363 !...................................
1364  end subroutine swrad
1365 !-----------------------------------
1367 
1368 
1372 !-----------------------------------
1373  subroutine rswinit &
1374  & ( me ) ! --- inputs:
1375 ! --- outputs: (none)
1376 
1377 ! =================== program usage description =================== !
1378 ! !
1379 ! purpose: initialize non-varying module variables, conversion factors,!
1380 ! and look-up tables. !
1381 ! !
1382 ! subprograms called: none !
1383 ! !
1384 ! ==================== defination of variables ==================== !
1385 ! !
1386 ! inputs: !
1387 ! me - print control for parallel process !
1388 ! !
1389 ! outputs: (none) !
1390 ! !
1391 ! external module variables: (in physparam) !
1392 ! iswrate - heating rate unit selections !
1393 ! =1: output in k/day !
1394 ! =2: output in k/second !
1395 ! iswrgas - control flag for rare gases (ch4,n2o,o2, etc.) !
1396 ! =0: do not include rare gases !
1397 ! >0: include all rare gases !
1398 ! iswcliq - liquid cloud optical properties contrl flag !
1399 ! =0: input cloud opt depth from diagnostic scheme !
1400 ! >0: input cwp,rew, and other cloud content parameters !
1401 ! isubcsw - sub-column cloud approximation control flag !
1402 ! =0: no sub-col cld treatment, use grid-mean cld quantities !
1403 ! =1: mcica sub-col, prescribed seeds to get random numbers !
1404 ! =2: mcica sub-col, providing array icseed for random numbers!
1405 ! icldflg - cloud scheme control flag !
1406 ! =0: diagnostic scheme gives cloud tau, omiga, and g. !
1407 ! =1: prognostic scheme gives cloud liq/ice path, etc. !
1408 ! iovrsw - clouds vertical overlapping control flag !
1409 ! =0: random overlapping clouds !
1410 ! =1: maximum/random overlapping clouds !
1411 ! =2: maximum overlap cloud !
1412 ! iswmode - control flag for 2-stream transfer scheme !
1413 ! =1; delta-eddington (joseph et al., 1976) !
1414 ! =2: pifm (zdunkowski et al., 1980) !
1415 ! =3: discrete ordinates (liou, 1973) !
1416 ! !
1417 ! ******************************************************************* !
1418 ! !
1419 ! definitions: !
1420 ! arrays for 10000-point look-up tables: !
1421 ! tau_tbl clear-sky optical depth !
1422 ! exp_tbl exponential lookup table for transmittance !
1423 ! !
1424 ! ******************************************************************* !
1425 ! !
1426 ! ====================== end of description block ================= !
1427 
1428 ! --- inputs:
1429  integer, intent(in) :: me
1430 
1431 ! --- outputs: none
1432 
1433 ! --- locals:
1434  real (kind=kind_phys), parameter :: expeps = 1.e-20
1435 
1436  integer :: i
1437 
1438  real (kind=kind_phys) :: tfn, tau
1439 
1440 !
1441 !===> ... begin here
1442 !
1443  if ( iovrsw<0 .or. iovrsw>2 ) then
1444  print *,' *** Error in specification of cloud overlap flag', &
1445  & ' IOVRSW=',iovrsw,' in RSWINIT !!'
1446  stop
1447  endif
1448 
1449  if (me == 0) then
1450  print *,' - Using AER Shortwave Radiation, Version: ',vtagsw
1451 
1452  if (iswmode == 1) then
1453  print *,' --- Delta-eddington 2-stream transfer scheme'
1454  else if (iswmode == 2) then
1455  print *,' --- PIFM 2-stream transfer scheme'
1456  else if (iswmode == 3) then
1457  print *,' --- Discrete ordinates 2-stream transfer scheme'
1458  endif
1459 
1460  if (iswrgas <= 0) then
1461  print *,' --- Rare gases absorption is NOT included in SW'
1462  else
1463  print *,' --- Include rare gases N2O, CH4, O2, absorptions',&
1464  & ' in SW'
1465  endif
1466 
1467  if ( isubcsw == 0 ) then
1468  print *,' --- Using standard grid average clouds, no ', &
1469  & 'sub-column clouds approximation applied'
1470  elseif ( isubcsw == 1 ) then
1471  print *,' --- Using MCICA sub-colum clouds approximation ', &
1472  & 'with a prescribed sequence of permutation seeds'
1473  elseif ( isubcsw == 2 ) then
1474  print *,' --- Using MCICA sub-colum clouds approximation ', &
1475  & 'with provided input array of permutation seeds'
1476  else
1477  print *,' *** Error in specification of sub-column cloud ', &
1478  & ' control flag isubcsw =',isubcsw,' !!'
1479  stop
1480  endif
1481  endif
1482 
1483 ! --- ... check cloud flags for consistency
1484 
1485  if ((icldflg == 0 .and. iswcliq /= 0) .or. &
1486  & (icldflg == 1 .and. iswcliq == 0)) then
1487  print *,' *** Model cloud scheme inconsistent with SW', &
1488  & ' radiation cloud radiative property setup !!'
1489  stop
1490  endif
1491 
1492 ! --- ... setup constant factors for heating rate
1493 ! the 1.0e-2 is to convert pressure from mb to N/m**2
1494 
1495  if (iswrate == 1) then
1496 ! heatfac = 8.4391
1497 ! heatfac = con_g * 86400. * 1.0e-2 / con_cp ! (in k/day)
1498  heatfac = con_g * 864.0 / con_cp ! (in k/day)
1499  else
1500  heatfac = con_g * 1.0e-2 / con_cp ! (in k/second)
1501  endif
1502 
1503 ! --- ... define exponential lookup tables for transmittance. tau is
1504 ! computed as a function of the tau transition function, and
1505 ! transmittance is calculated as a function of tau. all tables
1506 ! are computed at intervals of 0.0001. the inverse of the
1507 ! constant used in the Pade approximation to the tau transition
1508 ! function is set to bpade.
1509 
1510  exp_tbl(0) = 1.0
1511  exp_tbl(ntbmx) = expeps
1512 
1513  do i = 1, ntbmx-1
1514  tfn = float(i) / float(ntbmx-i)
1515  tau = bpade * tfn
1516  exp_tbl(i) = exp( -tau )
1517  enddo
1518 
1519  return
1520 !...................................
1521  end subroutine rswinit
1522 !-----------------------------------
1523 
1558 !-----------------------------------
1559  subroutine cldprop &
1560  & ( cfrac,cliqp,reliq,cicep,reice,cdat1,cdat2,cdat3,cdat4, & ! --- inputs
1561  & cf1, nlay, ipseed, &
1562  & taucw, ssacw, asycw, cldfrc, cldfmc & ! --- output
1563  & )
1565 ! =================== program usage description =================== !
1566 ! !
1567 ! Purpose: Compute the cloud optical properties for each cloudy layer !
1568 ! and g-point interval. !
1569 ! !
1570 ! subprograms called: none !
1571 ! !
1572 ! ==================== defination of variables ==================== !
1573 ! !
1574 ! inputs: size !
1575 ! cfrac - real, layer cloud fraction nlay !
1576 ! ..... for iswcliq > 0 (prognostic cloud sckeme) - - - !
1577 ! cliqp - real, layer in-cloud liq water path (g/m**2) nlay !
1578 ! reliq - real, mean eff radius for liq cloud (micron) nlay !
1579 ! cicep - real, layer in-cloud ice water path (g/m**2) nlay !
1580 ! reice - real, mean eff radius for ice cloud (micron) nlay !
1581 ! cdat1 - real, layer rain drop water path (g/m**2) nlay !
1582 ! cdat2 - real, effective radius for rain drop (micron) nlay !
1583 ! cdat3 - real, layer snow flake water path(g/m**2) nlay !
1584 ! cdat4 - real, mean eff radius for snow flake(micron) nlay !
1585 ! ..... for iswcliq = 0 (diagnostic cloud sckeme) - - - !
1586 ! cdat1 - real, layer cloud optical depth nlay !
1587 ! cdat2 - real, layer cloud single scattering albedo nlay !
1588 ! cdat3 - real, layer cloud asymmetry factor nlay !
1589 ! cdat4 - real, optional use nlay !
1590 ! cliqp - real, not used nlay !
1591 ! cicep - real, not used nlay !
1592 ! reliq - real, not used nlay !
1593 ! reice - real, not used nlay !
1594 ! !
1595 ! cf1 - real, effective total cloud cover at surface 1 !
1596 ! nlay - integer, vertical layer number 1 !
1597 ! ipseed- permutation seed for generating random numbers (isubcsw>0) !
1598 ! !
1599 ! outputs: !
1600 ! taucw - real, cloud optical depth, w/o delta scaled nlay*nbdsw !
1601 ! ssacw - real, weighted cloud single scattering albedo nlay*nbdsw !
1602 ! (ssa = ssacw / taucw) !
1603 ! asycw - real, weighted cloud asymmetry factor nlay*nbdsw !
1604 ! (asy = asycw / ssacw) !
1605 ! cldfrc - real, cloud fraction of grid mean value nlay !
1606 ! cldfmc - real, cloud fraction for each sub-column nlay*ngptsw!
1607 ! !
1608 ! !
1609 ! explanation of the method for each value of iswcliq, and iswcice. !
1610 ! set up in module "physparam" !
1611 ! !
1612 ! iswcliq=0 : input cloud optical property (tau, ssa, asy). !
1613 ! (used for diagnostic cloud method) !
1614 ! iswcliq>0 : input cloud liq/ice path and effective radius, also !
1615 ! require the user of 'iswcice' to specify the method !
1616 ! used to compute aborption due to water/ice parts. !
1617 ! ................................................................... !
1618 ! !
1619 ! iswcliq=1 : liquid water cloud optical properties are computed !
1620 ! as in hu and stamnes (1993), j. clim., 6, 728-742. !
1621 ! !
1622 ! iswcice used only when iswcliq > 0 !
1623 ! the cloud ice path (g/m2) and ice effective radius !
1624 ! (microns) are inputs. !
1625 ! iswcice=1 : ice cloud optical properties are computed as in !
1626 ! ebert and curry (1992), jgr, 97, 3831-3836. !
1627 ! iswcice=2 : ice cloud optical properties are computed as in !
1628 ! streamer v3.0 (2001), key, streamer user's guide, !
1629 ! cooperative institude for meteorological studies,95pp!
1630 ! iswcice=3 : ice cloud optical properties are computed as in !
1631 ! fu (1996), j. clim., 9. !
1632 ! !
1633 ! other cloud control module variables: !
1634 ! isubcsw =0: standard cloud scheme, no sub-col cloud approximation !
1635 ! >0: mcica sub-col cloud scheme using ipseed as permutation!
1636 ! seed for generating rundom numbers !
1637 ! !
1638 ! ====================== end of description block ================= !
1639 !
1641 
1642 ! --- inputs:
1643  integer, intent(in) :: nlay, ipseed
1644  real (kind=kind_phys), intent(in) :: cf1
1645 
1646  real (kind=kind_phys), dimension(nlay), intent(in) :: cliqp, &
1647  & reliq, cicep, reice, cdat1, cdat2, cdat3, cdat4, cfrac
1648 
1649 ! --- outputs:
1650  real (kind=kind_phys), dimension(nlay,ngptsw), intent(out) :: &
1651  & cldfmc
1652  real (kind=kind_phys), dimension(nlay,nbdsw), intent(out) :: &
1653  & taucw, ssacw, asycw
1654  real (kind=kind_phys), dimension(nlay), intent(out) :: cldfrc
1655 
1656 ! --- locals:
1657  real (kind=kind_phys), dimension(nblow:nbhgh) :: tauliq, tauice, &
1658  & ssaliq, ssaice, ssaran, ssasnw, asyliq, asyice, &
1659  & asyran, asysnw
1660  real (kind=kind_phys), dimension(nlay) :: cldf
1661 
1662  real (kind=kind_phys) :: dgeice, factor, fint, tauran, tausnw, &
1663  & cldliq, refliq, cldice, refice, cldran, cldsnw, refsnw, &
1664  & extcoliq, ssacoliq, asycoliq, extcoice, ssacoice, asycoice,&
1665  & dgesnw
1666 
1667  logical :: lcloudy(nlay,ngptsw)
1668  integer :: ia, ib, ig, jb, k, index
1669 
1670 !
1671 !===> ... begin here
1672 !
1673  do ib = 1, nbdsw
1674  do k = 1, nlay
1675  taucw(k,ib) = f_zero
1676  ssacw(k,ib) = f_one
1677  asycw(k,ib) = f_zero
1678  enddo
1679  enddo
1680 
1682 
1683  lab_if_iswcliq : if (iswcliq > 0) then
1684 
1685  lab_do_k : do k = 1, nlay
1686  lab_if_cld : if (cfrac(k) > ftiny) then
1687 
1699 
1700  cldran = cdat1(k)
1701 ! refran = cdat2(k)
1702  cldsnw = cdat3(k)
1703  refsnw = cdat4(k)
1704  dgesnw = 1.0315 * refsnw ! for fu's snow formula
1705 
1706  tauran = cldran * a0r
1707 
1708 ! --- if use fu's formula it needs to be normalized by snow/ice density
1709 ! !not use snow density = 0.1 g/cm**3 = 0.1 g/(mu * m**2)
1710 ! use ice density = 0.9167 g/cm**3 = 0.9167 g/(mu * m**2)
1711 ! 1/0.9167 = 1.09087
1712 ! factor 1.5396=8/(3*sqrt(3)) converts reff to generalized ice particle size
1713 ! use newer factor value 1.0315
1714  if (cldsnw>f_zero .and. refsnw>10.0_kind_phys) then
1715 ! tausnw = cldsnw * (a0s + a1s/refsnw)
1716  tausnw = cldsnw*1.09087*(a0s + a1s/dgesnw) ! fu's formula
1717  else
1718  tausnw = f_zero
1719  endif
1720 
1721  do ib = nblow, nbhgh
1722  ssaran(ib) = tauran * (f_one - b0r(ib))
1723  ssasnw(ib) = tausnw * (f_one - (b0s(ib)+b1s(ib)*dgesnw))
1724  asyran(ib) = ssaran(ib) * c0r(ib)
1725  asysnw(ib) = ssasnw(ib) * c0s(ib)
1726  enddo
1727 
1728  cldliq = cliqp(k)
1729  cldice = cicep(k)
1730  refliq = reliq(k)
1731  refice = reice(k)
1732 
1733 ! --- ... calculation of absorption coefficients due to water clouds.
1734 
1735  if ( cldliq <= f_zero ) then
1736  do ib = nblow, nbhgh
1737  tauliq(ib) = f_zero
1738  ssaliq(ib) = f_zero
1739  asyliq(ib) = f_zero
1740  enddo
1741  else
1742  if ( iswcliq == 1 ) then
1743  factor = refliq - 1.5
1744  index = max( 1, min( 57, int( factor ) ))
1745  fint = factor - float(index)
1746 
1747  do ib = nblow, nbhgh
1748  extcoliq = max(f_zero, extliq1(index,ib) &
1749  & + fint*(extliq1(index+1,ib)-extliq1(index,ib)) )
1750  ssacoliq = max(f_zero, min(f_one, ssaliq1(index,ib) &
1751  & + fint*(ssaliq1(index+1,ib)-ssaliq1(index,ib)) ))
1752 
1753  asycoliq = max(f_zero, min(f_one, asyliq1(index,ib) &
1754  & + fint*(asyliq1(index+1,ib)-asyliq1(index,ib)) ))
1755 ! forcoliq = asycoliq * asycoliq
1756 
1757  tauliq(ib) = cldliq * extcoliq
1758  ssaliq(ib) = tauliq(ib) * ssacoliq
1759  asyliq(ib) = ssaliq(ib) * asycoliq
1760  enddo
1761  endif ! end if_iswcliq_block
1762  endif ! end if_cldliq_block
1763 
1764 ! --- ... calculation of absorption coefficients due to ice clouds.
1765 
1766  if ( cldice <= f_zero ) then
1767  do ib = nblow, nbhgh
1768  tauice(ib) = f_zero
1769  ssaice(ib) = f_zero
1770  asyice(ib) = f_zero
1771  enddo
1772  else
1773 
1774 ! --- ... ebert and curry approach for all particle sizes though somewhat
1775 ! unjustified for large ice particles
1776 
1777  if ( iswcice == 1 ) then
1778  refice = min(130.0_kind_phys,max(13.0_kind_phys,refice))
1779 
1780  do ib = nblow, nbhgh
1781  ia = idxebc(ib) ! eb_&_c band index for ice cloud coeff
1782 
1783  extcoice = max(f_zero, abari(ia)+bbari(ia)/refice )
1784  ssacoice = max(f_zero, min(f_one, &
1785  & f_one-cbari(ia)-dbari(ia)*refice ))
1786  asycoice = max(f_zero, min(f_one, &
1787  & ebari(ia)+fbari(ia)*refice ))
1788 ! forcoice = asycoice * asycoice
1789 
1790  tauice(ib) = cldice * extcoice
1791  ssaice(ib) = tauice(ib) * ssacoice
1792  asyice(ib) = ssaice(ib) * asycoice
1793  enddo
1794 
1795 ! --- ... streamer approach for ice effective radius between 5.0 and 131.0 microns
1796 
1797  elseif ( iswcice == 2 ) then
1798  refice = min(131.0_kind_phys,max(5.0_kind_phys,refice))
1799 
1800  factor = (refice - 2.0) / 3.0
1801  index = max( 1, min( 42, int( factor ) ))
1802  fint = factor - float(index)
1803 
1804  do ib = nblow, nbhgh
1805  extcoice = max(f_zero, extice2(index,ib) &
1806  & + fint*(extice2(index+1,ib)-extice2(index,ib)) )
1807  ssacoice = max(f_zero, min(f_one, ssaice2(index,ib) &
1808  & + fint*(ssaice2(index+1,ib)-ssaice2(index,ib)) ))
1809  asycoice = max(f_zero, min(f_one, asyice2(index,ib) &
1810  & + fint*(asyice2(index+1,ib)-asyice2(index,ib)) ))
1811 ! forcoice = asycoice * asycoice
1812 
1813  tauice(ib) = cldice * extcoice
1814  ssaice(ib) = tauice(ib) * ssacoice
1815  asyice(ib) = ssaice(ib) * asycoice
1816  enddo
1817 
1818 ! --- ... fu's approach for ice effective radius between 4.8 and 135 microns
1819 ! (generalized effective size from 5 to 140 microns)
1820 
1821  elseif ( iswcice == 3 ) then
1822  dgeice = max( 5.0, min( 140.0, 1.0315*refice ))
1823 
1824  factor = (dgeice - 2.0) / 3.0
1825  index = max( 1, min( 45, int( factor ) ))
1826  fint = factor - float(index)
1827 
1828  do ib = nblow, nbhgh
1829  extcoice = max(f_zero, extice3(index,ib) &
1830  & + fint*(extice3(index+1,ib)-extice3(index,ib)) )
1831  ssacoice = max(f_zero, min(f_one, ssaice3(index,ib) &
1832  & + fint*(ssaice3(index+1,ib)-ssaice3(index,ib)) ))
1833  asycoice = max(f_zero, min(f_one, asyice3(index,ib) &
1834  & + fint*(asyice3(index+1,ib)-asyice3(index,ib)) ))
1835 ! fdelta = max(f_zero, min(f_one, fdlice3(index,ib) &
1836 ! & + fint*(fdlice3(index+1,ib)-fdlice3(index,ib)) ))
1837 ! forcoice = min( asycoice, fdelta+0.5/ssacoice ) ! see fu 1996 p. 2067
1838 
1839  tauice(ib) = cldice * extcoice
1840  ssaice(ib) = tauice(ib) * ssacoice
1841  asyice(ib) = ssaice(ib) * asycoice
1842  enddo
1843 
1844  endif ! end if_iswcice_block
1845  endif ! end if_cldice_block
1846 
1847  do ib = 1, nbdsw
1848  jb = nblow + ib - 1
1849  taucw(k,ib) = tauliq(jb)+tauice(jb)+tauran+tausnw
1850  ssacw(k,ib) = ssaliq(jb)+ssaice(jb)+ssaran(jb)+ssasnw(jb)
1851  asycw(k,ib) = asyliq(jb)+asyice(jb)+asyran(jb)+asysnw(jb)
1852  enddo
1853 
1854  endif lab_if_cld
1855  enddo lab_do_k
1856 
1857  else lab_if_iswcliq
1858 
1859  do k = 1, nlay
1860  if (cfrac(k) > ftiny) then
1861  do ib = 1, nbdsw
1862  taucw(k,ib) = cdat1(k)
1863  ssacw(k,ib) = cdat1(k) * cdat2(k)
1864  asycw(k,ib) = ssacw(k,ib) * cdat3(k)
1865  enddo
1866  endif
1867  enddo
1868 
1869  endif lab_if_iswcliq
1870 
1873 
1874  if ( isubcsw > 0 ) then ! mcica sub-col clouds approx
1875 
1876  cldf(:) = cfrac(:)
1877  where (cldf(:) < ftiny)
1878  cldf(:) = f_zero
1879  end where
1880 
1881 ! --- ... call sub-column cloud generator
1882 
1883  call mcica_subcol &
1884 ! --- inputs:
1885  & ( cldf, nlay, ipseed, &
1886 ! --- outputs:
1887  & lcloudy &
1888  & )
1889 
1890  do ig = 1, ngptsw
1891  do k = 1, nlay
1892  if ( lcloudy(k,ig) ) then
1893  cldfmc(k,ig) = f_one
1894  else
1895  cldfmc(k,ig) = f_zero
1896  endif
1897  enddo
1898  enddo
1899 
1900  else ! non-mcica, normalize cloud
1901 
1902  do k = 1, nlay
1903  cldfrc(k) = cfrac(k) / cf1
1904  enddo
1905  endif ! end if_isubcsw_block
1906 
1907  return
1908 !...................................
1909  end subroutine cldprop
1910 !-----------------------------------
1912 
1913 
1919 ! ----------------------------------
1920  subroutine mcica_subcol &
1921  & ( cldf, nlay, ipseed, & ! --- inputs
1922  & lcloudy & ! --- outputs
1923  & )
1925 ! ==================== defination of variables ==================== !
1926 ! !
1927 ! input variables: size !
1928 ! cldf - real, layer cloud fraction nlay !
1929 ! nlay - integer, number of model vertical layers 1 !
1930 ! ipseed - integer, permute seed for random num generator 1 !
1931 ! ** note : if the cloud generator is called multiple times, need !
1932 ! to permute the seed between each call; if between calls !
1933 ! for lw and sw, use values differ by the number of g-pts. !
1934 ! !
1935 ! output variables: !
1936 ! lcloudy - logical, sub-colum cloud profile flag array nlay*ngptsw!
1937 ! !
1938 ! other control flags from module variables: !
1939 ! iovrsw : control flag for cloud overlapping method !
1940 ! =0:random; =1:maximum/random; =2:maximum !
1941 ! !
1942 ! !
1943 ! ===================== end of definitions ==================== !
1944 
1945  implicit none
1946 
1947 ! --- inputs:
1948  integer, intent(in) :: nlay, ipseed
1949 
1950  real (kind=kind_phys), dimension(nlay), intent(in) :: cldf
1951 
1952 ! --- outputs:
1953  logical, dimension(nlay,ngptsw), intent(out):: lcloudy
1954 
1955 ! --- locals:
1956  real (kind=kind_phys) :: cdfunc(nlay,ngptsw), tem1, &
1957  & rand2d(nlay*ngptsw), rand1d(ngptsw)
1958 
1959  type(random_stat) :: stat ! for thread safe random generator
1960 
1961  integer :: k, n, k1
1962 !
1963 !===> ... begin here
1964 !
1965 ! --- ... advance randum number generator by ipseed values
1966 
1967  call random_setseed &
1968 ! --- inputs:
1969  & ( ipseed, &
1970 ! --- outputs:
1971  & stat &
1972  & )
1973 
1974 ! --- ... sub-column set up according to overlapping assumption
1975 
1976  select case ( iovrsw )
1977 
1978  case( 0 ) ! random overlap, pick a random value at every level
1979 
1980  call random_number &
1981 ! --- inputs: ( none )
1982 ! --- outputs:
1983  & ( rand2d, stat )
1984 
1985  k1 = 0
1986  do n = 1, ngptsw
1987  do k = 1, nlay
1988  k1 = k1 + 1
1989  cdfunc(k,n) = rand2d(k1)
1990  enddo
1991  enddo
1992 
1993  case( 1 ) ! max-ran overlap
1994 
1995  call random_number &
1996 ! --- inputs: ( none )
1997 ! --- outputs:
1998  & ( rand2d, stat )
1999 
2000  k1 = 0
2001  do n = 1, ngptsw
2002  do k = 1, nlay
2003  k1 = k1 + 1
2004  cdfunc(k,n) = rand2d(k1)
2005  enddo
2006  enddo
2007 
2008 ! --- first pick a random number for bottom/top layer.
2009 ! then walk up the column: (aer's code)
2010 ! if layer below is cloudy, use the same rand num in the layer below
2011 ! if layer below is clear, use a new random number
2012 
2013 ! --- from bottom up
2014  do k = 2, nlay
2015  k1 = k - 1
2016  tem1 = f_one - cldf(k1)
2017 
2018  do n = 1, ngptsw
2019  if ( cdfunc(k1,n) > tem1 ) then
2020  cdfunc(k,n) = cdfunc(k1,n)
2021  else
2022  cdfunc(k,n) = cdfunc(k,n) * tem1
2023  endif
2024  enddo
2025  enddo
2026 
2027 ! --- then walk down the column: (if use original author's method)
2028 ! if layer above is cloudy, use the same rand num in the layer above
2029 ! if layer above is clear, use a new random number
2030 
2031 ! --- from top down
2032 ! do k = nlay-1, 1, -1
2033 ! k1 = k + 1
2034 ! tem1 = f_one - cldf(k1)
2035 
2036 ! do n = 1, ngptsw
2037 ! if ( cdfunc(k1,n) > tem1 ) then
2038 ! cdfunc(k,n) = cdfunc(k1,n)
2039 ! else
2040 ! cdfunc(k,n) = cdfunc(k,n) * tem1
2041 ! endif
2042 ! enddo
2043 ! enddo
2044 
2045  case( 2 ) ! maximum overlap, pick same random numebr at every level
2046 
2047  call random_number &
2048 ! --- inputs: ( none )
2049 ! --- outputs:
2050  & ( rand1d, stat )
2051 
2052  do n = 1, ngptsw
2053  tem1 = rand1d(n)
2054 
2055  do k = 1, nlay
2056  cdfunc(k,n) = tem1
2057  enddo
2058  enddo
2059 
2060  end select
2061 
2062 ! --- ... generate subcolumns for homogeneous clouds
2063 
2064  do k = 1, nlay
2065  tem1 = f_one - cldf(k)
2066 
2067  do n = 1, ngptsw
2068  lcloudy(k,n) = cdfunc(k,n) >= tem1
2069  enddo
2070  enddo
2071 
2072  return
2073 ! ..................................
2074  end subroutine mcica_subcol
2075 ! ----------------------------------
2076 
2101 ! ----------------------------------
2102  subroutine setcoef &
2103  & ( pavel,tavel,h2ovmr, nlay,nlp1, & ! --- inputs
2104  & laytrop,jp,jt,jt1,fac00,fac01,fac10,fac11, & ! --- outputs
2105  & selffac,selffrac,indself,forfac,forfrac,indfor &
2106  & )
2108 ! =================== program usage description =================== !
2109 ! !
2110 ! purpose: compute various coefficients needed in radiative transfer !
2111 ! calculations. !
2112 ! !
2113 ! subprograms called: none !
2114 ! !
2115 ! ==================== defination of variables ==================== !
2116 ! !
2117 ! inputs: -size- !
2118 ! pavel - real, layer pressures (mb) nlay !
2119 ! tavel - real, layer temperatures (k) nlay !
2120 ! h2ovmr - real, layer w.v. volum mixing ratio (kg/kg) nlay !
2121 ! nlay/nlp1 - integer, total number of vertical layers, levels 1 !
2122 ! !
2123 ! outputs: !
2124 ! laytrop - integer, tropopause layer index (unitless) 1 !
2125 ! jp - real, indices of lower reference pressure nlay !
2126 ! jt, jt1 - real, indices of lower reference temperatures nlay !
2127 ! at levels of jp and jp+1 !
2128 ! facij - real, factors multiply the reference ks, nlay !
2129 ! i,j=0/1 for lower/higher of the 2 appropriate !
2130 ! temperatures and altitudes. !
2131 ! selffac - real, scale factor for w. v. self-continuum nlay !
2132 ! equals (w. v. density)/(atmospheric density !
2133 ! at 296k and 1013 mb) !
2134 ! selffrac - real, factor for temperature interpolation of nlay !
2135 ! reference w. v. self-continuum data !
2136 ! indself - integer, index of lower ref temp for selffac nlay !
2137 ! forfac - real, scale factor for w. v. foreign-continuum nlay !
2138 ! forfrac - real, factor for temperature interpolation of nlay !
2139 ! reference w.v. foreign-continuum data !
2140 ! indfor - integer, index of lower ref temp for forfac nlay !
2141 ! !
2142 ! ====================== end of definitions =================== !
2143 
2144 ! --- inputs:
2145  integer, intent(in) :: nlay, nlp1
2146 
2147  real (kind=kind_phys), dimension(:), intent(in) :: pavel, tavel, &
2148  & h2ovmr
2149 
2150 ! --- outputs:
2151  integer, dimension(nlay), intent(out) :: indself, indfor, &
2152  & jp, jt, jt1
2153  integer, intent(out) :: laytrop
2154 
2155  real (kind=kind_phys), dimension(nlay), intent(out) :: fac00, &
2156  & fac01, fac10, fac11, selffac, selffrac, forfac, forfrac
2157 
2158 ! --- locals:
2159  real (kind=kind_phys) :: plog, fp, fp1, ft, ft1, tem1, tem2
2160 
2161  integer :: i, k, jp1
2162 !
2163 !===> ... begin here
2164 !
2165  laytrop= nlay
2166 
2167  do k = 1, nlay
2168 
2169  forfac(k) = pavel(k)*stpfac / (tavel(k)*(f_one + h2ovmr(k)))
2170 
2171 ! --- ... find the two reference pressures on either side of the
2172 ! layer pressure. store them in jp and jp1. store in fp the
2173 ! fraction of the difference (in ln(pressure)) between these
2174 ! two values that the layer pressure lies.
2175 
2176  plog = log(pavel(k))
2177  jp(k) = max(1, min(58, int(36.0 - 5.0*(plog+0.04)) ))
2178  jp1 = jp(k) + 1
2179  fp = 5.0 * (preflog(jp(k)) - plog)
2180 
2181 ! --- ... determine, for each reference pressure (jp and jp1), which
2182 ! reference temperature (these are different for each reference
2183 ! pressure) is nearest the layer temperature but does not exceed it.
2184 ! store these indices in jt and jt1, resp. store in ft (resp. ft1)
2185 ! the fraction of the way between jt (jt1) and the next highest
2186 ! reference temperature that the layer temperature falls.
2187 
2188  tem1 = (tavel(k) - tref(jp(k))) / 15.0
2189  tem2 = (tavel(k) - tref(jp1 )) / 15.0
2190  jt(k) = max(1, min(4, int(3.0 + tem1) ))
2191  jt1(k) = max(1, min(4, int(3.0 + tem2) ))
2192  ft = tem1 - float(jt(k) - 3)
2193  ft1 = tem2 - float(jt1(k) - 3)
2194 
2195 ! --- ... we have now isolated the layer ln pressure and temperature,
2196 ! between two reference pressures and two reference temperatures
2197 ! (for each reference pressure). we multiply the pressure
2198 ! fraction fp with the appropriate temperature fractions to get
2199 ! the factors that will be needed for the interpolation that yields
2200 ! the optical depths (performed in routines taugbn for band n).
2201 
2202  fp1 = f_one - fp
2203  fac10(k) = fp1 * ft
2204  fac00(k) = fp1 * (f_one - ft)
2205  fac11(k) = fp * ft1
2206  fac01(k) = fp * (f_one - ft1)
2207 
2208 ! --- ... if the pressure is less than ~100mb, perform a different
2209 ! set of species interpolations.
2210 
2211  if ( plog > 4.56 ) then
2212 
2213  laytrop = k
2214 
2215 ! --- ... set up factors needed to separately include the water vapor
2216 ! foreign-continuum in the calculation of absorption coefficient.
2217 
2218  tem1 = (332.0 - tavel(k)) / 36.0
2219  indfor(k) = min(2, max(1, int(tem1)))
2220  forfrac(k) = tem1 - float(indfor(k))
2221 
2222 ! --- ... set up factors needed to separately include the water vapor
2223 ! self-continuum in the calculation of absorption coefficient.
2224 
2225  tem2 = (tavel(k) - 188.0) / 7.2
2226  indself(k) = min(9, max(1, int(tem2)-7))
2227  selffrac(k) = tem2 - float(indself(k) + 7)
2228  selffac(k) = h2ovmr(k) * forfac(k)
2229 
2230  else
2231 
2232 ! --- ... set up factors needed to separately include the water vapor
2233 ! foreign-continuum in the calculation of absorption coefficient.
2234 
2235  tem1 = (tavel(k) - 188.0) / 36.0
2236  indfor(k) = 3
2237  forfrac(k) = tem1 - f_one
2238 
2239  indself(k) = 0
2240  selffrac(k) = f_zero
2241  selffac(k) = f_zero
2242 
2243  endif
2244 
2245  enddo ! end_do_k_loop
2246 
2247  return
2248 ! ..................................
2249  end subroutine setcoef
2250 ! ----------------------------------
2251 
2291 !-----------------------------------
2292  subroutine spcvrtc &
2293  & ( ssolar,cosz,sntz,albbm,albdf,sfluxzen,cldfrc, & ! --- inputs
2294  & cf1,cf0,taug,taur,tauae,ssaae,asyae,taucw,ssacw,asycw, &
2295  & nlay, nlp1, &
2296  & fxupc,fxdnc,fxup0,fxdn0, & ! --- outputs
2297  & ftoauc,ftoau0,ftoadc,fsfcuc,fsfcu0,fsfcdc,fsfcd0, &
2298  & sfbmc,sfdfc,sfbm0,sfdf0,suvbfc,suvbf0 &
2299  & )
2301 ! =================== program usage description =================== !
2302 ! !
2303 ! purpose: computes the shortwave radiative fluxes using two-stream !
2304 ! method !
2305 ! !
2306 ! subprograms called: vrtqdr !
2307 ! !
2308 ! ==================== defination of variables ==================== !
2309 ! !
2310 ! inputs: size !
2311 ! ssolar - real, incoming solar flux at top 1 !
2312 ! cosz - real, cosine solar zenith angle 1 !
2313 ! sntz - real, secant solar zenith angle 1 !
2314 ! albbm - real, surface albedo for direct beam radiation 2 !
2315 ! albdf - real, surface albedo for diffused radiation 2 !
2316 ! sfluxzen- real, spectral distribution of incoming solar flux ngptsw!
2317 ! cldfrc - real, layer cloud fraction nlay !
2318 ! cf1 - real, >0: cloudy sky, otherwise: clear sky 1 !
2319 ! cf0 - real, =1-cf1 1 !
2320 ! taug - real, spectral optical depth for gases nlay*ngptsw!
2321 ! taur - real, optical depth for rayleigh scattering nlay*ngptsw!
2322 ! tauae - real, aerosols optical depth nlay*nbdsw !
2323 ! ssaae - real, aerosols single scattering albedo nlay*nbdsw !
2324 ! asyae - real, aerosols asymmetry factor nlay*nbdsw !
2325 ! taucw - real, weighted cloud optical depth nlay*nbdsw !
2326 ! ssacw - real, weighted cloud single scat albedo nlay*nbdsw !
2327 ! asycw - real, weighted cloud asymmetry factor nlay*nbdsw !
2328 ! nlay,nlp1 - integer, number of layers/levels 1 !
2329 ! !
2330 ! output variables: !
2331 ! fxupc - real, tot sky upward flux nlp1*nbdsw !
2332 ! fxdnc - real, tot sky downward flux nlp1*nbdsw !
2333 ! fxup0 - real, clr sky upward flux nlp1*nbdsw !
2334 ! fxdn0 - real, clr sky downward flux nlp1*nbdsw !
2335 ! ftoauc - real, tot sky toa upwd flux 1 !
2336 ! ftoau0 - real, clr sky toa upwd flux 1 !
2337 ! ftoadc - real, toa downward (incoming) solar flux 1 !
2338 ! fsfcuc - real, tot sky sfc upwd flux 1 !
2339 ! fsfcu0 - real, clr sky sfc upwd flux 1 !
2340 ! fsfcdc - real, tot sky sfc dnwd flux 1 !
2341 ! fsfcd0 - real, clr sky sfc dnwd flux 1 !
2342 ! sfbmc - real, tot sky sfc dnwd beam flux (nir/uv+vis) 2 !
2343 ! sfdfc - real, tot sky sfc dnwd diff flux (nir/uv+vis) 2 !
2344 ! sfbm0 - real, clr sky sfc dnwd beam flux (nir/uv+vis) 2 !
2345 ! sfdf0 - real, clr sky sfc dnwd diff flux (nir/uv+vis) 2 !
2346 ! suvbfc - real, tot sky sfc dnwd uv-b flux 1 !
2347 ! suvbf0 - real, clr sky sfc dnwd uv-b flux 1 !
2348 ! !
2349 ! internal variables: !
2350 ! zrefb - real, direct beam reflectivity for clear/cloudy nlp1 !
2351 ! zrefd - real, diffuse reflectivity for clear/cloudy nlp1 !
2352 ! ztrab - real, direct beam transmissivity for clear/cloudy nlp1 !
2353 ! ztrad - real, diffuse transmissivity for clear/cloudy nlp1 !
2354 ! zldbt - real, layer beam transmittance for clear/cloudy nlp1 !
2355 ! ztdbt - real, lev total beam transmittance for clr/cld nlp1 !
2356 ! !
2357 ! control parameters in module "physparam" !
2358 ! iswmode - control flag for 2-stream transfer schemes !
2359 ! = 1 delta-eddington (joseph et al., 1976) !
2360 ! = 2 pifm (zdunkowski et al., 1980) !
2361 ! = 3 discrete ordinates (liou, 1973) !
2362 ! !
2363 ! ******************************************************************* !
2364 ! original code description !
2365 ! !
2366 ! method: !
2367 ! ------- !
2368 ! standard delta-eddington, p.i.f.m., or d.o.m. layer calculations. !
2369 ! kmodts = 1 eddington (joseph et al., 1976) !
2370 ! = 2 pifm (zdunkowski et al., 1980) !
2371 ! = 3 discrete ordinates (liou, 1973) !
2372 ! !
2373 ! modifications: !
2374 ! -------------- !
2375 ! original: h. barker !
2376 ! revision: merge with rrtmg_sw: j.-j.morcrette, ecmwf, feb 2003 !
2377 ! revision: add adjustment for earth/sun distance:mjiacono,aer,oct2003!
2378 ! revision: bug fix for use of palbp and palbd: mjiacono, aer, nov2003!
2379 ! revision: bug fix to apply delta scaling to clear sky: aer, dec2004 !
2380 ! revision: code modified so that delta scaling is not done in cloudy !
2381 ! profiles if routine cldprop is used; delta scaling can be !
2382 ! applied by swithcing code below if cldprop is not used to !
2383 ! get cloud properties. aer, jan 2005 !
2384 ! revision: uniform formatting for rrtmg: mjiacono, aer, jul 2006 !
2385 ! revision: use exponential lookup table for transmittance: mjiacono, !
2386 ! aer, aug 2007 !
2387 ! !
2388 ! ******************************************************************* !
2389 ! ====================== end of description block ================= !
2390 
2391 ! --- constant parameters:
2392  real (kind=kind_phys), parameter :: zcrit = 0.9999995 ! thresold for conservative scattering
2393  real (kind=kind_phys), parameter :: zsr3 = sqrt(3.0)
2394  real (kind=kind_phys), parameter :: od_lo = 0.06
2395  real (kind=kind_phys), parameter :: eps1 = 1.0e-8
2396 
2397 ! --- inputs:
2398  integer, intent(in) :: nlay, nlp1
2399 
2400  real (kind=kind_phys), dimension(nlay,ngptsw), intent(in) :: &
2401  & taug, taur
2402  real (kind=kind_phys), dimension(nlay,nbdsw), intent(in) :: &
2403  & taucw, ssacw, asycw, tauae, ssaae, asyae
2404 
2405  real (kind=kind_phys), dimension(ngptsw), intent(in) :: sfluxzen
2406  real (kind=kind_phys), dimension(nlay), intent(in) :: cldfrc
2407 
2408  real (kind=kind_phys), dimension(2), intent(in) :: albbm, albdf
2409 
2410  real (kind=kind_phys), intent(in) :: cosz, sntz, cf1, cf0, ssolar
2411 
2412 ! --- outputs:
2413  real (kind=kind_phys), dimension(nlp1,nbdsw), intent(out) :: &
2414  & fxupc, fxdnc, fxup0, fxdn0
2415 
2416  real (kind=kind_phys), dimension(2), intent(out) :: sfbmc, sfdfc, &
2417  & sfbm0, sfdf0
2418 
2419  real (kind=kind_phys), intent(out) :: suvbfc, suvbf0, ftoadc, &
2420  & ftoauc, ftoau0, fsfcuc, fsfcu0, fsfcdc, fsfcd0
2421 
2422 ! --- locals:
2423  real (kind=kind_phys), dimension(nlay) :: ztaus, zssas, zasys, &
2424  & zldbt0
2425 
2426  real (kind=kind_phys), dimension(nlp1) :: zrefb, zrefd, ztrab, &
2427  & ztrad, ztdbt, zldbt, zfu, zfd
2428 
2429  real (kind=kind_phys) :: ztau1, zssa1, zasy1, ztau0, zssa0, &
2430  & zasy0, zasy3, zssaw, zasyw, zgam1, zgam2, zgam3, zgam4, &
2431  & zc0, zc1, za1, za2, zb1, zb2, zrk, zrk2, zrp, zrp1, zrm1, &
2432  & zrpp, zrkg1, zrkg3, zrkg4, zexp1, zexm1, zexp2, zexm2, &
2433  & zexp3, zexp4, zden1, ze1r45, ftind, zsolar, zrefb1, &
2434  & zrefd1, ztrab1, ztrad1, ztdbt0, zr1, zr2, zr3, zr4, zr5, &
2435  & zt1, zt2, zt3, zf1, zf2
2436 
2437  integer :: ib, ibd, jb, jg, k, kp, itind
2438 !
2439 !===> ... begin here
2440 
2442  do ib = 1, nbdsw
2443  do k = 1, nlp1
2444  fxdnc(k,ib) = f_zero
2445  fxupc(k,ib) = f_zero
2446  fxdn0(k,ib) = f_zero
2447  fxup0(k,ib) = f_zero
2448  enddo
2449  enddo
2450 
2451  ftoadc = f_zero
2452  ftoauc = f_zero
2453  ftoau0 = f_zero
2454  fsfcuc = f_zero
2455  fsfcu0 = f_zero
2456  fsfcdc = f_zero
2457  fsfcd0 = f_zero
2458 
2459 !! --- ... uv-b surface downward fluxes
2460  suvbfc = f_zero
2461  suvbf0 = f_zero
2462 
2463 !! --- ... output surface flux components
2464  sfbmc(1) = f_zero
2465  sfbmc(2) = f_zero
2466  sfdfc(1) = f_zero
2467  sfdfc(2) = f_zero
2468  sfbm0(1) = f_zero
2469  sfbm0(2) = f_zero
2470  sfdf0(1) = f_zero
2471  sfdf0(2) = f_zero
2472 
2473 ! --- ... loop over all g-points in each band
2474 
2475  lab_do_jg : do jg = 1, ngptsw
2476 
2477  jb = ngb(jg)
2478  ib = jb + 1 - nblow
2479  ibd = idxsfc(jb)
2480 
2481  zsolar = ssolar * sfluxzen(jg)
2482 
2483 ! --- ... set up toa direct beam and surface values (beam and diff)
2484 
2485  ztdbt(nlp1) = f_one
2486  ztdbt0 = f_one
2487 
2488  zldbt(1) = f_zero
2489  if (ibd /= 0) then
2490  zrefb(1) = albbm(ibd)
2491  zrefd(1) = albdf(ibd)
2492  else
2493  zrefb(1) = 0.5 * (albbm(1) + albbm(2))
2494  zrefd(1) = 0.5 * (albdf(1) + albdf(2))
2495  endif
2496  ztrab(1) = f_zero
2497  ztrad(1) = f_zero
2498 
2509 
2510  do k = nlay, 1, -1
2511  kp = k + 1
2512 
2513  ztau0 = max( ftiny, taur(k,jg)+taug(k,jg)+tauae(k,ib) )
2514  zssa0 = taur(k,jg) + tauae(k,ib)*ssaae(k,ib)
2515  zasy0 = asyae(k,ib)*ssaae(k,ib)*tauae(k,ib)
2516  zssaw = min( oneminus, zssa0 / ztau0 )
2517  zasyw = zasy0 / max( ftiny, zssa0 )
2518 
2519 ! --- ... saving clear-sky quantities for later total-sky usage
2520  ztaus(k) = ztau0
2521  zssas(k) = zssa0
2522  zasys(k) = zasy0
2523 
2524 ! --- ... delta scaling for clear-sky condition
2525  za1 = zasyw * zasyw
2526  za2 = zssaw * za1
2527 
2528  ztau1 = (f_one - za2) * ztau0
2529  zssa1 = (zssaw - za2) / (f_one - za2)
2530 !org zasy1 = (zasyw - za1) / (f_one - za1) ! this line is replaced by the next
2531  zasy1 = zasyw / (f_one + zasyw) ! to reduce truncation error
2532  zasy3 = 0.75 * zasy1
2533 
2534 ! --- ... general two-stream expressions
2535  if ( iswmode == 1 ) then
2536  zgam1 = 1.75 - zssa1 * (f_one + zasy3)
2537  zgam2 =-0.25 + zssa1 * (f_one - zasy3)
2538  zgam3 = 0.5 - zasy3 * cosz
2539  elseif ( iswmode == 2 ) then ! pifm
2540  zgam1 = 2.0 - zssa1 * (1.25 + zasy3)
2541  zgam2 = 0.75* zssa1 * (f_one- zasy1)
2542  zgam3 = 0.5 - zasy3 * cosz
2543  elseif ( iswmode == 3 ) then ! discrete ordinates
2544  zgam1 = zsr3 * (2.0 - zssa1 * (1.0 + zasy1)) * 0.5
2545  zgam2 = zsr3 * zssa1 * (1.0 - zasy1) * 0.5
2546  zgam3 = (1.0 - zsr3 * zasy1 * cosz) * 0.5
2547  endif
2548  zgam4 = f_one - zgam3
2549 
2550 ! --- ... compute homogeneous reflectance and transmittance
2551 
2552  if ( zssaw >= zcrit ) then ! for conservative scattering
2553  za1 = zgam1 * cosz - zgam3
2554  za2 = zgam1 * ztau1
2555 
2556 ! --- ... use exponential lookup table for transmittance, or expansion
2557 ! of exponential for low optical depth
2558 
2559  zb1 = min( ztau1*sntz , 500.0 )
2560  if ( zb1 <= od_lo ) then
2561  zb2 = f_one - zb1 + 0.5*zb1*zb1
2562  else
2563  ftind = zb1 / (bpade + zb1)
2564  itind = ftind*ntbmx + 0.5
2565  zb2 = exp_tbl(itind)
2566  endif
2567 
2568 ! ... collimated beam
2569  zrefb(kp) = max(f_zero, min(f_one, &
2570  & (za2 - za1*(f_one - zb2))/(f_one + za2) ))
2571  ztrab(kp) = max(f_zero, min(f_one, f_one-zrefb(kp) ))
2572 
2573 ! ... isotropic incidence
2574  zrefd(kp) = max(f_zero, min(f_one, za2/(f_one + za2) ))
2575  ztrad(kp) = max(f_zero, min(f_one, f_one-zrefd(kp) ))
2576 
2577  else ! for non-conservative scattering
2578  za1 = zgam1*zgam4 + zgam2*zgam3
2579  za2 = zgam1*zgam3 + zgam2*zgam4
2580  zrk = sqrt( (zgam1 - zgam2) * (zgam1 + zgam2) )
2581  zrk2= 2.0 * zrk
2582 
2583  zrp = zrk * cosz
2584  zrp1 = f_one + zrp
2585  zrm1 = f_one - zrp
2586  zrpp = f_one - zrp*zrp
2587  zrkg1= zrk + zgam1
2588  zrkg3= zrk * zgam3
2589  zrkg4= zrk * zgam4
2590 
2591  zr1 = zrm1 * (za2 + zrkg3)
2592  zr2 = zrp1 * (za2 - zrkg3)
2593  zr3 = zrk2 * (zgam3 - za2*cosz)
2594  zr4 = zrpp * zrkg1
2595  zr5 = zrpp * (zrk - zgam1)
2596 
2597  zt1 = zrp1 * (za1 + zrkg4)
2598  zt2 = zrm1 * (za1 - zrkg4)
2599  zt3 = zrk2 * (zgam4 + za1*cosz)
2600 
2601 ! --- ... use exponential lookup table for transmittance, or expansion
2602 ! of exponential for low optical depth
2603 
2604  zb1 = min( zrk*ztau1, 500.0 )
2605  if ( zb1 <= od_lo ) then
2606  zexm1 = f_one - zb1 + 0.5*zb1*zb1
2607  else
2608  ftind = zb1 / (bpade + zb1)
2609  itind = ftind*ntbmx + 0.5
2610  zexm1 = exp_tbl(itind)
2611  endif
2612  zexp1 = f_one / zexm1
2613 
2614  zb2 = min( sntz*ztau1, 500.0 )
2615  if ( zb2 <= od_lo ) then
2616  zexm2 = f_one - zb2 + 0.5*zb2*zb2
2617  else
2618  ftind = zb2 / (bpade + zb2)
2619  itind = ftind*ntbmx + 0.5
2620  zexm2 = exp_tbl(itind)
2621  endif
2622  zexp2 = f_one / zexm2
2623  ze1r45 = zr4*zexp1 + zr5*zexm1
2624 
2625 ! ... collimated beam
2626  if (ze1r45>=-eps1 .and. ze1r45<=eps1) then
2627  zrefb(kp) = eps1
2628  ztrab(kp) = zexm2
2629  else
2630  zden1 = zssa1 / ze1r45
2631  zrefb(kp) = max(f_zero, min(f_one, &
2632  & (zr1*zexp1 - zr2*zexm1 - zr3*zexm2)*zden1 ))
2633  ztrab(kp) = max(f_zero, min(f_one, zexm2*(f_one &
2634  & - (zt1*zexp1 - zt2*zexm1 - zt3*zexp2)*zden1) ))
2635  endif
2636 
2637 ! ... diffuse beam
2638  zden1 = zr4 / (ze1r45 * zrkg1)
2639  zrefd(kp) = max(f_zero, min(f_one, &
2640  & zgam2*(zexp1 - zexm1)*zden1 ))
2641  ztrad(kp) = max(f_zero, min(f_one, zrk2*zden1 ))
2642  endif ! end if_zssaw_block
2643 
2644 ! --- ... direct beam transmittance. use exponential lookup table
2645 ! for transmittance, or expansion of exponential for low
2646 ! optical depth
2647 
2648  zr1 = ztau1 * sntz
2649  if ( zr1 <= od_lo ) then
2650  zexp3 = f_one - zr1 + 0.5*zr1*zr1
2651  else
2652  ftind = zr1 / (bpade + zr1)
2653  itind = max(0, min(ntbmx, int(0.5+ntbmx*ftind) ))
2654  zexp3 = exp_tbl(itind)
2655  endif
2656 
2657  ztdbt(k) = zexp3 * ztdbt(kp)
2658  zldbt(kp) = zexp3
2659 
2660 ! --- ... pre-delta-scaling clear and cloudy direct beam transmittance
2661 ! (must use 'orig', unscaled cloud optical depth)
2662 
2663  zr1 = ztau0 * sntz
2664  if ( zr1 <= od_lo ) then
2665  zexp4 = f_one - zr1 + 0.5*zr1*zr1
2666  else
2667  ftind = zr1 / (bpade + zr1)
2668  itind = max(0, min(ntbmx, int(0.5+ntbmx*ftind) ))
2669  zexp4 = exp_tbl(itind)
2670  endif
2671 
2672  zldbt0(k) = zexp4
2673  ztdbt0 = zexp4 * ztdbt0
2674  enddo ! end do_k_loop
2675 
2676  call vrtqdr &
2677 ! --- inputs:
2678  & ( zrefb,zrefd,ztrab,ztrad,zldbt,ztdbt, &
2679  & nlay, nlp1, &
2680 ! --- outputs:
2681  & zfu, zfd &
2682  & )
2683 
2684 ! --- ... compute upward and downward fluxes at levels
2685  do k = 1, nlp1
2686  fxup0(k,ib) = fxup0(k,ib) + zsolar*zfu(k)
2687  fxdn0(k,ib) = fxdn0(k,ib) + zsolar*zfd(k)
2688  enddo
2689 
2690 !! --- ... surface downward beam/diffused flux components
2691  zb1 = zsolar*ztdbt0
2692  zb2 = zsolar*(zfd(1) - ztdbt0)
2693 
2694  if (ibd /= 0) then
2695  sfbm0(ibd) = sfbm0(ibd) + zb1
2696  sfdf0(ibd) = sfdf0(ibd) + zb2
2697  else
2698  zf1 = 0.5 * zb1
2699  zf2 = 0.5 * zb2
2700  sfbm0(1) = sfbm0(1) + zf1
2701  sfdf0(1) = sfdf0(1) + zf2
2702  sfbm0(2) = sfbm0(2) + zf1
2703  sfdf0(2) = sfdf0(2) + zf2
2704  endif
2705 ! sfbm0(ibd) = sfbm0(ibd) + zsolar*ztdbt0
2706 ! sfdf0(ibd) = sfdf0(ibd) + zsolar*(zfd(1) - ztdbt0)
2707 
2717 
2718  if ( cf1 > eps ) then
2719 
2720 ! --- ... set up toa direct beam and surface values (beam and diff)
2721  ztdbt0 = f_one
2722  zldbt(1) = f_zero
2723 
2724  do k = nlay, 1, -1
2725  kp = k + 1
2726  zc0 = f_one - cldfrc(k)
2727  zc1 = cldfrc(k)
2728  if ( zc1 > ftiny ) then ! it is a cloudy-layer
2729 
2730  ztau0 = ztaus(k) + taucw(k,ib)
2731  zssa0 = zssas(k) + ssacw(k,ib)
2732  zasy0 = zasys(k) + asycw(k,ib)
2733  zssaw = min(oneminus, zssa0 / ztau0)
2734  zasyw = zasy0 / max(ftiny, zssa0)
2735 
2736 ! --- ... delta scaling for total-sky condition
2737  za1 = zasyw * zasyw
2738  za2 = zssaw * za1
2739 
2740  ztau1 = (f_one - za2) * ztau0
2741  zssa1 = (zssaw - za2) / (f_one - za2)
2742 !org zasy1 = (zasyw - za1) / (f_one - za1)
2743  zasy1 = zasyw / (f_one + zasyw)
2744  zasy3 = 0.75 * zasy1
2745 
2746 ! --- ... general two-stream expressions
2747  if ( iswmode == 1 ) then
2748  zgam1 = 1.75 - zssa1 * (f_one + zasy3)
2749  zgam2 =-0.25 + zssa1 * (f_one - zasy3)
2750  zgam3 = 0.5 - zasy3 * cosz
2751  elseif ( iswmode == 2 ) then ! pifm
2752  zgam1 = 2.0 - zssa1 * (1.25 + zasy3)
2753  zgam2 = 0.75* zssa1 * (f_one- zasy1)
2754  zgam3 = 0.5 - zasy3 * cosz
2755  elseif ( iswmode == 3 ) then ! discrete ordinates
2756  zgam1 = zsr3 * (2.0 - zssa1 * (1.0 + zasy1)) * 0.5
2757  zgam2 = zsr3 * zssa1 * (1.0 - zasy1) * 0.5
2758  zgam3 = (1.0 - zsr3 * zasy1 * cosz) * 0.5
2759  endif
2760  zgam4 = f_one - zgam3
2761 
2762  zrefb1 = zrefb(kp)
2763  zrefd1 = zrefd(kp)
2764  ztrab1 = ztrab(kp)
2765  ztrad1 = ztrad(kp)
2766 
2767 ! --- ... compute homogeneous reflectance and transmittance
2768 
2769  if ( zssaw >= zcrit ) then ! for conservative scattering
2770  za1 = zgam1 * cosz - zgam3
2771  za2 = zgam1 * ztau1
2772 
2773 ! --- ... use exponential lookup table for transmittance, or expansion
2774 ! of exponential for low optical depth
2775 
2776  zb1 = min( ztau1*sntz , 500.0 )
2777  if ( zb1 <= od_lo ) then
2778  zb2 = f_one - zb1 + 0.5*zb1*zb1
2779  else
2780  ftind = zb1 / (bpade + zb1)
2781  itind = ftind*ntbmx + 0.5
2782  zb2 = exp_tbl(itind)
2783  endif
2784 
2785 ! ... collimated beam
2786  zrefb(kp) = max(f_zero, min(f_one, &
2787  & (za2 - za1*(f_one - zb2))/(f_one + za2) ))
2788  ztrab(kp) = max(f_zero, min(f_one, f_one-zrefb(kp)))
2789 
2790 ! ... isotropic incidence
2791  zrefd(kp) = max(f_zero, min(f_one, za2 / (f_one+za2) ))
2792  ztrad(kp) = max(f_zero, min(f_one, f_one - zrefd(kp) ))
2793 
2794  else ! for non-conservative scattering
2795  za1 = zgam1*zgam4 + zgam2*zgam3
2796  za2 = zgam1*zgam3 + zgam2*zgam4
2797  zrk = sqrt( (zgam1 - zgam2) * (zgam1 + zgam2) )
2798  zrk2= 2.0 * zrk
2799 
2800  zrp = zrk * cosz
2801  zrp1 = f_one + zrp
2802  zrm1 = f_one - zrp
2803  zrpp = f_one - zrp*zrp
2804  zrkg1= zrk + zgam1
2805  zrkg3= zrk * zgam3
2806  zrkg4= zrk * zgam4
2807 
2808  zr1 = zrm1 * (za2 + zrkg3)
2809  zr2 = zrp1 * (za2 - zrkg3)
2810  zr3 = zrk2 * (zgam3 - za2*cosz)
2811  zr4 = zrpp * zrkg1
2812  zr5 = zrpp * (zrk - zgam1)
2813 
2814  zt1 = zrp1 * (za1 + zrkg4)
2815  zt2 = zrm1 * (za1 - zrkg4)
2816  zt3 = zrk2 * (zgam4 + za1*cosz)
2817 
2818 ! --- ... use exponential lookup table for transmittance, or expansion
2819 ! of exponential for low optical depth
2820 
2821  zb1 = min( zrk*ztau1, 500.0 )
2822  if ( zb1 <= od_lo ) then
2823  zexm1 = f_one - zb1 + 0.5*zb1*zb1
2824  else
2825  ftind = zb1 / (bpade + zb1)
2826  itind = ftind*ntbmx + 0.5
2827  zexm1 = exp_tbl(itind)
2828  endif
2829  zexp1 = f_one / zexm1
2830 
2831  zb2 = min( ztau1*sntz, 500.0 )
2832  if ( zb2 <= od_lo ) then
2833  zexm2 = f_one - zb2 + 0.5*zb2*zb2
2834  else
2835  ftind = zb2 / (bpade + zb2)
2836  itind = ftind*ntbmx + 0.5
2837  zexm2 = exp_tbl(itind)
2838  endif
2839  zexp2 = f_one / zexm2
2840  ze1r45 = zr4*zexp1 + zr5*zexm1
2841 
2842 ! ... collimated beam
2843  if ( ze1r45>=-eps1 .and. ze1r45<=eps1 ) then
2844  zrefb(kp) = eps1
2845  ztrab(kp) = zexm2
2846  else
2847  zden1 = zssa1 / ze1r45
2848  zrefb(kp) = max(f_zero, min(f_one, &
2849  & (zr1*zexp1-zr2*zexm1-zr3*zexm2)*zden1 ))
2850  ztrab(kp) = max(f_zero, min(f_one, zexm2*(f_one - &
2851  & (zt1*zexp1-zt2*zexm1-zt3*zexp2)*zden1) ))
2852  endif
2853 
2854 ! ... diffuse beam
2855  zden1 = zr4 / (ze1r45 * zrkg1)
2856  zrefd(kp) = max(f_zero, min(f_one, &
2857  & zgam2*(zexp1 - zexm1)*zden1 ))
2858  ztrad(kp) = max(f_zero, min(f_one, zrk2*zden1 ))
2859  endif ! end if_zssaw_block
2860 
2861 ! --- ... combine clear and cloudy contributions for total sky
2862 ! and calculate direct beam transmittances
2863 
2864  zrefb(kp) = zc0*zrefb1 + zc1*zrefb(kp)
2865  zrefd(kp) = zc0*zrefd1 + zc1*zrefd(kp)
2866  ztrab(kp) = zc0*ztrab1 + zc1*ztrab(kp)
2867  ztrad(kp) = zc0*ztrad1 + zc1*ztrad(kp)
2868 
2869 ! --- ... direct beam transmittance. use exponential lookup table
2870 ! for transmittance, or expansion of exponential for low
2871 ! optical depth
2872 
2873  zr1 = ztau1 * sntz
2874  if ( zr1 <= od_lo ) then
2875  zexp3 = f_one - zr1 + 0.5*zr1*zr1
2876  else
2877  ftind = zr1 / (bpade + zr1)
2878  itind = max(0, min(ntbmx, int(0.5+ntbmx*ftind) ))
2879  zexp3 = exp_tbl(itind)
2880  endif
2881 
2882  zldbt(kp) = zc0*zldbt(kp) + zc1*zexp3
2883  ztdbt(k) = zldbt(kp) * ztdbt(kp)
2884 
2885 ! --- ... pre-delta-scaling clear and cloudy direct beam transmittance
2886 ! (must use 'orig', unscaled cloud optical depth)
2887 
2888  zr1 = ztau0 * sntz
2889  if ( zr1 <= od_lo ) then
2890  zexp4 = f_one - zr1 + 0.5*zr1*zr1
2891  else
2892  ftind = zr1 / (bpade + zr1)
2893  itind = max(0, min(ntbmx, int(0.5+ntbmx*ftind) ))
2894  zexp4 = exp_tbl(itind)
2895  endif
2896 
2897  ztdbt0 = (zc0*zldbt0(k) + zc1*zexp4) * ztdbt0
2898 
2899  else ! if_zc1_block --- it is a clear layer
2900 
2901 ! --- ... direct beam transmittance
2902  ztdbt(k) = zldbt(kp) * ztdbt(kp)
2903 
2904 ! --- ... pre-delta-scaling clear and cloudy direct beam transmittance
2905  ztdbt0 = zldbt0(k) * ztdbt0
2906 
2907  endif ! end if_zc1_block
2908  enddo ! end do_k_loop
2909 
2910 ! --- ... perform vertical quadrature
2911 
2912  call vrtqdr &
2913 ! --- inputs:
2914  & ( zrefb,zrefd,ztrab,ztrad,zldbt,ztdbt, &
2915  & nlay, nlp1, &
2916 ! --- outputs:
2917  & zfu, zfd &
2918  & )
2919 
2920 ! --- ... compute upward and downward fluxes at levels
2921  do k = 1, nlp1
2922  fxupc(k,ib) = fxupc(k,ib) + zsolar*zfu(k)
2923  fxdnc(k,ib) = fxdnc(k,ib) + zsolar*zfd(k)
2924  enddo
2925 
2927 ! --- ... surface downward beam/diffused flux components
2928  zb1 = zsolar*ztdbt0
2929  zb2 = zsolar*(zfd(1) - ztdbt0)
2930 
2931  if (ibd /= 0) then
2932  sfbmc(ibd) = sfbmc(ibd) + zb1
2933  sfdfc(ibd) = sfdfc(ibd) + zb2
2934  else
2935  zf1 = 0.5 * zb1
2936  zf2 = 0.5 * zb2
2937  sfbmc(1) = sfbmc(1) + zf1
2938  sfdfc(1) = sfdfc(1) + zf2
2939  sfbmc(2) = sfbmc(2) + zf1
2940  sfdfc(2) = sfdfc(2) + zf2
2941  endif
2942 ! sfbmc(ibd) = sfbmc(ibd) + zsolar*ztdbt0
2943 ! sfdfc(ibd) = sfdfc(ibd) + zsolar*(zfd(1) - ztdbt0)
2944 
2945  endif ! end if_cf1_block
2946 
2947  enddo lab_do_jg
2948 
2949 ! --- ... end of g-point loop
2950 
2951  do ib = 1, nbdsw
2952  ftoadc = ftoadc + fxdn0(nlp1,ib)
2953  ftoau0 = ftoau0 + fxup0(nlp1,ib)
2954  fsfcu0 = fsfcu0 + fxup0(1,ib)
2955  fsfcd0 = fsfcd0 + fxdn0(1,ib)
2956  enddo
2957 
2958 !! --- ... uv-b surface downward flux
2959  ibd = nuvb - nblow + 1
2960  suvbf0 = fxdn0(1,ibd)
2961 
2962  if ( cf1 <= eps ) then ! clear column, set total-sky=clear-sky fluxes
2963  do ib = 1, nbdsw
2964  do k = 1, nlp1
2965  fxupc(k,ib) = fxup0(k,ib)
2966  fxdnc(k,ib) = fxdn0(k,ib)
2967  enddo
2968  enddo
2969 
2970  ftoauc = ftoau0
2971  fsfcuc = fsfcu0
2972  fsfcdc = fsfcd0
2973 
2974 !! --- ... surface downward beam/diffused flux components
2975  sfbmc(1) = sfbm0(1)
2976  sfdfc(1) = sfdf0(1)
2977  sfbmc(2) = sfbm0(2)
2978  sfdfc(2) = sfdf0(2)
2979 
2980 !! --- ... uv-b surface downward flux
2981  suvbfc = suvbf0
2982  else ! cloudy column, compute total-sky fluxes
2983  do ib = 1, nbdsw
2984  do k = 1, nlp1
2985  fxupc(k,ib) = cf1*fxupc(k,ib) + cf0*fxup0(k,ib)
2986  fxdnc(k,ib) = cf1*fxdnc(k,ib) + cf0*fxdn0(k,ib)
2987  enddo
2988  enddo
2989 
2990  do ib = 1, nbdsw
2991  ftoauc = ftoauc + fxupc(nlp1,ib)
2992  fsfcuc = fsfcuc + fxupc(1,ib)
2993  fsfcdc = fsfcdc + fxdnc(1,ib)
2994  enddo
2995 
2996 !! --- ... uv-b surface downward flux
2997  suvbfc = fxdnc(1,ibd)
2998 
2999 !! --- ... surface downward beam/diffused flux components
3000  sfbmc(1) = cf1*sfbmc(1) + cf0*sfbm0(1)
3001  sfbmc(2) = cf1*sfbmc(2) + cf0*sfbm0(2)
3002  sfdfc(1) = cf1*sfdfc(1) + cf0*sfdf0(1)
3003  sfdfc(2) = cf1*sfdfc(2) + cf0*sfdf0(2)
3004  endif ! end if_cf1_block
3005 
3006  return
3007 !...................................
3008  end subroutine spcvrtc
3009 !-----------------------------------
3011 
3051 !-----------------------------------
3052  subroutine spcvrtm &
3053  & ( ssolar,cosz,sntz,albbm,albdf,sfluxzen,cldfmc, & ! --- inputs
3054  & cf1,cf0,taug,taur,tauae,ssaae,asyae,taucw,ssacw,asycw, &
3055  & nlay, nlp1, &
3056  & fxupc,fxdnc,fxup0,fxdn0, & ! --- outputs
3057  & ftoauc,ftoau0,ftoadc,fsfcuc,fsfcu0,fsfcdc,fsfcd0, &
3058  & sfbmc,sfdfc,sfbm0,sfdf0,suvbfc,suvbf0 &
3059  & )
3061 ! =================== program usage description =================== !
3062 ! !
3063 ! purpose: computes the shortwave radiative fluxes using two-stream !
3064 ! method of h. barker and mcica, the monte-carlo independent!
3065 ! column approximation, for the representation of sub-grid !
3066 ! cloud variability (i.e. cloud overlap). !
3067 ! !
3068 ! subprograms called: vrtqdr !
3069 ! !
3070 ! ==================== defination of variables ==================== !
3071 ! !
3072 ! inputs: size !
3073 ! ssolar - real, incoming solar flux at top 1 !
3074 ! cosz - real, cosine solar zenith angle 1 !
3075 ! sntz - real, secant solar zenith angle 1 !
3076 ! albbm - real, surface albedo for direct beam radiation 2 !
3077 ! albdf - real, surface albedo for diffused radiation 2 !
3078 ! sfluxzen- real, spectral distribution of incoming solar flux ngptsw!
3079 ! cldfmc - real, layer cloud fraction for g-point nlay*ngptsw!
3080 ! cf1 - real, >0: cloudy sky, otherwise: clear sky 1 !
3081 ! cf0 - real, =1-cf1 1 !
3082 ! taug - real, spectral optical depth for gases nlay*ngptsw!
3083 ! taur - real, optical depth for rayleigh scattering nlay*ngptsw!
3084 ! tauae - real, aerosols optical depth nlay*nbdsw !
3085 ! ssaae - real, aerosols single scattering albedo nlay*nbdsw !
3086 ! asyae - real, aerosols asymmetry factor nlay*nbdsw !
3087 ! taucw - real, weighted cloud optical depth nlay*nbdsw !
3088 ! ssacw - real, weighted cloud single scat albedo nlay*nbdsw !
3089 ! asycw - real, weighted cloud asymmetry factor nlay*nbdsw !
3090 ! nlay,nlp1 - integer, number of layers/levels 1 !
3091 ! !
3092 ! output variables: !
3093 ! fxupc - real, tot sky upward flux nlp1*nbdsw !
3094 ! fxdnc - real, tot sky downward flux nlp1*nbdsw !
3095 ! fxup0 - real, clr sky upward flux nlp1*nbdsw !
3096 ! fxdn0 - real, clr sky downward flux nlp1*nbdsw !
3097 ! ftoauc - real, tot sky toa upwd flux 1 !
3098 ! ftoau0 - real, clr sky toa upwd flux 1 !
3099 ! ftoadc - real, toa downward (incoming) solar flux 1 !
3100 ! fsfcuc - real, tot sky sfc upwd flux 1 !
3101 ! fsfcu0 - real, clr sky sfc upwd flux 1 !
3102 ! fsfcdc - real, tot sky sfc dnwd flux 1 !
3103 ! fsfcd0 - real, clr sky sfc dnwd flux 1 !
3104 ! sfbmc - real, tot sky sfc dnwd beam flux (nir/uv+vis) 2 !
3105 ! sfdfc - real, tot sky sfc dnwd diff flux (nir/uv+vis) 2 !
3106 ! sfbm0 - real, clr sky sfc dnwd beam flux (nir/uv+vis) 2 !
3107 ! sfdf0 - real, clr sky sfc dnwd diff flux (nir/uv+vis) 2 !
3108 ! suvbfc - real, tot sky sfc dnwd uv-b flux 1 !
3109 ! suvbf0 - real, clr sky sfc dnwd uv-b flux 1 !
3110 ! !
3111 ! internal variables: !
3112 ! zrefb - real, direct beam reflectivity for clear/cloudy nlp1 !
3113 ! zrefd - real, diffuse reflectivity for clear/cloudy nlp1 !
3114 ! ztrab - real, direct beam transmissivity for clear/cloudy nlp1 !
3115 ! ztrad - real, diffuse transmissivity for clear/cloudy nlp1 !
3116 ! zldbt - real, layer beam transmittance for clear/cloudy nlp1 !
3117 ! ztdbt - real, lev total beam transmittance for clr/cld nlp1 !
3118 ! !
3119 ! control parameters in module "physparam" !
3120 ! iswmode - control flag for 2-stream transfer schemes !
3121 ! = 1 delta-eddington (joseph et al., 1976) !
3122 ! = 2 pifm (zdunkowski et al., 1980) !
3123 ! = 3 discrete ordinates (liou, 1973) !
3124 ! !
3125 ! ******************************************************************* !
3126 ! original code description !
3127 ! !
3128 ! method: !
3129 ! ------- !
3130 ! standard delta-eddington, p.i.f.m., or d.o.m. layer calculations. !
3131 ! kmodts = 1 eddington (joseph et al., 1976) !
3132 ! = 2 pifm (zdunkowski et al., 1980) !
3133 ! = 3 discrete ordinates (liou, 1973) !
3134 ! !
3135 ! modifications: !
3136 ! -------------- !
3137 ! original: h. barker !
3138 ! revision: merge with rrtmg_sw: j.-j.morcrette, ecmwf, feb 2003 !
3139 ! revision: add adjustment for earth/sun distance:mjiacono,aer,oct2003!
3140 ! revision: bug fix for use of palbp and palbd: mjiacono, aer, nov2003!
3141 ! revision: bug fix to apply delta scaling to clear sky: aer, dec2004 !
3142 ! revision: code modified so that delta scaling is not done in cloudy !
3143 ! profiles if routine cldprop is used; delta scaling can be !
3144 ! applied by swithcing code below if cldprop is not used to !
3145 ! get cloud properties. aer, jan 2005 !
3146 ! revision: uniform formatting for rrtmg: mjiacono, aer, jul 2006 !
3147 ! revision: use exponential lookup table for transmittance: mjiacono, !
3148 ! aer, aug 2007 !
3149 ! !
3150 ! ******************************************************************* !
3151 ! ====================== end of description block ================= !
3152 
3153 ! --- constant parameters:
3154  real (kind=kind_phys), parameter :: zcrit = 0.9999995 ! thresold for conservative scattering
3155  real (kind=kind_phys), parameter :: zsr3 = sqrt(3.0)
3156  real (kind=kind_phys), parameter :: od_lo = 0.06
3157  real (kind=kind_phys), parameter :: eps1 = 1.0e-8
3158 
3159 ! --- inputs:
3160  integer, intent(in) :: nlay, nlp1
3161 
3162  real (kind=kind_phys), dimension(nlay,ngptsw), intent(in) :: &
3163  & taug, taur, cldfmc
3164  real (kind=kind_phys), dimension(nlay,nbdsw), intent(in) :: &
3165  & taucw, ssacw, asycw, tauae, ssaae, asyae
3166 
3167  real (kind=kind_phys), dimension(ngptsw), intent(in) :: sfluxzen
3168 
3169  real (kind=kind_phys), dimension(2), intent(in) :: albbm, albdf
3170 
3171  real (kind=kind_phys), intent(in) :: cosz, sntz, cf1, cf0, ssolar
3172 
3173 ! --- outputs:
3174  real (kind=kind_phys), dimension(nlp1,nbdsw), intent(out) :: &
3175  & fxupc, fxdnc, fxup0, fxdn0
3176 
3177  real (kind=kind_phys), dimension(2), intent(out) :: sfbmc, sfdfc, &
3178  & sfbm0, sfdf0
3179 
3180  real (kind=kind_phys), intent(out) :: suvbfc, suvbf0, ftoadc, &
3181  & ftoauc, ftoau0, fsfcuc, fsfcu0, fsfcdc, fsfcd0
3182 
3183 ! --- locals:
3184  real (kind=kind_phys), dimension(nlay) :: ztaus, zssas, zasys, &
3185  & zldbt0
3186 
3187  real (kind=kind_phys), dimension(nlp1) :: zrefb, zrefd, ztrab, &
3188  & ztrad, ztdbt, zldbt, zfu, zfd
3189 
3190  real (kind=kind_phys) :: ztau1, zssa1, zasy1, ztau0, zssa0, &
3191  & zasy0, zasy3, zssaw, zasyw, zgam1, zgam2, zgam3, zgam4, &
3192  & za1, za2, zb1, zb2, zrk, zrk2, zrp, zrp1, zrm1, zrpp, &
3193  & zrkg1, zrkg3, zrkg4, zexp1, zexm1, zexp2, zexm2, zden1, &
3194  & zexp3, zexp4, ze1r45, ftind, zsolar, ztdbt0, zr1, zr2, &
3195  & zr3, zr4, zr5, zt1, zt2, zt3, zf1, zf2
3196 
3197  integer :: ib, ibd, jb, jg, k, kp, itind
3198 !
3199 !===> ... begin here
3200 !
3202 
3203  do ib = 1, nbdsw
3204  do k = 1, nlp1
3205  fxdnc(k,ib) = f_zero
3206  fxupc(k,ib) = f_zero
3207  fxdn0(k,ib) = f_zero
3208  fxup0(k,ib) = f_zero
3209  enddo
3210  enddo
3211 
3212  ftoadc = f_zero
3213  ftoauc = f_zero
3214  ftoau0 = f_zero
3215  fsfcuc = f_zero
3216  fsfcu0 = f_zero
3217  fsfcdc = f_zero
3218  fsfcd0 = f_zero
3219 
3220 !! --- ... uv-b surface downward fluxes
3221  suvbfc = f_zero
3222  suvbf0 = f_zero
3223 
3224 !! --- ... output surface flux components
3225  sfbmc(1) = f_zero
3226  sfbmc(2) = f_zero
3227  sfdfc(1) = f_zero
3228  sfdfc(2) = f_zero
3229  sfbm0(1) = f_zero
3230  sfbm0(2) = f_zero
3231  sfdf0(1) = f_zero
3232  sfdf0(2) = f_zero
3233 
3234 ! --- ... loop over all g-points in each band
3235 
3236  lab_do_jg : do jg = 1, ngptsw
3237 
3238  jb = ngb(jg)
3239  ib = jb + 1 - nblow
3240  ibd = idxsfc(jb) ! spectral band index
3241 
3242  zsolar = ssolar * sfluxzen(jg)
3243 
3244 ! --- ... set up toa direct beam and surface values (beam and diff)
3245 
3246  ztdbt(nlp1) = f_one
3247  ztdbt0 = f_one
3248 
3249  zldbt(1) = f_zero
3250  if (ibd /= 0) then
3251  zrefb(1) = albbm(ibd)
3252  zrefd(1) = albdf(ibd)
3253  else
3254  zrefb(1) = 0.5 * (albbm(1) + albbm(2))
3255  zrefd(1) = 0.5 * (albdf(1) + albdf(2))
3256  endif
3257  ztrab(1) = f_zero
3258  ztrad(1) = f_zero
3259 
3269 
3270  do k = nlay, 1, -1
3271  kp = k + 1
3272 
3273  ztau0 = max( ftiny, taur(k,jg)+taug(k,jg)+tauae(k,ib) )
3274  zssa0 = taur(k,jg) + tauae(k,ib)*ssaae(k,ib)
3275  zasy0 = asyae(k,ib)*ssaae(k,ib)*tauae(k,ib)
3276  zssaw = min( oneminus, zssa0 / ztau0 )
3277  zasyw = zasy0 / max( ftiny, zssa0 )
3278 
3279 ! --- ... saving clear-sky quantities for later total-sky usage
3280  ztaus(k) = ztau0
3281  zssas(k) = zssa0
3282  zasys(k) = zasy0
3283 
3284 ! --- ... delta scaling for clear-sky condition
3285  za1 = zasyw * zasyw
3286  za2 = zssaw * za1
3287 
3288  ztau1 = (f_one - za2) * ztau0
3289  zssa1 = (zssaw - za2) / (f_one - za2)
3290 !org zasy1 = (zasyw - za1) / (f_one - za1) ! this line is replaced by the next
3291  zasy1 = zasyw / (f_one + zasyw) ! to reduce truncation error
3292  zasy3 = 0.75 * zasy1
3293 
3294 ! --- ... general two-stream expressions
3295  if ( iswmode == 1 ) then
3296  zgam1 = 1.75 - zssa1 * (f_one + zasy3)
3297  zgam2 =-0.25 + zssa1 * (f_one - zasy3)
3298  zgam3 = 0.5 - zasy3 * cosz
3299  elseif ( iswmode == 2 ) then ! pifm
3300  zgam1 = 2.0 - zssa1 * (1.25 + zasy3)
3301  zgam2 = 0.75* zssa1 * (f_one- zasy1)
3302  zgam3 = 0.5 - zasy3 * cosz
3303  elseif ( iswmode == 3 ) then ! discrete ordinates
3304  zgam1 = zsr3 * (2.0 - zssa1 * (1.0 + zasy1)) * 0.5
3305  zgam2 = zsr3 * zssa1 * (1.0 - zasy1) * 0.5
3306  zgam3 = (1.0 - zsr3 * zasy1 * cosz) * 0.5
3307  endif
3308  zgam4 = f_one - zgam3
3309 
3310 ! --- ... compute homogeneous reflectance and transmittance
3311 
3312  if ( zssaw >= zcrit ) then ! for conservative scattering
3313  za1 = zgam1 * cosz - zgam3
3314  za2 = zgam1 * ztau1
3315 
3316 ! --- ... use exponential lookup table for transmittance, or expansion
3317 ! of exponential for low optical depth
3318 
3319  zb1 = min( ztau1*sntz , 500.0 )
3320  if ( zb1 <= od_lo ) then
3321  zb2 = f_one - zb1 + 0.5*zb1*zb1
3322  else
3323  ftind = zb1 / (bpade + zb1)
3324  itind = ftind*ntbmx + 0.5
3325  zb2 = exp_tbl(itind)
3326  endif
3327 
3328 ! ... collimated beam
3329  zrefb(kp) = max(f_zero, min(f_one, &
3330  & (za2 - za1*(f_one - zb2))/(f_one + za2) ))
3331  ztrab(kp) = max(f_zero, min(f_one, f_one-zrefb(kp) ))
3332 
3333 ! ... isotropic incidence
3334  zrefd(kp) = max(f_zero, min(f_one, za2/(f_one + za2) ))
3335  ztrad(kp) = max(f_zero, min(f_one, f_one-zrefd(kp) ))
3336 
3337  else ! for non-conservative scattering
3338  za1 = zgam1*zgam4 + zgam2*zgam3
3339  za2 = zgam1*zgam3 + zgam2*zgam4
3340  zrk = sqrt( (zgam1 - zgam2) * (zgam1 + zgam2) )
3341  zrk2= 2.0 * zrk
3342 
3343  zrp = zrk * cosz
3344  zrp1 = f_one + zrp
3345  zrm1 = f_one - zrp
3346  zrpp = f_one - zrp*zrp
3347  zrkg1= zrk + zgam1
3348  zrkg3= zrk * zgam3
3349  zrkg4= zrk * zgam4
3350 
3351  zr1 = zrm1 * (za2 + zrkg3)
3352  zr2 = zrp1 * (za2 - zrkg3)
3353  zr3 = zrk2 * (zgam3 - za2*cosz)
3354  zr4 = zrpp * zrkg1
3355  zr5 = zrpp * (zrk - zgam1)
3356 
3357  zt1 = zrp1 * (za1 + zrkg4)
3358  zt2 = zrm1 * (za1 - zrkg4)
3359  zt3 = zrk2 * (zgam4 + za1*cosz)
3360 
3361 ! --- ... use exponential lookup table for transmittance, or expansion
3362 ! of exponential for low optical depth
3363 
3364  zb1 = min( zrk*ztau1, 500.0 )
3365  if ( zb1 <= od_lo ) then
3366  zexm1 = f_one - zb1 + 0.5*zb1*zb1
3367  else
3368  ftind = zb1 / (bpade + zb1)
3369  itind = ftind*ntbmx + 0.5
3370  zexm1 = exp_tbl(itind)
3371  endif
3372  zexp1 = f_one / zexm1
3373 
3374  zb2 = min( sntz*ztau1, 500.0 )
3375  if ( zb2 <= od_lo ) then
3376  zexm2 = f_one - zb2 + 0.5*zb2*zb2
3377  else
3378  ftind = zb2 / (bpade + zb2)
3379  itind = ftind*ntbmx + 0.5
3380  zexm2 = exp_tbl(itind)
3381  endif
3382  zexp2 = f_one / zexm2
3383  ze1r45 = zr4*zexp1 + zr5*zexm1
3384 
3385 ! ... collimated beam
3386  if (ze1r45>=-eps1 .and. ze1r45<=eps1) then
3387  zrefb(kp) = eps1
3388  ztrab(kp) = zexm2
3389  else
3390  zden1 = zssa1 / ze1r45
3391  zrefb(kp) = max(f_zero, min(f_one, &
3392  & (zr1*zexp1 - zr2*zexm1 - zr3*zexm2)*zden1 ))
3393  ztrab(kp) = max(f_zero, min(f_one, zexm2*(f_one &
3394  & - (zt1*zexp1 - zt2*zexm1 - zt3*zexp2)*zden1) ))
3395  endif
3396 
3397 ! ... diffuse beam
3398  zden1 = zr4 / (ze1r45 * zrkg1)
3399  zrefd(kp) = max(f_zero, min(f_one, &
3400  & zgam2*(zexp1 - zexm1)*zden1 ))
3401  ztrad(kp) = max(f_zero, min(f_one, zrk2*zden1 ))
3402  endif ! end if_zssaw_block
3403 
3404 ! --- ... direct beam transmittance. use exponential lookup table
3405 ! for transmittance, or expansion of exponential for low
3406 ! optical depth
3407 
3408  zr1 = ztau1 * sntz
3409  if ( zr1 <= od_lo ) then
3410  zexp3 = f_one - zr1 + 0.5*zr1*zr1
3411  else
3412  ftind = zr1 / (bpade + zr1)
3413  itind = max(0, min(ntbmx, int(0.5+ntbmx*ftind) ))
3414  zexp3 = exp_tbl(itind)
3415  endif
3416 
3417  ztdbt(k) = zexp3 * ztdbt(kp)
3418  zldbt(kp) = zexp3
3419 
3420 ! --- ... pre-delta-scaling clear and cloudy direct beam transmittance
3421 ! (must use 'orig', unscaled cloud optical depth)
3422 
3423  zr1 = ztau0 * sntz
3424  if ( zr1 <= od_lo ) then
3425  zexp4 = f_one - zr1 + 0.5*zr1*zr1
3426  else
3427  ftind = zr1 / (bpade + zr1)
3428  itind = max(0, min(ntbmx, int(0.5+ntbmx*ftind) ))
3429  zexp4 = exp_tbl(itind)
3430  endif
3431 
3432  zldbt0(k) = zexp4
3433  ztdbt0 = zexp4 * ztdbt0
3434  enddo ! end do_k_loop
3435 
3436  call vrtqdr &
3437 ! --- inputs:
3438  & ( zrefb,zrefd,ztrab,ztrad,zldbt,ztdbt, &
3439  & nlay, nlp1, &
3440 ! --- outputs:
3441  & zfu, zfd &
3442  & )
3443 
3444 ! --- ... compute upward and downward fluxes at levels
3445  do k = 1, nlp1
3446  fxup0(k,ib) = fxup0(k,ib) + zsolar*zfu(k)
3447  fxdn0(k,ib) = fxdn0(k,ib) + zsolar*zfd(k)
3448  enddo
3449 
3450 !! --- ... surface downward beam/diffuse flux components
3451  zb1 = zsolar*ztdbt0
3452  zb2 = zsolar*(zfd(1) - ztdbt0)
3453 
3454  if (ibd /= 0) then
3455  sfbm0(ibd) = sfbm0(ibd) + zb1
3456  sfdf0(ibd) = sfdf0(ibd) + zb2
3457  else
3458  zf1 = 0.5 * zb1
3459  zf2 = 0.5 * zb2
3460  sfbm0(1) = sfbm0(1) + zf1
3461  sfdf0(1) = sfdf0(1) + zf2
3462  sfbm0(2) = sfbm0(2) + zf1
3463  sfdf0(2) = sfdf0(2) + zf2
3464  endif
3465 ! sfbm0(ibd) = sfbm0(ibd) + zsolar*ztdbt0
3466 ! sfdf0(ibd) = sfdf0(ibd) + zsolar*(zfd(1) - ztdbt0)
3467 
3477 
3478  if ( cf1 > eps ) then
3479 
3480 ! --- ... set up toa direct beam and surface values (beam and diff)
3481  ztdbt0 = f_one
3482  zldbt(1) = f_zero
3483 
3484  do k = nlay, 1, -1
3485  kp = k + 1
3486  if ( cldfmc(k,jg) > ftiny ) then ! it is a cloudy-layer
3487 
3488  ztau0 = ztaus(k) + taucw(k,ib)
3489  zssa0 = zssas(k) + ssacw(k,ib)
3490  zasy0 = zasys(k) + asycw(k,ib)
3491  zssaw = min(oneminus, zssa0 / ztau0)
3492  zasyw = zasy0 / max(ftiny, zssa0)
3493 
3494 ! --- ... delta scaling for total-sky condition
3495  za1 = zasyw * zasyw
3496  za2 = zssaw * za1
3497 
3498  ztau1 = (f_one - za2) * ztau0
3499  zssa1 = (zssaw - za2) / (f_one - za2)
3500 !org zasy1 = (zasyw - za1) / (f_one - za1)
3501  zasy1 = zasyw / (f_one + zasyw)
3502  zasy3 = 0.75 * zasy1
3503 
3504 ! --- ... general two-stream expressions
3505  if ( iswmode == 1 ) then
3506  zgam1 = 1.75 - zssa1 * (f_one + zasy3)
3507  zgam2 =-0.25 + zssa1 * (f_one - zasy3)
3508  zgam3 = 0.5 - zasy3 * cosz
3509  elseif ( iswmode == 2 ) then ! pifm
3510  zgam1 = 2.0 - zssa1 * (1.25 + zasy3)
3511  zgam2 = 0.75* zssa1 * (f_one- zasy1)
3512  zgam3 = 0.5 - zasy3 * cosz
3513  elseif ( iswmode == 3 ) then ! discrete ordinates
3514  zgam1 = zsr3 * (2.0 - zssa1 * (1.0 + zasy1)) * 0.5
3515  zgam2 = zsr3 * zssa1 * (1.0 - zasy1) * 0.5
3516  zgam3 = (1.0 - zsr3 * zasy1 * cosz) * 0.5
3517  endif
3518  zgam4 = f_one - zgam3
3519 
3520 ! --- ... compute homogeneous reflectance and transmittance
3521 
3522  if ( zssaw >= zcrit ) then ! for conservative scattering
3523  za1 = zgam1 * cosz - zgam3
3524  za2 = zgam1 * ztau1
3525 
3526 ! --- ... use exponential lookup table for transmittance, or expansion
3527 ! of exponential for low optical depth
3528 
3529  zb1 = min( ztau1*sntz , 500.0 )
3530  if ( zb1 <= od_lo ) then
3531  zb2 = f_one - zb1 + 0.5*zb1*zb1
3532  else
3533  ftind = zb1 / (bpade + zb1)
3534  itind = ftind*ntbmx + 0.5
3535  zb2 = exp_tbl(itind)
3536  endif
3537 
3538 ! ... collimated beam
3539  zrefb(kp) = max(f_zero, min(f_one, &
3540  & (za2 - za1*(f_one - zb2))/(f_one + za2) ))
3541  ztrab(kp) = max(f_zero, min(f_one, f_one-zrefb(kp)))
3542 
3543 ! ... isotropic incidence
3544  zrefd(kp) = max(f_zero, min(f_one, za2 / (f_one+za2) ))
3545  ztrad(kp) = max(f_zero, min(f_one, f_one - zrefd(kp) ))
3546 
3547  else ! for non-conservative scattering
3548  za1 = zgam1*zgam4 + zgam2*zgam3
3549  za2 = zgam1*zgam3 + zgam2*zgam4
3550  zrk = sqrt( (zgam1 - zgam2) * (zgam1 + zgam2) )
3551  zrk2= 2.0 * zrk
3552 
3553  zrp = zrk * cosz
3554  zrp1 = f_one + zrp
3555  zrm1 = f_one - zrp
3556  zrpp = f_one - zrp*zrp
3557  zrkg1= zrk + zgam1
3558  zrkg3= zrk * zgam3
3559  zrkg4= zrk * zgam4
3560 
3561  zr1 = zrm1 * (za2 + zrkg3)
3562  zr2 = zrp1 * (za2 - zrkg3)
3563  zr3 = zrk2 * (zgam3 - za2*cosz)
3564  zr4 = zrpp * zrkg1
3565  zr5 = zrpp * (zrk - zgam1)
3566 
3567  zt1 = zrp1 * (za1 + zrkg4)
3568  zt2 = zrm1 * (za1 - zrkg4)
3569  zt3 = zrk2 * (zgam4 + za1*cosz)
3570 
3571 ! --- ... use exponential lookup table for transmittance, or expansion
3572 ! of exponential for low optical depth
3573 
3574  zb1 = min( zrk*ztau1, 500.0 )
3575  if ( zb1 <= od_lo ) then
3576  zexm1 = f_one - zb1 + 0.5*zb1*zb1
3577  else
3578  ftind = zb1 / (bpade + zb1)
3579  itind = ftind*ntbmx + 0.5
3580  zexm1 = exp_tbl(itind)
3581  endif
3582  zexp1 = f_one / zexm1
3583 
3584  zb2 = min( ztau1*sntz, 500.0 )
3585  if ( zb2 <= od_lo ) then
3586  zexm2 = f_one - zb2 + 0.5*zb2*zb2
3587  else
3588  ftind = zb2 / (bpade + zb2)
3589  itind = ftind*ntbmx + 0.5
3590  zexm2 = exp_tbl(itind)
3591  endif
3592  zexp2 = f_one / zexm2
3593  ze1r45 = zr4*zexp1 + zr5*zexm1
3594 
3595 ! ... collimated beam
3596  if ( ze1r45>=-eps1 .and. ze1r45<=eps1 ) then
3597  zrefb(kp) = eps1
3598  ztrab(kp) = zexm2
3599  else
3600  zden1 = zssa1 / ze1r45
3601  zrefb(kp) = max(f_zero, min(f_one, &
3602  & (zr1*zexp1-zr2*zexm1-zr3*zexm2)*zden1 ))
3603  ztrab(kp) = max(f_zero, min(f_one, zexm2*(f_one - &
3604  & (zt1*zexp1-zt2*zexm1-zt3*zexp2)*zden1) ))
3605  endif
3606 
3607 ! ... diffuse beam
3608  zden1 = zr4 / (ze1r45 * zrkg1)
3609  zrefd(kp) = max(f_zero, min(f_one, &
3610  & zgam2*(zexp1 - zexm1)*zden1 ))
3611  ztrad(kp) = max(f_zero, min(f_one, zrk2*zden1 ))
3612  endif ! end if_zssaw_block
3613 
3614 ! --- ... direct beam transmittance. use exponential lookup table
3615 ! for transmittance, or expansion of exponential for low
3616 ! optical depth
3617 
3618  zr1 = ztau1 * sntz
3619  if ( zr1 <= od_lo ) then
3620  zexp3 = f_one - zr1 + 0.5*zr1*zr1
3621  else
3622  ftind = zr1 / (bpade + zr1)
3623  itind = max(0, min(ntbmx, int(0.5+ntbmx*ftind) ))
3624  zexp3 = exp_tbl(itind)
3625  endif
3626 
3627  zldbt(kp) = zexp3
3628  ztdbt(k) = zexp3 * ztdbt(kp)
3629 
3630 ! --- ... pre-delta-scaling clear and cloudy direct beam transmittance
3631 ! (must use 'orig', unscaled cloud optical depth)
3632 
3633  zr1 = ztau0 * sntz
3634  if ( zr1 <= od_lo ) then
3635  zexp4 = f_one - zr1 + 0.5*zr1*zr1
3636  else
3637  ftind = zr1 / (bpade + zr1)
3638  itind = max(0, min(ntbmx, int(0.5+ntbmx*ftind) ))
3639  zexp4 = exp_tbl(itind)
3640  endif
3641 
3642  ztdbt0 = zexp4 * ztdbt0
3643 
3644  else ! if_cldfmc_block --- it is a clear layer
3645 
3646 ! --- ... direct beam transmittance
3647  ztdbt(k) = zldbt(kp) * ztdbt(kp)
3648 
3649 ! --- ... pre-delta-scaling clear and cloudy direct beam transmittance
3650  ztdbt0 = zldbt0(k) * ztdbt0
3651 
3652  endif ! end if_cldfmc_block
3653  enddo ! end do_k_loop
3654 
3655 ! --- ... perform vertical quadrature
3656 
3657  call vrtqdr &
3658 ! --- inputs:
3659  & ( zrefb,zrefd,ztrab,ztrad,zldbt,ztdbt, &
3660  & nlay, nlp1, &
3661 ! --- outputs:
3662  & zfu, zfd &
3663  & )
3664 
3665 ! --- ... compute upward and downward fluxes at levels
3666  do k = 1, nlp1
3667  fxupc(k,ib) = fxupc(k,ib) + zsolar*zfu(k)
3668  fxdnc(k,ib) = fxdnc(k,ib) + zsolar*zfd(k)
3669  enddo
3670 
3672 ! --- ... surface downward beam/diffused flux components
3673  zb1 = zsolar*ztdbt0
3674  zb2 = zsolar*(zfd(1) - ztdbt0)
3675 
3676  if (ibd /= 0) then
3677  sfbmc(ibd) = sfbmc(ibd) + zb1
3678  sfdfc(ibd) = sfdfc(ibd) + zb2
3679  else
3680  zf1 = 0.5 * zb1
3681  zf2 = 0.5 * zb2
3682  sfbmc(1) = sfbmc(1) + zf1
3683  sfdfc(1) = sfdfc(1) + zf2
3684  sfbmc(2) = sfbmc(2) + zf1
3685  sfdfc(2) = sfdfc(2) + zf2
3686  endif
3687 ! sfbmc(ibd) = sfbmc(ibd) + zsolar*ztdbt0
3688 ! sfdfc(ibd) = sfdfc(ibd) + zsolar*(zfd(1) - ztdbt0)
3689 
3690  endif ! end if_cf1_block
3691 
3692  enddo lab_do_jg
3693 
3694 ! --- ... end of g-point loop
3695 
3696  do ib = 1, nbdsw
3697  ftoadc = ftoadc + fxdn0(nlp1,ib)
3698  ftoau0 = ftoau0 + fxup0(nlp1,ib)
3699  fsfcu0 = fsfcu0 + fxup0(1,ib)
3700  fsfcd0 = fsfcd0 + fxdn0(1,ib)
3701  enddo
3702 
3703 !! --- ... uv-b surface downward flux
3704  ibd = nuvb - nblow + 1
3705  suvbf0 = fxdn0(1,ibd)
3706 
3707  if ( cf1 <= eps ) then ! clear column, set total-sky=clear-sky fluxes
3708  do ib = 1, nbdsw
3709  do k = 1, nlp1
3710  fxupc(k,ib) = fxup0(k,ib)
3711  fxdnc(k,ib) = fxdn0(k,ib)
3712  enddo
3713  enddo
3714 
3715  ftoauc = ftoau0
3716  fsfcuc = fsfcu0
3717  fsfcdc = fsfcd0
3718 
3719 !! --- ... surface downward beam/diffused flux components
3720  sfbmc(1) = sfbm0(1)
3721  sfdfc(1) = sfdf0(1)
3722  sfbmc(2) = sfbm0(2)
3723  sfdfc(2) = sfdf0(2)
3724 
3725 !! --- ... uv-b surface downward flux
3726  suvbfc = suvbf0
3727  else ! cloudy column, compute total-sky fluxes
3728  do ib = 1, nbdsw
3729  ftoauc = ftoauc + fxupc(nlp1,ib)
3730  fsfcuc = fsfcuc + fxupc(1,ib)
3731  fsfcdc = fsfcdc + fxdnc(1,ib)
3732  enddo
3733 
3734 !! --- ... uv-b surface downward flux
3735  suvbfc = fxdnc(1,ibd)
3736  endif ! end if_cf1_block
3737 
3738  return
3739 !...................................
3740  end subroutine spcvrtm
3741 !-----------------------------------
3742 
3756 !-----------------------------------
3757  subroutine vrtqdr &
3758  & ( zrefb,zrefd,ztrab,ztrad,zldbt,ztdbt, & ! inputs
3759  & nlay, nlp1, &
3760  & zfu, zfd & ! outputs:
3761  & )
3763 ! =================== program usage description =================== !
3764 ! !
3765 ! purpose: computes the upward and downward radiation fluxes !
3766 ! !
3767 ! interface: "vrtqdr" is called by "spcvrc" and "spcvrm" !
3768 ! !
3769 ! subroutines called : none !
3770 ! !
3771 ! ==================== defination of variables ==================== !
3772 ! !
3773 ! input variables: !
3774 ! zrefb(NLP1) - layer direct beam reflectivity !
3775 ! zrefd(NLP1) - layer diffuse reflectivity !
3776 ! ztrab(NLP1) - layer direct beam transmissivity !
3777 ! ztrad(NLP1) - layer diffuse transmissivity !
3778 ! zldbt(NLP1) - layer mean beam transmittance !
3779 ! ztdbt(NLP1) - total beam transmittance at levels !
3780 ! NLAY, NLP1 - number of layers/levels !
3781 ! !
3782 ! output variables: !
3783 ! zfu (NLP1) - upward flux at layer interface !
3784 ! zfd (NLP1) - downward flux at layer interface !
3785 ! !
3786 ! ******************************************************************* !
3787 ! ====================== end of description block ================= !
3788 
3789 ! --- inputs:
3790  integer, intent(in) :: nlay, nlp1
3791 
3792  real (kind=kind_phys), dimension(nlp1), intent(in) :: zrefb, &
3793  & zrefd, ztrab, ztrad, ztdbt, zldbt
3794 
3795 ! --- outputs:
3796  real (kind=kind_phys), dimension(nlp1), intent(out) :: zfu, zfd
3797 
3798 ! --- locals:
3799  real (kind=kind_phys), dimension(nlp1) :: zrupb,zrupd,zrdnd,ztdn
3800 
3801  real (kind=kind_phys) :: zden1
3802 
3803  integer :: k, kp
3804 !
3805 !===> ... begin here
3806 !
3807 
3809  zrupb(1) = zrefb(1) ! direct beam
3810  zrupd(1) = zrefd(1) ! diffused
3811 
3813  do k = 1, nlay
3814  kp = k + 1
3815 
3816  zden1 = f_one / ( f_one - zrupd(k)*zrefd(kp) )
3817  zrupb(kp) = zrefb(kp) + ( ztrad(kp) * &
3818  & ( (ztrab(kp) - zldbt(kp))*zrupd(k) + &
3819  & zldbt(kp)*zrupb(k)) ) * zden1
3820  zrupd(kp) = zrefd(kp) + ztrad(kp)*ztrad(kp)*zrupd(k)*zden1
3821  enddo
3822 
3824  ztdn(nlp1) = f_one
3825  zrdnd(nlp1) = f_zero
3826  ztdn(nlay) = ztrab(nlp1)
3827  zrdnd(nlay) = zrefd(nlp1)
3828 
3830  do k = nlay, 2, -1
3831  zden1 = f_one / (f_one - zrefd(k)*zrdnd(k))
3832  ztdn(k-1) = ztdbt(k)*ztrab(k) + ( ztrad(k) * &
3833  & ( (ztdn(k) - ztdbt(k)) + ztdbt(k) * &
3834  & zrefb(k)*zrdnd(k) )) * zden1
3835  zrdnd(k-1) = zrefd(k) + ztrad(k)*ztrad(k)*zrdnd(k)*zden1
3836  enddo
3837 
3839  do k = 1, nlp1
3840  zden1 = f_one / (f_one - zrdnd(k)*zrupd(k))
3841  zfu(k) = ( ztdbt(k)*zrupb(k) + &
3842  & (ztdn(k) - ztdbt(k))*zrupd(k) ) * zden1
3843  zfd(k) = ztdbt(k) + ( ztdn(k) - ztdbt(k) + &
3844  & ztdbt(k)*zrupb(k)*zrdnd(k) ) * zden1
3845  enddo
3846 
3847  return
3848 !...................................
3849  end subroutine vrtqdr
3850 !-----------------------------------
3852 
3892 !-----------------------------------
3893  subroutine taumol &
3894  & ( colamt,colmol,fac00,fac01,fac10,fac11,jp,jt,jt1,laytrop, & ! --- inputs
3895  & forfac,forfrac,indfor,selffac,selffrac,indself, nlay, &
3896  & sfluxzen, taug, taur & ! --- outputs
3897  & )
3899 ! ================== program usage description ================== !
3900 ! !
3901 ! description: !
3902 ! calculate optical depths for gaseous absorption and rayleigh !
3903 ! scattering. !
3904 ! !
3905 ! subroutines called: taugb## (## = 16 - 29) !
3906 ! !
3907 ! ==================== defination of variables ==================== !
3908 ! !
3909 ! inputs: size !
3910 ! colamt - real, column amounts of absorbing gases the index !
3911 ! are for h2o, co2, o3, n2o, ch4, and o2, !
3912 ! respectively (molecules/cm**2) nlay*maxgas!
3913 ! colmol - real, total column amount (dry air+water vapor) nlay !
3914 ! facij - real, for each layer, these are factors that are !
3915 ! needed to compute the interpolation factors !
3916 ! that multiply the appropriate reference k- !
3917 ! values. a value of 0/1 for i,j indicates !
3918 ! that the corresponding factor multiplies !
3919 ! reference k-value for the lower/higher of the !
3920 ! two appropriate temperatures, and altitudes, !
3921 ! respectively. naly !
3922 ! jp - real, the index of the lower (in altitude) of the !
3923 ! two appropriate ref pressure levels needed !
3924 ! for interpolation. nlay !
3925 ! jt, jt1 - integer, the indices of the lower of the two approp !
3926 ! ref temperatures needed for interpolation (for !
3927 ! pressure levels jp and jp+1, respectively) nlay !
3928 ! laytrop - integer, tropopause layer index 1 !
3929 ! forfac - real, scale factor needed to foreign-continuum. nlay !
3930 ! forfrac - real, factor needed for temperature interpolation nlay !
3931 ! indfor - integer, index of the lower of the two appropriate !
3932 ! reference temperatures needed for foreign- !
3933 ! continuum interpolation nlay !
3934 ! selffac - real, scale factor needed to h2o self-continuum. nlay !
3935 ! selffrac- real, factor needed for temperature interpolation !
3936 ! of reference h2o self-continuum data nlay !
3937 ! indself - integer, index of the lower of the two appropriate !
3938 ! reference temperatures needed for the self- !
3939 ! continuum interpolation nlay !
3940 ! nlay - integer, number of vertical layers 1 !
3941 ! !
3942 ! output: !
3943 ! sfluxzen- real, spectral distribution of incoming solar flux ngptsw!
3944 ! taug - real, spectral optical depth for gases nlay*ngptsw!
3945 ! taur - real, opt depth for rayleigh scattering nlay*ngptsw!
3946 ! !
3947 ! =================================================================== !
3948 ! ************ original subprogram description *************** !
3949 ! !
3950 ! optical depths developed for the !
3951 ! !
3952 ! rapid radiative transfer model (rrtm) !
3953 ! !
3954 ! atmospheric and environmental research, inc. !
3955 ! 131 hartwell avenue !
3956 ! lexington, ma 02421 !
3957 ! !
3958 ! !
3959 ! eli j. mlawer !
3960 ! jennifer delamere !
3961 ! steven j. taubman !
3962 ! shepard a. clough !
3963 ! !
3964 ! !
3965 ! !
3966 ! email: mlawer@aer.com !
3967 ! email: jdelamer@aer.com !
3968 ! !
3969 ! the authors wish to acknowledge the contributions of the !
3970 ! following people: patrick d. brown, michael j. iacono, !
3971 ! ronald e. farren, luke chen, robert bergstrom. !
3972 ! !
3973 ! ******************************************************************* !
3974 ! !
3975 ! taumol !
3976 ! !
3977 ! this file contains the subroutines taugbn (where n goes from !
3978 ! 16 to 29). taugbn calculates the optical depths and Planck !
3979 ! fractions per g-value and layer for band n. !
3980 ! !
3981 ! output: optical depths (unitless) !
3982 ! fractions needed to compute planck functions at every layer !
3983 ! and g-value !
3984 ! !
3985 ! modifications: !
3986 ! !
3987 ! revised: adapted to f90 coding, j.-j.morcrette, ecmwf, feb 2003 !
3988 ! revised: modified for g-point reduction, mjiacono, aer, dec 2003 !
3989 ! revised: reformatted for consistency with rrtmg_lw, mjiacono, aer, !
3990 ! jul 2006 !
3991 ! !
3992 ! ******************************************************************* !
3993 ! ====================== end of description block ================= !
3994 
3995 ! --- inputs:
3996  integer, intent(in) :: nlay, laytrop
3997 
3998  integer, dimension(nlay), intent(in) :: indfor, indself, &
3999  & jp, jt, jt1
4000 
4001  real (kind=kind_phys), dimension(nlay), intent(in) :: colmol, &
4002  & fac00, fac01, fac10, fac11, forfac, forfrac, selffac, &
4003  & selffrac
4004 
4005  real (kind=kind_phys), dimension(nlay,maxgas),intent(in) :: colamt
4006 
4007 ! --- outputs:
4008  real (kind=kind_phys), dimension(ngptsw), intent(out) :: sfluxzen
4009 
4010  real (kind=kind_phys), dimension(nlay,ngptsw), intent(out) :: &
4011  & taug, taur
4012 
4013 ! --- locals:
4014  real (kind=kind_phys) :: fs, speccomb, specmult, colm1, colm2
4015 
4016  integer, dimension(nlay,nblow:nbhgh) :: id0, id1
4017 
4018  integer :: ibd, j, jb, js, k, klow, khgh, klim, ks, njb, ns
4019 !
4020 !===> ... begin here
4021 !
4022 ! --- ... loop over each spectral band
4023 
4024  do jb = nblow, nbhgh
4025 
4026 ! --- ... indices for layer optical depth
4027 
4028  do k = 1, laytrop
4029  id0(k,jb) = ((jp(k)-1)*5 + (jt(k)-1)) * nspa(jb)
4030  id1(k,jb) = ( jp(k) *5 + (jt1(k)-1)) * nspa(jb)
4031  enddo
4032 
4033  do k = laytrop+1, nlay
4034  id0(k,jb) = ((jp(k)-13)*5 + (jt(k)-1)) * nspb(jb)
4035  id1(k,jb) = ((jp(k)-12)*5 + (jt1(k)-1)) * nspb(jb)
4036  enddo
4037 
4038 ! --- ... calculate spectral flux at toa
4039 
4040  ibd = ibx(jb)
4041  njb = ng(jb)
4042  ns = ngs(jb)
4043 
4044  select case (jb)
4045 
4046  case (16, 20, 23, 25, 26, 29)
4047 
4048  do j = 1, njb
4049  sfluxzen(ns+j) = sfluxref01(j,1,ibd)
4050  enddo
4051 
4052  case (27)
4053 
4054  do j = 1, njb
4055  sfluxzen(ns+j) = scalekur * sfluxref01(j,1,ibd)
4056  enddo
4057 
4058  case default
4059 
4060  if (jb==17 .or. jb==28) then
4061 
4062  ks = nlay
4063  lab_do_k1 : do k = laytrop, nlay-1
4064  if (jp(k)<layreffr(jb) .and. jp(k+1)>=layreffr(jb)) then
4065  ks = k + 1
4066  exit lab_do_k1
4067  endif
4068  enddo lab_do_k1
4069 
4070  colm1 = colamt(ks,ix1(jb))
4071  colm2 = colamt(ks,ix2(jb))
4072  speccomb = colm1 + strrat(jb)*colm2
4073  specmult = specwt(jb) * min( oneminus, colm1/speccomb )
4074  js = 1 + int( specmult )
4075  fs = mod(specmult, f_one)
4076 
4077  do j = 1, njb
4078  sfluxzen(ns+j) = sfluxref02(j,js,ibd) &
4079  & + fs * (sfluxref02(j,js+1,ibd) - sfluxref02(j,js,ibd))
4080  enddo
4081 
4082  else
4083 
4084  ks = laytrop
4085  lab_do_k2 : do k = 1, laytrop-1
4086  if (jp(k)<layreffr(jb) .and. jp(k+1)>=layreffr(jb)) then
4087  ks = k + 1
4088  exit lab_do_k2
4089  endif
4090  enddo lab_do_k2
4091 
4092  colm1 = colamt(ks,ix1(jb))
4093  colm2 = colamt(ks,ix2(jb))
4094  speccomb = colm1 + strrat(jb)*colm2
4095  specmult = specwt(jb) * min( oneminus, colm1/speccomb )
4096  js = 1 + int( specmult )
4097  fs = mod(specmult, f_one)
4098 
4099  do j = 1, njb
4100  sfluxzen(ns+j) = sfluxref03(j,js,ibd) &
4101  & + fs * (sfluxref03(j,js+1,ibd) - sfluxref03(j,js,ibd))
4102  enddo
4103 
4104  endif
4105 
4106  end select
4107 
4108  enddo
4109 
4111 
4113  call taumol16
4115  call taumol17
4117  call taumol18
4119  call taumol19
4121  call taumol20
4123  call taumol21
4125  call taumol22
4127  call taumol23
4129  call taumol24
4131  call taumol25
4133  call taumol26
4135  call taumol27
4137  call taumol28
4139  call taumol29
4140 
4141 
4142 ! =================
4143  contains
4144 ! =================
4145 
4148 !-----------------------------------
4149  subroutine taumol16
4150 !...................................
4151 
4152 ! ------------------------------------------------------------------ !
4153 ! band 16: 2600-3250 cm-1 (low - h2o,ch4; high - ch4) !
4154 ! ------------------------------------------------------------------ !
4155 !
4156  use module_radsw_kgb16
4157 
4158 ! --- locals:
4159 
4160  real (kind=kind_phys) :: speccomb, specmult, tauray, fs, fs1, &
4161  & fac000,fac001,fac010,fac011, fac100,fac101,fac110,fac111
4162 
4163  integer :: ind01, ind02, ind03, ind04, ind11, ind12, ind13, ind14
4164  integer :: inds, indf, indsp, indfp, j, js, k
4165 
4166 !
4167 !===> ... begin here
4168 !
4169 
4170 ! --- ... compute the optical depth by interpolating in ln(pressure),
4171 ! temperature, and appropriate species. below laytrop, the water
4172 ! vapor self-continuum is interpolated (in temperature) separately.
4173 
4174  do k = 1, nlay
4175  tauray = colmol(k) * rayl
4176 
4177  do j = 1, ng16
4178  taur(k,ns16+j) = tauray
4179  enddo
4180  enddo
4181 
4182  do k = 1, laytrop
4183  speccomb = colamt(k,1) + strrat(16)*colamt(k,5)
4184  specmult = 8.0 * min( oneminus, colamt(k,1)/speccomb )
4185 
4186  js = 1 + int( specmult )
4187  fs = mod( specmult, f_one )
4188  fs1= f_one - fs
4189  fac000 = fs1 * fac00(k)
4190  fac010 = fs1 * fac10(k)
4191  fac100 = fs * fac00(k)
4192  fac110 = fs * fac10(k)
4193  fac001 = fs1 * fac01(k)
4194  fac011 = fs1 * fac11(k)
4195  fac101 = fs * fac01(k)
4196  fac111 = fs * fac11(k)
4197 
4198  ind01 = id0(k,16) + js
4199  ind02 = ind01 + 1
4200  ind03 = ind01 + 9
4201  ind04 = ind01 + 10
4202  ind11 = id1(k,16) + js
4203  ind12 = ind11 + 1
4204  ind13 = ind11 + 9
4205  ind14 = ind11 + 10
4206  inds = indself(k)
4207  indf = indfor(k)
4208  indsp= inds + 1
4209  indfp= indf + 1
4210 
4211  do j = 1, ng16
4212  taug(k,ns16+j) = speccomb &
4213  & *( fac000 * absa(ind01,j) + fac100 * absa(ind02,j) &
4214  & + fac010 * absa(ind03,j) + fac110 * absa(ind04,j) &
4215  & + fac001 * absa(ind11,j) + fac101 * absa(ind12,j) &
4216  & + fac011 * absa(ind13,j) + fac111 * absa(ind14,j) ) &
4217  & + colamt(k,1) * (selffac(k) * (selfref(inds,j) &
4218  & + selffrac(k) * (selfref(indsp,j)-selfref(inds,j))) &
4219  & + forfac(k) * (forref(indf,j) + forfrac(k) &
4220  & * (forref(indfp,j) - forref(indf,j))))
4221  enddo
4222  enddo
4223 
4224  do k = laytrop+1, nlay
4225  ind01 = id0(k,16) + 1
4226  ind02 = ind01 + 1
4227  ind11 = id1(k,16) + 1
4228  ind12 = ind11 + 1
4229 
4230  do j = 1, ng16
4231  taug(k,ns16+j) = colamt(k,5) &
4232  & * ( fac00(k)*absb(ind01,j) + fac10(k)*absb(ind02,j) &
4233  & + fac01(k)*absb(ind11,j) + fac11(k)*absb(ind12,j) )
4234  enddo
4235  enddo
4236 
4237  return
4238 !...................................
4239  end subroutine taumol16
4240 !-----------------------------------
4241 
4242 
4245 !-----------------------------------
4246  subroutine taumol17
4247 !...................................
4248 
4249 ! ------------------------------------------------------------------ !
4250 ! band 17: 3250-4000 cm-1 (low - h2o,co2; high - h2o,co2) !
4251 ! ------------------------------------------------------------------ !
4252 !
4253  use module_radsw_kgb17
4254 
4255 ! --- locals:
4256  real (kind=kind_phys) :: speccomb, specmult, tauray, fs, fs1, &
4257  & fac000,fac001,fac010,fac011, fac100,fac101,fac110,fac111
4258 
4259  integer :: ind01, ind02, ind03, ind04, ind11, ind12, ind13, ind14
4260  integer :: inds, indf, indsp, indfp, j, js, k
4261 
4262 !
4263 !===> ... begin here
4264 !
4265 
4266 ! --- ... compute the optical depth by interpolating in ln(pressure),
4267 ! temperature, and appropriate species. below laytrop, the water
4268 ! vapor self-continuum is interpolated (in temperature) separately.
4269 
4270  do k = 1, nlay
4271  tauray = colmol(k) * rayl
4272 
4273  do j = 1, ng17
4274  taur(k,ns17+j) = tauray
4275  enddo
4276  enddo
4277 
4278  do k = 1, laytrop
4279  speccomb = colamt(k,1) + strrat(17)*colamt(k,2)
4280  specmult = 8.0 * min(oneminus, colamt(k,1) / speccomb)
4281 
4282  js = 1 + int(specmult)
4283  fs = mod(specmult, f_one)
4284  fs1= f_one - fs
4285  fac000 = fs1 * fac00(k)
4286  fac010 = fs1 * fac10(k)
4287  fac100 = fs * fac00(k)
4288  fac110 = fs * fac10(k)
4289  fac001 = fs1 * fac01(k)
4290  fac011 = fs1 * fac11(k)
4291  fac101 = fs * fac01(k)
4292  fac111 = fs * fac11(k)
4293 
4294  ind01 = id0(k,17) + js
4295  ind02 = ind01 + 1
4296  ind03 = ind01 + 9
4297  ind04 = ind01 + 10
4298  ind11 = id1(k,17) + js
4299  ind12 = ind11 + 1
4300  ind13 = ind11 + 9
4301  ind14 = ind11 + 10
4302 
4303  inds = indself(k)
4304  indf = indfor(k)
4305  indsp= inds + 1
4306  indfp= indf + 1
4307 
4308  do j = 1, ng17
4309  taug(k,ns17+j) = speccomb &
4310  & * ( fac000 * absa(ind01,j) + fac100 * absa(ind02,j) &
4311  & + fac010 * absa(ind03,j) + fac110 * absa(ind04,j) &
4312  & + fac001 * absa(ind11,j) + fac101 * absa(ind12,j) &
4313  & + fac011 * absa(ind13,j) + fac111 * absa(ind14,j) ) &
4314  & + colamt(k,1) * (selffac(k) * (selfref(inds,j) &
4315  & + selffrac(k) * (selfref(indsp,j)-selfref(inds,j))) &
4316  & + forfac(k) * (forref(indf,j) + forfrac(k) &
4317  & * (forref(indfp,j) - forref(indf,j))))
4318  enddo
4319  enddo
4320 
4321  do k = laytrop+1, nlay
4322  speccomb = colamt(k,1) + strrat(17)*colamt(k,2)
4323  specmult = 4.0 * min(oneminus, colamt(k,1) / speccomb)
4324 
4325  js = 1 + int(specmult)
4326  fs = mod(specmult, f_one)
4327  fs1= f_one - fs
4328  fac000 = fs1 * fac00(k)
4329  fac010 = fs1 * fac10(k)
4330  fac100 = fs * fac00(k)
4331  fac110 = fs * fac10(k)
4332  fac001 = fs1 * fac01(k)
4333  fac011 = fs1 * fac11(k)
4334  fac101 = fs * fac01(k)
4335  fac111 = fs * fac11(k)
4336 
4337  ind01 = id0(k,17) + js
4338  ind02 = ind01 + 1
4339  ind03 = ind01 + 5
4340  ind04 = ind01 + 6
4341  ind11 = id1(k,17) + js
4342  ind12 = ind11 + 1
4343  ind13 = ind11 + 5
4344  ind14 = ind11 + 6
4345 
4346  indf = indfor(k)
4347  indfp= indf + 1
4348 
4349  do j = 1, ng17
4350  taug(k,ns17+j) = speccomb &
4351  & * ( fac000 * absb(ind01,j) + fac100 * absb(ind02,j) &
4352  & + fac010 * absb(ind03,j) + fac110 * absb(ind04,j) &
4353  & + fac001 * absb(ind11,j) + fac101 * absb(ind12,j) &
4354  & + fac011 * absb(ind13,j) + fac111 * absb(ind14,j) ) &
4355  & + colamt(k,1) * forfac(k) * (forref(indf,j) &
4356  & + forfrac(k) * (forref(indfp,j) - forref(indf,j)))
4357  enddo
4358  enddo
4359 
4360  return
4361 !...................................
4362  end subroutine taumol17
4363 !-----------------------------------
4364 
4365 
4368 !-----------------------------------
4369  subroutine taumol18
4370 !...................................
4371 
4372 ! ------------------------------------------------------------------ !
4373 ! band 18: 4000-4650 cm-1 (low - h2o,ch4; high - ch4) !
4374 ! ------------------------------------------------------------------ !
4375 !
4376  use module_radsw_kgb18
4377 
4378 ! --- locals:
4379  real (kind=kind_phys) :: speccomb, specmult, tauray, fs, fs1, &
4380  & fac000,fac001,fac010,fac011, fac100,fac101,fac110,fac111
4381 
4382  integer :: ind01, ind02, ind03, ind04, ind11, ind12, ind13, ind14
4383  integer :: inds, indf, indsp, indfp, j, js, k
4384 
4385 !
4386 !===> ... begin here
4387 !
4388 
4389 ! --- ... compute the optical depth by interpolating in ln(pressure),
4390 ! temperature, and appropriate species. below laytrop, the water
4391 ! vapor self-continuum is interpolated (in temperature) separately.
4392 
4393  do k = 1, nlay
4394  tauray = colmol(k) * rayl
4395 
4396  do j = 1, ng18
4397  taur(k,ns18+j) = tauray
4398  enddo
4399  enddo
4400 
4401  do k = 1, laytrop
4402  speccomb = colamt(k,1) + strrat(18)*colamt(k,5)
4403  specmult = 8.0 * min(oneminus, colamt(k,1) / speccomb)
4404 
4405  js = 1 + int(specmult)
4406  fs = mod(specmult, f_one)
4407  fs1= f_one - fs
4408  fac000 = fs1 * fac00(k)
4409  fac010 = fs1 * fac10(k)
4410  fac100 = fs * fac00(k)
4411  fac110 = fs * fac10(k)
4412  fac001 = fs1 * fac01(k)
4413  fac011 = fs1 * fac11(k)
4414  fac101 = fs * fac01(k)
4415  fac111 = fs * fac11(k)
4416 
4417  ind01 = id0(k,18) + js
4418  ind02 = ind01 + 1
4419  ind03 = ind01 + 9
4420  ind04 = ind01 + 10
4421  ind11 = id1(k,18) + js
4422  ind12 = ind11 + 1
4423  ind13 = ind11 + 9
4424  ind14 = ind11 + 10
4425 
4426  inds = indself(k)
4427  indf = indfor(k)
4428  indsp= inds + 1
4429  indfp= indf + 1
4430 
4431  do j = 1, ng18
4432  taug(k,ns18+j) = speccomb &
4433  & * ( fac000 * absa(ind01,j) + fac100 * absa(ind02,j) &
4434  & + fac010 * absa(ind03,j) + fac110 * absa(ind04,j) &
4435  & + fac001 * absa(ind11,j) + fac101 * absa(ind12,j) &
4436  & + fac011 * absa(ind13,j) + fac111 * absa(ind14,j) ) &
4437  & + colamt(k,1) * (selffac(k) * (selfref(inds,j) &
4438  & + selffrac(k) * (selfref(indsp,j)-selfref(inds,j))) &
4439  & + forfac(k) * (forref(indf,j) + forfrac(k) &
4440  & * (forref(indfp,j) - forref(indf,j))))
4441  enddo
4442  enddo
4443 
4444  do k = laytrop+1, nlay
4445  ind01 = id0(k,18) + 1
4446  ind02 = ind01 + 1
4447  ind11 = id1(k,18) + 1
4448  ind12 = ind11 + 1
4449 
4450  do j = 1, ng18
4451  taug(k,ns18+j) = colamt(k,5) &
4452  & * ( fac00(k)*absb(ind01,j) + fac10(k)*absb(ind02,j) &
4453  & + fac01(k)*absb(ind11,j) + fac11(k)*absb(ind12,j) )
4454  enddo
4455  enddo
4456 
4457  return
4458 !...................................
4459  end subroutine taumol18
4460 !-----------------------------------
4461 
4464 !-----------------------------------
4465  subroutine taumol19
4466 !...................................
4467 
4468 ! ------------------------------------------------------------------ !
4469 ! band 19: 4650-5150 cm-1 (low - h2o,co2; high - co2) !
4470 ! ------------------------------------------------------------------ !
4471 !
4472  use module_radsw_kgb19
4473 
4474 ! --- locals:
4475  real (kind=kind_phys) :: speccomb, specmult, tauray, fs, fs1, &
4476  & fac000,fac001,fac010,fac011, fac100,fac101,fac110,fac111
4477 
4478  integer :: ind01, ind02, ind03, ind04, ind11, ind12, ind13, ind14
4479  integer :: inds, indf, indsp, indfp, j, js, k
4480 
4481 !
4482 !===> ... begin here
4483 !
4484 
4485 ! --- ... compute the optical depth by interpolating in ln(pressure),
4486 ! temperature, and appropriate species. below laytrop, the water
4487 ! vapor self-continuum is interpolated (in temperature) separately.
4488 
4489  do k = 1, nlay
4490  tauray = colmol(k) * rayl
4491 
4492  do j = 1, ng19
4493  taur(k,ns19+j) = tauray
4494  enddo
4495  enddo
4496 
4497  do k = 1, laytrop
4498  speccomb = colamt(k,1) + strrat(19)*colamt(k,2)
4499  specmult = 8.0 * min(oneminus, colamt(k,1) / speccomb)
4500 
4501  js = 1 + int(specmult)
4502  fs = mod(specmult, f_one)
4503  fs1= f_one - fs
4504  fac000 = fs1 * fac00(k)
4505  fac010 = fs1 * fac10(k)
4506  fac100 = fs * fac00(k)
4507  fac110 = fs * fac10(k)
4508  fac001 = fs1 * fac01(k)
4509  fac011 = fs1 * fac11(k)
4510  fac101 = fs * fac01(k)
4511  fac111 = fs * fac11(k)
4512 
4513  ind01 = id0(k,19) + js
4514  ind02 = ind01 + 1
4515  ind03 = ind01 + 9
4516  ind04 = ind01 + 10
4517  ind11 = id1(k,19) + js
4518  ind12 = ind11 + 1
4519  ind13 = ind11 + 9
4520  ind14 = ind11 + 10
4521 
4522  inds = indself(k)
4523  indf = indfor(k)
4524  indsp= inds + 1
4525  indfp= indf + 1
4526 
4527  do j = 1, ng19
4528  taug(k,ns19+j) = speccomb &
4529  & * ( fac000 * absa(ind01,j) + fac100 * absa(ind02,j) &
4530  & + fac010 * absa(ind03,j) + fac110 * absa(ind04,j) &
4531  & + fac001 * absa(ind11,j) + fac101 * absa(ind12,j) &
4532  & + fac011 * absa(ind13,j) + fac111 * absa(ind14,j) ) &
4533  & + colamt(k,1) * (selffac(k) * (selfref(inds,j) &
4534  & + selffrac(k) * (selfref(indsp,j)-selfref(inds,j))) &
4535  & + forfac(k) * (forref(indf,j) + forfrac(k) &
4536  & * (forref(indfp,j) - forref(indf,j))))
4537  enddo
4538  enddo
4539 
4540  do k = laytrop+1, nlay
4541  ind01 = id0(k,19) + 1
4542  ind02 = ind01 + 1
4543  ind11 = id1(k,19) + 1
4544  ind12 = ind11 + 1
4545 
4546  do j = 1, ng19
4547  taug(k,ns19+j) = colamt(k,2) &
4548  & * ( fac00(k)*absb(ind01,j) + fac10(k)*absb(ind02,j) &
4549  & + fac01(k)*absb(ind11,j) + fac11(k)*absb(ind12,j) )
4550  enddo
4551  enddo
4552 
4553 !...................................
4554  end subroutine taumol19
4555 !-----------------------------------
4556 
4557 
4560 !-----------------------------------
4561  subroutine taumol20
4562 !...................................
4563 
4564 ! ------------------------------------------------------------------ !
4565 ! band 20: 5150-6150 cm-1 (low - h2o; high - h2o) !
4566 ! ------------------------------------------------------------------ !
4567 !
4568  use module_radsw_kgb20
4569 
4570 ! --- locals:
4571  real (kind=kind_phys) :: tauray
4572 
4573  integer :: ind01, ind02, ind11, ind12
4574  integer :: inds, indf, indsp, indfp, j, k
4575 
4576 !
4577 !===> ... begin here
4578 !
4579 
4580 ! --- ... compute the optical depth by interpolating in ln(pressure),
4581 ! temperature, and appropriate species. below laytrop, the water
4582 ! vapor self-continuum is interpolated (in temperature) separately.
4583 
4584  do k = 1, nlay
4585  tauray = colmol(k) * rayl
4586 
4587  do j = 1, ng20
4588  taur(k,ns20+j) = tauray
4589  enddo
4590  enddo
4591 
4592  do k = 1, laytrop
4593  ind01 = id0(k,20) + 1
4594  ind02 = ind01 + 1
4595  ind11 = id1(k,20) + 1
4596  ind12 = ind11 + 1
4597 
4598  inds = indself(k)
4599  indf = indfor(k)
4600  indsp= inds + 1
4601  indfp= indf + 1
4602 
4603  do j = 1, ng20
4604  taug(k,ns20+j) = colamt(k,1) &
4605  & * ( (fac00(k)*absa(ind01,j) + fac10(k)*absa(ind02,j) &
4606  & + fac01(k)*absa(ind11,j) + fac11(k)*absa(ind12,j)) &
4607  & + selffac(k) * (selfref(inds,j) + selffrac(k) &
4608  & * (selfref(indsp,j) - selfref(inds,j))) &
4609  & + forfac(k) * (forref(indf,j) + forfrac(k) &
4610  & * (forref(indfp,j) - forref(indf,j))) ) &
4611  & + colamt(k,5) * absch4(j)
4612  enddo
4613  enddo
4614 
4615  do k = laytrop+1, nlay
4616  ind01 = id0(k,20) + 1
4617  ind02 = ind01 + 1
4618  ind11 = id1(k,20) + 1
4619  ind12 = ind11 + 1
4620 
4621  indf = indfor(k)
4622  indfp= indf + 1
4623 
4624  do j = 1, ng20
4625  taug(k,ns20+j) = colamt(k,1) &
4626  & * ( fac00(k)*absb(ind01,j) + fac10(k)*absb(ind02,j) &
4627  & + fac01(k)*absb(ind11,j) + fac11(k)*absb(ind12,j) &
4628  & + forfac(k) * (forref(indf,j) + forfrac(k) &
4629  & * (forref(indfp,j) - forref(indf,j))) ) &
4630  & + colamt(k,5) * absch4(j)
4631  enddo
4632  enddo
4633 
4634  return
4635 !...................................
4636  end subroutine taumol20
4637 !-----------------------------------
4638 
4639 
4642 !-----------------------------------
4643  subroutine taumol21
4644 !...................................
4645 
4646 ! ------------------------------------------------------------------ !
4647 ! band 21: 6150-7700 cm-1 (low - h2o,co2; high - h2o,co2) !
4648 ! ------------------------------------------------------------------ !
4649 !
4650  use module_radsw_kgb21
4651 
4652 ! --- locals:
4653  real (kind=kind_phys) :: speccomb, specmult, tauray, fs, fs1, &
4654  & fac000,fac001,fac010,fac011, fac100,fac101,fac110,fac111
4655 
4656  integer :: ind01, ind02, ind03, ind04, ind11, ind12, ind13, ind14
4657  integer :: inds, indf, indsp, indfp, j, js, k
4658 
4659 !
4660 !===> ... begin here
4661 !
4662 
4663 ! --- ... compute the optical depth by interpolating in ln(pressure),
4664 ! temperature, and appropriate species. below laytrop, the water
4665 ! vapor self-continuum is interpolated (in temperature) separately.
4666 
4667  do k = 1, nlay
4668  tauray = colmol(k) * rayl
4669 
4670  do j = 1, ng21
4671  taur(k,ns21+j) = tauray
4672  enddo
4673  enddo
4674 
4675  do k = 1, laytrop
4676  speccomb = colamt(k,1) + strrat(21)*colamt(k,2)
4677  specmult = 8.0 * min(oneminus, colamt(k,1) / speccomb)
4678 
4679  js = 1 + int(specmult)
4680  fs = mod(specmult, f_one)
4681  fs1= f_one - fs
4682  fac000 = fs1 * fac00(k)
4683  fac010 = fs1 * fac10(k)
4684  fac100 = fs * fac00(k)
4685  fac110 = fs * fac10(k)
4686  fac001 = fs1 * fac01(k)
4687  fac011 = fs1 * fac11(k)
4688  fac101 = fs * fac01(k)
4689  fac111 = fs * fac11(k)
4690 
4691  ind01 = id0(k,21) + js
4692  ind02 = ind01 + 1
4693  ind03 = ind01 + 9
4694  ind04 = ind01 + 10
4695  ind11 = id1(k,21) + js
4696  ind12 = ind11 + 1
4697  ind13 = ind11 + 9
4698  ind14 = ind11 + 10
4699 
4700  inds = indself(k)
4701  indf = indfor(k)
4702  indsp= inds + 1
4703  indfp= indf + 1
4704 
4705  do j = 1, ng21
4706  taug(k,ns21+j) = speccomb &
4707  & * ( fac000 * absa(ind01,j) + fac100 * absa(ind02,j) &
4708  & + fac010 * absa(ind03,j) + fac110 * absa(ind04,j) &
4709  & + fac001 * absa(ind11,j) + fac101 * absa(ind12,j) &
4710  & + fac011 * absa(ind13,j) + fac111 * absa(ind14,j) ) &
4711  & + colamt(k,1) * (selffac(k) * (selfref(inds,j) &
4712  & + selffrac(k) * (selfref(indsp,j) - selfref(inds,j))) &
4713  & + forfac(k) * (forref(indf,j) + forfrac(k) &
4714  & * (forref(indfp,j) - forref(indf,j))))
4715  enddo
4716  enddo
4717 
4718  do k = laytrop+1, nlay
4719  speccomb = colamt(k,1) + strrat(21)*colamt(k,2)
4720  specmult = 4.0 * min(oneminus, colamt(k,1) / speccomb)
4721 
4722  js = 1 + int(specmult)
4723  fs = mod(specmult, f_one)
4724  fs1= f_one - fs
4725  fac000 = fs1 * fac00(k)
4726  fac010 = fs1 * fac10(k)
4727  fac100 = fs * fac00(k)
4728  fac110 = fs * fac10(k)
4729  fac001 = fs1 * fac01(k)
4730  fac011 = fs1 * fac11(k)
4731  fac101 = fs * fac01(k)
4732  fac111 = fs * fac11(k)
4733 
4734  ind01 = id0(k,21) + js
4735  ind02 = ind01 + 1
4736  ind03 = ind01 + 5
4737  ind04 = ind01 + 6
4738  ind11 = id1(k,21) + js
4739  ind12 = ind11 + 1
4740  ind13 = ind11 + 5
4741  ind14 = ind11 + 6
4742 
4743  indf = indfor(k)
4744  indfp= indf + 1
4745 
4746  do j = 1, ng21
4747  taug(k,ns21+j) = speccomb &
4748  & * ( fac000 * absb(ind01,j) + fac100 * absb(ind02,j) &
4749  & + fac010 * absb(ind03,j) + fac110 * absb(ind04,j) &
4750  & + fac001 * absb(ind11,j) + fac101 * absb(ind12,j) &
4751  & + fac011 * absb(ind13,j) + fac111 * absb(ind14,j) ) &
4752  & + colamt(k,1) * forfac(k) * (forref(indf,j) &
4753  & + forfrac(k) * (forref(indfp,j) - forref(indf,j)))
4754  enddo
4755  enddo
4756 
4757 !...................................
4758  end subroutine taumol21
4759 !-----------------------------------
4760 
4761 
4764 !-----------------------------------
4765  subroutine taumol22
4766 !...................................
4767 
4768 ! ------------------------------------------------------------------ !
4769 ! band 22: 7700-8050 cm-1 (low - h2o,o2; high - o2) !
4770 ! ------------------------------------------------------------------ !
4771 !
4772  use module_radsw_kgb22
4773 
4774 ! --- locals:
4775  real (kind=kind_phys) :: speccomb, specmult, tauray, fs, fs1, &
4776  & fac000,fac001,fac010,fac011, fac100,fac101,fac110,fac111, &
4777  & o2adj, o2cont, o2tem
4778 
4779  integer :: ind01, ind02, ind03, ind04, ind11, ind12, ind13, ind14
4780  integer :: inds, indf, indsp, indfp, j, js, k
4781 
4782 !
4783 !===> ... begin here
4784 !
4785 ! --- ... the following factor is the ratio of total o2 band intensity (lines
4786 ! and mate continuum) to o2 band intensity (line only). it is needed
4787 ! to adjust the optical depths since the k's include only lines.
4788 
4789  o2adj = 1.6
4790  o2tem = 4.35e-4 / (350.0*2.0)
4791 
4792 
4793 ! --- ... compute the optical depth by interpolating in ln(pressure),
4794 ! temperature, and appropriate species. below laytrop, the water
4795 ! vapor self-continuum is interpolated (in temperature) separately.
4796 
4797  do k = 1, nlay
4798  tauray = colmol(k) * rayl
4799 
4800  do j = 1, ng22
4801  taur(k,ns22+j) = tauray
4802  enddo
4803  enddo
4804 
4805  do k = 1, laytrop
4806  o2cont = o2tem * colamt(k,6)
4807  speccomb = colamt(k,1) + strrat(22)*colamt(k,6)
4808  specmult = 8.0 * min(oneminus, colamt(k,1) / speccomb)
4809 
4810  js = 1 + int(specmult)
4811  fs = mod(specmult, f_one)
4812  fs1= f_one - fs
4813  fac000 = fs1 * fac00(k)
4814  fac010 = fs1 * fac10(k)
4815  fac100 = fs * fac00(k)
4816  fac110 = fs * fac10(k)
4817  fac001 = fs1 * fac01(k)
4818  fac011 = fs1 * fac11(k)
4819  fac101 = fs * fac01(k)
4820  fac111 = fs * fac11(k)
4821 
4822  ind01 = id0(k,22) + js
4823  ind02 = ind01 + 1
4824  ind03 = ind01 + 9
4825  ind04 = ind01 + 10
4826  ind11 = id1(k,22) + js
4827  ind12 = ind11 + 1
4828  ind13 = ind11 + 9
4829  ind14 = ind11 + 10
4830 
4831  inds = indself(k)
4832  indf = indfor(k)
4833  indsp= inds + 1
4834  indfp= indf + 1
4835 
4836  do j = 1, ng22
4837  taug(k,ns22+j) = speccomb &
4838  & * ( fac000 * absa(ind01,j) + fac100 * absa(ind02,j) &
4839  & + fac010 * absa(ind03,j) + fac110 * absa(ind04,j) &
4840  & + fac001 * absa(ind11,j) + fac101 * absa(ind12,j) &
4841  & + fac011 * absa(ind13,j) + fac111 * absa(ind14,j) ) &
4842  & + colamt(k,1) * (selffac(k) * (selfref(inds,j) &
4843  & + selffrac(k) * (selfref(indsp,j)-selfref(inds,j))) &
4844  & + forfac(k) * (forref(indf,j) + forfrac(k) &
4845  & * (forref(indfp,j) - forref(indf,j)))) + o2cont
4846  enddo
4847  enddo
4848 
4849  do k = laytrop+1, nlay
4850  o2cont = o2tem * colamt(k,6)
4851 
4852  ind01 = id0(k,22) + 1
4853  ind02 = ind01 + 1
4854  ind11 = id1(k,22) + 1
4855  ind12 = ind11 + 1
4856 
4857  do j = 1, ng22
4858  taug(k,ns22+j) = colamt(k,6) * o2adj &
4859  & * ( fac00(k)*absb(ind01,j) + fac10(k)*absb(ind02,j) &
4860  & + fac01(k)*absb(ind11,j) + fac11(k)*absb(ind12,j) ) &
4861  & + o2cont
4862  enddo
4863  enddo
4864 
4865  return
4866 !...................................
4867  end subroutine taumol22
4868 !-----------------------------------
4869 
4870 
4873 !-----------------------------------
4874  subroutine taumol23
4875 !...................................
4876 
4877 ! ------------------------------------------------------------------ !
4878 ! band 23: 8050-12850 cm-1 (low - h2o; high - nothing) !
4879 ! ------------------------------------------------------------------ !
4880 !
4881  use module_radsw_kgb23
4882 
4883 ! --- locals:
4884  integer :: ind01, ind02, ind11, ind12
4885  integer :: inds, indf, indsp, indfp, j, k
4886 
4887 !
4888 !===> ... begin here
4889 !
4890 
4891 ! --- ... compute the optical depth by interpolating in ln(pressure),
4892 ! temperature, and appropriate species. below laytrop, the water
4893 ! vapor self-continuum is interpolated (in temperature) separately.
4894 
4895  do k = 1, nlay
4896  do j = 1, ng23
4897  taur(k,ns23+j) = colmol(k) * rayl(j)
4898  enddo
4899  enddo
4900 
4901  do k = 1, laytrop
4902  ind01 = id0(k,23) + 1
4903  ind02 = ind01 + 1
4904  ind11 = id1(k,23) + 1
4905  ind12 = ind11 + 1
4906 
4907  inds = indself(k)
4908  indf = indfor(k)
4909  indsp= inds + 1
4910  indfp= indf + 1
4911 
4912  do j = 1, ng23
4913  taug(k,ns23+j) = colamt(k,1) * (givfac &
4914  & * ( fac00(k)*absa(ind01,j) + fac10(k)*absa(ind02,j) &
4915  & + fac01(k)*absa(ind11,j) + fac11(k)*absa(ind12,j) ) &
4916  & + selffac(k) * (selfref(inds,j) + selffrac(k) &
4917  & * (selfref(indsp,j) - selfref(inds,j))) &
4918  & + forfac(k) * (forref(indf,j) + forfrac(k) &
4919  & * (forref(indfp,j) - forref(indf,j))))
4920  enddo
4921  enddo
4922 
4923  do k = laytrop+1, nlay
4924  do j = 1, ng23
4925  taug(k,ns23+j) = f_zero
4926  enddo
4927  enddo
4928 
4929 !...................................
4930  end subroutine taumol23
4931 !-----------------------------------
4932 
4933 
4936 !-----------------------------------
4937  subroutine taumol24
4938 !...................................
4939 
4940 ! ------------------------------------------------------------------ !
4941 ! band 24: 12850-16000 cm-1 (low - h2o,o2; high - o2) !
4942 ! ------------------------------------------------------------------ !
4943 !
4944  use module_radsw_kgb24
4945 
4946 ! --- locals:
4947  real (kind=kind_phys) :: speccomb, specmult, fs, fs1, &
4948  & fac000,fac001,fac010,fac011, fac100,fac101,fac110,fac111
4949 
4950  integer :: ind01, ind02, ind03, ind04, ind11, ind12, ind13, ind14
4951  integer :: inds, indf, indsp, indfp, j, js, k
4952 
4953 !
4954 !===> ... begin here
4955 !
4956 
4957 ! --- ... compute the optical depth by interpolating in ln(pressure),
4958 ! temperature, and appropriate species. below laytrop, the water
4959 ! vapor self-continuum is interpolated (in temperature) separately.
4960 
4961  do k = 1, laytrop
4962  speccomb = colamt(k,1) + strrat(24)*colamt(k,6)
4963  specmult = 8.0 * min(oneminus, colamt(k,1) / speccomb)
4964 
4965  js = 1 + int(specmult)
4966  fs = mod(specmult, f_one)
4967  fs1= f_one - fs
4968  fac000 = fs1 * fac00(k)
4969  fac010 = fs1 * fac10(k)
4970  fac100 = fs * fac00(k)
4971  fac110 = fs * fac10(k)
4972  fac001 = fs1 * fac01(k)
4973  fac011 = fs1 * fac11(k)
4974  fac101 = fs * fac01(k)
4975  fac111 = fs * fac11(k)
4976 
4977  ind01 = id0(k,24) + js
4978  ind02 = ind01 + 1
4979  ind03 = ind01 + 9
4980  ind04 = ind01 + 10
4981  ind11 = id1(k,24) + js
4982  ind12 = ind11 + 1
4983  ind13 = ind11 + 9
4984  ind14 = ind11 + 10
4985 
4986  inds = indself(k)
4987  indf = indfor(k)
4988  indsp= inds + 1
4989  indfp= indf + 1
4990 
4991  do j = 1, ng24
4992  taug(k,ns24+j) = speccomb &
4993  & * ( fac000 * absa(ind01,j) + fac100 * absa(ind02,j) &
4994  & + fac010 * absa(ind03,j) + fac110 * absa(ind04,j) &
4995  & + fac001 * absa(ind11,j) + fac101 * absa(ind12,j) &
4996  & + fac011 * absa(ind13,j) + fac111 * absa(ind14,j) ) &
4997  & + colamt(k,3) * abso3a(j) + colamt(k,1) &
4998  & * (selffac(k) * (selfref(inds,j) + selffrac(k) &
4999  & * (selfref(indsp,j) - selfref(inds,j))) &
5000  & + forfac(k) * (forref(indf,j) + forfrac(k) &
5001  & * (forref(indfp,j) - forref(indf,j))))
5002 
5003  taur(k,ns24+j) = colmol(k) &
5004  & * (rayla(j,js) + fs*(rayla(j,js+1) - rayla(j,js)))
5005  enddo
5006  enddo
5007 
5008  do k = laytrop+1, nlay
5009  ind01 = id0(k,24) + 1
5010  ind02 = ind01 + 1
5011  ind11 = id1(k,24) + 1
5012  ind12 = ind11 + 1
5013 
5014  do j = 1, ng24
5015  taug(k,ns24+j) = colamt(k,6) &
5016  & * ( fac00(k)*absb(ind01,j) + fac10(k)*absb(ind02,j) &
5017  & + fac01(k)*absb(ind11,j) + fac11(k)*absb(ind12,j) ) &
5018  & + colamt(k,3) * abso3b(j)
5019 
5020  taur(k,ns24+j) = colmol(k) * raylb(j)
5021  enddo
5022  enddo
5023 
5024  return
5025 !...................................
5026  end subroutine taumol24
5027 !-----------------------------------
5028 
5029 
5032 !-----------------------------------
5033  subroutine taumol25
5034 !...................................
5035 
5036 ! ------------------------------------------------------------------ !
5037 ! band 25: 16000-22650 cm-1 (low - h2o; high - nothing) !
5038 ! ------------------------------------------------------------------ !
5039 !
5040  use module_radsw_kgb25
5041 
5042 ! --- locals:
5043  integer :: ind01, ind02, ind11, ind12
5044  integer :: j, k
5045 
5046 !
5047 !===> ... begin here
5048 !
5049 
5050 ! --- ... compute the optical depth by interpolating in ln(pressure),
5051 ! temperature, and appropriate species. below laytrop, the water
5052 ! vapor self-continuum is interpolated (in temperature) separately.
5053 
5054  do k = 1, nlay
5055  do j = 1, ng25
5056  taur(k,ns25+j) = colmol(k) * rayl(j)
5057  enddo
5058  enddo
5059 
5060  do k = 1, laytrop
5061  ind01 = id0(k,25) + 1
5062  ind02 = ind01 + 1
5063  ind11 = id1(k,25) + 1
5064  ind12 = ind11 + 1
5065 
5066  do j = 1, ng25
5067  taug(k,ns25+j) = colamt(k,1) &
5068  & * ( fac00(k)*absa(ind01,j) + fac10(k)*absa(ind02,j) &
5069  & + fac01(k)*absa(ind11,j) + fac11(k)*absa(ind12,j) ) &
5070  & + colamt(k,3) * abso3a(j)
5071  enddo
5072  enddo
5073 
5074  do k = laytrop+1, nlay
5075  do j = 1, ng25
5076  taug(k,ns25+j) = colamt(k,3) * abso3b(j)
5077  enddo
5078  enddo
5079 
5080  return
5081 !...................................
5082  end subroutine taumol25
5083 !-----------------------------------
5084 
5085 
5088 !-----------------------------------
5089  subroutine taumol26
5090 !...................................
5091 
5092 ! ------------------------------------------------------------------ !
5093 ! band 26: 22650-29000 cm-1 (low - nothing; high - nothing) !
5094 ! ------------------------------------------------------------------ !
5095 !
5096  use module_radsw_kgb26
5097 
5098 ! --- locals:
5099  integer :: j, k
5100 
5101 !
5102 !===> ... begin here
5103 !
5104 
5105 ! --- ... compute the optical depth by interpolating in ln(pressure),
5106 ! temperature, and appropriate species. below laytrop, the water
5107 ! vapor self-continuum is interpolated (in temperature) separately.
5108 
5109  do k = 1, nlay
5110  do j = 1, ng26
5111  taug(k,ns26+j) = f_zero
5112  taur(k,ns26+j) = colmol(k) * rayl(j)
5113  enddo
5114  enddo
5115 
5116  return
5117 !...................................
5118  end subroutine taumol26
5119 !-----------------------------------
5120 
5121 
5124 !-----------------------------------
5125  subroutine taumol27
5126 !...................................
5127 
5128 ! ------------------------------------------------------------------ !
5129 ! band 27: 29000-38000 cm-1 (low - o3; high - o3) !
5130 ! ------------------------------------------------------------------ !
5131 !
5132  use module_radsw_kgb27
5133 !
5134 ! --- locals:
5135  integer :: ind01, ind02, ind11, ind12
5136  integer :: j, k
5137 
5138 !
5139 !===> ... begin here
5140 !
5141 
5142 ! --- ... compute the optical depth by interpolating in ln(pressure),
5143 ! temperature, and appropriate species. below laytrop, the water
5144 ! vapor self-continuum is interpolated (in temperature) separately.
5145 
5146  do k = 1, nlay
5147  do j = 1, ng27
5148  taur(k,ns27+j) = colmol(k) * rayl(j)
5149  enddo
5150  enddo
5151 
5152  do k = 1, laytrop
5153  ind01 = id0(k,27) + 1
5154  ind02 = ind01 + 1
5155  ind11 = id1(k,27) + 1
5156  ind12 = ind11 + 1
5157 
5158  do j = 1, ng27
5159  taug(k,ns27+j) = colamt(k,3) &
5160  & * ( fac00(k)*absa(ind01,j) + fac10(k)*absa(ind02,j) &
5161  & + fac01(k)*absa(ind11,j) + fac11(k)*absa(ind12,j) )
5162  enddo
5163  enddo
5164 
5165  do k = laytrop+1, nlay
5166  ind01 = id0(k,27) + 1
5167  ind02 = ind01 + 1
5168  ind11 = id1(k,27) + 1
5169  ind12 = ind11 + 1
5170 
5171  do j = 1, ng27
5172  taug(k,ns27+j) = colamt(k,3) &
5173  & * ( fac00(k)*absb(ind01,j) + fac10(k)*absb(ind02,j) &
5174  & + fac01(k)*absb(ind11,j) + fac11(k)*absb(ind12,j) )
5175  enddo
5176  enddo
5177 
5178  return
5179 !...................................
5180  end subroutine taumol27
5181 !-----------------------------------
5182 
5183 
5186 !-----------------------------------
5187  subroutine taumol28
5188 !...................................
5189 
5190 ! ------------------------------------------------------------------ !
5191 ! band 28: 38000-50000 cm-1 (low - o3,o2; high - o3,o2) !
5192 ! ------------------------------------------------------------------ !
5193 !
5194  use module_radsw_kgb28
5195 
5196 ! --- locals:
5197  real (kind=kind_phys) :: speccomb, specmult, tauray, fs, fs1, &
5198  & fac000,fac001,fac010,fac011, fac100,fac101,fac110,fac111
5199 
5200  integer :: ind01, ind02, ind03, ind04, ind11, ind12, ind13, ind14
5201  integer :: j, js, k
5202 
5203 !
5204 !===> ... begin here
5205 !
5206 
5207 ! --- ... compute the optical depth by interpolating in ln(pressure),
5208 ! temperature, and appropriate species. below laytrop, the water
5209 ! vapor self-continuum is interpolated (in temperature) separately.
5210 
5211  do k = 1, nlay
5212  tauray = colmol(k) * rayl
5213 
5214  do j = 1, ng28
5215  taur(k,ns28+j) = tauray
5216  enddo
5217  enddo
5218 
5219  do k = 1, laytrop
5220  speccomb = colamt(k,3) + strrat(28)*colamt(k,6)
5221  specmult = 8.0 * min(oneminus, colamt(k,3) / speccomb)
5222 
5223  js = 1 + int(specmult)
5224  fs = mod(specmult, f_one)
5225  fs1= f_one - fs
5226  fac000 = fs1 * fac00(k)
5227  fac010 = fs1 * fac10(k)
5228  fac100 = fs * fac00(k)
5229  fac110 = fs * fac10(k)
5230  fac001 = fs1 * fac01(k)
5231  fac011 = fs1 * fac11(k)
5232  fac101 = fs * fac01(k)
5233  fac111 = fs * fac11(k)
5234 
5235  ind01 = id0(k,28) + js
5236  ind02 = ind01 + 1
5237  ind03 = ind01 + 9
5238  ind04 = ind01 + 10
5239  ind11 = id1(k,28) + js
5240  ind12 = ind11 + 1
5241  ind13 = ind11 + 9
5242  ind14 = ind11 + 10
5243 
5244  do j = 1, ng28
5245  taug(k,ns28+j) = speccomb &
5246  & * ( fac000 * absa(ind01,j) + fac100 * absa(ind02,j) &
5247  & + fac010 * absa(ind03,j) + fac110 * absa(ind04,j) &
5248  & + fac001 * absa(ind11,j) + fac101 * absa(ind12,j) &
5249  & + fac011 * absa(ind13,j) + fac111 * absa(ind14,j) )
5250  enddo
5251  enddo
5252 
5253  do k = laytrop+1, nlay
5254  speccomb = colamt(k,3) + strrat(28)*colamt(k,6)
5255  specmult = 4.0 * min(oneminus, colamt(k,3) / speccomb)
5256 
5257  js = 1 + int(specmult)
5258  fs = mod(specmult, f_one)
5259  fs1= f_one - fs
5260  fac000 = fs1 * fac00(k)
5261  fac010 = fs1 * fac10(k)
5262  fac100 = fs * fac00(k)
5263  fac110 = fs * fac10(k)
5264  fac001 = fs1 * fac01(k)
5265  fac011 = fs1 * fac11(k)
5266  fac101 = fs * fac01(k)
5267  fac111 = fs * fac11(k)
5268 
5269  ind01 = id0(k,28) + js
5270  ind02 = ind01 + 1
5271  ind03 = ind01 + 5
5272  ind04 = ind01 + 6
5273  ind11 = id1(k,28) + js
5274  ind12 = ind11 + 1
5275  ind13 = ind11 + 5
5276  ind14 = ind11 + 6
5277 
5278  do j = 1, ng28
5279  taug(k,ns28+j) = speccomb &
5280  & * ( fac000 * absb(ind01,j) + fac100 * absb(ind02,j) &
5281  & + fac010 * absb(ind03,j) + fac110 * absb(ind04,j) &
5282  & + fac001 * absb(ind11,j) + fac101 * absb(ind12,j) &
5283  & + fac011 * absb(ind13,j) + fac111 * absb(ind14,j) )
5284  enddo
5285  enddo
5286 
5287  return
5288 !...................................
5289  end subroutine taumol28
5290 !-----------------------------------
5291 
5292 
5295 !-----------------------------------
5296  subroutine taumol29
5297 !...................................
5298 
5299 ! ------------------------------------------------------------------ !
5300 ! band 29: 820-2600 cm-1 (low - h2o; high - co2) !
5301 ! ------------------------------------------------------------------ !
5302 !
5303  use module_radsw_kgb29
5304 
5305 ! --- locals:
5306  real (kind=kind_phys) :: tauray
5307 
5308  integer :: ind01, ind02, ind11, ind12
5309  integer :: inds, indf, indsp, indfp, j, k
5310 
5311 !
5312 !===> ... begin here
5313 !
5314 
5315 ! --- ... compute the optical depth by interpolating in ln(pressure),
5316 ! temperature, and appropriate species. below laytrop, the water
5317 ! vapor self-continuum is interpolated (in temperature) separately.
5318 
5319  do k = 1, nlay
5320  tauray = colmol(k) * rayl
5321 
5322  do j = 1, ng29
5323  taur(k,ns29+j) = tauray
5324  enddo
5325  enddo
5326 
5327  do k = 1, laytrop
5328  ind01 = id0(k,29) + 1
5329  ind02 = ind01 + 1
5330  ind11 = id1(k,29) + 1
5331  ind12 = ind11 + 1
5332 
5333  inds = indself(k)
5334  indf = indfor(k)
5335  indsp= inds + 1
5336  indfp= indf + 1
5337 
5338  do j = 1, ng29
5339  taug(k,ns29+j) = colamt(k,1) &
5340  & * ( (fac00(k)*absa(ind01,j) + fac10(k)*absa(ind02,j) &
5341  & + fac01(k)*absa(ind11,j) + fac11(k)*absa(ind12,j) ) &
5342  & + selffac(k) * (selfref(inds,j) + selffrac(k) &
5343  & * (selfref(indsp,j) - selfref(inds,j))) &
5344  & + forfac(k) * (forref(indf,j) + forfrac(k) &
5345  & * (forref(indfp,j) - forref(indf,j)))) &
5346  & + colamt(k,2) * absco2(j)
5347  enddo
5348  enddo
5349 
5350  do k = laytrop+1, nlay
5351  ind01 = id0(k,29) + 1
5352  ind02 = ind01 + 1
5353  ind11 = id1(k,29) + 1
5354  ind12 = ind11 + 1
5355 
5356  do j = 1, ng29
5357  taug(k,ns29+j) = colamt(k,2) &
5358  & * ( fac00(k)*absb(ind01,j) + fac10(k)*absb(ind02,j) &
5359  & + fac01(k)*absb(ind11,j) + fac11(k)*absb(ind12,j) ) &
5360  & + colamt(k,1) * absh2o(j)
5361  enddo
5362  enddo
5363 
5364  return
5365 !...................................
5366  end subroutine taumol29
5367 !-----------------------------------
5368 
5369 !...................................
5370  end subroutine taumol
5371 !-----------------------------------
5372 !! @}
5373 
5374 !
5375 !........................................!
5376  end module module_radsw_main !
5377 !========================================!
5378 !! @}
real(kind=kind_phys), dimension(msf22, ng22), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
integer, save iovrsw
cloud overlapping control flag for SW =0:use random cloud overlapping method =1:use maximum-rando...
Definition: physparam.f:251
real(kind=kind_phys), parameter, public rayl
rayleigh extinction coefficient at
This module sets up absorption coeffients for band 19: 4650-5150 cm-1 (low - h2o,co2; high - co2) ...
integer, save isubcsw
sub-column cloud approx flag in SW radiation =0:no McICA approximation in SW radiation =1:use McI...
Definition: physparam.f:295
subroutine taumol(colamt, colmol, fac00, fac01, fac10, fac11, jp, jt, jt1, laytrop, forfac, forfrac, indfor, selffac, selffrac, indself, nlay, sfluxzen, taug, taur )
This subroutine calculates optical depths for gaseous absorption and rayleigh scattering subroutine...
Definition: radsw_main.f:3898
real(kind=kind_phys), parameter con_amw
molecular wght of water vapor ( )
Definition: physcons.f:138
real(kind=kind_phys), dimension(msf24, ng24), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), parameter, public rayl
rayleigh extinction coefficient at
real(kind=kind_phys), dimension(5), public ebari
asymmetry coefficients
Definition: radsw_datatb.f:278
real(kind=kind_phys), dimension(msf18, ng18), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
This module sets up absorption coeffients for band 24: 12850-16000 cm-1 (low - h2o, o2; high - o2)
real(kind=kind_phys), dimension(msa19, ng19), public absa
the array absa(585,NG19) (ka(9,5,13,NG19)) contains absorption coefs at the 16 chosen g-values for a ...
subroutine taumol17
The subroutine computes the optical depth in band 17: 3250-4000 cm-1 (low - h2o,co2; high - h2o...
Definition: radsw_main.f:4247
real(kind=kind_phys) heatfac
the factor for heating rates (in k/day, or k/sec set by subroutine 'rswinit')
Definition: radsw_main.f:498
subroutine spcvrtm(ssolar, cosz, sntz, albbm, albdf, sfluxzen, cldfmc, cf1, cf0, taug, taur, tauae, ssaae, asyae, taucw, ssacw, asycw, nlay, nlp1, fxupc, fxdnc, fxup0, fxdn0, ftoauc, ftoau0, ftoadc, fsfcuc, fsfcu0, fsfcdc, fsfcd0, sfbmc, sfdfc, sfbm0, sfdf0, suvbfc, suvbf0 )
This subroutine computes the shortwave radiative fluxes using two-stream method of h...
Definition: radsw_main.f:3060
real(kind=kind_phys), dimension(msa23, ng23), public absa
the array absa(65,NG23) (ka(5,13,NG23)) contains absorption coefs at the 16 chosen g-values for a ran...
integer, dimension(nblow:nbhgh), public ix2
indexes for 2nd entries of the two key species for each of the spectral bands
real(kind=kind_phys), parameter con_g
gravity ( )
Definition: physcons.f:59
real(kind=kind_phys), dimension(0:ntbmx) exp_tbl
those data will be set up only once by "rswinit"
Definition: radsw_main.f:493
integer, dimension(nblow:nbhgh), public ix1
indexes for 1st entries of the two key species for each of the spectral bands
derived type for special components of surface SW fluxes
Definition: radsw_param.f:110
real(kind=kind_phys), dimension(ng24), public abso3a
o3
real(kind=kind_phys), dimension(msb28, ng28), public absb
the array absb(1175,6) (kb(5,5,13:59,6)) contains absorption coefs at the 16 chosen g-values for a ra...
real(kind=kind_phys), dimension(nblow:nbhgh), public c0r
asymmetry coefficients
This module sets up absorption coeffients for band 27: 29000-38000 cm-1 (low - o3; high - o3) ...
real(kind=kind_phys), dimension(43, nblow:nbhgh), public asyice2
asymmetry coefficients
Definition: radsw_datatb.f:249
integer, parameter iswrgas
SW minor gases effect control flag (CH4 and O2): =0:no; =1:yes. =0: minor gases' effects are not in...
Definition: physparam.f:73
real(kind=kind_phys), dimension(43, nblow:nbhgh), public extice2
extinction coefficients
Definition: radsw_datatb.f:243
real(kind=kind_phys), dimension(msf16, ng16), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
integer, parameter nbhgh
band range upper index
Definition: radsw_param.f:130
This module sets up absorption coeffients for band 20: 5150-6150 cm-1 (low - h2o; high - h2o) ...
integer, parameter ntbmx
index upper limit of optical depth and transmittance tables
Definition: radsw_param.f:140
real(kind=kind_phys), dimension(msb24, ng24), public absb
the array absb(235,8) (kb(5,13:59,8)) contains absorption coefs at the 16 chosen g-values for a range...
real(kind=kind_phys), public a0s
optical depth coefficients
real(kind=kind_phys), dimension(ngmax, mfs01, mfb01), target, public sfluxref01
spectral solar fluxes, j=1,2,...,7 for SW band number of 16,20,23,25,26,27,29
integer, parameter nuvb
uv-b band index
Definition: radsw_main.f:483
real(kind=kind_phys), dimension(ng26), public rayl
rayleigh extinction coefficient at all v
integer, parameter ngptsw
total number of g-point in all bands
Definition: radsw_param.f:134
real(kind=kind_phys), dimension(msf23, ng23), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), parameter, public rayl
rayleigh extinction coefficient at
real(kind=kind_phys), dimension(58, nblow:nbhgh), public extliq1
extinction coefficients
Definition: radsw_datatb.f:232
integer, parameter iswmode
SW control flag for scattering process approximation =1:two-stream delta-eddington (Joseph et al...
Definition: physparam.f:97
This module contains cloud radiative property coefficients.
Definition: radsw_datatb.f:176
real(kind=kind_phys), dimension(nblow:nbhgh), public c0s
asymmetry coefficients
real(kind=kind_phys), dimension(msb22, ng22), public absb
the array absb(235,2) (kb(5,13:59,2)) contains absorption coefs at the 16 chosen g-values for a range...
real(kind=kind_phys), dimension(ng24, mfx24), public rayla
rayleigh extinction coefficient at all v
This module sets up absorption coeffients for band 23: 8050-12850 cm-1 (low - h2o; high - nothing) ...
real(kind=kind_phys), dimension(msf19, ng19), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(msa29, ng29), public absa
the array absa(65,NG29) (ka(5,13,NG29)) contains absorption coefs at the 16 chosen g-values for a ran...
real(kind=kind_phys), dimension(msa22, ng22), public absa
the array absa(585,NG22) (ka(9,5,13,NG22)) contains absorption coefs at the 16 chosen g-values for a ...
subroutine, public swrad(plyr, plvl, tlyr, tlvl, qlyr, olyr, gasvmr, clouds, icseed, aerosols, sfcalb, cosz, solcon, NDAY, idxday, npts, nlay, nlp1, lprnt, hswc, topflx, sfcflx, HSW0, HSWB, FLXPRF, FDNCMP )
This subroutine is the main SW radiation routine.
Definition: radsw_main.f:592
real(kind=kind_phys), dimension(msa27, ng27), public absa
the array absa(65,NG27) (ka(5,13,NG27)) contains absorption coefs at the 16 chosen g-values for a ran...
subroutine vrtqdr(zrefb, zrefd, ztrab, ztrad, zldbt, ztdbt, NLAY, NLP1, zfu, zfd )
This subroutine is called by spcvrtc() and spcvrtm(), and computes the upward and downward radiation ...
Definition: radsw_main.f:3762
real(kind=kind_phys), dimension(ngmax, mfs02, mfb02), target, public sfluxref02
spectral solar fluxes, j=1,2 for SW band number of 17 and 28
real(kind=kind_phys), dimension(msb27, ng27), public absb
the array absb(235,8) (kb(5,13:59,8)) contains absorption coefs at the 16 chosen g-values for a range...
real(kind=kind_phys), dimension(msf20, ng20), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), dimension(msa16, ng16), public absa
the array absa(585,NG16) (ka(9,5,13,NG16)) contains absorption coefs at the 16 chosen g-values for a ...
real(kind=kind_phys), dimension(msa24, ng24), public absa
the array absa(585,NG24) (ka(9,5,13,NG24)) contains absorption coefs at the 16 chosen g-values for a ...
This module sets up absorption coeffients for band 18: 4000-4650 cm-1 (low - h2o,ch4; high - ch4) ...
subroutine setcoef(pavel, tavel, h2ovmr, nlay, nlp1, laytrop, jp, jt, jt1, fac00, fac01, fac10, fac11, selffac, selffrac, indself, forfac, forfrac, indfor )
This subroutine computes various coefficients needed in radiative transfer calculation.
Definition: radsw_main.f:2107
integer, save icldflg
cloud optical property scheme control flag =0:use diagnostic cloud scheme for cloud cover and mean ...
Definition: physparam.f:241
subroutine taumol22
The subroutine computes the optical depth in band 22: 7700-8050 cm-1 (low - h2o,o2; high - o2) ...
Definition: radsw_main.f:4766
real(kind=kind_phys), dimension(nblow:nbhgh), public b0s
single scattering albedo coefficients
derived type for SW fluxes' column profiles (at layer interfaces)
Definition: radsw_param.f:98
integer, dimension(nblow:nbhgh) idxebc
band index for cld prop
Definition: radsw_main.f:460
real(kind=kind_phys), dimension(msb29, ng29), public absb
the array absb(235,12) (kb(5,13:59,12)) contains absorption coefs at the 16 chosen g-values for a ran...
real(kind=kind_phys), dimension(ng20), public absch4
ch4
real(kind=kind_phys), dimension(43, nblow:nbhgh), public ssaice2
single scattering albedo coefficients
Definition: radsw_datatb.f:246
real(kind=kind_phys), parameter con_cp
spec heat air at p ( )
Definition: physcons.f:80
subroutine taumol23
The subroutine computes the optical depth in band 23: 8050-12850 cm-1 (low - h2o; high - nothing) ...
Definition: radsw_main.f:4875
real(kind=kind_phys), dimension(59) preflog
logarithm,ln(p), of a 59-level standard pressure profile
Definition: radsw_datatb.f:83
subroutine taumol26
The subroutine computes the optical depth in band 26: 22650-29000 cm-1 (low - nothing; high - nothing...
Definition: radsw_main.f:5090
integer, save iswcice
SW optical property for ice clouds (only iswcliq>0) =1:optical property scheme based on Ebert and C...
Definition: physparam.f:88
subroutine spcvrtc(ssolar, cosz, sntz, albbm, albdf, sfluxzen, cldfrc, cf1, cf0, taug, taur, tauae, ssaae, asyae, taucw, ssacw, asycw, nlay, nlp1, fxupc, fxdnc, fxup0, fxdn0, ftoauc, ftoau0, ftoadc, fsfcuc, fsfcu0, fsfcdc, fsfcd0, sfbmc, sfdfc, sfbm0, sfdf0, suvbfc, suvbf0 )
This subroutine computes the shortwave radiative fluxes using two-stream method.
Definition: radsw_main.f:2300
real(kind=kind_phys), dimension(ng25), public abso3b
o3
This module contains the reference pressures (in logarithm form) at 59 vertical levels (TOA is omitte...
Definition: radsw_datatb.f:73
integer, dimension(nblow:nbhgh) idxsfc
band index for sfc flux
Definition: radsw_main.f:458
subroutine taumol16
The subroutine computes the optical depth in band 16: 2600-3250 cm-1 (low - h2o,ch4; high - ch4) ...
Definition: radsw_main.f:4150
subroutine, public rswinit(me)
This subroutine initializes non-varying module variables, conversion factors, and look-up tables...
Definition: radsw_main.f:1375
This module is for specifying the band structures and program parameters used by the RRTMG-SW scheme...
Definition: radsw_param.f:66
real(kind=kind_phys), dimension(msb21, ng21), public absb
the array absb(1175,10) (kb(5,5,13:59,10)) contains absorption coefs at the 16 chosen g-values for a ...
integer, parameter nblow
band range lower index
Definition: radsw_param.f:128
subroutine taumol19
The subroutine computes the optical depth in band 19: 4650-5150 cm-1 (low - h2o,co2; high - co2) ...
Definition: radsw_main.f:4466
This module sets up absorption coeffients for band 26: 22650-29000 cm-1 (low - nothing; high - nothin...
subroutine taumol28
The subroutine computes the optical depth in band 28: 38000-50000 cm-1 (low - o3,o2; high - o3...
Definition: radsw_main.f:5188
subroutine taumol18
The subroutine computes the optical depth in band 18: 4000-4650 cm-1 (low - h2o,ch4; high - ch4) ...
Definition: radsw_main.f:4370
real(kind=kind_phys), dimension(nblow:nbhgh), public strrat
coefficients for computing binary absorbing species
integer, parameter iswrate
SW heating rate unit control flag: =1:k/day; =2:k/second.
Definition: physparam.f:68
real(kind=kind_phys), dimension(46, nblow:nbhgh), public extice3
extinction coefficients
Definition: radsw_datatb.f:255
real(kind=kind_phys), dimension(5), public fbari
asymmetry coefficients
Definition: radsw_datatb.f:280
real(kind=kind_phys), dimension(5), public dbari
single scattering albedo coefficients
Definition: radsw_datatb.f:276
This module sets up absorption coeffients for band 29: 820-2600 cm-1 (low - h2o; high - co2) ...
integer, save iswcliq
SW optical property for liquid clouds =0:input cld opt depth, ignoring iswcice setting =1:cloud o...
Definition: physparam.f:79
This module sets up absorption coeffients for band 17: 3250-4000 cm-1 (low - h2o,co2; high - h2o...
subroutine taumol29
The subroutine computes the optical depth in band 29: 820-2600 cm-1 (low - h2o; high - co2) ...
Definition: radsw_main.f:5297
real(kind=kind_phys), dimension(msa25, ng25), public absa
the array absa(65,NG25) (ka(5,13,NG25)) contains absorption coefs at the 16 chosen g-values for a ran...
real(kind=kind_phys), dimension(58, nblow:nbhgh), public asyliq1
asymmetry coefficients
Definition: radsw_datatb.f:238
real(kind=kind_phys), dimension(46, nblow:nbhgh), public asyice3
asymmetry coefficients
Definition: radsw_datatb.f:261
subroutine taumol27
The subroutine computes the optical depth in band 27: 29000-38000 cm-1 (low - o3; high - o3) ...
Definition: radsw_main.f:5126
This module sets up absorption coeffients for band 22: 7700-8050 cm-1 (low - h2o, o2; high - o2) ...
real(kind=kind_phys), dimension(msf29, ng29), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), parameter s0
internal solar constant
Definition: radsw_main.f:446
real(kind=kind_phys), dimension(ngmax, mfs03, mfb03), target, public sfluxref03
spectral solar fluxes, j=1,2,...,5 for SW band number of 18,19,21,22,24
integer, parameter ipsdsw0
initial permutation seed used for sub-column cloud scheme
Definition: radsw_main.f:502
This module contains various indexes and coefficients for SW spectral bands, as well as the spectral ...
real(kind=kind_phys), dimension(msa17, ng17), public absa
the array absa(585,NG17) (ka((9,5,13,NG17)) contains absorption coefs at the 16 chosen g-values for a...
real(kind=kind_phys), dimension(ng23), public rayl
rayleigh extinction coefficient at all v
real(kind=kind_phys), parameter con_avgd
avogadro constant ( )
Definition: physcons.f:131
real(kind=kind_phys), dimension(ng25), public abso3a
o3
subroutine taumol20
The subroutine computes the optical depth in band 20: 5150-6150 cm-1 (low - h2o; high - h2o) ...
Definition: radsw_main.f:4562
subroutine taumol21
The subroutine computes the optical depth in band 21: 6150-7700 cm-1 (low - h2o,co2; high - h2o...
Definition: radsw_main.f:4644
real(kind=kind_phys), dimension(msa21, ng21), public absa
the array absa(585,NG21) (ka((9,5,13,NG21)) contains absorption coefs at the 16 chosen g-values for a...
This module sets up absorption coeffients for band 25: 16000-22650 cm-1 (low - h2o; high - nothing) ...
real(kind=kind_phys), dimension(msb20, ng20), public absb
the array absb(235,10) (kb(5,13:59,10)) contains absorption coefs at the 16 chosen g-values for a ran...
real(kind=kind_phys), dimension(58, nblow:nbhgh), public ssaliq1
single scattering albedo coefficients
Definition: radsw_datatb.f:235
real(kind=kind_phys), dimension(msa18, ng18), public absa
the array absa(585,NG18) (ka(9,5,13,NG18)) contains absorption coefs at the 16 chosen g-values for a ...
real(kind=kind_phys), dimension(msb16, ng16), public absb
the array absb(235,6) (kb(5,13:59,6)) contains absorption coefs at the 16 chosen g-values for a range...
real(kind=kind_phys), parameter bpade
pade approx constant
Definition: radsw_main.f:442
real(kind=kind_phys), parameter, public rayl
rayleigh extinction coefficient at
integer, dimension(nblow:nbhgh) ngs
array contains values of NS16-NS29
Definition: radsw_param.f:168
integer, dimension(nblow:nbhgh), public ibx
band index (3rd index in array sfluxref described below)
real(kind=kind_phys), dimension(msb17, ng17), public absb
the array absb(1175,12) (kb(5,5,13:59,12)) contains absorption coefs at the 16 chosen g-values for a ...
real(kind=kind_phys), parameter, public rayl
rayleigh extinction coefficient
real(kind=kind_phys), parameter con_amo3
molecular wght of o3 ( )
Definition: physcons.f:140
subroutine taumol25
The subroutine computes the optical depth in band 25: 16000-22650 cm-1 (low - h2o; high - nothing) ...
Definition: radsw_main.f:5034
real(kind=kind_phys), dimension(msa20, ng20), public absa
the array absa(65,NG20) (ka(5,13,NG20)) contains absorption coefs at the 16 chosen g-values for a ran...
real(kind=kind_phys), dimension(46, nblow:nbhgh), public ssaice3
single scattering albedo coefficients
Definition: radsw_datatb.f:258
real(kind=kind_phys), public a0r
optical depth coefficients
This module sets up absorption coeffients for band 21: 6150-7700 cm-1 (low - h2o,co2; high - h2o...
real(kind=kind_phys), dimension(msb18, ng18), public absb
the array absb(235,8) (kb(5,13:59,8)) contains absorption coefs at the 16 chosen g-values for a range...
real(kind=kind_phys), dimension(5), public cbari
single scattering albedo coefficients
Definition: radsw_datatb.f:274
real(kind=kind_phys), parameter, public rayl
rayleigh extinction coefficient at v =
real(kind=kind_phys), parameter, public givfac
average giver et al. correction factor for this band.
derived type for SW fluxes at TOA
Definition: radsw_param.f:76
real(kind=kind_phys), dimension(msf21, ng21), 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, cf1, nlay, ipseed, taucw, ssacw, asycw, cldfrc, cldfmc )
This subroutine computes the cloud optical properties for each cloudy layer and g-point interval...
Definition: radsw_main.f:1564
real(kind=kind_phys), dimension(ng27), public rayl
rayleigh extinction coefficient
real(kind=kind_phys), dimension(msf17, ng17), public selfref
the array selfref contains the coefficient of the water vapor self-continuum (including the energy te...
real(kind=kind_phys), parameter, public rayl
rayleigh extinction coefficient at
integer, dimension(ngptsw) ngb
reverse checking of band index for each g-point
Definition: radsw_param.f:173
integer, save ivflip
vertical profile indexing flag
Definition: physparam.f:289
real(kind=kind_phys), dimension(ng29), public absh2o
h2o
integer, parameter maxgas
maximum number of absorbing gases
Definition: radsw_param.f:138
real(kind=kind_phys), dimension(msb19, ng19), public absb
the array absb(235,8) (kb(5,13:59,8)) contains absorption coefs at the 16 chosen g-values for a range...
integer, dimension(nblow:nbhgh), public layreffr
reference pressure level for each of the spectral bands
real(kind=kind_phys), dimension(nblow:nbhgh), public b0r
single scattering albedo coefficients
This module sets up absorption coeffients for band 28: 38000-50000 cm-1 (low - o3,o2; high - o3,o2)
real(kind=kind_phys), dimension(msa28, ng28), public absa
the array absa(585,NG28) (ka((9,5,13,NG28)) contains absorption coefs at the 16 chosen g-values for a...
real(kind=kind_phys), dimension(5), public abari
extinction coefficients
Definition: radsw_datatb.f:270
This module sets up absorption coefficients for band 16: 2600-3250 cm-1 (low - h2o, ch4; high - ch4)
derived type for SW fluxes at surface
Definition: radsw_param.f:86
real(kind=kind_phys), dimension(ng24), public abso3b
o3
real(kind=kind_phys), dimension(59) tref
MLS standard atmosphere temperature at the standard pressure levels.
Definition: radsw_datatb.f:85
subroutine mcica_subcol(cldf, nlay, ipseed, lcloudy )
This subroutine computes the sub-colum cloud profile flag array.
Definition: radsw_main.f:1924
real(kind=kind_phys), dimension(5), public bbari
extinction coefficients
Definition: radsw_datatb.f:272
real(kind=kind_phys), dimension(nblow:nbhgh), public specwt
weighting parameters for major absorbers in each band
real(kind=kind_phys), parameter, public rayl
rayleigh extinction coefficient at v = 3625
subroutine taumol24
The subroutine computes the optical depth in band 24: 12850-16000 cm-1 (low - h2o,o2; high - o2)
Definition: radsw_main.f:4938
real(kind=kind_phys), dimension(ng29), public absco2
co2
real(kind=kind_phys), parameter con_amd
molecular wght of dry air ( )
Definition: physcons.f:136
real(kind=kind_phys), dimension(ng25), public rayl
rayleigh extinction coefficient
real(kind=kind_phys), parameter, public rayl
rayleigh extinction coefficient at