FV3 Bundle
irrad.F90
Go to the documentation of this file.
1 module irradmod
2 
3 IMPLICIT NONE
4 
5 PRIVATE
8 
9 contains
10 
11  subroutine irrad ( np , & !Number of layers (LM)
12  ple_dev , & !Pressure at level edges (Pa)
13  ta_dev , & !d - Temperature (K)
14  wa_dev , & !d - Specific humidity (g/g)
15  oa_dev , & !d - Ozone (g/g)
16  tb_dev , & !Surface air temperature (K)
17  co2 , & !* Carbon dioxide (pppv)
18  trace , & !Option
19  n2o_dev , & !* Nitrous oxide (pppv)
20  ch4_dev , & !* Methane (pppv)
21  cfc11_dev , & !* Trichlorofluoromethane (pppv)
22  cfc12_dev , & !* Dichlorodifluoromethane (pppv)
23  cfc22_dev , & !* Chlorodifluoromethane (pppv)
24  cwc_dev , & !Cloud water mixing ratio (kg/kg)
25  fcld_dev , & !Cloud amount (fraction)
26  ict , & !Level index separating high and middle clouds
27  icb , & !Level index separating middle and low clouds
28  reff_dev , & !Effective size of cloud particles (micron)
29  ns , & !Number of sub-grid surface types
30  fs_dev , & !Fractional cover of sub-grid regions
31  tg_dev , & !Land or ocean surface temperature
32  eg_dev , & !Land or ocean surface emissivity
33  tv_dev , & !Vegetation temperature
34  ev_dev , & !Vegetation emissivity
35  rv_dev , & !Vegetation reflectivity
36  na , & !Number of bands
37  nb , & !Number of bands in IRRAD calcs for Chou
38  taua_dev , & !Aerosol optical thickness
39  ssaa_dev , & !Aerosol single scattering albedo
40  asya_dev , & !Aerosol asymmetry factor
41  flxu_dev , & !Upwelling flux, all-sky
42  flxd_dev , & !Downwelling flux, all-sky
43  dfdts_dev , & !Sensitivity of net downward flux to surface temperature
44  aib_ir, awb_ir, aiw_ir, &
45  aww_ir, aig_ir, awg_ir, &
46  xkw, xke, mw, aw, bw, pm, &
47  fkw, gkw, cb, dcb, &
48  w11, w12, w13, p11, p12, &
49  p13, dwe, dpe, &
50  c1, c2, c3, &
51  oo1, oo2, oo3, &
52  h11, h12, h13, &
53  h21, h22, h23, &
54  h81, h82, h83 )
55 
56  IMPLICIT NONE
57 
58  !Radiation constants, these need to be inputs for the autodiff tool
59  real(8), intent(IN) :: aib_ir(3,10), awb_ir(4,10), aiw_ir(4,10)
60  real(8), intent(IN) :: aww_ir(4,10), aig_ir(4,10), awg_ir(4,10)
61 
62  integer, intent(IN) :: mw(9)
63  real(8), intent(IN) :: xkw(9), xke(9), aw(9), bw(9), pm(9)
64  real(8), intent(IN) :: fkw(6,9), gkw(6,3), cb(6,10), dcb(5,10)
65  real(8), intent(IN) :: w11, w12, w13, p11, p12
66  real(8), intent(IN) :: p13, dwe, dpe
67  real(8), intent(IN) :: c1(26,30), c2(26,30), c3(26,30)
68  real(8), intent(IN) :: oo1(26,21), oo2(26,21), oo3(26,21)
69  real(8), intent(IN) :: h11(26,31), h12(26,31), h13(26,31)
70  real(8), intent(IN) :: h21(26,31), h22(26,31), h23(26,31)
71  real(8), intent(IN) :: h81(26,31), h82(26,31), h83(26,31)
72 
73  !----- INPUTS -----
74  INTEGER, INTENT(IN) :: np, ict, icb, ns, na, nb
75  LOGICAL, INTENT(IN) :: trace
76 
77  real(8), INTENT(IN) :: co2
78 
79  !Rank 2 inputs
80  real(8), INTENT(IN) :: tb_dev
81 
82  !Rank 3 (Prognostic variables and tracers)
83  real(8), DIMENSION(np), INTENT(IN) :: ta_dev, wa_dev, oa_dev, fcld_dev
84  real(8), DIMENSION(np), INTENT(IN) :: n2o_dev, ch4_dev, cfc11_dev, cfc12_dev, cfc22_dev
85  real(8), DIMENSION(np+1), INTENT(IN) :: ple_dev
86 
87  !Rank 3 (surface types)
88  real(8), DIMENSION(ns), INTENT(IN) :: fs_dev, tg_dev, tv_dev
89  real(8), DIMENSION(ns,10), INTENT(IN) :: eg_dev, ev_dev, rv_dev
90 
91  !Rank 3 (diagnostic cloud parts)
92  real(8), DIMENSION(np,4), INTENT(IN) :: cwc_dev, reff_dev
93 
94  !Rank 3 (aerosols)
95  real(8), DIMENSION(np,nb), INTENT(INOUT) :: taua_dev, ssaa_dev, asya_dev
96 
97 
98  !----- OUPUTS -----
99  real(8), DIMENSION(np+1), INTENT(OUT) :: flxu_dev
100  real(8), DIMENSION(np+1), INTENT(OUT) :: flxd_dev
101  real(8), DIMENSION(np+1), INTENT(OUT) :: dfdts_dev
102 
103  !----- LOCALS -----
104  real(8), parameter :: cons_grav = 9.80665
105 
106  integer, parameter :: nx1 = 26
107  integer, parameter :: no1 = 21
108  integer, parameter :: nc1 = 30
109  integer, parameter :: nh1 = 31
110 
111 
112  !Temporary arrays
113  real(8) :: pa(0:np),dt(0:np)
114  real(8) :: x1,x2,x3
115  real(8) :: dh2o(0:np),dcont(0:np),dco2(0:np),do3(0:np)
116  real(8) :: dn2o(0:np),dch4(0:np)
117  real(8) :: df11(0:np),df12(0:np),df22(0:np)
118  real(8) :: th2o(6),tcon(3),tco2(6)
119  real(8) :: tn2o(4),tch4(4),tcom(6)
120  real(8) :: tf11,tf12,tf22
121  real(8) :: blayer(0:np+1),blevel(0:np+1)
122  real(8) :: bd(0:np+1),bu(0:np+1)
123  real(8) :: bs,dbs,rflxs
124  real(8) :: dp(0:np)
125  real(8) :: trant,tranal
126  real(8) :: transfc(0:np+1)
127  real(8) :: flxu(0:np+1),flxd(0:np+1)
128  real(8) :: taerlyr(0:np)
129 
130  !OVERCAST
131  integer :: ncld(3)
132  integer :: icx(0:np)
133  !OVERCAST
134 
135  integer :: idx, rc
136  integer :: k,l,ip,iw,ibn,ik,iq,isb,k1,k2,ne
137 
138  real(8) :: enn(0:np)
139  real(8) :: cldhi,cldmd,cldlw,tcldlyr(0:np),fclr
140  real(8) :: x,xx,yy,p1,a1,b1,fk1,a2,b2,fk2
141  real(8) :: w1,ff
142 
143  logical :: oznbnd,co2bnd,h2otable,conbnd,n2obnd
144  logical :: ch4bnd,combnd,f11bnd,f12bnd,f22bnd,b10bnd
145  logical :: do_aerosol
146 
147  !Temp arrays and variables for consolidation of tables
148  integer, parameter :: max_num_tables = 17
149  real(8) :: exptbl(0:np,max_num_tables)
150  type :: band_table
151  integer :: start
152  integer :: end
153  end type band_table
154  type(band_table) :: h2oexp
155  type(band_table) :: conexp
156  type(band_table) :: co2exp
157  type(band_table) :: n2oexp
158  type(band_table) :: ch4exp
159  type(band_table) :: comexp
160  type(band_table) :: f11exp
161  type(band_table) :: f12exp
162  type(band_table) :: f22exp
163 
164  !Variables for new getirtau routine
165  real(8) :: dp_pa(np)
166  real(8) :: fcld_col(np)
167  real(8) :: reff_col(np,4)
168  real(8) :: cwc_col(np,4)
169 
170  real(8) :: h2oexp_tmp(0:np,5),conexp_tmp(0:np),co2exp_tmp(0:np,6),n2oexp_tmp(0:np,2)
171 
172  !BEGIN CALCULATIONS ...
173 
174  !compute layer pressure (pa) and layer temperature minus 250K (dt)
175  do k=1,np
176  pa(k) = 0.5*(ple_dev(k+1)+ple_dev(k))*0.01
177  dp(k) = (ple_dev(k+1)-ple_dev(k))*0.01
178  dp_pa(k) = (ple_dev(k+1)-ple_dev(k)) ! dp in Pascals for getirtau
179  dt(k) = ta_dev(k)-250.0
180 
181  !compute layer absorber amount
182 
183  !dh2o : water vapor amount (g/cm**2)
184  !dcont: scaled water vapor amount for continuum absorption
185  ! (g/cm**2)
186  !dco2 : co2 amount (cm-atm)stp
187  !do3 : o3 amount (cm-atm)stp
188  !dn2o : n2o amount (cm-atm)stp
189  !dch4 : ch4 amount (cm-atm)stp
190  !df11 : cfc11 amount (cm-atm)stp
191  !df12 : cfc12 amount (cm-atm)stp
192  !df22 : cfc22 amount (cm-atm)stp
193  !the factor 1.02 is equal to 1000/980
194  !factors 789 and 476 are for unit conversion
195  !the factor 0.001618 is equal to 1.02/(.622*1013.25)
196  !the factor 6.081 is equal to 1800/296
197 
198  dh2o(k) = 1.02*wa_dev(k)*dp(k)
199  do3(k) = 476.*oa_dev(k)*dp(k)
200  dco2(k) = 789.*co2 *dp(k)
201  dch4(k) = 789.*ch4_dev(k)*dp(k)
202  dn2o(k) = 789.*n2o_dev(k)*dp(k)
203  df11(k) = 789.*cfc11_dev(k)*dp(k)
204  df12(k) = 789.*cfc12_dev(k)*dp(k)
205  df22(k) = 789.*cfc22_dev(k)*dp(k)
206 
207  dh2o(k) = max(dh2o(k),1.e-10)
208  do3(k) = max(do3(k),1.e-6)
209  dco2(k) = max(dco2(k),1.e-4)
210 
211  !Compute scaled water vapor amount for h2o continuum absorption
212  !following eq. (4.21).
213 
214  xx=pa(k)*0.001618*wa_dev(k)*wa_dev(k)*dp(k)
215  dcont(k) = xx*exp(1800./ta_dev(k)-6.081)
216 
217  !Fill the reff, cwc, and fcld for the column
218  fcld_col(k) = fcld_dev(k)
219  do l = 1, 4
220  reff_col(k,l) = reff_dev(k,l)
221  cwc_col(k,l) = cwc_dev(k,l)
222  end do
223 
224  end do
225 
226  !A layer is added above the top of the model atmosphere.
227  !Index "0" is the layer above the top of the atmosphere.
228 
229  dp(0) = max(ple_dev(1)*0.01,0.005)
230  pa(0) = 0.5*dp(0)
231  dt(0) = ta_dev(1)-250.0
232 
233  dh2o(0) = 1.02*wa_dev(1)*dp(0)
234  do3(0) = 476.*oa_dev(1)*dp(0)
235  dco2(0) = 789.*co2 *dp(0)
236  dch4(0) = 789.*ch4_dev(1)*dp(0)
237  dn2o(0) = 789.*n2o_dev(1)*dp(0)
238  df11(0) = 789.*cfc11_dev(1)*dp(0)
239  df12(0) = 789.*cfc12_dev(1)*dp(0)
240  df22(0) = 789.*cfc22_dev(1)*dp(0)
241 
242  dh2o(0) = max(dh2o(0),1.e-10)
243  do3(0) = max(do3(0),1.e-6)
244  dco2(0) = max(dco2(0),1.e-4)
245 
246  xx=pa(0)*0.001618*wa_dev(1)*wa_dev(1)*dp(0)
247  dcont(0) = xx*exp(1800./ta_dev(1)-6.081)
248 
249  !The surface (np+1) is treated as a layer filled with black clouds.
250  !transfc is the transmittance between the surface and a pressure
251  !level.
252  transfc(np+1)=1.0
253 
254  !Initialize fluxes
255  do k=1,np+1
256  flxu_dev(k) = 0.0
257  flxd_dev(k) = 0.0
258  dfdts_dev(k)= 0.0
259  end do
260 
261  !Integration over spectral bands
262  do ibn=1,10
263 
264  if (ibn == 10 .and. .not. trace) return
265 
266  !if h2otable, compute h2o (line) transmittance using table look-up.
267  !if conbnd, compute h2o (continuum) transmittance in bands 2-7.
268  !if co2bnd, compute co2 transmittance in band 3.
269  !if oznbnd, compute o3 transmittance in band 5.
270  !if n2obnd, compute n2o transmittance in bands 6 and 7.
271  !if ch4bnd, compute ch4 transmittance in bands 6 and 7.
272  !if combnd, compute co2-minor transmittance in bands 4 and 5.
273  !if f11bnd, compute cfc11 transmittance in bands 4 and 5.
274  !if f12bnd, compute cfc12 transmittance in bands 4 and 6.
275  !if f22bnd, compute cfc22 transmittance in bands 4 and 6.
276  !if b10bnd, compute flux reduction due to n2o in band 10.
277 
278  h2otable=ibn == 1 .or. ibn == 2 .or. ibn == 8
279  conbnd =ibn >= 2 .and. ibn <= 7
280  co2bnd =ibn == 3
281  oznbnd =ibn == 5
282  n2obnd =ibn == 6 .or. ibn == 7
283  ch4bnd =ibn == 6 .or. ibn == 7
284  combnd =ibn == 4 .or. ibn == 5
285  f11bnd =ibn == 4 .or. ibn == 5
286  f12bnd =ibn == 4 .or. ibn == 6
287  f22bnd =ibn == 4 .or. ibn == 6
288  b10bnd =ibn == 10
289 
290  do_aerosol = na > 0
291 
292  exptbl = 0.0
293 
294  !Control packing of the new exponential tables by band
295 
296  select case (ibn)
297  case (2)
298  conexp%start = 1
299  conexp%end = 1
300  case (3)
301  h2oexp%start = 1
302  h2oexp%end = 6
303  conexp%start = 7
304  conexp%end = 9
305  case (4)
306  h2oexp%start = 1
307  h2oexp%end = 6
308  conexp%start = 7
309  conexp%end = 7
310  comexp%start = 8
311  comexp%end = 13
312  f11exp%start = 14
313  f11exp%end = 14
314  f12exp%start = 15
315  f12exp%end = 15
316  f22exp%start = 16
317  f22exp%end = 16
318  case (5)
319  h2oexp%start = 1
320  h2oexp%end = 6
321  conexp%start = 7
322  conexp%end = 7
323  comexp%start = 8
324  comexp%end = 13
325  f11exp%start = 14
326  f11exp%end = 14
327  case (6)
328  h2oexp%start = 1
329  h2oexp%end = 6
330  conexp%start = 7
331  conexp%end = 7
332  n2oexp%start = 8
333  n2oexp%end = 11
334  ch4exp%start = 12
335  ch4exp%end = 15
336  f12exp%start = 16
337  f12exp%end = 16
338  f22exp%start = 17
339  f22exp%end = 17
340  case (7)
341  h2oexp%start = 1
342  h2oexp%end = 6
343  conexp%start = 7
344  conexp%end = 7
345  n2oexp%start = 8
346  n2oexp%end = 11
347  ch4exp%start = 12
348  ch4exp%end = 15
349  case (9)
350  h2oexp%start = 1
351  h2oexp%end = 6
352  case (10)
353  h2oexp%start = 1
354  h2oexp%end = 5
355  conexp%start = 6
356  conexp%end = 6
357  co2exp%start = 7
358  co2exp%end = 12
359  n2oexp%start = 13
360  n2oexp%end = 14
361  end select
362 
363  !blayer is the spectrally integrated planck flux of the mean layer
364  !temperature derived from eq. (3.11)
365  !The fitting for the planck flux is valid for the range 160-345 K.
366 
367  do k=1,np
368  call planck(ibn,cb,ta_dev(k),blayer(k))
369  end do
370 
371  !Index "0" is the layer above the top of the atmosphere.
372  blayer(0)=blayer(1)
373  blevel(0)=blayer(1)
374 
375  !Surface emission and reflectivity. See Section 9.
376  !bs and dbs include the effect of surface emissivity.
377  call sfcflux (ibn,cb,dcb,ns,fs_dev,tg_dev,eg_dev,tv_dev,ev_dev,rv_dev,&
378  bs,dbs,rflxs)
379 
380  blayer(np+1)=bs
381 
382  !interpolate Planck function at model levels (linear in p)
383 
384  do k=2,np
385  blevel(k)=(blayer(k-1)*dp(k)+blayer(k)*dp(k-1))/(dp(k-1)+dp(k))
386  end do
387 
388  !Extrapolate blevel(1) from blayer(2) and blayer(1)
389 
390  blevel(1)=blayer(1)+(blayer(1)-blayer(2))*dp(1)/(dp(1)+dp(2))
391  blevel(0)=blevel(1)
392 
393  !If the surface air temperature tb is known, compute blevel(np+1)
394  call planck(ibn,cb,tb_dev,blevel(np+1))
395 
396  !Compute cloud optical thickness following Eqs. (6.4a,b) and (6.7)
397  ! NOTE: dp_pa is only dims(1:np) as the 0'th level isn't needed in getirtau.
398  ! Plus, the pressures in getirtau *MUST* be in Pascals.
399  ! Slots for reff, hydrometeors and tauall are as follows:
400  ! 1 Cloud Ice
401  ! 2 Cloud Liquid
402  ! 3 Falling Liquid (Rain)
403  ! 4 Falling Ice (Snow)
404 
405  call getirtau1(ibn,np,dp_pa,fcld_col,reff_col,cwc_col,&
406  tcldlyr,enn,aib_ir,awb_ir, &
407  aiw_ir, aww_ir, aig_ir, awg_ir, cons_grav)
408 
409  do k=0,np
410  icx(k) = k
411  end do
412 
413  call mkicx(np,ict,icb,enn,icx,ncld)
414 
415  !Compute optical thickness, single-scattering albedo and asymmetry
416  !factor for a mixture of "na" aerosol types. Eqs. (7.1)-(7.3)
417  if (do_aerosol) then
418  taerlyr(0)=1.0
419 
420  do k=1,np
421 
422  !-----taerlyr is the aerosol diffuse transmittance
423  taerlyr(k)=1.0
424  if (taua_dev(k,ibn) > 0.001) then
425  if (ssaa_dev(k,ibn) > 0.001) then
426  asya_dev(k,ibn)=asya_dev(k,ibn)/ssaa_dev(k,ibn)
427  ssaa_dev(k,ibn)=ssaa_dev(k,ibn)/taua_dev(k,ibn)
428 
429  !Parameterization of aerosol scattering following
430  ff=.5+(.3739+(0.0076+0.1185*asya_dev(k,ibn))*asya_dev(k,ibn))*asya_dev(k,ibn)
431  taua_dev(k,ibn)=taua_dev(k,ibn)*(1.-ssaa_dev(k,ibn)*ff)
432  end if
433  taerlyr(k)=exp(-1.66*taua_dev(k,ibn))
434  end if
435  end do
436  end if
437 
438  !Compute the exponential terms (Eq. 8.21) at each layer due to
439  !water vapor line absorption when k-distribution is used
440  if (.not. h2otable .and. .not. b10bnd) then
441  call h2oexps(ibn,np,dh2o,pa,dt,xkw,aw,bw,pm,mw,exptbl(:,h2oexp%start:h2oexp%end))
442  end if
443 
444  !compute the exponential terms (Eq. 4.24) at each layer due to
445  !water vapor continuum absorption.
446 
447  ne=0
448  if (conbnd) then
449  ne=1
450  if (ibn == 3) ne=3
451  call conexps(ibn,np,dcont,xke,exptbl(:,conexp%start:conexp%end))
452  end if
453 
454 
455  if (trace) then
456 
457  !compute the exponential terms at each layer due to n2o absorption
458  if (n2obnd) then
459  call n2oexps(ibn,np,dn2o,pa,dt,exptbl(:,n2oexp%start:n2oexp%end))
460  end if
461 
462  !compute the exponential terms at each layer due to ch4 absorption
463  if (ch4bnd) then
464  call ch4exps(ibn,np,dch4,pa,dt,exptbl(:,ch4exp%start:ch4exp%end))
465  end if
466 
467  !Compute the exponential terms due to co2 minor absorption
468  if (combnd) then
469  call comexps(ibn,np,dco2,dt,exptbl(:,comexp%start:comexp%end))
470  end if
471 
472  !Compute the exponential terms due to cfc11 absorption.
473  !The values of the parameters are given in Table 7.
474  if (f11bnd) then
475  a1 = 1.26610e-3
476  b1 = 3.55940e-6
477  fk1 = 1.89736e+1
478  a2 = 8.19370e-4
479  b2 = 4.67810e-6
480  fk2 = 1.01487e+1
481  call cfcexps(ibn,np,a1,b1,fk1,a2,b2,fk2,df11,dt,&
482  exptbl(:,f11exp%start:f11exp%end))
483  end if
484 
485  !Compute the exponential terms due to cfc12 absorption.
486  if (f12bnd) then
487  a1 = 8.77370e-4
488  b1 =-5.88440e-6
489  fk1 = 1.58104e+1
490  a2 = 8.62000e-4
491  b2 =-4.22500e-6
492  fk2 = 3.70107e+1
493  call cfcexps(ibn,np,a1,b1,fk1,a2,b2,fk2,df12,dt,&
494  exptbl(:,f12exp%start:f12exp%end))
495  end if
496 
497  !Compute the exponential terms due to cfc22 absorption.
498  if (f22bnd) then
499  a1 = 9.65130e-4
500  b1 = 1.31280e-5
501  fk1 = 6.18536e+0
502  a2 =-3.00010e-5
503  b2 = 5.25010e-7
504  fk2 = 3.27912e+1
505  call cfcexps(ibn,np,a1,b1,fk1,a2,b2,fk2,df22,dt,&
506  exptbl(:,f22exp%start:f22exp%end))
507  end if
508 
509  !Compute the exponential terms at each layer in band 10 due to
510  !h2o line and continuum, co2, and n2o absorption
511 
512  if (b10bnd) then
513  call b10exps(np,dh2o,dcont,dco2,dn2o,pa,dt, &
514  h2oexp_tmp,exptbl(:,conexp%start:conexp%end),co2exp_tmp,n2oexp_tmp)
515 
516  exptbl(:,h2oexp%start:h2oexp%end) = h2oexp_tmp
517  exptbl(:,co2exp%start:co2exp%end) = co2exp_tmp
518  exptbl(:,n2oexp%start:n2oexp%end) = n2oexp_tmp
519 
520  end if
521  end if
522 
523  !blayer(np+1) includes the effect of surface emissivity.
524 
525  bu(0)=0.0 ! ALT: this was undefined, check with Max if 0.0 is good value
526  bd(0)=blayer(1)
527  bu(np+1)=blayer(np+1)
528 
529  !do-loop 1500 is for computing upward (bu) and downward (bd)
530  !Here, trant is the transmittance of the layer k2-1.
531  do k2=1,np+1
532 
533  !for h2o line transmission
534  if (.not. h2otable) then
535  th2o=1.0
536  end if
537 
538  !for h2o continuum transmission
539  tcon=1.0
540 
541  x1=0.0
542  x2=0.0
543  x3=0.0
544  trant=1.0
545 
546  if (h2otable) then
547 
548  !Compute water vapor transmittance using table look-up.
549  if (ibn == 1) then
550  call tablup(nx1,nh1,dh2o(k2-1),pa(k2-1),dt(k2-1),x1,x2,x3, &
551  w11,p11,dwe,dpe,h11,h12,h13,trant)
552  end if
553  if (ibn == 2) then
554  call tablup(nx1,nh1,dh2o(k2-1),pa(k2-1),dt(k2-1),x1,x2,x3, &
555  w11,p11,dwe,dpe,h21,h22,h23,trant)
556  end if
557  if (ibn == 8) then
558  call tablup(nx1,nh1,dh2o(k2-1),pa(k2-1),dt(k2-1),x1,x2,x3, &
559  w11,p11,dwe,dpe,h81,h82,h83,trant)
560  end if
561 
562  !for water vapor continuum absorption
563  if (conbnd) then
564  tcon(1)=tcon(1)*exptbl(k2-1,conexp%start) ! Only the first exp
565  trant=trant*tcon(1)
566  end if
567 
568  else
569 
570  !compute water vapor transmittance using k-distribution
571  if (.not. b10bnd) then
572  call h2okdis(ibn,np,k2-1,fkw,gkw,ne,&
573  exptbl(:,h2oexp%start:h2oexp%end), &
574  exptbl(:,conexp%start:conexp%end), &
575  th2o,tcon,trant)
576  end if
577 
578  end if
579 
580  if (co2bnd) then
581  !Compute co2 transmittance using table look-up method
582  call tablup(nx1,nc1,dco2(k2-1),pa(k2-1),dt(k2-1),x1,x2,x3, &
583  w12,p12,dwe,dpe,c1,c2,c3,trant)
584  end if
585 
586  !Always use table look-up to compute o3 transmittance.
587  if (oznbnd) then
588  call tablup(nx1,no1,do3(k2-1),pa(k2-1),dt(k2-1),x1,x2,x3, &
589  w13,p13,dwe,dpe,oo1,oo2,oo3,trant)
590  end if
591 
592  !include aerosol effect
593  if (do_aerosol) then
594  trant=trant*taerlyr(k2-1)
595  end if
596 
597  !Compute upward (bu) and downward (bd) emission of the layer k2-1
598  xx=(1.-enn(k2-1))*trant
599  yy=min(0.9999,xx)
600  yy=max(0.00001,yy)
601  xx=(blevel(k2-1)-blevel(k2))/log(yy)
602  bd(k2-1)=(blevel(k2)-blevel(k2-1)*yy)/(1.0-yy)-xx
603  bu(k2-1)=(blevel(k2-1)+blevel(k2))-bd(k2-1)
604 
605  end do
606 
607  !Initialize fluxes
608  flxu = 0.0
609  flxd = 0.0
610 
611  !Compute upward and downward fluxes for each spectral band, ibn.
612  do k1=0,np
613 
614  !initialization
615  cldlw = 0.0
616  cldmd = 0.0
617  cldhi = 0.0
618  tranal= 1.0
619 
620  !for h2o line transmission
621  if (.not. h2otable) then
622  th2o=1.0
623  end if
624 
625  !for h2o continuum transmission
626  tcon=1.0
627 
628  if (trace) then !Add trace gases contribution
629 
630  if (n2obnd) then !n2o
631  tn2o=1.0
632  end if
633 
634  if (ch4bnd) then !ch4
635  tch4=1.0
636  end if
637 
638  if (combnd) then !co2-minor
639  tcom=1.0
640  end if
641 
642  if (f11bnd) then !cfc-11
643  tf11=1.0
644  end if
645 
646  if (f12bnd) then !cfc-12
647  tf12=1.0
648  end if
649 
650  if (f22bnd) then !cfc-22
651  tf22=1.0
652  end if
653 
654  if (b10bnd) then !
655  th2o=1.0
656 
657  tco2=1.0
658 
659  tcon(1)=1.0
660 
661  tn2o=1.0
662  end if
663 
664  end if
665 
666  x1=0.0
667  x2=0.0
668  x3=0.0
669 
670  do k2=k1+1,np+1
671 
672  trant=1.0
673  fclr =1.0
674 
675  if (h2otable) then
676 
677  !Compute water vapor transmittance using table look-up.
678  if (ibn == 1) then
679  call tablup(nx1,nh1,dh2o(k2-1),pa(k2-1),dt(k2-1),x1,x2,x3, &
680  w11,p11,dwe,dpe,h11,h12,h13,trant)
681  end if
682  if (ibn == 2) then
683  call tablup(nx1,nh1,dh2o(k2-1),pa(k2-1),dt(k2-1),x1,x2,x3, &
684  w11,p11,dwe,dpe,h21,h22,h23,trant)
685  end if
686  if (ibn == 8) then
687  call tablup(nx1,nh1,dh2o(k2-1),pa(k2-1),dt(k2-1),x1,x2,x3, &
688  w11,p11,dwe,dpe,h81,h82,h83,trant)
689  end if
690 
691  if (conbnd) then
692  tcon(1)=tcon(1)*exptbl(k2-1,conexp%start) ! Only the first exp
693  trant=trant*tcon(1)
694  end if
695 
696  else
697 
698  !Compute water vapor transmittance using k-distribution
699  if (.not. b10bnd) then
700  call h2okdis(ibn,np,k2-1,fkw,gkw,ne,&
701  exptbl(:,h2oexp%start:h2oexp%end), &
702  exptbl(:,conexp%start:conexp%end), &
703  th2o,tcon,trant)
704  end if
705 
706  end if
707 
708  if (co2bnd) then
709 
710  !Compute co2 transmittance using table look-up method.
711  call tablup(nx1,nc1,dco2(k2-1),pa(k2-1),dt(k2-1),x1,x2,x3, &
712  w12,p12,dwe,dpe,c1,c2,c3,trant)
713  end if
714 
715  if (oznbnd) then
716  !Always use table look-up to compute o3 transmittanc
717  call tablup(nx1,no1,do3(k2-1),pa(k2-1),dt(k2-1),x1,x2,x3, &
718  w13,p13,dwe,dpe,oo1,oo2,oo3,trant)
719  end if
720 
721  if (trace) then !Add trace gas effects
722 
723  if (n2obnd) then !n2o
724  call n2okdis(ibn,np,k2-1,exptbl(:,n2oexp%start:n2oexp%end),tn2o,trant)
725  end if
726 
727  if (ch4bnd) then !ch4
728  call ch4kdis(ibn,np,k2-1,exptbl(:,ch4exp%start:ch4exp%end),tch4,trant)
729  end if
730 
731  if (combnd) then !co2-minor
732  call comkdis(ibn,np,k2-1,exptbl(:,comexp%start:comexp%end),tcom,trant)
733  end if
734 
735  if (f11bnd) then !cfc11
736  call cfckdis(np,k2-1,exptbl(:,f11exp%start:f11exp%end),tf11,trant)
737  end if
738 
739  if (f12bnd) then !cfc12
740  call cfckdis(np,k2-1,exptbl(:,f12exp%start:f12exp%end),tf12,trant)
741  end if
742 
743  if (f22bnd) then !CFC22
744  call cfckdis(np,k2-1,exptbl(:,f22exp%start:f22exp%end),tf22,trant)
745  end if
746 
747  if (b10bnd) then
748  call b10kdis(np,k2-1,&
749  exptbl(:,h2oexp%start:h2oexp%end),&
750  exptbl(:,conexp%start:conexp%end),&
751  exptbl(:,co2exp%start:co2exp%end),&
752  exptbl(:,n2oexp%start:n2oexp%end),&
753  th2o,tcon,tco2,tn2o,trant)
754  end if
755 
756  end if
757 
758 
759  if (do_aerosol) then
760  tranal=tranal*taerlyr(k2-1)
761  trant=trant *tranal
762  end if
763 
764  if (enn(k2-1) >= 0.001) then
765  call cldovlp (np,k1,k2,ict,icb,icx,ncld,enn,tcldlyr,cldhi,cldmd,cldlw)
766  end if
767 
768  fclr=(1.0-cldhi)*(1.0-cldmd)*(1.0-cldlw)
769 
770  if (k2 == k1+1 .and. ibn /= 10) then
771  flxu(k1)=flxu(k1)-bu(k1)
772  flxd(k2)=flxd(k2)+bd(k1)
773  end if
774 
775  xx=trant*(bu(k2-1)-bu(k2))
776  flxu(k1)=flxu(k1)+xx*fclr
777 
778  if (k1 == 0) then !mjs bd(-1) is not defined
779  xx=-trant*bd(k1)
780  else
781  xx= trant*(bd(k1-1)-bd(k1))
782  end if
783  flxd(k2)=flxd(k2)+xx*fclr
784 
785  end do
786 
787  transfc(k1) =trant*fclr
788 
789  if (k1 > 0)then
790  dfdts_dev(k1) =dfdts_dev(k1)-dbs*transfc(k1)
791  end if
792 
793  end do
794 
795  if (.not. b10bnd) then !surface emission
796 
797  flxu(np+1) = -blayer(np+1)
798  dfdts_dev(np+1)= dfdts_dev(np+1)-dbs
799 
800  do k=1,np+1
801  flxu(k) = flxu(k)-flxd(np+1)*transfc(k)*rflxs
802  end do
803 
804  end if
805 
806  do k=1,np+1 !Summation of fluxes over spectral bands
807 
808  flxu_dev(k) = flxu_dev(k) + flxu(k)
809  flxd_dev(k) = flxd_dev(k) + flxd(k)
810 
811  end do
812 
813  end do
814 
815  end subroutine irrad
816 
817 !***********************************************************************
818  subroutine planck(ibn,cb,t,xlayer)
819 !***********************************************************************
820 !
821 !-----Compute spectrally integrated Planck flux
822 !
823  implicit none
824 
825  integer, intent(in) :: ibn ! spectral band index
826  real(8), intent(in) :: cb(6,10) ! Planck table coefficients
827  real(8), intent(in) :: t ! temperature (K)
828  real(8), intent(out) :: xlayer ! planck flux (w/m2)
829 
830  xlayer=t*(t*(t*(t*(t*cb(6,ibn)+cb(5,ibn))+cb(4,ibn))+cb(3,ibn))+cb(2,ibn))+cb(1,ibn)
831 
832  end subroutine planck
833 
834 
835 !***********************************************************************
836  subroutine plancd(ibn,dcb,t,dbdt)
837 !***********************************************************************
838 !
839 !-----Compute the derivative of Planck flux wrt temperature
840 !
841  implicit none
842 
843  integer, intent(in) :: ibn ! spectral band index
844  real(8), intent(in) :: dcb(5,10) ! Planck function derivative coefficients
845  real(8), intent(in) :: t ! temperature (K)
846  real(8), intent(out) :: dbdt ! derivative of Planck flux wrt temperature
847 
848  dbdt=t*(t*(t*(t*dcb(5,ibn)+dcb(4,ibn))+dcb(3,ibn))+dcb(2,ibn))+dcb(1,ibn)
849 
850  end subroutine plancd
851 
852 
853 !**********************************************************************
854  subroutine h2oexps(ib,np,dh2o,pa,dt,xkw,aw,bw,pm,mw,h2oexp)
855 !**********************************************************************
856 ! Compute exponentials for water vapor line absorption
857 ! in individual layers using Eqs. (8.21) and (8.22).
858 !
859 !---- input parameters
860 ! spectral band (ib)
861 ! number of layers (np)
862 ! layer water vapor amount for line absorption (dh2o)
863 ! layer pressure (pa)
864 ! layer temperature minus 250K (dt)
865 ! absorption coefficients for the first k-distribution
866 ! function due to h2o line absorption (xkw)
867 ! coefficients for the temperature and pressure scaling (aw,bw,pm)
868 ! ratios between neighboring absorption coefficients for
869 ! h2o line absorption (mw)
870 !
871 !---- output parameters
872 ! 6 exponentials for each layer (h2oexp)
873 !**********************************************************************
874  implicit none
875 
876  integer :: ib,np,ik,k
877 
878 !---- input parameters ------
879 
880  real(8) :: dh2o(0:np),pa(0:np),dt(0:np)
881 
882 !---- output parameters -----
883 
884  real(8) :: h2oexp(0:np,6)
885 
886 !---- static data -----
887 
888  integer :: mw(9)
889  real(8) :: xkw(9),aw(9),bw(9),pm(9)
890 
891 !---- temporary arrays -----
892 
893  real(8) :: xh
894 
895 !**********************************************************************
896 ! note that the 3 sub-bands in band 3 use the same set of xkw, aw,
897 ! and bw, therefore, h2oexp for these sub-bands are identical.
898 !**********************************************************************
899 
900  do k=0,np
901 
902 !-----xh is the scaled water vapor amount for line absorption
903 ! computed from Eq. (4.4).
904 
905  xh = dh2o(k)*(pa(k)/500.)**pm(ib) &
906  * ( 1.+(aw(ib)+bw(ib)* dt(k))*dt(k) )
907 
908 !-----h2oexp is the water vapor transmittance of the layer k
909 ! due to line absorption
910 
911  h2oexp(k,1) = exp(-xh*xkw(ib))
912 
913 !-----compute transmittances from Eq. (8.22)
914 
915  do ik=2,6
916  if (mw(ib) == 6) then
917  xh = h2oexp(k,ik-1)*h2oexp(k,ik-1)
918  h2oexp(k,ik) = xh*xh*xh
919  elseif (mw(ib) == 8) then
920  xh = h2oexp(k,ik-1)*h2oexp(k,ik-1)
921  xh = xh*xh
922  h2oexp(k,ik) = xh*xh
923  elseif (mw(ib) == 9) then
924  xh=h2oexp(k,ik-1)*h2oexp(k,ik-1)*h2oexp(k,ik-1)
925  h2oexp(k,ik) = xh*xh*xh
926  else
927  xh = h2oexp(k,ik-1)*h2oexp(k,ik-1)
928  xh = xh*xh
929  xh = xh*xh
930  h2oexp(k,ik) = xh*xh
931  end if
932  end do
933  end do
934 
935  end subroutine h2oexps
936 
937 
938 !**********************************************************************
939  subroutine conexps(ib,np,dcont,xke,conexp)
940 !**********************************************************************
941 ! compute exponentials for continuum absorption in individual layers.
942 !
943 !---- input parameters
944 ! spectral band (ib)
945 ! number of layers (np)
946 ! layer scaled water vapor amount for continuum absorption (dcont)
947 ! absorption coefficients for the first k-distribution function
948 ! due to water vapor continuum absorption (xke)
949 !
950 !---- output parameters
951 ! 1 or 3 exponentials for each layer (conexp)
952 !**********************************************************************
953  implicit none
954 
955  integer :: ib,np,k
956 
957 !---- input parameters ------
958 
959  real(8) :: dcont(0:np)
960 
961 !---- updated parameters -----
962 
963  real(8) :: conexp(0:np,3)
964 
965 !---- static data -----
966 
967  real(8) :: xke(9)
968 
969 !****************************************************************
970 
971  do k=0,np
972 
973  conexp(k,1) = exp(-dcont(k)*xke(ib))
974 
975 !-----The absorption coefficients for sub-bands 3b and 3a are, respectively,
976 ! two and four times the absorption coefficient for sub-band 3c (Table 9).
977 ! Note that conexp(3) is for sub-band 3a.
978 
979  if (ib == 3) then
980  conexp(k,2) = conexp(k,1) *conexp(k,1)
981  conexp(k,3) = conexp(k,2) *conexp(k,2)
982  end if
983 
984  end do
985 
986  end subroutine conexps
987 
988 
989 !**********************************************************************
990  subroutine n2oexps(ib,np,dn2o,pa,dt,n2oexp)
991 !**********************************************************************
992 ! Compute n2o exponentials for individual layers
993 !
994 !---- input parameters
995 ! spectral band (ib)
996 ! number of layers (np)
997 ! layer n2o amount (dn2o)
998 ! layer pressure (pa)
999 ! layer temperature minus 250K (dt)
1000 !
1001 !---- output parameters
1002 ! 2 or 4 exponentials for each layer (n2oexp)
1003 !**********************************************************************
1004  implicit none
1005 
1006  integer :: ib,k,np
1007 
1008 !---- input parameters -----
1009 
1010  real(8) :: dn2o(0:np),pa(0:np),dt(0:np)
1011 
1012 !---- output parameters -----
1013 
1014  real(8) :: n2oexp(0:np,4)
1015 
1016 !---- temporary arrays -----
1017 
1018  real(8) :: xc,xc1,xc2
1019 
1020 !-----Scaling and absorption data are given in Table 5.
1021 ! Transmittances are computed using Eqs. (8.21) and (8.22).
1022 
1023  do k=0,np
1024 
1025 !-----four exponential by powers of 21 for band 6.
1026 
1027  if (ib == 6) then
1028 
1029  xc=dn2o(k)*(1.+(1.9297e-3+4.3750e-6*dt(k))*dt(k))
1030  n2oexp(k,1)=exp(-xc*6.31582e-2)
1031 
1032  xc=n2oexp(k,1)*n2oexp(k,1)*n2oexp(k,1)
1033  xc1=xc*xc
1034  xc2=xc1*xc1
1035  n2oexp(k,2)=xc*xc1*xc2
1036 
1037 !-----four exponential by powers of 8 for band 7
1038 
1039  else
1040 
1041  xc=dn2o(k)*(pa(k)/500.0)**0.48 &
1042  *(1.+(1.3804e-3+7.4838e-6*dt(k))*dt(k))
1043  n2oexp(k,1)=exp(-xc*5.35779e-2)
1044 
1045  xc=n2oexp(k,1)*n2oexp(k,1)
1046  xc=xc*xc
1047  n2oexp(k,2)=xc*xc
1048  xc=n2oexp(k,2)*n2oexp(k,2)
1049  xc=xc*xc
1050  n2oexp(k,3)=xc*xc
1051  xc=n2oexp(k,3)*n2oexp(k,3)
1052  xc=xc*xc
1053  n2oexp(k,4)=xc*xc
1054  end if
1055 
1056  end do
1057 
1058  end subroutine n2oexps
1059 
1060 
1061 !**********************************************************************
1062  subroutine ch4exps(ib,np,dch4,pa,dt,ch4exp)
1063 !**********************************************************************
1064 ! Compute ch4 exponentials for individual layers
1065 !
1066 !---- input parameters
1067 ! spectral band (ib)
1068 ! number of layers (np)
1069 ! layer ch4 amount (dch4)
1070 ! layer pressure (pa)
1071 ! layer temperature minus 250K (dt)
1072 !
1073 !---- output parameters
1074 ! 1 or 4 exponentials for each layer (ch4exp)
1075 !**********************************************************************
1076  implicit none
1077 
1078  integer :: ib,np,k
1079 
1080 !---- input parameters -----
1081 
1082  real(8) :: dch4(0:np),pa(0:np),dt(0:np)
1083 
1084 !---- output parameters -----
1085 
1086  real(8) :: ch4exp(0:np,4)
1087 
1088 !---- temporary arrays -----
1089 
1090  real(8) :: xc
1091 
1092 !***** Scaling and absorption data are given in Table 5 *****
1093 
1094  do k=0,np
1095 
1096 !-----four exponentials for band 6
1097 
1098  if (ib == 6) then
1099 
1100  xc=dch4(k)*(1.+(1.7007e-2+1.5826e-4*dt(k))*dt(k))
1101  ch4exp(k,1)=exp(-xc*5.80708e-3)
1102 
1103 !-----four exponentials by powers of 12 for band 7
1104 
1105  else
1106 
1107  xc=dch4(k)*(pa(k)/500.0)**0.65 &
1108  *(1.+(5.9590e-4-2.2931e-6*dt(k))*dt(k))
1109  ch4exp(k,1)=exp(-xc*6.29247e-2)
1110 
1111  xc=ch4exp(k,1)*ch4exp(k,1)*ch4exp(k,1)
1112  xc=xc*xc
1113  ch4exp(k,2)=xc*xc
1114 
1115  xc=ch4exp(k,2)*ch4exp(k,2)*ch4exp(k,2)
1116  xc=xc*xc
1117  ch4exp(k,3)=xc*xc
1118 
1119  xc=ch4exp(k,3)*ch4exp(k,3)*ch4exp(k,3)
1120  xc=xc*xc
1121  ch4exp(k,4)=xc*xc
1122 
1123  end if
1124 
1125  end do
1126 
1127  end subroutine ch4exps
1128 
1129 
1130 !**********************************************************************
1131  subroutine comexps(ib,np,dcom,dt,comexp)
1132 !**********************************************************************
1133 ! Compute co2-minor exponentials for individual layers using
1134 ! Eqs. (8.21) and (8.22).
1135 !
1136 !---- input parameters
1137 ! spectral band (ib)
1138 ! number of layers (np)
1139 ! layer co2 amount (dcom)
1140 ! layer temperature minus 250K (dt)
1141 !
1142 !---- output parameters
1143 ! 6 exponentials for each layer (comexp)
1144 !**********************************************************************
1145  implicit none
1146 
1147  integer :: ib,ik,np,k
1148 
1149 !---- input parameters -----
1150 
1151  real(8) :: dcom(0:np),dt(0:np)
1152 
1153 !---- output parameters -----
1154 
1155  real(8) :: comexp(0:np,6)
1156 
1157 !---- temporary arrays -----
1158 
1159  real(8) :: xc
1160 
1161 !***** Scaling and absorpton data are given in Table 6 *****
1162 
1163  do k=0,np
1164 
1165  if (ib == 4) then
1166  xc=dcom(k)*(1.+(3.5775e-2+4.0447e-4*dt(k))*dt(k))
1167  end if
1168 
1169  if (ib == 5) then
1170  xc=dcom(k)*(1.+(3.4268e-2+3.7401e-4*dt(k))*dt(k))
1171  end if
1172 
1173  comexp(k,1)=exp(-xc*1.922e-7)
1174 
1175  do ik=2,6
1176  xc=comexp(k,ik-1)*comexp(k,ik-1)
1177  xc=xc*xc
1178  comexp(k,ik)=xc*comexp(k,ik-1)
1179  end do
1180 
1181  end do
1182 
1183  end subroutine comexps
1184 
1185 
1186 !**********************************************************************
1187  subroutine cfcexps(ib,np,a1,b1,fk1,a2,b2,fk2,dcfc,dt,cfcexp)
1188 !**********************************************************************
1189 ! compute cfc(-11, -12, -22) exponentials for individual layers.
1190 !
1191 !---- input parameters
1192 ! spectral band (ib)
1193 ! number of layers (np)
1194 ! parameters for computing the scaled cfc amounts
1195 ! for temperature scaling (a1,b1,a2,b2)
1196 ! the absorption coefficients for the
1197 ! first k-distribution function due to cfcs (fk1,fk2)
1198 ! layer cfc amounts (dcfc)
1199 ! layer temperature minus 250K (dt)
1200 !
1201 !---- output parameters
1202 ! 1 exponential for each layer (cfcexp)
1203 !**********************************************************************
1204  implicit none
1205 
1206  integer :: ib,np,k
1207 
1208 !---- input parameters -----
1209 
1210  real(8) :: dcfc(0:np),dt(0:np)
1211 
1212 !---- output parameters -----
1213 
1214  real(8) :: cfcexp(0:np)
1215 
1216 !---- static data -----
1217 
1218  real(8) :: a1,b1,fk1,a2,b2,fk2
1219 
1220 !---- temporary arrays -----
1221 
1222  real(8) :: xf
1223 
1224 !**********************************************************************
1225 
1226  do k=0,np
1227 
1228 !-----compute the scaled cfc amount (xf) and exponential (cfcexp)
1229 
1230  if (ib == 4) then
1231  xf=dcfc(k)*(1.+(a1+b1*dt(k))*dt(k))
1232  cfcexp(k)=exp(-xf*fk1)
1233  else
1234  xf=dcfc(k)*(1.+(a2+b2*dt(k))*dt(k))
1235  cfcexp(k)=exp(-xf*fk2)
1236  end if
1237 
1238  end do
1239 
1240  end subroutine cfcexps
1241 
1242 
1243 !**********************************************************************
1244  subroutine b10exps(np,dh2o,dcont,dco2,dn2o,pa,dt, &
1245  h2oexp,conexp,co2exp,n2oexp)
1246 !**********************************************************************
1247 ! Compute band3a exponentials for individual layers
1248 !
1249 !---- input parameters
1250 ! number of layers (np)
1251 ! layer h2o amount for line absorption (dh2o)
1252 ! layer h2o amount for continuum absorption (dcont)
1253 ! layer co2 amount (dco2)
1254 ! layer n2o amount (dn2o)
1255 ! layer pressure (pa)
1256 ! layer temperature minus 250K (dt)
1257 !
1258 !---- output parameters
1259 !
1260 ! exponentials for each layer (h2oexp,conexp,co2exp,n2oexp)
1261 !**********************************************************************
1262  implicit none
1263 
1264  integer :: np,k
1265 
1266 !---- input parameters -----
1267 
1268  real(8) :: dh2o(0:np),dcont(0:np),dn2o(0:np)
1269  real(8) :: dco2(0:np),pa(0:np),dt(0:np)
1270 
1271 !---- output parameters -----
1272 
1273  real(8) :: h2oexp(0:np,5),conexp(0:np),co2exp(0:np,6),n2oexp(0:np,2)
1274 
1275 !---- temporary arrays -----
1276 
1277  real(8) :: xx,xx1,xx2,xx3
1278 
1279 !**********************************************************************
1280 
1281  do k=0,np
1282 
1283 !-----Compute scaled h2o-line amount for Band 10 (Eq. 4.4 and Table 3).
1284 
1285  xx=dh2o(k)*(pa(k)/500.0) &
1286  *(1.+(0.0149+6.20e-5*dt(k))*dt(k))
1287 
1288 !-----six exponentials by powers of 8
1289 
1290  h2oexp(k,1)=exp(-xx*0.10624)
1291 
1292  xx=h2oexp(k,1)*h2oexp(k,1)
1293  xx=xx*xx
1294  h2oexp(k,2)=xx*xx
1295 
1296  xx=h2oexp(k,2)*h2oexp(k,2)
1297  xx=xx*xx
1298  h2oexp(k,3)=xx*xx
1299 
1300  xx=h2oexp(k,3)*h2oexp(k,3)
1301  xx=xx*xx
1302  h2oexp(k,4)=xx*xx
1303 
1304  xx=h2oexp(k,4)*h2oexp(k,4)
1305  xx=xx*xx
1306  h2oexp(k,5)=xx*xx
1307 
1308 !-----one exponential of h2o continuum for sub-band 3a (Table 9).
1309 
1310  conexp(k)=exp(-dcont(k)*109.0)
1311 
1312 !-----Scaled co2 amount for the Band 10 (Eq. 4.4, Tables 3 and 6).
1313 
1314  xx=dco2(k)*(pa(k)/300.0)**0.5 &
1315  *(1.+(0.0179+1.02e-4*dt(k))*dt(k))
1316 
1317 !-----six exponentials by powers of 8
1318 
1319  co2exp(k,1)=exp(-xx*2.656e-5)
1320 
1321  xx=co2exp(k,1)*co2exp(k,1)
1322  xx=xx*xx
1323  co2exp(k,2)=xx*xx
1324 
1325  xx=co2exp(k,2)*co2exp(k,2)
1326  xx=xx*xx
1327  co2exp(k,3)=xx*xx
1328 
1329  xx=co2exp(k,3)*co2exp(k,3)
1330  xx=xx*xx
1331  co2exp(k,4)=xx*xx
1332 
1333  xx=co2exp(k,4)*co2exp(k,4)
1334  xx=xx*xx
1335  co2exp(k,5)=xx*xx
1336 
1337  xx=co2exp(k,5)*co2exp(k,5)
1338  xx=xx*xx
1339  co2exp(k,6)=xx*xx
1340 
1341 !-----Compute the scaled n2o amount for Band 10 (Table 5).
1342 
1343  xx=dn2o(k)*(1.+(1.4476e-3+3.6656e-6*dt(k))*dt(k))
1344 
1345 !-----Two exponentials by powers of 58
1346 
1347  n2oexp(k,1)=exp(-xx*0.25238)
1348 
1349  xx=n2oexp(k,1)*n2oexp(k,1)
1350  xx1=xx*xx
1351  xx1=xx1*xx1
1352  xx2=xx1*xx1
1353  xx3=xx2*xx2
1354  n2oexp(k,2)=xx*xx1*xx2*xx3
1355 
1356  end do
1357 
1358  end subroutine b10exps
1359 
1360 
1361 !**********************************************************************
1362  subroutine tablup(nx1,nh1,dw,p,dt,s1,s2,s3,w1,p1, &
1363  dwe,dpe,coef1,coef2,coef3,tran)
1364 !**********************************************************************
1365 ! Compute water vapor, co2 and o3 transmittances between level
1366 ! k1 and and level k2 , using table look-up.
1367 !
1368 ! Calculations follow Eq. (4.16).
1369 !
1370 !---- input ---------------------
1371 !
1372 ! number of pressure intervals in the table (nx1)
1373 ! number of absorber amount intervals in the table (nh1)
1374 ! layer absorber amount (dw)
1375 ! layer pressure in mb (p)
1376 ! deviation of layer temperature from 250K (dt)
1377 ! first value of absorber amount (log10) in the table (w1)
1378 ! first value of pressure (log10) in the table (p1)
1379 ! size of the interval of absorber amount (log10) in the table (dwe)
1380 ! size of the interval of pressure (log10) in the table (dpe)
1381 ! pre-computed coefficients (coef1, coef2, and coef3)
1382 !
1383 !---- updated ---------------------
1384 !
1385 ! column integrated absorber amount (s1)
1386 ! absorber-weighted column pressure (s2)
1387 ! absorber-weighted column temperature (s3)
1388 ! transmittance (tran)
1389 !
1390 ! Note: Units of s1 are g/cm**2 for water vapor and
1391 ! (cm-atm)stp for co2 and o3.
1392 !
1393 !**********************************************************************
1394  implicit none
1395 
1396  integer :: nx1,nh1
1397 
1398 !---- input parameters -----
1399 
1400  real(8) :: w1,p1,dwe,dpe
1401  real(8) :: dw,p,dt
1402  real(8) :: coef1(nx1,nh1),coef2(nx1,nh1),coef3(nx1,nh1)
1403 
1404 !---- update parameter -----
1405 
1406  real(8) :: s1,s2,s3,tran
1407 
1408 !---- temporary variables -----
1409 
1410  real(8) :: we,pe,fw,fp,pa,pb,pc,ax,ba,bb,t1,ca,cb,t2
1411  real(8) :: x1,x2,x3,xx, x1c
1412  integer :: iw,ip
1413 
1414 !-----Compute effective pressure (x2) and temperature (x3) following
1415 ! Eqs. (8.28) and (8.29)
1416 
1417  s1=s1+dw
1418  s2=s2+p*dw
1419  s3=s3+dt*dw
1420 
1421  x1=s1
1422  x1c=1.0/s1
1423  x2=s2*x1c
1424  x3=s3*x1c
1425 
1426 !-----normalize we and pe
1427 
1428 ! we=(log10(x1)-w1)/dwe
1429 ! pe=(log10(x2)-p1)/dpe
1430  we=(log10(x1)-w1)*dwe
1431  pe=(log10(x2)-p1)*dpe
1432 
1433 !-----restrict the magnitudes of the normalized we and pe.
1434 
1435  we=min(we,real(nh1-1))
1436  pe=min(pe,real(nx1-1))
1437 
1438 !-----assign iw and ip and compute the distance of we and pe
1439 ! from iw and ip.
1440 
1441  iw=int(we+1.0)
1442  iw=min(iw,nh1-1)
1443  iw=max(iw, 2)
1444  fw=we-real(iw-1)
1445 
1446  ip=int(pe+1.0)
1447  ip=min(ip,nx1-1)
1448  ip=max(ip, 1)
1449  fp=pe-real(ip-1)
1450 
1451 !-----linear interpolation in pressure
1452 
1453  pa = coef1(ip,iw-1)+(coef1(ip+1,iw-1)-coef1(ip,iw-1))*fp
1454  pb = coef1(ip, iw)+(coef1(ip+1, iw)-coef1(ip, iw))*fp
1455  pc = coef1(ip,iw+1)+(coef1(ip+1,iw+1)-coef1(ip,iw+1))*fp
1456 
1457 !-----quadratic interpolation in absorber amount for coef1
1458 
1459  ax = ( (pc+pa)*fw + (pc-pa) ) *fw*0.5 + pb*(1.-fw*fw)
1460 
1461 !-----linear interpolation in absorber amount for coef2 and coef3
1462 
1463  ba = coef2(ip, iw)+(coef2(ip+1, iw)-coef2(ip, iw))*fp
1464  bb = coef2(ip,iw+1)+(coef2(ip+1,iw+1)-coef2(ip,iw+1))*fp
1465  t1 = ba+(bb-ba)*fw
1466 
1467  ca = coef3(ip, iw)+(coef3(ip+1, iw)-coef3(ip, iw))*fp
1468  cb = coef3(ip,iw+1)+(coef3(ip+1,iw+1)-coef3(ip,iw+1))*fp
1469  t2 = ca + (cb-ca)*fw
1470 
1471 !-----update the total transmittance between levels k1 and k2
1472 
1473  xx=(ax + (t1+t2*x3) * x3)
1474  xx= min(xx,0.9999999)
1475  xx= max(xx,0.0000001)
1476  tran= tran*xx
1477 
1478  end subroutine tablup
1479 
1480 
1481 !**********************************************************************
1482  subroutine h2okdis(ib,np,k,fkw,gkw,ne,h2oexp,conexp, &
1483  th2o,tcon,tran)
1484 !**********************************************************************
1485 ! compute water vapor transmittance between levels k1 and k2, using the k-distribution method.
1486 !
1487 !---- input parameters
1488 ! spectral band (ib)
1489 ! number of levels (np)
1490 ! current level (k)
1491 ! planck-weighted k-distribution function due to
1492 ! h2o line absorption (fkw)
1493 ! planck-weighted k-distribution function due to
1494 ! h2o continuum absorption (gkw)
1495 ! number of terms used in each band to compute water vapor
1496 ! continuum transmittance (ne)
1497 ! exponentials for line absorption (h2oexp)
1498 ! exponentials for continuum absorption (conexp)
1499 !
1500 !---- updated parameters
1501 ! transmittance between levels k1 and k2 due to
1502 ! water vapor line absorption (th2o)
1503 ! transmittance between levels k1 and k2 due to
1504 ! water vapor continuum absorption (tcon)
1505 ! total transmittance (tran)
1506 !
1507 !**********************************************************************
1508  implicit none
1509 
1510 !---- input parameters ------
1511 
1512  integer :: ib,ne,np,k
1513  real(8) :: h2oexp(0:np,6),conexp(0:np,3)
1514  real(8) :: fkw(6,9),gkw(6,3)
1515 
1516 !---- updated parameters -----
1517 
1518  real(8) :: th2o(6),tcon(3),tran
1519 
1520 !---- temporary arrays -----
1521 
1522  real(8) :: trnth2o
1523 
1524 !-----tco2 are the six exp factors between levels k1 and k2
1525 ! tran is the updated total transmittance between levels k1 and k2
1526 
1527 !-----th2o is the 6 exp factors between levels k1 and k2 due to
1528 ! h2o line absorption.
1529 
1530 !-----tcon is the 3 exp factors between levels k1 and k2 due to
1531 ! h2o continuum absorption.
1532 
1533 !-----trnth2o is the total transmittance between levels k1 and k2 due
1534 ! to both line and continuum absorption.
1535 
1536 !-----Compute th2o following Eq. (8.23).
1537 
1538  th2o(1) = th2o(1)*h2oexp(k,1)
1539  th2o(2) = th2o(2)*h2oexp(k,2)
1540  th2o(3) = th2o(3)*h2oexp(k,3)
1541  th2o(4) = th2o(4)*h2oexp(k,4)
1542  th2o(5) = th2o(5)*h2oexp(k,5)
1543  th2o(6) = th2o(6)*h2oexp(k,6)
1544 
1545  if (ne == 0) then
1546 
1547 !-----Compute trnh2o following Eq. (8.25). fkw is given in Table 4.
1548 
1549  trnth2o =(fkw(1,ib)*th2o(1) &
1550  + fkw(2,ib)*th2o(2) &
1551  + fkw(3,ib)*th2o(3) &
1552  + fkw(4,ib)*th2o(4) &
1553  + fkw(5,ib)*th2o(5) &
1554  + fkw(6,ib)*th2o(6))
1555 
1556 
1557  tran = tran*trnth2o
1558 
1559  elseif (ne == 1) then
1560 
1561 !-----Compute trnh2o following Eqs. (8.25) and (4.27).
1562 
1563  tcon(1) = tcon(1)*conexp(k,1)
1564 
1565  trnth2o =(fkw(1,ib)*th2o(1) &
1566  + fkw(2,ib)*th2o(2) &
1567  + fkw(3,ib)*th2o(3) &
1568  + fkw(4,ib)*th2o(4) &
1569  + fkw(5,ib)*th2o(5) &
1570  + fkw(6,ib)*th2o(6))*tcon(1)
1571 
1572  tran = tran*trnth2o
1573 
1574  else
1575 
1576 !-----For band 3. This band is divided into 3 subbands.
1577 
1578  tcon(1)= tcon(1)*conexp(k,1)
1579  tcon(2)= tcon(2)*conexp(k,2)
1580  tcon(3)= tcon(3)*conexp(k,3)
1581 
1582 !-----Compute trnh2o following Eqs. (4.29) and (8.25).
1583 
1584  trnth2o = ( gkw(1,1)*th2o(1) &
1585  + gkw(2,1)*th2o(2) &
1586  + gkw(3,1)*th2o(3) &
1587  + gkw(4,1)*th2o(4) &
1588  + gkw(5,1)*th2o(5) &
1589  + gkw(6,1)*th2o(6) ) * tcon(1) &
1590  + ( gkw(1,2)*th2o(1) &
1591  + gkw(2,2)*th2o(2) &
1592  + gkw(3,2)*th2o(3) &
1593  + gkw(4,2)*th2o(4) &
1594  + gkw(5,2)*th2o(5) &
1595  + gkw(6,2)*th2o(6) ) * tcon(2) &
1596  + ( gkw(1,3)*th2o(1) &
1597  + gkw(2,3)*th2o(2) &
1598  + gkw(3,3)*th2o(3) &
1599  + gkw(4,3)*th2o(4) &
1600  + gkw(5,3)*th2o(5) &
1601  + gkw(6,3)*th2o(6) ) * tcon(3)
1602 
1603  tran = tran*trnth2o
1604 
1605  end if
1606 
1607  end subroutine h2okdis
1608 
1609 
1610 !**********************************************************************
1611  subroutine n2okdis(ib,np,k,n2oexp,tn2o,tran)
1612 !**********************************************************************
1613 ! compute n2o transmittances between levels k1 and k2, using the k-distribution method with linear
1614 ! pressure scaling.
1615 !
1616 !---- input parameters
1617 ! spectral band (ib)
1618 ! number of levels (np)
1619 ! current level (k)
1620 ! exponentials for n2o absorption (n2oexp)
1621 !
1622 !---- updated parameters
1623 ! transmittance between levels k1 and k2 due to n2o absorption
1624 ! for the various values of the absorption coefficient (tn2o)
1625 ! total transmittance (tran)
1626 !
1627 !**********************************************************************
1628  implicit none
1629  integer :: ib,np,k
1630 
1631 !---- input parameters -----
1632 
1633  real(8) :: n2oexp(0:np,4)
1634 
1635 !---- updated parameters -----
1636 
1637  real(8) :: tn2o(4),tran
1638 
1639 !---- temporary arrays -----
1640 
1641  real(8) :: xc
1642 
1643 !-----tn2o is computed from Eq. (8.23).
1644 ! xc is the total n2o transmittance computed from (8.25)
1645 ! The k-distribution functions are given in Table 5.
1646 
1647 !-----band 6
1648 
1649  if (ib == 6) then
1650 
1651  tn2o(1)=tn2o(1)*n2oexp(k,1)
1652  xc= 0.940414*tn2o(1)
1653 
1654  tn2o(2)=tn2o(2)*n2oexp(k,2)
1655  xc=xc+0.059586*tn2o(2)
1656 
1657 !-----band 7
1658 
1659  else
1660 
1661  tn2o(1)=tn2o(1)*n2oexp(k,1)
1662  xc= 0.561961*tn2o(1)
1663 
1664  tn2o(2)=tn2o(2)*n2oexp(k,2)
1665  xc=xc+0.138707*tn2o(2)
1666 
1667  tn2o(3)=tn2o(3)*n2oexp(k,3)
1668  xc=xc+0.240670*tn2o(3)
1669 
1670  tn2o(4)=tn2o(4)*n2oexp(k,4)
1671  xc=xc+0.058662*tn2o(4)
1672 
1673  end if
1674 
1675  tran=tran*xc
1676 
1677  end subroutine n2okdis
1678 
1679 
1680 !**********************************************************************
1681  subroutine ch4kdis(ib,np,k,ch4exp,tch4,tran)
1682 !**********************************************************************
1683 ! compute ch4 transmittances between levels k1 and k2, using the k-distribution method with
1684 ! linear pressure scaling.
1685 !
1686 !---- input parameters
1687 ! spectral band (ib)
1688 ! number of levels (np)
1689 ! current level (k)
1690 ! exponentials for ch4 absorption (ch4exp)
1691 !
1692 !---- updated parameters
1693 ! transmittance between levels k1 and k2 due to ch4 absorption
1694 ! for the various values of the absorption coefficient (tch4)
1695 ! total transmittance (tran)
1696 !
1697 !**********************************************************************
1698  implicit none
1699  integer :: ib,np,k
1700 
1701 !---- input parameters -----
1702 
1703  real(8) :: ch4exp(0:np,4)
1704 
1705 !---- updated parameters -----
1706 
1707  real(8) :: tch4(4),tran
1708 
1709 !---- temporary arrays -----
1710 
1711  real(8) :: xc
1712 
1713 !-----tch4 is computed from Eq. (8.23).
1714 ! xc is the total ch4 transmittance computed from (8.25)
1715 ! The k-distribution functions are given in Table 5.
1716 
1717 !-----band 6
1718 
1719  if (ib == 6) then
1720 
1721  tch4(1)=tch4(1)*ch4exp(k,1)
1722  xc= tch4(1)
1723 
1724 !-----band 7
1725 
1726  else
1727 
1728  tch4(1)=tch4(1)*ch4exp(k,1)
1729  xc= 0.610650*tch4(1)
1730 
1731  tch4(2)=tch4(2)*ch4exp(k,2)
1732  xc=xc+0.280212*tch4(2)
1733 
1734  tch4(3)=tch4(3)*ch4exp(k,3)
1735  xc=xc+0.107349*tch4(3)
1736 
1737  tch4(4)=tch4(4)*ch4exp(k,4)
1738  xc=xc+0.001789*tch4(4)
1739 
1740  end if
1741 
1742  tran=tran*xc
1743 
1744  end subroutine ch4kdis
1745 
1746 
1747 !**********************************************************************
1748  subroutine comkdis(ib,np,k,comexp,tcom,tran)
1749 !**********************************************************************
1750 ! compute co2-minor transmittances between levels k1 and k2, using the k-distribution method
1751 ! with linear pressure scaling.
1752 !
1753 !---- input parameters
1754 ! spectral band (ib)
1755 ! number of levels (np)
1756 ! current level (k)
1757 ! exponentials for co2-minor absorption (comexp)
1758 !
1759 !---- updated parameters
1760 ! transmittance between levels k1 and k2 due to co2-minor absorption
1761 ! for the various values of the absorption coefficient (tcom)
1762 ! total transmittance (tran)
1763 !
1764 !**********************************************************************
1765  implicit none
1766  integer :: ib,np,k
1767 
1768 !---- input parameters -----
1769 
1770  real(8) :: comexp(0:np,6)
1771 
1772 !---- updated parameters -----
1773 
1774  real(8) :: tcom(6),tran
1775 
1776 !---- temporary arrays -----
1777 
1778  real(8) :: xc
1779 
1780 !-----tcom is computed from Eq. (8.23).
1781 ! xc is the total co2 transmittance computed from (8.25)
1782 ! The k-distribution functions are given in Table 6.
1783 
1784 !-----band 4
1785 
1786  if (ib == 4) then
1787 
1788  tcom(1)=tcom(1)*comexp(k,1)
1789  xc= 0.12159*tcom(1)
1790  tcom(2)=tcom(2)*comexp(k,2)
1791  xc=xc+0.24359*tcom(2)
1792  tcom(3)=tcom(3)*comexp(k,3)
1793  xc=xc+0.24981*tcom(3)
1794  tcom(4)=tcom(4)*comexp(k,4)
1795  xc=xc+0.26427*tcom(4)
1796  tcom(5)=tcom(5)*comexp(k,5)
1797  xc=xc+0.07807*tcom(5)
1798  tcom(6)=tcom(6)*comexp(k,6)
1799  xc=xc+0.04267*tcom(6)
1800 
1801 !-----band 5
1802 
1803  else
1804 
1805  tcom(1)=tcom(1)*comexp(k,1)
1806  xc= 0.06869*tcom(1)
1807  tcom(2)=tcom(2)*comexp(k,2)
1808  xc=xc+0.14795*tcom(2)
1809  tcom(3)=tcom(3)*comexp(k,3)
1810  xc=xc+0.19512*tcom(3)
1811  tcom(4)=tcom(4)*comexp(k,4)
1812  xc=xc+0.33446*tcom(4)
1813  tcom(5)=tcom(5)*comexp(k,5)
1814  xc=xc+0.17199*tcom(5)
1815  tcom(6)=tcom(6)*comexp(k,6)
1816  xc=xc+0.08179*tcom(6)
1817 
1818  end if
1819 
1820  tran=tran*xc
1821 
1822  end subroutine comkdis
1823 
1824 
1825 !**********************************************************************
1826  subroutine cfckdis(np,k,cfcexp,tcfc,tran)
1827 !**********************************************************************
1828 ! compute cfc-(11,12,22) transmittances between levels k1 and k2, using the k-distribution method with
1829 ! linear pressure scaling.
1830 !
1831 !---- input parameters
1832 ! number of levels (np)
1833 ! current level (k)
1834 ! exponentials for cfc absorption (cfcexp)
1835 !
1836 !---- updated parameters
1837 ! transmittance between levels k1 and k2 due to cfc absorption
1838 ! for the various values of the absorption coefficient (tcfc)
1839 ! total transmittance (tran)
1840 !
1841 !**********************************************************************
1842  implicit none
1843 
1844 !---- input parameters -----
1845 
1846  integer :: k, np
1847  real(8) :: cfcexp(0:np)
1848 
1849 !---- updated parameters -----
1850 
1851  real(8) :: tcfc,tran
1852 
1853 !-----tcfc is the exp factors between levels k1 and k2.
1854 
1855  tcfc=tcfc*cfcexp(k)
1856  tran=tran*tcfc
1857 
1858  end subroutine cfckdis
1859 
1860 
1861 !**********************************************************************
1862  subroutine b10kdis(np,k,h2oexp,conexp,co2exp,n2oexp, &
1863  th2o,tcon,tco2,tn2o,tran)
1864 !**********************************************************************
1865 !
1866 ! compute h2o (line and continuum),co2,n2o transmittances between
1867 ! levels k1 and k2, using the k-distribution
1868 ! method with linear pressure scaling.
1869 !
1870 !---- input parameters
1871 ! number of levels (np)
1872 ! current level (k)
1873 ! exponentials for h2o line absorption (h2oexp)
1874 ! exponentials for h2o continuum absorption (conexp)
1875 ! exponentials for co2 absorption (co2exp)
1876 ! exponentials for n2o absorption (n2oexp)
1877 !
1878 !---- updated parameters
1879 ! transmittance between levels k1 and k2 due to h2o line absorption
1880 ! for the various values of the absorption coefficient (th2o)
1881 ! transmittance between levels k1 and k2 due to h2o continuum
1882 ! absorption for the various values of the absorption
1883 ! coefficient (tcon)
1884 ! transmittance between levels k1 and k2 due to co2 absorption
1885 ! for the various values of the absorption coefficient (tco2)
1886 ! transmittance between levels k1 and k2 due to n2o absorption
1887 ! for the various values of the absorption coefficient (tn2o)
1888 ! total transmittance (tran)
1889 !
1890 !**********************************************************************
1891  implicit none
1892 
1893  integer :: np,k
1894 
1895 !---- input parameters -----
1896 
1897  real(8) :: h2oexp(0:np,5),conexp(0:np),co2exp(0:np,6), &
1898  n2oexp(0:np,2)
1899 
1900 !---- updated parameters -----
1901 
1902  real(8) :: th2o(6),tcon(3),tco2(6),tn2o(4), &
1903  tran
1904 
1905 !---- temporary arrays -----
1906 
1907  real(8) :: xx
1908 
1909 !-----For h2o line. The k-distribution functions are given in Table 4.
1910 
1911  th2o(1)=th2o(1)*h2oexp(k,1)
1912  xx= 0.3153*th2o(1)
1913 
1914  th2o(2)=th2o(2)*h2oexp(k,2)
1915  xx=xx+0.4604*th2o(2)
1916 
1917  th2o(3)=th2o(3)*h2oexp(k,3)
1918  xx=xx+0.1326*th2o(3)
1919 
1920  th2o(4)=th2o(4)*h2oexp(k,4)
1921  xx=xx+0.0798*th2o(4)
1922 
1923  th2o(5)=th2o(5)*h2oexp(k,5)
1924  xx=xx+0.0119*th2o(5)
1925 
1926  tran=xx
1927 
1928 !-----For h2o continuum. Note that conexp(k,3) is for subband 3a.
1929 
1930  tcon(1)=tcon(1)*conexp(k)
1931  tran=tran*tcon(1)
1932 
1933 !-----For co2 (Table 6)
1934 
1935  tco2(1)=tco2(1)*co2exp(k,1)
1936  xx= 0.2673*tco2(1)
1937 
1938  tco2(2)=tco2(2)*co2exp(k,2)
1939  xx=xx+ 0.2201*tco2(2)
1940 
1941  tco2(3)=tco2(3)*co2exp(k,3)
1942  xx=xx+ 0.2106*tco2(3)
1943 
1944  tco2(4)=tco2(4)*co2exp(k,4)
1945  xx=xx+ 0.2409*tco2(4)
1946 
1947  tco2(5)=tco2(5)*co2exp(k,5)
1948  xx=xx+ 0.0196*tco2(5)
1949 
1950  tco2(6)=tco2(6)*co2exp(k,6)
1951  xx=xx+ 0.0415*tco2(6)
1952 
1953  tran=tran*xx
1954 
1955 !-----For n2o (Table 5)
1956 
1957  tn2o(1)=tn2o(1)*n2oexp(k,1)
1958  xx= 0.970831*tn2o(1)
1959 
1960  tn2o(2)=tn2o(2)*n2oexp(k,2)
1961  xx=xx+0.029169*tn2o(2)
1962 
1963  tran=tran*(xx-1.0)
1964 
1965  end subroutine b10kdis
1966 
1967 
1968 !mjs
1969 
1970 !***********************************************************************
1971  subroutine cldovlp (np,k1,k2,ict,icb,icx,ncld,enn,ett, &
1972  cldhi,cldmd,cldlw)
1973 !***********************************************************************
1974 !
1975 ! update the effective superlayer cloud fractions between levels k1
1976 ! and k2 following Eqs.(6.18)-(6.21). This assumes that the input
1977 ! are the fractions between k1 and k2-1.
1978 !
1979 ! input parameters
1980 !
1981 ! np: number of layers
1982 ! k1: index for top level
1983 ! k2: index for bottom level
1984 ! ict: the level separating high and middle clouds
1985 ! icb: the level separating middle and low clouds
1986 ! icx: indeces sorted by enn in the three superlayers
1987 ! enn: effective fractional cloud cover of a layer
1988 ! ett: transmittance of a cloud layer
1989 !
1990 ! update paremeters
1991 !
1992 ! cldhi: Effective high-level cloudiness
1993 ! cldmd: Effective middle-level cloudiness
1994 ! cldlw: Effective low-level cloudiness
1995 !
1996 !
1997 !***********************************************************************
1998 
1999  implicit none
2000 
2001  integer, intent(IN ) :: np,k1,k2,ict,icb,icx(0:np),ncld(3)
2002  real(8), intent(IN ) :: enn(0:np), ett(0:np)
2003 
2004  real(8), intent(INOUT) :: cldhi,cldmd,cldlw
2005 
2006  integer :: j,k,km,kx
2007 
2008  km=k2-1
2009 
2010  if (km < ict ) then ! do high clouds
2011 
2012  kx=ncld(1)
2013 
2014  if(kx==1 .or. cldhi==0.) then
2015  cldhi = enn(km)
2016  else
2017  !if ( (kx.lt.1 .or. kx.gt.1) .and. abs(cldhi) .gt. 0.) then
2018  cldhi = 0.0
2019  if(kx/=0) then
2020  do k=ict-kx,ict-1
2021  j=icx(k)
2022  if(j>=k1 .and. j<=km) cldhi=enn(j)+ett(j)*cldhi
2023  end do
2024  end if
2025  end if
2026 
2027  elseif(km >= ict .and. km < icb) then ! do middle clouds
2028 
2029  kx=ncld(2)
2030 
2031  if(kx==1 .or. cldmd==0.) then
2032  cldmd = enn(km)
2033  else
2034  !if ( (kx.lt.1 .or. kx.gt.1) .and. abs(cldhi) .gt. 0.) then
2035  cldmd = 0.0
2036  if(kx/=0) then
2037  do k=icb-kx,icb-1
2038  j=icx(k)
2039  if(j>=k1 .and. j<=km) cldmd=enn(j)+ett(j)*cldmd
2040  end do
2041  end if
2042  end if
2043 
2044  else ! do low clouds
2045 
2046  kx=ncld(3)
2047 
2048  if(kx==1 .or. cldlw==0.) then
2049  cldlw = enn(km)
2050  else
2051  !if ( (kx.lt.1 .or. kx.gt.1) .and. abs(cldhi) .gt. 0.) then
2052  cldlw = 0.0
2053  if(kx/=0) then
2054  do k=np+1-kx,np
2055  j=icx(k)
2056  if(j>=k1 .and. j<=km) cldlw=enn(j)+ett(j)*cldlw
2057  end do
2058  end if
2059  end if
2060 
2061  end if
2062 
2063  end subroutine cldovlp
2064 
2065 !***********************************************************************
2066  subroutine sfcflux (ibn,cb,dcb,ns,fs,tg,eg,tv,ev,rv,bs,dbs,rflxs)
2067 !***********************************************************************
2068 ! Compute emission and reflection by an homogeneous/inhomogeneous
2069 ! surface with vegetation cover.
2070 !
2071 !-----Input parameters
2072 ! index for the spectral band (ibn)
2073 ! number of sub-grid box (ns)
2074 ! fractional cover of sub-grid box (fs)
2075 ! sub-grid ground temperature (tg)
2076 ! sub-grid ground emissivity (eg)
2077 ! sub-grid vegetation temperature (tv)
2078 ! sub-grid vegetation emissivity (ev)
2079 ! sub-grid vegetation reflectivity (rv)
2080 !
2081 !-----Output parameters Unit
2082 ! Emission by the surface (ground+vegetation) (bs) W/m^2
2083 ! Derivative of bs rwt to temperature (dbs) W/m^2
2084 ! Reflection by the surface (rflxs) W/m^2
2085 !
2086 !**********************************************************************
2087  implicit none
2088 
2089 !---- input parameters -----
2090  integer :: ibn,ns
2091  real(8) :: cb(6,10)
2092  real(8) :: dcb(5,10)
2093  real(8) :: fs(ns),tg(ns),eg(ns,10)
2094  real(8) :: tv(ns),ev(ns,10),rv(ns,10)
2095 
2096 !---- output parameters -----
2097  real(8) :: bs,dbs,rflxs
2098 
2099 !---- temporary arrays -----
2100  integer :: j
2101  real(8) :: bg(ns),bv(ns),dbg(ns),dbv(ns)
2102  real(8) :: xx,yy,zz
2103 
2104 !***************************************************************
2105 
2106 !-----compute planck flux and the derivative wrt to temperature
2107 ! c.f. eqs. (3.11) and (3.12).
2108 
2109  do j=1,ns
2110  call planck(ibn,cb,tg(j),bg(j))
2111  call planck(ibn,cb,tv(j),bv(j))
2112  call plancd(ibn,dcb,tg(j),dbg(j))
2113  call plancd(ibn,dcb,tv(j),dbv(j))
2114  end do
2115 
2116 !-----
2117 
2118  if (fs(1) > 0.9999) then
2119  if (ev(1,ibn) < 0.0001 .and. rv(1,ibn) < 0.0001) then
2120 
2121 !-----for homogeneous surface without vegetation
2122 ! following Eqs. (9.4), (9.5), and (3.13)
2123 
2124  bs =eg(1,ibn)*bg(1)
2125  dbs=eg(1,ibn)*dbg(1)
2126  rflxs=1.0-eg(1,ibn)
2127  else
2128 
2129 !-----With vegetation
2130 ! following Eqs. (9.1), (9.3), and (9.13)
2131 
2132  xx=ev(1,ibn)*bv(1)
2133  yy=1.0-ev(1,ibn)-rv(1,ibn)
2134  zz=1.0-eg(1,ibn)
2135  bs=yy*(eg(1,ibn)*bg(1)+zz*xx)+xx
2136 
2137  xx=ev(1,ibn)*dbv(1)
2138  dbs=yy*(eg(1,ibn)*dbg(1)+zz*xx)+xx
2139 
2140  rflxs=rv(1,ibn)+zz*yy*yy/(1.0-rv(1,ibn)*zz)
2141  end if
2142  else
2143 
2144 !-----for nonhomogeneous surface
2145 
2146  bs=0.0
2147  dbs=0.0
2148  rflxs=0.0
2149 
2150  if (ev(1,ibn) < 0.0001 .and. rv(1,ibn) < 0.0001) then
2151 
2152 !-----No vegetation, following Eqs. (9.9), (9.10), and (9.13)
2153 
2154  do j=1,ns
2155  bs=bs+fs(j)*eg(j,ibn)*bg(j)
2156  dbs=dbs+fs(j)*eg(j,ibn)*dbg(j)
2157  rflxs=rflxs+fs(j)*(1.0-eg(j,ibn))
2158  end do
2159  else
2160 
2161 !-----With vegetation, following Eqs. (9.6), (9.7), and (9.13)
2162 
2163  do j=1,ns
2164  xx=ev(j,ibn)*bv(j)
2165  yy=1.0-ev(j,ibn)-rv(j,ibn)
2166  zz=1.0-eg(j,ibn)
2167  bs=bs+fs(j)*(yy*(eg(j,ibn)*bg(j)+zz*xx)+xx)
2168 
2169  xx=ev(j,ibn)*dbv(j)
2170  dbs=dbs+fs(j)*(yy*(eg(j,ibn)*dbg(j)+zz*xx)+xx)
2171 
2172  rflxs=rflxs+fs(j)*(rv(j,ibn)+zz*yy*yy &
2173  /(1.0-rv(j,ibn)*zz))
2174  end do
2175  end if
2176  end if
2177 
2178  end subroutine sfcflux
2179 
2180 !mjs
2181 
2182 
2183 !***********************************************************************
2184  subroutine mkicx(np,ict,icb,enn,icx,ncld)
2185 !***********************************************************************
2186 
2187  implicit none
2188 
2189  integer, intent(IN ) :: np, ict, icb
2190  real(8), intent(IN ) :: enn(0:np)
2191  integer, intent(INOUT) :: icx(0:np)
2192  integer, intent( OUT) :: ncld(3)
2193 
2194  call sortit(enn( 0:ict-1),icx( 0:ict-1),ncld(1), 0, ict-1)
2195  call sortit(enn(ict:icb-1),icx(ict:icb-1),ncld(2),ict, icb-1)
2196  call sortit(enn(icb:np ),icx(icb: np),ncld(3),icb, np)
2197 
2198  end subroutine mkicx
2199 
2200 !***********************************************************************
2201  subroutine sortit(ENN,LST,NCL,ibg,iend)
2202 !***********************************************************************
2203 
2204  implicit none
2205 
2206  integer, intent( OUT) :: ncl
2207  integer, intent(IN ) :: ibg, iend
2208  real(8), intent(IN ) :: enn(ibg:iend)
2209  integer, intent(INOUT) :: lst(ibg:iend)
2210 
2211  integer :: l, ll, i
2212  real(8) :: eno
2213 
2214  if(enn(ibg)>0) then
2215  ncl=1
2216  else
2217  ncl=0
2218  end if
2219 
2220  do l=ibg+1,iend
2221  eno = enn(lst(l))
2222 
2223  if(eno>0) ncl=ncl+1
2224 
2225  ll=lst(l)
2226  i=l-1
2227  do while(i>ibg-1)
2228  if (enn(lst(i))<=eno) exit
2229  lst(i+1)=lst(i)
2230  i=i-1
2231  end do
2232  lst(i+1)=ll
2233  end do
2234 
2235  end subroutine sortit
2236 
2237 
2238  subroutine getirtau1(ib,nlevs,dp,fcld,reff,hydromets,&
2239  tcldlyr,enn, &
2240  aib_ir1, awb_ir1, &
2241  aiw_ir1, aww_ir1, &
2242  aig_ir1, awg_ir1, CONS_GRAV)
2244 ! !USES:
2245 
2246  implicit none
2247 
2248 ! !INPUT PARAMETERS:
2249  integer, intent(IN ) :: ib ! Band number
2250  integer, intent(IN ) :: nlevs ! Number of levels
2251  real(8), intent(IN ) :: dp(nlevs) ! Delta pressure in Pa
2252  real(8), intent(IN ) :: fcld(nlevs) ! Cloud fraction (used sometimes)
2253  real(8), intent(IN ) :: reff(nlevs,4) ! Effective radius (microns)
2254  real(8), intent(IN ) :: hydromets(nlevs,4) ! Hydrometeors (kg/kg)
2255  real(8), intent(IN ) :: aib_ir1(3,10), awb_ir1(4,10), aiw_ir1(4,10)
2256  real(8), intent(IN ) :: aww_ir1(4,10), aig_ir1(4,10), awg_ir1(4,10)
2257  real(8), intent(IN ) :: cons_grav
2258 
2259 ! !OUTPUT PARAMETERS:
2260  real(8), intent(OUT) :: tcldlyr(0:nlevs ) ! Flux transmissivity?
2261  real(8), intent(OUT) :: enn(0:nlevs ) ! Flux transmissivity of a cloud layer?
2262 
2263 ! !DESCRIPTION:
2264 ! Compute in-cloud or grid mean optical depths for infrared wavelengths
2265 ! Slots for reff, hydrometeors and tauall are as follows:
2266 ! 1 Cloud Ice
2267 ! 2 Cloud Liquid
2268 ! 3 Falling Liquid (Rain)
2269 ! 4 Falling Ice (Snow)
2270 !
2271 ! In the below calculations, the constants used in the tau calculation are in
2272 ! m$^2$ g$^{-1}$ and m$^2$ g$^{-1}$ $\mu$m. Thus, we must convert the kg contained in the
2273 ! pressure (Pa = kg m$^{-1}$ s$^{-2}$) to grams.
2274 !
2275 ! !REVISION HISTORY:
2276 ! 2011.11.18 MAT moved to Radiation_Shared and revised arg list, units
2277 !
2278 !EOP
2279 !------------------------------------------------------------------------------
2280 !BOC
2281  integer :: k
2282  real(8) :: taucld1,taucld2,taucld3,taucld4
2283  real(8) :: g1,g2,g3,g4,gg
2284  real(8) :: w1,w2,w3,w4,ww
2285  real(8) :: ff,tauc
2286 
2287  real(8) :: reff_snow
2288 
2289 
2290 !-----Compute cloud optical thickness following Eqs. (6.4a,b) and (6.7)
2291 ! Rain optical thickness is set to 0.00307 /(gm/m**2).
2292 ! It is for a specific drop size distribution provided by Q. Fu.
2293 
2294  tcldlyr(0) = 1.0
2295  enn(0) = 0.0
2296 
2297  do k = 1, nlevs
2298  if(reff(k,1)<=0.0) then
2299  taucld1=0.0
2300  else
2301  taucld1=(((dp(k)*1.0e3)/cons_grav)*hydromets(k,1))*(aib_ir1(1,ib)+aib_ir1(2,ib)/&
2302  reff(k,1)**aib_ir1(3,ib))
2303  end if
2304 
2305  taucld2=(((dp(k)*1.0e3)/cons_grav)*hydromets(k,2))*(awb_ir1(1,ib)+(awb_ir1(2,ib)+&
2306  (awb_ir1(3,ib)+awb_ir1(4,ib)*reff(k,2))*reff(k,2))*reff(k,2))
2307 
2308  taucld3=0.00307*(((dp(k)*1.0e3)/cons_grav)*hydromets(k,3))
2309 
2310 !-----Below, we use the table of coefficients tabulated for suspended
2311 ! cloud ice particles (aib_ir1) for falling snow. These coefficients
2312 ! lead to unphysical (negative) values of cloud optical thickness
2313 ! for effective radii greater than 113 microns. By restricting the
2314 ! effective radius of snow to 112 microns, we prevent unphysical
2315 ! optical thicknesses.
2316 
2317  reff_snow = min(reff(k,4),112.0)
2318 
2319  if(reff_snow<=0.0) then
2320  taucld4=0.0
2321  else
2322  taucld4=(((dp(k)*1.0e3)/cons_grav)*hydromets(k,4))*(aib_ir1(1,ib)+aib_ir1(2,ib)/&
2323  reff_snow**aib_ir1(3,ib))
2324  end if
2325 
2326 !-----Compute cloud single-scattering albedo and asymmetry factor for
2327 ! a mixture of ice particles and liquid drops following
2328 ! Eqs. (6.5), (6.6), (6.15) and (6.16).
2329 ! Single-scattering albedo and asymmetry factor of rain are set
2330 ! to 0.54 and 0.95, respectively, based on the information provided
2331 ! by Prof. Qiang Fu.
2332 
2333  tauc=taucld1+taucld2+taucld3+taucld4
2334 
2335  if (tauc > 0.02 .and. fcld(k) > 0.01) then
2336 
2337  w1=taucld1*(aiw_ir1(1,ib)+(aiw_ir1(2,ib)+(aiw_ir1(3,ib) &
2338  +aiw_ir1(4,ib)*reff(k,1))*reff(k,1))*reff(k,1))
2339  w2=taucld2*(aww_ir1(1,ib)+(aww_ir1(2,ib)+(aww_ir1(3,ib)&
2340  +aww_ir1(4,ib)*reff(k,2))*reff(k,2))*reff(k,2))
2341  w3=taucld3*0.54
2342  w4=taucld4*(aiw_ir1(1,ib)+(aiw_ir1(2,ib)+(aiw_ir1(3,ib) &
2343  +aiw_ir1(4,ib)*reff_snow)*reff_snow)*reff_snow)
2344  ww=(w1+w2+w3+w4)/tauc
2345 
2346 
2347  g1=w1*(aig_ir1(1,ib)+(aig_ir1(2,ib)+(aig_ir1(3,ib)&
2348  +aig_ir1(4,ib)*reff(k,1))*reff(k,1))*reff(k,1))
2349  g2=w2*(awg_ir1(1,ib)+(awg_ir1(2,ib)+(awg_ir1(3,ib) &
2350  +awg_ir1(4,ib)*reff(k,2))*reff(k,2))*reff(k,2))
2351  g3=w3*0.95
2352  g4=w4*(aig_ir1(1,ib)+(aig_ir1(2,ib)+(aig_ir1(3,ib)&
2353  +aig_ir1(4,ib)*reff_snow)*reff_snow)*reff_snow)
2354 
2355  if (abs(w1+w2+w3+w4).gt.0.0) then
2356  gg=(g1+g2+g3+g4)/(w1+w2+w3+w4)
2357  else
2358  gg=0.5
2359  end if
2360 
2361 !-----Parameterization of LW scattering following Eqs. (6.11)
2362 ! and (6.12).
2363 
2364  ff=0.5+(0.3739+(0.0076+0.1185*gg)*gg)*gg
2365 
2366 !ALT: temporary protection against negative cloud optical thickness
2367 
2368  tauc=max((1.-ww*ff),0.0)*tauc
2369 
2370 !-----compute cloud diffuse transmittance. It is approximated by using
2371 ! a diffusivity factor of 1.66.
2372 
2373  tcldlyr(k) = exp(-1.66*tauc)
2374  enn(k) = fcld(k)*(1.0-tcldlyr(k)) ! N in the documentation (6.13)
2375 
2376  else
2377 
2378  tcldlyr(k) = 1.0
2379  enn(k) = 0.0
2380 
2381  end if
2382  end do
2383 
2384 
2385  end subroutine getirtau1
2386 
2387 end module irradmod
subroutine, public b10exps(np, dh2o, dcont, dco2, dn2o, pa, dt, h2oexp, conexp, co2exp, n2oexp)
Definition: irrad.F90:1246
subroutine, public h2okdis(ib, np, k, fkw, gkw, ne, h2oexp, conexp, th2o, tcon, tran)
Definition: irrad.F90:1484
subroutine, public ch4exps(ib, np, dch4, pa, dt, ch4exp)
Definition: irrad.F90:1063
subroutine, public cfckdis(np, k, cfcexp, tcfc, tran)
Definition: irrad.F90:1827
subroutine, public ch4kdis(ib, np, k, ch4exp, tch4, tran)
Definition: irrad.F90:1682
subroutine, public cfcexps(ib, np, a1, b1, fk1, a2, b2, fk2, dcfc, dt, cfcexp)
Definition: irrad.F90:1188
integer, parameter, public fp
Definition: Type_Kinds.f90:124
integer, parameter, public ip
Definition: Type_Kinds.f90:97
subroutine, public n2oexps(ib, np, dn2o, pa, dt, n2oexp)
Definition: irrad.F90:991
subroutine, public n2okdis(ib, np, k, n2oexp, tn2o, tran)
Definition: irrad.F90:1612
subroutine, public comexps(ib, np, dcom, dt, comexp)
Definition: irrad.F90:1132
subroutine, public cldovlp(np, k1, k2, ict, icb, icx, ncld, enn, ett, cldhi, cldmd, cldlw)
Definition: irrad.F90:1973
subroutine, public planck(ibn, cb, t, xlayer)
Definition: irrad.F90:819
subroutine, public conexps(ib, np, dcont, xke, conexp)
Definition: irrad.F90:940
subroutine, public irrad(np, ple_dev, ta_dev, wa_dev, oa_dev, tb_dev, co2, trace, n2o_dev, ch4_dev, cfc11_dev, cfc12_dev, cfc22_dev, cwc_dev, fcld_dev, ict, icb, reff_dev, ns, fs_dev, tg_dev, eg_dev, tv_dev, ev_dev, rv_dev, na, nb, taua_dev, ssaa_dev, asya_dev, flxu_dev, flxd_dev, dfdts_dev, aib_ir, awb_ir, aiw_ir, aww_ir, aig_ir, awg_ir, xkw, xke, mw, aw, bw, pm, fkw, gkw, cb, dcb, w11, w12, w13, p11, p12, p13, dwe, dpe, c1, c2, c3, oo1, oo2, oo3, h11, h12, h13, h21, h22, h23, h81, h82, h83)
Definition: irrad.F90:55
subroutine, public h2oexps(ib, np, dh2o, pa, dt, xkw, aw, bw, pm, mw, h2oexp)
Definition: irrad.F90:855
subroutine, public tablup(nx1, nh1, dw, p, dt, s1, s2, s3, w1, p1, dwe, dpe, coef1, coef2, coef3, tran)
Definition: irrad.F90:1364
subroutine, public sfcflux(ibn, cb, dcb, ns, fs, tg, eg, tv, ev, rv, bs, dbs, rflxs)
Definition: irrad.F90:2067
subroutine, public sortit(ENN, LST, NCL, ibg, iend)
Definition: irrad.F90:2202
subroutine, public getirtau1(ib, nlevs, dp, fcld, reff, hydromets, tcldlyr, enn, aib_ir1, awb_ir1, aiw_ir1, aww_ir1, aig_ir1, awg_ir1, CONS_GRAV)
Definition: irrad.F90:2243
subroutine, public b10kdis(np, k, h2oexp, conexp, co2exp, n2oexp, th2o, tcon, tco2, tn2o, tran)
Definition: irrad.F90:1864
#define max(a, b)
Definition: mosaic_util.h:33
subroutine, public comkdis(ib, np, k, comexp, tcom, tran)
Definition: irrad.F90:1749
subroutine, public plancd(ibn, dcb, t, dbdt)
Definition: irrad.F90:837
#define min(a, b)
Definition: mosaic_util.h:32
subroutine, public mkicx(np, ict, icb, enn, icx, ncld)
Definition: irrad.F90:2185