PageRenderTime 85ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 1ms

/wrfv2_fire/phys/module_ra_cam.F

http://github.com/jbeezley/wrf-fire
FORTRAN Legacy | 7901 lines | 4745 code | 545 blank | 2611 comment | 157 complexity | 1d2649a1c0515f0f3dc8a5f07df2f95b MD5 | raw file
Possible License(s): AGPL-1.0
  1. MODULE module_ra_cam
  2. use module_ra_cam_support
  3. use module_cam_support, only: endrun
  4. implicit none
  5. !
  6. ! A. Slingo's data for cloud particle radiative properties (from 'A GCM
  7. ! Parameterization for the Shortwave Properties of Water Clouds' JAS
  8. ! vol. 46 may 1989 pp 1419-1427)
  9. !
  10. real(r8) abarl(4) ! A coefficient for extinction optical depth
  11. real(r8) bbarl(4) ! B coefficient for extinction optical depth
  12. real(r8) cbarl(4) ! C coefficient for single scat albedo
  13. real(r8) dbarl(4) ! D coefficient for single scat albedo
  14. real(r8) ebarl(4) ! E coefficient for asymmetry parameter
  15. real(r8) fbarl(4) ! F coefficient for asymmetry parameter
  16. save abarl, bbarl, cbarl, dbarl, ebarl, fbarl
  17. data abarl/ 2.817e-02, 2.682e-02,2.264e-02,1.281e-02/
  18. data bbarl/ 1.305 , 1.346 ,1.454 ,1.641 /
  19. data cbarl/-5.62e-08 ,-6.94e-06 ,4.64e-04 ,0.201 /
  20. data dbarl/ 1.63e-07 , 2.35e-05 ,1.24e-03 ,7.56e-03 /
  21. data ebarl/ 0.829 , 0.794 ,0.754 ,0.826 /
  22. data fbarl/ 2.482e-03, 4.226e-03,6.560e-03,4.353e-03/
  23. #if 0
  24. ! moved and changed to local variables into radcswmx for thread-safety, JM 20100217
  25. real(r8) abarli ! A coefficient for current spectral band
  26. real(r8) bbarli ! B coefficient for current spectral band
  27. real(r8) cbarli ! C coefficient for current spectral band
  28. real(r8) dbarli ! D coefficient for current spectral band
  29. real(r8) ebarli ! E coefficient for current spectral band
  30. real(r8) fbarli ! F coefficient for current spectral band
  31. #endif
  32. !
  33. ! Caution... A. Slingo recommends no less than 4.0 micro-meters nor
  34. ! greater than 20 micro-meters
  35. !
  36. ! ice water coefficients (Ebert and Curry,1992, JGR, 97, 3831-3836)
  37. !
  38. real(r8) abari(4) ! a coefficient for extinction optical depth
  39. real(r8) bbari(4) ! b coefficient for extinction optical depth
  40. real(r8) cbari(4) ! c coefficient for single scat albedo
  41. real(r8) dbari(4) ! d coefficient for single scat albedo
  42. real(r8) ebari(4) ! e coefficient for asymmetry parameter
  43. real(r8) fbari(4) ! f coefficient for asymmetry parameter
  44. save abari, bbari, cbari, dbari, ebari, fbari
  45. data abari/ 3.448e-03, 3.448e-03,3.448e-03,3.448e-03/
  46. data bbari/ 2.431 , 2.431 ,2.431 ,2.431 /
  47. data cbari/ 1.00e-05 , 1.10e-04 ,1.861e-02,.46658 /
  48. data dbari/ 0.0 , 1.405e-05,8.328e-04,2.05e-05 /
  49. data ebari/ 0.7661 , 0.7730 ,0.794 ,0.9595 /
  50. data fbari/ 5.851e-04, 5.665e-04,7.267e-04,1.076e-04/
  51. #if 0
  52. ! moved and changed to local variables into radcswmx for thread-safety, JM 20100217
  53. real(r8) abarii ! A coefficient for current spectral band
  54. real(r8) bbarii ! B coefficient for current spectral band
  55. real(r8) cbarii ! C coefficient for current spectral band
  56. real(r8) dbarii ! D coefficient for current spectral band
  57. real(r8) ebarii ! E coefficient for current spectral band
  58. real(r8) fbarii ! F coefficient for current spectral band
  59. #endif
  60. !
  61. real(r8) delta ! Pressure (in atm) for stratos. h2o limit
  62. real(r8) o2mmr ! O2 mass mixing ratio:
  63. save delta, o2mmr
  64. !
  65. ! UPDATE TO H2O NEAR-IR: Delta optimized for Hitran 2K and CKD 2.4
  66. !
  67. data delta / 0.0014257179260883 /
  68. !
  69. ! END UPDATE
  70. !
  71. data o2mmr / .23143 /
  72. ! Next series depends on spectral interval
  73. !
  74. real(r8) frcsol(nspint) ! Fraction of solar flux in spectral interval
  75. real(r8) wavmin(nspint) ! Min wavelength (micro-meters) of interval
  76. real(r8) wavmax(nspint) ! Max wavelength (micro-meters) of interval
  77. real(r8) raytau(nspint) ! Rayleigh scattering optical depth
  78. real(r8) abh2o(nspint) ! Absorption coefficiant for h2o (cm2/g)
  79. real(r8) abo3 (nspint) ! Absorption coefficiant for o3 (cm2/g)
  80. real(r8) abco2(nspint) ! Absorption coefficiant for co2 (cm2/g)
  81. real(r8) abo2 (nspint) ! Absorption coefficiant for o2 (cm2/g)
  82. real(r8) ph2o(nspint) ! Weight of h2o in spectral interval
  83. real(r8) pco2(nspint) ! Weight of co2 in spectral interval
  84. real(r8) po2 (nspint) ! Weight of o2 in spectral interval
  85. real(r8) nirwgt(nspint) ! Spectral Weights to simulate Nimbus-7 filter
  86. save frcsol ,wavmin ,wavmax ,raytau ,abh2o ,abo3 , &
  87. abco2 ,abo2 ,ph2o ,pco2 ,po2 ,nirwgt
  88. data frcsol / .001488, .001389, .001290, .001686, .002877, &
  89. .003869, .026336, .360739, .065392, .526861, &
  90. .526861, .526861, .526861, .526861, .526861, &
  91. .526861, .006239, .001834, .001834/
  92. !
  93. ! weight for 0.64 - 0.7 microns appropriate to clear skies over oceans
  94. !
  95. data nirwgt / 0.0, 0.0, 0.0, 0.0, 0.0, &
  96. 0.0, 0.0, 0.0, 0.320518, 1.0, 1.0, &
  97. 1.0, 1.0, 1.0, 1.0, 1.0, &
  98. 1.0, 1.0, 1.0 /
  99. data wavmin / .200, .245, .265, .275, .285, &
  100. .295, .305, .350, .640, .700, .701, &
  101. .701, .701, .701, .702, .702, &
  102. 2.630, 4.160, 4.160/
  103. data wavmax / .245, .265, .275, .285, .295, &
  104. .305, .350, .640, .700, 5.000, 5.000, &
  105. 5.000, 5.000, 5.000, 5.000, 5.000, &
  106. 2.860, 4.550, 4.550/
  107. !
  108. ! UPDATE TO H2O NEAR-IR: Rayleigh scattering optimized for Hitran 2K & CKD 2.4
  109. !
  110. real(r8) v_raytau_35
  111. real(r8) v_raytau_64
  112. real(r8) v_abo3_35
  113. real(r8) v_abo3_64
  114. parameter( &
  115. v_raytau_35 = 0.155208, &
  116. v_raytau_64 = 0.0392, &
  117. v_abo3_35 = 2.4058030e+01, &
  118. v_abo3_64 = 2.210e+01 &
  119. )
  120. data raytau / 4.020, 2.180, 1.700, 1.450, 1.250, &
  121. 1.085, 0.730, v_raytau_35, v_raytau_64, &
  122. 0.02899756, 0.01356763, 0.00537341, &
  123. 0.00228515, 0.00105028, 0.00046631, &
  124. 0.00025734, &
  125. .0001, .0001, .0001/
  126. !
  127. ! END UPDATE
  128. !
  129. !
  130. ! Absorption coefficients
  131. !
  132. !
  133. ! UPDATE TO H2O NEAR-IR: abh2o optimized for Hitran 2K and CKD 2.4
  134. !
  135. data abh2o / .000, .000, .000, .000, .000, &
  136. .000, .000, .000, .000, &
  137. 0.00256608, 0.06310504, 0.42287445, 2.45397941, &
  138. 11.20070807, 47.66091389, 240.19010243, &
  139. .000, .000, .000/
  140. !
  141. ! END UPDATE
  142. !
  143. data abo3 /5.370e+04, 13.080e+04, 9.292e+04, 4.530e+04, 1.616e+04, &
  144. 4.441e+03, 1.775e+02, v_abo3_35, v_abo3_64, .000, &
  145. .000, .000 , .000 , .000 , .000, &
  146. .000, .000 , .000 , .000 /
  147. data abco2 / .000, .000, .000, .000, .000, &
  148. .000, .000, .000, .000, .000, &
  149. .000, .000, .000, .000, .000, &
  150. .000, .094, .196, 1.963/
  151. data abo2 / .000, .000, .000, .000, .000, &
  152. .000, .000, .000,1.11e-05,6.69e-05, &
  153. .000, .000, .000, .000, .000, &
  154. .000, .000, .000, .000/
  155. !
  156. ! Spectral interval weights
  157. !
  158. data ph2o / .000, .000, .000, .000, .000, &
  159. .000, .000, .000, .000, .505, &
  160. .210, .120, .070, .048, .029, &
  161. .018, .000, .000, .000/
  162. data pco2 / .000, .000, .000, .000, .000, &
  163. .000, .000, .000, .000, .000, &
  164. .000, .000, .000, .000, .000, &
  165. .000, 1.000, .640, .360/
  166. data po2 / .000, .000, .000, .000, .000, &
  167. .000, .000, .000, 1.000, 1.000, &
  168. .000, .000, .000, .000, .000, &
  169. .000, .000, .000, .000/
  170. real(r8) amo ! Molecular weight of ozone (g/mol)
  171. save amo
  172. data amo / 48.0000 /
  173. contains
  174. subroutine camrad(RTHRATENLW,RTHRATENSW, &
  175. dolw,dosw, &
  176. SWUPT,SWUPTC,SWDNT,SWDNTC, &
  177. LWUPT,LWUPTC,LWDNT,LWDNTC, &
  178. SWUPB,SWUPBC,SWDNB,SWDNBC, &
  179. LWUPB,LWUPBC,LWDNB,LWDNBC, &
  180. swcf,lwcf,olr,cemiss,taucldc,taucldi,coszr, &
  181. GSW,GLW,XLAT,XLONG, &
  182. ALBEDO,t_phy,TSK,EMISS, &
  183. QV3D,QC3D,QR3D,QI3D,QS3D,QG3D, &
  184. ALSWVISDIR,ALSWVISDIF, & !ssib
  185. ALSWNIRDIR,ALSWNIRDIF, & !ssib
  186. SWVISDIR,SWVISDIF, & !ssib
  187. SWNIRDIR,SWNIRDIF, & !ssib
  188. sf_surface_physics, & !ssib
  189. F_QV,F_QC,F_QR,F_QI,F_QS,F_QG, &
  190. f_ice_phy,f_rain_phy, &
  191. p_phy,p8w,z,pi_phy,rho_phy,dz8w, &
  192. CLDFRA,XLAND,XICE,SNOW, &
  193. ozmixm,pin0,levsiz,num_months, &
  194. m_psp,m_psn,aerosolcp,aerosolcn,m_hybi0, &
  195. cam_abs_dim1, cam_abs_dim2, &
  196. paerlev,naer_c, &
  197. GMT,JULDAY,JULIAN,YR,DT,XTIME,DECLIN,SOLCON, &
  198. RADT,DEGRAD,n_cldadv, &
  199. abstot_3d, absnxt_3d, emstot_3d, &
  200. doabsems, &
  201. ids,ide, jds,jde, kds,kde, &
  202. ims,ime, jms,jme, kms,kme, &
  203. its,ite, jts,jte, kts,kte )
  204. USE module_wrf_error
  205. USE module_state_description, ONLY : SSIBSCHEME !ssib
  206. !------------------------------------------------------------------
  207. IMPLICIT NONE
  208. !------------------------------------------------------------------
  209. INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde, &
  210. ims,ime, jms,jme, kms,kme, &
  211. its,ite, jts,jte, kts,kte
  212. LOGICAL, INTENT(IN ) :: F_QV,F_QC,F_QR,F_QI,F_QS,F_QG
  213. LOGICAL, INTENT(INout) :: doabsems
  214. LOGICAL, INTENT(IN ) :: dolw,dosw
  215. INTEGER, INTENT(IN ) :: n_cldadv
  216. INTEGER, INTENT(IN ) :: JULDAY
  217. REAL, INTENT(IN ) :: JULIAN
  218. INTEGER, INTENT(IN ) :: YR
  219. REAL, INTENT(IN ) :: DT
  220. INTEGER, INTENT(IN ) :: levsiz, num_months
  221. INTEGER, INTENT(IN ) :: paerlev, naer_c
  222. INTEGER, INTENT(IN ) :: cam_abs_dim1, cam_abs_dim2
  223. REAL, INTENT(IN ) :: RADT,DEGRAD, &
  224. XTIME,DECLIN,SOLCON,GMT
  225. !
  226. !
  227. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
  228. INTENT(IN ) :: P_PHY, &
  229. P8W, &
  230. Z, &
  231. pi_PHY, &
  232. rho_PHY, &
  233. dz8w, &
  234. T_PHY, &
  235. QV3D, &
  236. QC3D, &
  237. QR3D, &
  238. QI3D, &
  239. QS3D, &
  240. QG3D, &
  241. CLDFRA
  242. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
  243. INTENT(INOUT) :: RTHRATENLW, &
  244. RTHRATENSW
  245. !
  246. REAL, DIMENSION( ims:ime, jms:jme ), &
  247. INTENT(IN ) :: XLAT, &
  248. XLONG, &
  249. XLAND, &
  250. XICE, &
  251. SNOW, &
  252. EMISS, &
  253. TSK, &
  254. ALBEDO
  255. REAL, DIMENSION( ims:ime, levsiz, jms:jme, num_months ), &
  256. INTENT(IN ) :: OZMIXM
  257. REAL, DIMENSION(levsiz), INTENT(IN ) :: PIN0
  258. REAL, DIMENSION(ims:ime,jms:jme), INTENT(IN ) :: m_psp,m_psn
  259. REAL, DIMENSION(paerlev), intent(in) :: m_hybi0
  260. REAL, DIMENSION( ims:ime, paerlev, jms:jme, naer_c ), &
  261. INTENT(IN ) :: aerosolcp, aerosolcn
  262. !
  263. REAL, DIMENSION( ims:ime, jms:jme ), &
  264. INTENT(INOUT) :: GSW, GLW
  265. !---------SSiB variables (fds 06/2010)----------------
  266. REAL, DIMENSION( ims:ime, jms:jme ), &
  267. INTENT(IN) :: ALSWVISDIR, &
  268. ALSWVISDIF, &
  269. ALSWNIRDIR, &
  270. ALSWNIRDIF
  271. REAL, DIMENSION( ims:ime, jms:jme ), &
  272. INTENT(OUT) :: SWVISDIR, &
  273. SWVISDIF, &
  274. SWNIRDIR, &
  275. SWNIRDIF
  276. INTEGER, INTENT(IN) :: sf_surface_physics
  277. !--------------------------------------
  278. ! saving arrays for doabsems reduction of radiation calcs
  279. REAL, DIMENSION( ims:ime, kms:kme, cam_abs_dim2 , jms:jme ), &
  280. INTENT(INOUT) :: abstot_3d
  281. REAL, DIMENSION( ims:ime, kms:kme, cam_abs_dim1 , jms:jme ), &
  282. INTENT(INOUT) :: absnxt_3d
  283. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
  284. INTENT(INOUT) :: emstot_3d
  285. ! Added outputs of total and clearsky fluxes etc
  286. ! Note that k=1 refers to the half level below the model lowest level (Sfc)
  287. ! k=kme refers to the half level above the model highest level (TOA)
  288. !
  289. ! REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
  290. ! INTENT(INOUT) :: swup, &
  291. ! swupclear, &
  292. ! swdn, &
  293. ! swdnclear, &
  294. ! lwup, &
  295. ! lwupclear, &
  296. ! lwdn, &
  297. ! lwdnclear
  298. REAL, DIMENSION( ims:ime, jms:jme ), OPTIONAL, INTENT(INOUT) ::&
  299. SWUPT,SWUPTC,SWDNT,SWDNTC, &
  300. LWUPT,LWUPTC,LWDNT,LWDNTC, &
  301. SWUPB,SWUPBC,SWDNB,SWDNBC, &
  302. LWUPB,LWUPBC,LWDNB,LWDNBC
  303. REAL, DIMENSION( ims:ime, jms:jme ), &
  304. INTENT(INOUT) :: swcf, &
  305. lwcf, &
  306. olr, &
  307. coszr
  308. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ) , &
  309. INTENT(OUT ) :: cemiss, & ! cloud emissivity for isccp
  310. taucldc, & ! cloud water optical depth for isccp
  311. taucldi ! cloud ice optical depth for isccp
  312. !
  313. !
  314. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
  315. INTENT(IN ) :: &
  316. F_ICE_PHY, &
  317. F_RAIN_PHY
  318. ! LOCAL VARIABLES
  319. INTEGER :: lchnk, ncol, pcols, pver, pverp, pverr, pverrp
  320. INTEGER :: pcnst, pnats, ppcnst, i, j, k, ii, kk, kk1, m, n
  321. integer :: begchunk, endchunk
  322. integer :: nyrm, nyrp
  323. real(r8) doymodel, doydatam, doydatap, deltat, fact1, fact2
  324. REAL :: XT24, TLOCTM, HRANG, XXLAT, oldXT24
  325. real(r8), DIMENSION( 1:ite-its+1 ) :: coszrs, landfrac, landm, snowh, icefrac, lwups
  326. real(r8), DIMENSION( 1:ite-its+1 ) :: asdir, asdif, aldir, aldif, ps
  327. real(r8), DIMENSION( 1:ite-its+1, 1:kte-kts+1 ) :: cld, pmid, lnpmid, pdel, zm, t
  328. real(r8), DIMENSION( 1:ite-its+1, 1:kte-kts+2 ) :: pint, lnpint
  329. real(r8), DIMENSION( 1:ite-its+1, 1:kte-kts+1, n_cldadv) :: q
  330. ! real(r8), DIMENSION( 1:kte-kts+1 ) :: hypm ! reference pressures at midpoints
  331. ! real(r8), DIMENSION( 1:kte-kts+2 ) :: hypi ! reference pressures at interfaces
  332. real(r8), dimension( 1:ite-its+1, 1:kte-kts+1 ) :: cicewp ! in-cloud cloud ice water path
  333. real(r8), dimension( 1:ite-its+1, 1:kte-kts+1 ) :: cliqwp ! in-cloud cloud liquid water path
  334. real(r8), dimension( 1:ite-its+1, 0:kte-kts+1 ) :: tauxcl ! cloud water optical depth
  335. real(r8), dimension( 1:ite-its+1, 0:kte-kts+1 ) :: tauxci ! cloud ice optical depth
  336. real(r8), dimension( 1:ite-its+1, 1:kte-kts+1 ) :: emis ! cloud emissivity
  337. real(r8), dimension( 1:ite-its+1, 1:kte-kts+1 ) :: rel ! effective drop radius (microns)
  338. real(r8), dimension( 1:ite-its+1, 1:kte-kts+1 ) :: rei ! ice effective drop size (microns)
  339. real(r8), dimension( 1:ite-its+1, 1:kte-kts+2 ) :: pmxrgn ! Maximum values of pressure for each
  340. integer , dimension( 1:ite-its+1 ) :: nmxrgn ! Number of maximally overlapped regions
  341. real(r8), dimension( 1:ite-its+1 ) :: fsns ! Surface absorbed solar flux
  342. real(r8), dimension( 1:ite-its+1 ) :: fsnt ! Net column abs solar flux at model top
  343. real(r8), dimension( 1:ite-its+1 ) :: flns ! Srf longwave cooling (up-down) flux
  344. real(r8), dimension( 1:ite-its+1 ) :: flnt ! Net outgoing lw flux at model top
  345. ! Added outputs of total and clearsky fluxes etc
  346. real(r8), dimension( 1:ite-its+1, 1:kte-kts+2 ) :: fsup ! Upward total sky solar
  347. real(r8), dimension( 1:ite-its+1, 1:kte-kts+2 ) :: fsupc ! Upward clear sky solar
  348. real(r8), dimension( 1:ite-its+1, 1:kte-kts+2 ) :: fsdn ! Downward total sky solar
  349. real(r8), dimension( 1:ite-its+1, 1:kte-kts+2 ) :: fsdnc ! Downward clear sky solar
  350. real(r8), dimension( 1:ite-its+1, 1:kte-kts+2 ) :: flup ! Upward total sky longwave
  351. real(r8), dimension( 1:ite-its+1, 1:kte-kts+2 ) :: flupc ! Upward clear sky longwave
  352. real(r8), dimension( 1:ite-its+1, 1:kte-kts+2 ) :: fldn ! Downward total sky longwave
  353. real(r8), dimension( 1:ite-its+1, 1:kte-kts+2 ) :: fldnc ! Downward clear sky longwave
  354. real(r8), dimension( 1:ite-its+1 ) :: swcftoa ! Top of the atmosphere solar cloud forcing
  355. real(r8), dimension( 1:ite-its+1 ) :: lwcftoa ! Top of the atmosphere longwave cloud forcing
  356. real(r8), dimension( 1:ite-its+1 ) :: olrtoa ! Top of the atmosphere outgoing longwave
  357. !
  358. real(r8), dimension( 1:ite-its+1 ) :: sols ! Downward solar rad onto surface (sw direct)
  359. real(r8), dimension( 1:ite-its+1 ) :: soll ! Downward solar rad onto surface (lw direct)
  360. real(r8), dimension( 1:ite-its+1 ) :: solsd ! Downward solar rad onto surface (sw diffuse)
  361. real(r8), dimension( 1:ite-its+1 ) :: solld ! Downward solar rad onto surface (lw diffuse)
  362. real(r8), dimension( 1:ite-its+1, 1:kte-kts+1 ) :: qrs ! Solar heating rate
  363. real(r8), dimension( 1:ite-its+1 ) :: fsds ! Flux Shortwave Downwelling Surface
  364. real(r8), dimension( 1:ite-its+1, 1:kte-kts+1 ) :: qrl ! Longwave cooling rate
  365. real(r8), dimension( 1:ite-its+1 ) :: flwds ! Surface down longwave flux
  366. real(r8), dimension( 1:ite-its+1, levsiz, num_months ) :: ozmixmj ! monthly ozone mixing ratio
  367. real(r8), dimension( 1:ite-its+1, levsiz ) :: ozmix ! ozone mixing ratio (time interpolated)
  368. real(r8), dimension(levsiz) :: pin ! ozone pressure level
  369. real(r8), dimension(1:ite-its+1) :: m_psjp,m_psjn ! MATCH surface pressure
  370. real(r8), dimension( 1:ite-its+1, paerlev, naer_c ) :: aerosoljp ! monthly aerosol concentrations
  371. real(r8), dimension( 1:ite-its+1, paerlev, naer_c ) :: aerosoljn ! monthly aerosol concentrations
  372. real(r8), dimension(paerlev) :: m_hybi
  373. real(r8), dimension(1:ite-its+1 ) :: clat ! latitude in radians for columns
  374. real(r8), dimension(its:ite,kts:kte+1,kts:kte+1) :: abstot ! Total absorptivity
  375. real(r8), dimension(its:ite,kts:kte,4) :: absnxt ! Total nearest layer absorptivity
  376. real(r8), dimension(its:ite,kts:kte+1) :: emstot ! Total emissivity
  377. CHARACTER(LEN=256) :: msgstr
  378. #if !defined(MAC_KLUDGE)
  379. lchnk = 1
  380. begchunk = ims
  381. endchunk = ime
  382. ncol = ite - its + 1
  383. pcols= ite - its + 1
  384. pver = kte - kts + 1
  385. pverp= pver + 1
  386. pverr = kte - kts + 1
  387. pverrp= pverr + 1
  388. ! number of advected constituents and non-advected constituents (including water vapor)
  389. ppcnst = n_cldadv
  390. ! number of non-advected constituents
  391. pnats = 0
  392. pcnst = ppcnst-pnats
  393. ! check the # species defined for the input climatology and naer
  394. ! if(naer_c.ne.naer) then
  395. ! WRITE( wrf_err_message , * ) 'naer_c ne naer ', naer_c, naer
  396. if(naer_c.ne.naer_all) then
  397. WRITE( wrf_err_message , * ) 'naer_c-1 ne naer_all ', naer_c, naer_all
  398. CALL wrf_error_fatal ( wrf_err_message )
  399. endif
  400. ! update CO2 volume mixing ratio (co2vmr)
  401. ! determine time interpolation factors, check sanity
  402. ! of interpolation factors to within 32-bit roundoff
  403. ! assume that day of year is 1 for all input data
  404. !
  405. nyrm = yr - yrdata(1) + 1
  406. nyrp = nyrm + 1
  407. doymodel = yr*365. + julian
  408. doydatam = yrdata(nyrm)*365. + 1.
  409. doydatap = yrdata(nyrp)*365. + 1.
  410. deltat = doydatap - doydatam
  411. fact1 = (doydatap - doymodel)/deltat
  412. fact2 = (doymodel - doydatam)/deltat
  413. co2vmr = (co2(nyrm)*fact1 + co2(nyrp)*fact2)*1.e-06
  414. co2mmr=co2vmr*mwco2/mwdry
  415. !
  416. !===================================================
  417. ! Radiation computations
  418. !===================================================
  419. do k=1,levsiz
  420. pin(k)=pin0(k)
  421. enddo
  422. do k=1,paerlev
  423. m_hybi(k)=m_hybi0(k)
  424. enddo
  425. ! check for uninitialized arrays
  426. if(abstot_3d(its,kts,kts,jts) .eq. 0.0 .and. .not.doabsems .and. dolw)then
  427. CALL wrf_debug(0, 'camrad lw: CAUTION: re-calculating abstot, absnxt, emstot on restart')
  428. doabsems = .true.
  429. endif
  430. do j =jts,jte
  431. !
  432. ! Cosine solar zenith angle for current time step
  433. !
  434. ! call zenith (calday, clat, clon, coszrs, ncol)
  435. do i = its,ite
  436. ii = i - its + 1
  437. ! XT24 is the fractional part of simulation days plus half of RADT expressed in
  438. ! units of minutes
  439. ! JULIAN is in days
  440. ! RADT is in minutes
  441. XT24=MOD(XTIME+RADT*0.5,1440.)
  442. TLOCTM=GMT+XT24/60.+XLONG(I,J)/15.
  443. HRANG=15.*(TLOCTM-12.)*DEGRAD
  444. XXLAT=XLAT(I,J)*DEGRAD
  445. clat(ii)=xxlat
  446. coszrs(II)=SIN(XXLAT)*SIN(DECLIN)+COS(XXLAT)*COS(DECLIN)*COS(HRANG)
  447. enddo
  448. ! moist variables
  449. do k = kts,kte
  450. kk = kte - k + kts
  451. do i = its,ite
  452. ii = i - its + 1
  453. ! convert to specific humidity
  454. q(ii,kk,1) = max(1.e-10,qv3d(i,k,j)/(1.+qv3d(i,k,j)))
  455. IF ( F_QI .and. F_QC .and. F_QS ) THEN
  456. q(ii,kk,ixcldliq) = max(0.,qc3d(i,k,j)/(1.+qv3d(i,k,j)))
  457. q(ii,kk,ixcldice) = max(0.,(qi3d(i,k,j)+qs3d(i,k,j))/(1.+qv3d(i,k,j)))
  458. ELSE IF ( F_QC .and. F_QR ) THEN
  459. ! Warm rain or simple ice
  460. q(ii,kk,ixcldliq) = 0.
  461. q(ii,kk,ixcldice) = 0.
  462. if(t_phy(i,k,j).gt.273.15)q(ii,kk,ixcldliq) = max(0.,qc3d(i,k,j)/(1.+qv3d(i,k,j)))
  463. if(t_phy(i,k,j).le.273.15)q(ii,kk,ixcldice) = max(0.,qc3d(i,k,j)/(1.+qv3d(i,k,j)))
  464. ELSE IF ( F_QC .and. F_QS ) THEN
  465. ! For Ferrier (note that currently Ferrier has QI, so this section will not be used)
  466. q(ii,kk,ixcldice) = max(0.,qc3d(i,k,j)/(1.+qv3d(i,k,j))*f_ice_phy(i,k,j))
  467. q(ii,kk,ixcldliq) = max(0.,qc3d(i,k,j)/(1.+qv3d(i,k,j))*(1.-f_ice_phy(i,k,j))*(1.-f_rain_phy(i,k,j)))
  468. ELSE
  469. q(ii,kk,ixcldliq) = 0.
  470. q(ii,kk,ixcldice) = 0.
  471. ENDIF
  472. cld(ii,kk) = CLDFRA(I,K,J)
  473. enddo
  474. enddo
  475. do i = its,ite
  476. ii = i - its + 1
  477. landfrac(ii) = 2.-XLAND(I,J)
  478. landm(ii) = landfrac(ii)
  479. snowh(ii) = 0.001*SNOW(I,J)
  480. icefrac(ii) = XICE(I,J)
  481. enddo
  482. do m=1,num_months-1
  483. do k=1,levsiz
  484. do i = its,ite
  485. ii = i - its + 1
  486. ozmixmj(ii,k,m) = ozmixm(i,k,j,m+1)
  487. enddo
  488. enddo
  489. enddo
  490. do i = its,ite
  491. ii = i - its + 1
  492. m_psjp(ii) = m_psp(i,j)
  493. m_psjn(ii) = m_psn(i,j)
  494. enddo
  495. do n=1,naer_c
  496. do k=1,paerlev
  497. do i = its,ite
  498. ii = i - its + 1
  499. aerosoljp(ii,k,n) = aerosolcp(i,k,j,n)
  500. aerosoljn(ii,k,n) = aerosolcn(i,k,j,n)
  501. enddo
  502. enddo
  503. enddo
  504. !
  505. ! Complete radiation calculations
  506. !
  507. do i = its,ite
  508. ii = i - its + 1
  509. lwups(ii) = stebol*EMISS(I,J)*TSK(I,J)**4
  510. enddo
  511. do k = kts,kte+1
  512. kk = kte - k + kts + 1
  513. do i = its,ite
  514. ii = i - its + 1
  515. pint(ii,kk) = p8w(i,k,j)
  516. if(k.eq.kts)ps(ii)=pint(ii,kk)
  517. lnpint(ii,kk) = log(pint(ii,kk))
  518. enddo
  519. enddo
  520. if(.not.doabsems .and. dolw)then
  521. ! do kk = kts,kte+1
  522. do kk = 1,cam_abs_dim2
  523. do kk1 = kts,kte+1
  524. do i = its,ite
  525. abstot(i,kk1,kk) = abstot_3d(i,kk1,kk,j)
  526. enddo
  527. enddo
  528. enddo
  529. ! do kk = 1,4
  530. do kk = 1,cam_abs_dim1
  531. do kk1 = kts,kte
  532. do i = its,ite
  533. absnxt(i,kk1,kk) = absnxt_3d(i,kk1,kk,j)
  534. enddo
  535. enddo
  536. enddo
  537. do kk = kts,kte+1
  538. do i = its,ite
  539. emstot(i,kk) = emstot_3d(i,kk,j)
  540. enddo
  541. enddo
  542. endif
  543. do k = kts,kte
  544. kk = kte - k + kts
  545. do i = its,ite
  546. ii = i - its + 1
  547. pmid(ii,kk) = p_phy(i,k,j)
  548. lnpmid(ii,kk) = log(pmid(ii,kk))
  549. lnpint(ii,kk) = log(pint(ii,kk))
  550. pdel(ii,kk) = pint(ii,kk+1) - pint(ii,kk)
  551. t(ii,kk) = t_phy(i,k,j)
  552. zm(ii,kk) = z(i,k,j)
  553. enddo
  554. enddo
  555. ! Compute cloud water/ice paths and optical properties for input to radiation
  556. call param_cldoptics_calc(ncol, pcols, pver, pverp, pverr, pverrp, ppcnst, q, cld, landfrac, landm,icefrac, &
  557. pdel, t, ps, pmid, pint, cicewp, cliqwp, emis, rel, rei, pmxrgn, nmxrgn, snowh)
  558. !-----fds (06/2010)----------------------------
  559. SELECT CASE(sf_surface_physics)
  560. CASE (SSIBSCHEME)
  561. if (xtime .gt. 1.0) then
  562. ! call wrf_message("using SSiB albedoes for land points")
  563. do i = its,ite
  564. ii = i - its + 1
  565. if (xland(i,j).lt.1.5) then !land points only
  566. asdir(ii) = ALSWVISDIR(i,j) ! SSiB visdir albedo
  567. asdif(ii) = ALSWVISDIF(i,j) ! SSiB visdif albedo
  568. aldir(ii) = ALSWNIRDIR(i,j) ! SSiB nirdir albedo
  569. aldif(ii) = ALSWNIRDIF(i,j) ! SSiB nirdif albedo
  570. else
  571. asdir(ii) = albedo(i,j)
  572. asdif(ii) = albedo(i,j)
  573. aldir(ii) = albedo(i,j)
  574. aldif(ii) = albedo(i,j)
  575. endif
  576. enddo
  577. else
  578. do i = its,ite
  579. ii = i - its + 1
  580. asdir(ii) = albedo(i,j)
  581. asdif(ii) = albedo(i,j)
  582. aldir(ii) = albedo(i,j)
  583. aldif(ii) = albedo(i,j)
  584. enddo
  585. endif
  586. CASE DEFAULT
  587. do i = its,ite
  588. ii = i - its + 1
  589. ! use same albedo for direct and diffuse
  590. ! change this when separate values are provided
  591. asdir(ii) = albedo(i,j)
  592. asdif(ii) = albedo(i,j)
  593. aldir(ii) = albedo(i,j)
  594. aldif(ii) = albedo(i,j)
  595. enddo
  596. END SELECT
  597. !-----------------------------------------------
  598. ! WRF allocate space here (not needed if oznini is called)
  599. ! allocate (ozmix(pcols,levsiz,begchunk:endchunk)) ! This line from oznini.F90
  600. call radctl (j,lchnk, ncol, pcols, pver, pverp, pverr, pverrp, ppcnst, pcnst, lwups, emis, pmid, &
  601. pint, lnpmid, lnpint, pdel, t, q, &
  602. cld, cicewp, cliqwp, tauxcl, tauxci, coszrs, clat, asdir, asdif, &
  603. aldir, aldif, solcon, GMT,JULDAY,JULIAN,DT,XTIME, &
  604. pin, ozmixmj, ozmix, levsiz, num_months, &
  605. m_psjp,m_psjn, aerosoljp, aerosoljn, m_hybi, paerlev, naer_c, pmxrgn, nmxrgn, &
  606. dolw, dosw, doabsems, abstot, absnxt, emstot, &
  607. fsup, fsupc, fsdn, fsdnc, flup, flupc, fldn, fldnc, swcftoa, lwcftoa, olrtoa, &
  608. fsns, fsnt ,flns ,flnt , &
  609. qrs, qrl, flwds, rel, rei, &
  610. sols, soll, solsd, solld, &
  611. landfrac, zm, fsds)
  612. do k = kts,kte
  613. kk = kte - k + kts
  614. do i = its,ite
  615. ii = i - its + 1
  616. if(dolw)RTHRATENLW(I,K,J) = 1.e4*qrl(ii,kk)/(cpair*pi_phy(i,k,j))
  617. if(dosw)RTHRATENSW(I,K,J) = 1.e4*qrs(ii,kk)/(cpair*pi_phy(i,k,j))
  618. cemiss(i,k,j) = emis(ii,kk)
  619. taucldc(i,k,j) = tauxcl(ii,kk)
  620. taucldi(i,k,j) = tauxci(ii,kk)
  621. enddo
  622. enddo
  623. if(doabsems .and. dolw)then
  624. ! do kk = kts,kte+1
  625. do kk = 1,cam_abs_dim2
  626. do kk1 = kts,kte+1
  627. do i = its,ite
  628. abstot_3d(i,kk1,kk,j) = abstot(i,kk1,kk)
  629. enddo
  630. enddo
  631. enddo
  632. ! do kk = 1,4
  633. do kk = 1,cam_abs_dim1
  634. do kk1 = kts,kte
  635. do i = its,ite
  636. absnxt_3d(i,kk1,kk,j) = absnxt(i,kk1,kk)
  637. enddo
  638. enddo
  639. enddo
  640. do kk = kts,kte+1
  641. do i = its,ite
  642. emstot_3d(i,kk,j) = emstot(i,kk)
  643. enddo
  644. enddo
  645. endif
  646. IF(PRESENT(SWUPT))THEN
  647. if(dosw)then
  648. ! Added shortwave and longwave upward/downward total and clear sky fluxes
  649. do k = kts,kte+1
  650. kk = kte +1 - k + kts
  651. do i = its,ite
  652. ii = i - its + 1
  653. ! swup(i,k,j) = fsup(ii,kk)
  654. ! swupclear(i,k,j) = fsupc(ii,kk)
  655. ! swdn(i,k,j) = fsdn(ii,kk)
  656. ! swdnclear(i,k,j) = fsdnc(ii,kk)
  657. if(k.eq.kte+1)then
  658. swupt(i,j) = fsup(ii,kk)
  659. swuptc(i,j) = fsupc(ii,kk)
  660. swdnt(i,j) = fsdn(ii,kk)
  661. swdntc(i,j) = fsdnc(ii,kk)
  662. endif
  663. if(k.eq.kts)then
  664. swupb(i,j) = fsup(ii,kk)
  665. swupbc(i,j) = fsupc(ii,kk)
  666. swdnb(i,j) = fsdn(ii,kk)
  667. swdnbc(i,j) = fsdnc(ii,kk)
  668. endif
  669. ! if(i.eq.30.and.j.eq.30) then
  670. ! print 1234, 'short ', i,ii,k,kk,fsup(ii,kk),fsupc(ii,kk),fsdn(ii,kk),fsdnc(ii,kk)
  671. ! 1234 format (a6,4i4,4f10.3)
  672. ! endif
  673. enddo
  674. enddo
  675. endif
  676. if(dolw)then
  677. ! Added shortwave and longwave upward/downward total and clear sky fluxes
  678. do k = kts,kte+1
  679. kk = kte +1 - k + kts
  680. do i = its,ite
  681. ii = i - its + 1
  682. ! lwup(i,k,j) = flup(ii,kk)
  683. ! lwupclear(i,k,j) = flupc(ii,kk)
  684. ! lwdn(i,k,j) = fldn(ii,kk)
  685. ! lwdnclear(i,k,j) = fldnc(ii,kk)
  686. if(k.eq.kte+1)then
  687. lwupt(i,j) = flup(ii,kk)
  688. lwuptc(i,j) = flupc(ii,kk)
  689. lwdnt(i,j) = fldn(ii,kk)
  690. lwdntc(i,j) = fldnc(ii,kk)
  691. endif
  692. if(k.eq.kts)then
  693. lwupb(i,j) = flup(ii,kk)
  694. lwupbc(i,j) = flupc(ii,kk)
  695. lwdnb(i,j) = fldn(ii,kk)
  696. lwdnbc(i,j) = fldnc(ii,kk)
  697. endif
  698. ! if(i.eq.30.and.j.eq.30) then
  699. ! print 1234, 'long ', i,ii,k,kk,flup(ii,kk),flupc(ii,kk),fldn(ii,kk),fldnc(ii,kk)
  700. ! 1234 format (a6,4i4,4f10.3)
  701. ! endif
  702. enddo
  703. enddo
  704. endif
  705. ENDIF
  706. do i = its,ite
  707. ii = i - its + 1
  708. ! Added shortwave and longwave cloud forcing at TOA and surface
  709. if(dolw)then
  710. GLW(I,J) = flwds(ii)
  711. lwcf(i,j) = lwcftoa(ii)
  712. olr(i,j) = olrtoa(ii)
  713. endif
  714. if(dosw)then
  715. GSW(I,J) = fsns(ii)
  716. swcf(i,j) = swcftoa(ii)
  717. coszr(i,j) = coszrs(ii)
  718. endif
  719. enddo
  720. !-------fds (06/2010)---------
  721. SELECT CASE(sf_surface_physics)
  722. CASE (SSIBSCHEME)
  723. ! call wrf_message("CAM using ssib albedo2")
  724. if(dosw)then
  725. do i = its,ite
  726. ii = i - its + 1
  727. SWVISDIR(I,J) = sols(ii) !SSiB
  728. SWVISDIF(I,J) = solsd(ii) !SSiB
  729. SWNIRDIR(I,J) = soll(ii) !SSiB
  730. SWNIRDIF(I,J) = solld(ii) !SSiB
  731. enddo
  732. endif
  733. END SELECT
  734. !-----------------------------
  735. enddo ! j-loop
  736. #endif
  737. end subroutine camrad
  738. !====================================================================
  739. SUBROUTINE camradinit( &
  740. R_D,R_V,CP,G,STBOLT,EP_2,shalf,pptop, &
  741. ozmixm,pin,levsiz,XLAT,num_months, &
  742. m_psp,m_psn,m_hybi,aerosolcp,aerosolcn, &
  743. paerlev,naer_c, &
  744. ids, ide, jds, jde, kds, kde, &
  745. ims, ime, jms, jme, kms, kme, &
  746. its, ite, jts, jte, kts, kte )
  747. USE module_wrf_error
  748. USE module_state_description
  749. !USE module_configure
  750. !--------------------------------------------------------------------
  751. IMPLICIT NONE
  752. !--------------------------------------------------------------------
  753. INTEGER , INTENT(IN) :: ids, ide, jds, jde, kds, kde, &
  754. ims, ime, jms, jme, kms, kme, &
  755. its, ite, jts, jte, kts, kte
  756. REAL, intent(in) :: pptop
  757. REAL, INTENT(IN) :: R_D,R_V,CP,G,STBOLT,EP_2
  758. REAL, DIMENSION( kms:kme ) :: shalf
  759. INTEGER, INTENT(IN ) :: levsiz, num_months
  760. INTEGER, INTENT(IN ) :: paerlev, naer_c
  761. REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN ) :: XLAT
  762. REAL, DIMENSION( ims:ime, levsiz, jms:jme, num_months ), &
  763. INTENT(INOUT ) :: OZMIXM
  764. REAL, DIMENSION(levsiz), INTENT(INOUT ) :: PIN
  765. REAL, DIMENSION(ims:ime, jms:jme), INTENT(INOUT ) :: m_psp,m_psn
  766. REAL, DIMENSION(paerlev), INTENT(INOUT ) :: m_hybi
  767. REAL, DIMENSION( ims:ime, paerlev, jms:jme, naer_c ), &
  768. INTENT(INOUT) :: aerosolcp,aerosolcn
  769. REAL(r8) :: pstd
  770. REAL(r8) :: rh2o, cpair
  771. ! These were made allocatable 20090612 to save static memory allocation. JM
  772. IF ( .NOT. ALLOCATED( ksul ) ) ALLOCATE( ksul( nrh, nspint ) )
  773. IF ( .NOT. ALLOCATED( wsul ) ) ALLOCATE( wsul( nrh, nspint ) )
  774. IF ( .NOT. ALLOCATED( gsul ) ) ALLOCATE( gsul( nrh, nspint ) )
  775. IF ( .NOT. ALLOCATED( ksslt ) ) ALLOCATE( ksslt( nrh, nspint ) )
  776. IF ( .NOT. ALLOCATED( wsslt ) ) ALLOCATE( wsslt( nrh, nspint ) )
  777. IF ( .NOT. ALLOCATED( gsslt ) ) ALLOCATE( gsslt( nrh, nspint ) )
  778. IF ( .NOT. ALLOCATED( kcphil ) ) ALLOCATE( kcphil( nrh, nspint ) )
  779. IF ( .NOT. ALLOCATED( wcphil ) ) ALLOCATE( wcphil( nrh, nspint ) )
  780. IF ( .NOT. ALLOCATED( gcphil ) ) ALLOCATE( gcphil( nrh, nspint ) )
  781. IF ( .NOT. ALLOCATED(ah2onw ) ) ALLOCATE( ah2onw(n_p, n_tp, n_u, n_te, n_rh) )
  782. IF ( .NOT. ALLOCATED(eh2onw ) ) ALLOCATE( eh2onw(n_p, n_tp, n_u, n_te, n_rh) )
  783. IF ( .NOT. ALLOCATED(ah2ow ) ) ALLOCATE( ah2ow(n_p, n_tp, n_u, n_te, n_rh) )
  784. IF ( .NOT. ALLOCATED(cn_ah2ow) ) ALLOCATE( cn_ah2ow(n_p, n_tp, n_u, n_te, n_rh) )
  785. IF ( .NOT. ALLOCATED(cn_eh2ow) ) ALLOCATE( cn_eh2ow(n_p, n_tp, n_u, n_te, n_rh) )
  786. IF ( .NOT. ALLOCATED(ln_ah2ow) ) ALLOCATE( ln_ah2ow(n_p, n_tp, n_u, n_te, n_rh) )
  787. IF ( .NOT. ALLOCATED(ln_eh2ow) ) ALLOCATE( ln_eh2ow(n_p, n_tp, n_u, n_te, n_rh) )
  788. #if !defined(MAC_KLUDGE)
  789. ozncyc = .true.
  790. indirect = .true.
  791. ixcldliq = 2
  792. ixcldice = 3
  793. #if (NMM_CORE != 1)
  794. ! aerosol array is not in the NMM Registry
  795. ! since CAM radiation not available to NMM (yet)
  796. ! so this is blocked out to enable CAM compilation with NMM
  797. idxSUL = P_SUL
  798. idxSSLT = P_SSLT
  799. idxDUSTfirst = P_DUST1
  800. idxOCPHO = P_OCPHO
  801. idxCARBONfirst = P_OCPHO
  802. idxBCPHO = P_BCPHO
  803. idxOCPHI = P_OCPHI
  804. idxBCPHI = P_BCPHI
  805. idxBG = P_BG
  806. idxVOLC = P_VOLC
  807. #endif
  808. pstd = 101325.0
  809. ! from physconst module
  810. mwdry = 28.966 ! molecular weight dry air ~ kg/kmole (shr_const_mwdair)
  811. mwco2 = 44. ! molecular weight co2
  812. mwh2o = 18.016 ! molecular weight water vapor (shr_const_mwwv)
  813. mwch4 = 16. ! molecular weight ch4
  814. mwn2o = 44. ! molecular weight n2o
  815. mwf11 = 136. ! molecular weight cfc11
  816. mwf12 = 120. ! molecular weight cfc12
  817. cappa = R_D/CP
  818. rair = R_D
  819. tmelt = 273.16 ! freezing T of fresh water ~ K
  820. r_universal = 6.02214e26 * STBOLT ! Universal gas constant ~ J/K/kmole
  821. latvap = 2.501e6 ! latent heat of evaporation ~ J/kg
  822. latice = 3.336e5 ! latent heat of fusion ~ J/kg
  823. zvir = R_V/R_D - 1.
  824. rh2o = R_V
  825. cpair = CP
  826. !
  827. epsqs = EP_2
  828. CALL radini(G, CP, EP_2, STBOLT, pstd*10.0 )
  829. CALL esinti(epsqs ,latvap ,latice ,rh2o ,cpair ,tmelt )
  830. CALL oznini(ozmixm,pin,levsiz,num_months,XLAT, &
  831. ids, ide, jds, jde, kds, kde, &
  832. ims, ime, jms, jme, kms, kme, &
  833. its, ite, jts, jte, kts, kte)
  834. CALL aerosol_init(m_psp,m_psn,m_hybi,aerosolcp,aerosolcn,paerlev,naer_c,shalf,pptop, &
  835. ids, ide, jds, jde, kds, kde, &
  836. ims, ime, jms, jme, kms, kme, &
  837. its, ite, jts, jte, kts, kte)
  838. #endif
  839. END SUBROUTINE camradinit
  840. #if !defined(MAC_KLUDGE)
  841. subroutine oznint(julday,julian,dt,gmt,xtime,ozmixmj,ozmix,levsiz,num_months,pcols)
  842. IMPLICIT NONE
  843. INTEGER, INTENT(IN ) :: levsiz, num_months,pcols
  844. REAL(r8), DIMENSION( pcols, levsiz, num_months ), &
  845. INTENT(IN ) :: ozmixmj
  846. REAL, INTENT(IN ) :: XTIME,GMT
  847. INTEGER, INTENT(IN ) :: JULDAY
  848. REAL, INTENT(IN ) :: JULIAN
  849. REAL, INTENT(IN ) :: DT
  850. REAL(r8), DIMENSION( pcols, levsiz ), &
  851. INTENT(OUT ) :: ozmix
  852. !Local
  853. REAL(r8) :: intJULIAN
  854. integer :: np1,np,nm,m,k,i
  855. integer :: IJUL
  856. integer, dimension(12) :: date_oz
  857. data date_oz/16, 45, 75, 105, 136, 166, 197, 228, 258, 289, 319, 350/
  858. real(r8) :: cdayozp, cdayozm
  859. real(r8) :: fact1, fact2
  860. logical :: finddate
  861. CHARACTER(LEN=256) :: msgstr
  862. ! JULIAN starts from 0.0 at 0Z on 1 Jan.
  863. intJULIAN = JULIAN + 1.0_r8 ! offset by one day
  864. ! jan 1st 00z is julian=1.0 here
  865. IJUL=INT(intJULIAN)
  866. ! Note that following will drift.
  867. ! Need to use actual month/day info to compute julian.
  868. intJULIAN=intJULIAN-FLOAT(IJUL)
  869. IJUL=MOD(IJUL,365)
  870. IF(IJUL.EQ.0)IJUL=365
  871. intJULIAN=intJULIAN+IJUL
  872. np1=1
  873. finddate=.false.
  874. ! do m=1,num_months
  875. do m=1,12
  876. if(date_oz(m).gt.intjulian.and..not.finddate) then
  877. np1=m
  878. finddate=.true.
  879. endif
  880. enddo
  881. cdayozp=date_oz(np1)
  882. if(np1.gt.1) then
  883. cdayozm=date_oz(np1-1)
  884. np=np1
  885. nm=np-1
  886. else
  887. cdayozm=date_oz(12)
  888. np=np1
  889. nm=12
  890. endif
  891. call getfactors(ozncyc,np1, cdayozm, cdayozp,intjulian, &
  892. fact1, fact2)
  893. !
  894. ! Time interpolation.
  895. !
  896. do k=1,levsiz
  897. do i=1,pcols
  898. ozmix(i,k) = ozmixmj(i,k,nm)*fact1 + ozmixmj(i,k,np)*fact2
  899. end do
  900. end do
  901. END subroutine oznint
  902. subroutine get_aerosol(c, julday, julian, dt, gmt, xtime, m_psp, m_psn, aerosoljp, &
  903. aerosoljn, m_hybi, paerlev, naer_c, pint, pcols, pver, pverp, pverr, pverrp, AEROSOLt, scale)
  904. !------------------------------------------------------------------
  905. !
  906. ! Input:
  907. ! time at which aerosol mmrs are needed (get_curr_calday())
  908. ! chunk index
  909. ! CAM's vertical grid (pint)
  910. !
  911. ! Output:
  912. ! values for Aerosol Mass Mixing Ratios at specified time
  913. ! on vertical grid specified by CAM (AEROSOLt)
  914. !
  915. ! Method:
  916. ! first determine which indexs of aerosols are the bounding data sets
  917. ! interpolate both onto vertical grid aerm(),aerp().
  918. ! from those two, interpolate in time.
  919. !
  920. !------------------------------------------------------------------
  921. ! use volcanicmass, only: get_volcanic_mass
  922. ! use timeinterp, only: getfactors
  923. !
  924. ! aerosol fields interpolated to current time step
  925. ! on pressure levels of this time step.
  926. ! these should be made read-only for other modules
  927. ! Is allocation done correctly here?
  928. !
  929. integer, intent(in) :: c ! Chunk Id.
  930. integer, intent(in) :: paerlev, naer_c, pcols, pver, pverp, pverr, pverrp
  931. real(r8), intent(in) :: pint(pcols,pverp) ! midpoint pres.
  932. real(r8), intent(in) :: scale(naer_all) ! scale each aerosol by this amount
  933. REAL, INTENT(IN ) :: XTIME,GMT
  934. INTEGER, INTENT(IN ) :: JULDAY
  935. REAL, INTENT(IN ) :: JULIAN
  936. REAL, INTENT(IN ) :: DT
  937. real(r8), intent(in ) :: m_psp(pcols),m_psn(pcols) ! Match surface pressure
  938. real(r8), intent(in ) :: aerosoljp(pcols,paerlev,naer_c)
  939. real(r8), intent(in ) :: aerosoljn(pcols,paerlev,naer_c)
  940. real(r8), intent(in ) :: m_hybi(paerlev)
  941. real(r8), intent(out) :: AEROSOLt(pcols, pver, naer_all) ! aerosols
  942. !
  943. ! Local workspace
  944. !
  945. real(r8) caldayloc ! calendar day of current timestep
  946. real(r8) fact1, fact2 ! time interpolation factors
  947. integer :: nm = 1 ! index to prv month in array. init to 1 and toggle between 1 and 2
  948. integer :: np = 2 ! index to nxt month in array. init to 2 and toggle between 1 and 2
  949. integer :: mo_nxt = bigint ! index to nxt month in file
  950. integer :: mo_prv ! index to previous month
  951. real(r8) :: cdaym = inf ! calendar day of prv month
  952. real(r8) :: cdayp = inf ! calendar day of next month
  953. real(r8) :: Mid(12) ! Days into year for mid month date
  954. data Mid/16.5, 46.0, 75.5, 106.0, 136.5, 167.0, 197.5, 228.5, 259.0, 289.5, 320.0, 350.5 /
  955. integer i, k, j ! spatial indices
  956. integer m ! constituent index
  957. integer lats(pcols),lons(pcols) ! latitude and longitudes of column
  958. integer ncol ! number of columns
  959. INTEGER IJUL
  960. REAL(r8) intJULIAN
  961. real(r8) speciesmin(naer) ! minimal value for each species
  962. !
  963. ! values before current time step "the minus month"
  964. ! aerosolm(pcols,pver) is value of preceeding month's aerosol mmr
  965. ! aerosolp(pcols,pver) is value of next month's aerosol mmr
  966. ! (think minus and plus or values to left and right of point to be interpolated)
  967. !
  968. real(r8) AEROSOLm(pcols,pver,naer) ! aerosol mmr from MATCH in column at previous (minus) month
  969. !
  970. ! values beyond (or at) current time step "the plus month"
  971. !
  972. real(r8) AEROSOLp(pcols,pver,naer) ! aerosol mmr from MATCH in column at next (plus) month
  973. CHARACTER(LEN=256) :: msgstr
  974. ! JULIAN starts from 0.0 at 0Z on 1 Jan.
  975. intJULIAN = JULIAN + 1.0_r8 ! offset by one day
  976. ! jan 1st 00z is julian=1.0 here
  977. IJUL=INT(intJULIAN)
  978. ! Note that following will drift.
  979. ! Need to use actual month/day info to compute julian.
  980. intJULIAN=intJULIAN-FLOAT(IJUL)
  981. IJUL=MOD(IJUL,365)
  982. IF(IJUL.EQ.0)IJUL=365
  983. caldayloc=intJULIAN+IJUL
  984. if (caldayloc < Mid(1)) then
  985. mo_prv = 12
  986. mo_nxt = 1
  987. else if (caldayloc >= Mid(12)) then
  988. mo_prv = 12
  989. mo_nxt = 1
  990. else
  991. do i = 2 , 12
  992. if (caldayloc < Mid(i)) then
  993. mo_prv = i-1
  994. mo_nxt = i
  995. exit
  996. end if
  997. end do
  998. end if
  999. !
  1000. ! Set initial calendar day values
  1001. !
  1002. cdaym = Mid(mo_prv)
  1003. cdayp = Mid(mo_nxt)
  1004. !
  1005. ! Determine time interpolation factors. 1st arg says we are cycling 1 year of data
  1006. !
  1007. call getfactors (.true., mo_nxt, cdaym, cdayp, caldayloc, &
  1008. fact1, fact2)
  1009. !
  1010. ! interpolate (prv and nxt month) bounding datasets onto cam vertical grid.
  1011. ! compute mass mixing ratios on CAMS's pressure coordinate
  1012. ! for both the "minus" and "plus" months
  1013. !
  1014. ! ncol = get_ncols_p(c)
  1015. ncol = pcols
  1016. ! call vert_interpolate (M_ps_cam_col(1,c,nm), pint, nm, AEROSOLm, ncol, c)
  1017. ! call vert_interpolate (M_ps_cam_col(1,c,np), pint, np, AEROSOLp, ncol, c)
  1018. call vert_interpolate (m_psp, aerosoljp, m_hybi, paerlev, naer_c, pint, nm, AEROSOLm, pcols, pver, pverp, ncol, c)
  1019. call vert_interpolate (m_psn, aerosoljn, m_hybi, paerlev, naer_c, pint, np, AEROSOLp, pcols, pver, pverp, ncol, c)
  1020. !
  1021. ! Time interpolate.
  1022. !
  1023. do m=1,naer
  1024. do k=1,pver
  1025. do i=1,ncol
  1026. AEROSOLt(i,k,m) = AEROSOLm(i,k,m)*fact1 + AEROSOLp(i,k,m)*fact2
  1027. end do
  1028. end do
  1029. end do
  1030. ! do i=1,ncol
  1031. ! Match_ps_chunk(i,c) = m_ps(i,nm)*fact1 + m_ps(i,np)*fact2
  1032. ! end do
  1033. !
  1034. ! get background aerosol (tuning) field
  1035. !
  1036. call background (c, ncol, pint, pcols, pverr, pverrp, AEROSOLt(:, :, idxBG))
  1037. !
  1038. ! find volcanic aerosol masses
  1039. !
  1040. ! if (strat_volcanic) then
  1041. ! call get_volcanic_mass(c, AEROSOLt(:,:,idxVOLC))
  1042. ! else
  1043. AEROSOLt(:,:,idxVOLC) = 0._r8
  1044. ! endif
  1045. !
  1046. ! exit if mmr is negative (we have previously set
  1047. ! cumulative mass to be a decreasing function.)
  1048. !
  1049. speciesmin(:) = 0. ! speciesmin(m) = 0 is minimum mmr for each species
  1050. do m=1,naer
  1051. do k=1,pver
  1052. do i=1,ncol
  1053. if (AEROSOLt(i, k, m) < speciesmin(m)) then
  1054. write(6,*) 'AEROSOL_INTERPOLATE: negative mass mixing ratio, exiting'
  1055. write(6,*) 'm, column, pver',m, i, k ,AEROSOLt(i, k, m)
  1056. call endrun ()
  1057. end if
  1058. end do
  1059. end do
  1060. end do
  1061. !
  1062. ! scale any AEROSOLS as required
  1063. !
  1064. call scale_aerosols (AEROSOLt, pcols, pver, ncol, c, scale)
  1065. return
  1066. end subroutine get_aerosol
  1067. subroutine aerosol_indirect(ncol,lchnk,pcols,pver,ppcnst,landfrac,pmid,t,qm1,cld,zm,rel)
  1068. !--------------------------------------------------------------
  1069. ! Compute effect of sulfate on effective liquid water radius
  1070. ! Method of Martin et. al.
  1071. !--------------------------------------------------------------
  1072. ! use constituents, only: ppcnst, cnst_get_ind
  1073. ! use history, only: outfld
  1074. !#include <comctl.h>
  1075. integer, intent(in) :: ncol ! number of atmospheric columns
  1076. integer, intent(in) :: lchnk ! chunk identifier
  1077. integer, intent(in) :: pcols,pver,ppcnst
  1078. real(r8), intent(in) :: landfrac(pcols) ! land fraction
  1079. real(r8), intent(in) :: pmid(pcols,pver) ! Model level pressures
  1080. real(r8), intent(in) :: t(pcols,pver) ! Model level temperatures
  1081. real(r8), intent(in) :: qm1(pcols,pver,ppcnst) ! Specific humidity and tracers
  1082. real(r8), intent(in) :: cld(pcols,pver) ! Fractional cloud cover
  1083. real(r8), intent(in) :: zm(pcols,pver) ! Height of midpoints (above surface)
  1084. real(r8), intent(in) :: rel(pcols,pver) ! liquid effective drop size (microns)
  1085. !
  1086. ! local variables
  1087. !
  1088. real(r8) locrhoair(pcols,pver) ! dry air density [kg/m^3 ]
  1089. real(r8) lwcwat(pcols,pver) ! in-cloud liquid water path [kg/m^3 ]
  1090. real(r8) sulfmix(pcols,pver) ! sulfate mass mixing ratio [kg/kg ]
  1091. real(r8) so4mass(pcols,pver) ! sulfate mass concentration [g/cm^3 ]
  1092. real(r8) Aso4(pcols,pver) ! sulfate # concentration [#/cm^3 ]
  1093. real(r8) Ntot(pcols,pver) ! ccn # concentration [#/cm^3 ]
  1094. real(r8) relmod(pcols,pver) ! effective radius [microns]
  1095. real(r8) wrel(pcols,pver) ! weighted effective radius [microns]
  1096. real(r8) wlwc(pcols,pver) ! weighted liq. water content [kg/m^3 ]
  1097. real(r8) cldfrq(pcols,pver) ! frequency of occurance of...
  1098. ! ! clouds (cld => 0.01) [fraction]
  1099. real(r8) locPi ! my piece of the pi
  1100. real(r8) Rdryair ! gas constant of dry air [J/deg/kg]
  1101. real(r8) rhowat ! density of water [kg/m^3 ]
  1102. real(r8) Acoef ! m->A conversion factor; assumes
  1103. ! ! Dbar=0.10, sigma=2.0 [g^-1 ]
  1104. real(r8) rekappa ! kappa in evaluation of re(lmod)
  1105. real(r8) recoef ! temp. coeficient for calc of re(lmod)
  1106. real(r8) reexp ! 1.0/3.0
  1107. real(r8) Ntotb ! temp var to hold below cloud ccn
  1108. ! -- Parameters for background CDNC (from `ambient' non-sulfate aerosols)...
  1109. real(r8) Cmarn ! Coef for CDNC_marine [cm^-3]
  1110. real(r8) Cland ! Coef for CDNC_land [cm^-3]
  1111. real(r8) Hmarn ! Scale height for CDNC_marine [m]
  1112. real(r8) Hland ! Scale height for CDNC_land [m]
  1113. parameter ( Cmarn = 50.0, Cland = 100.0 )
  1114. parameter ( Hmarn = 1000.0, Hland = 2000.0 )
  1115. real(r8) bgaer ! temp var to hold background CDNC
  1116. integer i,k ! loop indices
  1117. !
  1118. ! Statement functions
  1119. !
  1120. logical land ! is this a column over land?
  1121. land(i) = nint(landfrac(i)).gt.0.5_r8
  1122. if (indirect) then
  1123. ! call endrun ('AEROSOL_INDIRECT: indirect effect is obsolete')
  1124. ! ramping is not yet resolved so sulfmix is 0.
  1125. sulfmix(1:ncol,1:pver) = 0._r8
  1126. locPi = 3.141592654
  1127. Rdryair = 287.04
  1128. rhowat = 1000.0
  1129. Acoef = 1.2930E14
  1130. recoef = 3.0/(4.0*locPi*rhowat)
  1131. reexp = 1.0/3.0
  1132. ! call cnst_get_ind('CLDLIQ', ixcldliq)
  1133. do k=pver,1,-1
  1134. do i = 1,ncol
  1135. locrhoair(i,k) = pmid(i,k)/( Rdryair*t(i,k) )
  1136. lwcwat(i,k) = ( qm1(i,k,ixcldliq)/max(0.01_r8,cld(i,k)) )* &
  1137. locrhoair(i,k)
  1138. ! NOTE: 0.001 converts kg/m3 -> g/cm3
  1139. so4mass(i,k) = sulfmix(i,k)*locrhoair(i,k)*0.001
  1140. Aso4(i,k) = so4mass(i,k)*Acoef
  1141. if (Aso4(i,k) <= 280.0) then
  1142. Aso4(i,k) = max(36.0_r8,Aso4(i,k))
  1143. Ntot(i,k) = -1.15E-3*Aso4(i,k)**2 + 0.963*Aso4(i,k)+5.30
  1144. rekappa = 0.80
  1145. else
  1146. Aso4(i,k) = min(1500.0_r8,Aso4(i,k))
  1147. Ntot(i,k) = -2.10E-4*Aso4(i,k)**2 + 0.568*Aso4(i,k)-27.9
  1148. rekappa = 0.67
  1149. end if
  1150. if (land(i)) then ! Account for local background aerosol;
  1151. bgaer = Cland*exp(-(zm(i,k)/Hland))
  1152. Ntot(i,k) = max(bgaer,Ntot(i,k))
  1153. else
  1154. bgaer = Cmarn*exp(-(zm(i,k)/Hmarn))
  1155. Ntot(i,k) = max(bgaer,Ntot(i,k))
  1156. end if
  1157. if (k == pver) then
  1158. Ntotb = Ntot(i,k)
  1159. else
  1160. Ntotb = Ntot(i,k+1)
  1161. end if
  1162. relmod(i,k) = (( (recoef*lwcwat(i,k))/(rekappa*Ntotb))**reexp)*10000.0
  1163. relmod(i,k) = max(4.0_r8,relmod(i,k))
  1164. relmod(i,k) = min(20.0_r8,relmod(i,k))
  1165. if (cld(i,k) >= 0.01) then
  1166. cldfrq(i,k) = 1.0
  1167. else
  1168. cldfrq(i,k) = 0.0
  1169. end if
  1170. wrel(i,k) = relmod(i,k)*cldfrq(i,k)
  1171. wlwc(i,k) = lwcwat(i,k)*cldfrq(i,k)
  1172. end do
  1173. end do
  1174. ! call outfld('MSO4 ',so4mass,pcols,lchnk)
  1175. ! call outfld('LWC ',lwcwat ,pcols,lchnk)
  1176. ! call outfld('CLDFRQ ',cldfrq ,pcols,lchnk)
  1177. ! call outfld('WREL ',wrel ,pcols,lchnk)
  1178. ! call outfld('WLWC ',wlwc ,pcols,lchnk)
  1179. ! write(6,*)'WARNING: indirect calculation has no effects'
  1180. else
  1181. do k = 1, pver
  1182. do i = 1, ncol
  1183. relmod(i,k) = rel(i,k)
  1184. end do
  1185. end do
  1186. endif
  1187. ! call outfld('REL ',relmod ,pcols,lchnk)
  1188. return
  1189. end subroutine aerosol_indirect
  1190. subroutine aer_trn(aer_mpp, aer_trn_ttl, pcols, plev, plevp )
  1191. !
  1192. ! Purpose: Compute strat. aerosol transmissions needed in absorptivity/
  1193. ! emissivity calculations
  1194. ! aer_trn() is called by radclw() when doabsems is .true.
  1195. !
  1196. ! use shr_kind_mod, only: r8 => shr_kind_r8
  1197. ! use pmgrid
  1198. ! use ppgrid
  1199. ! use prescribed_aerosols, only: strat_volcanic
  1200. implicit none
  1201. ! Input arguments
  1202. !
  1203. ! [kg m-2] Volcanics path above kth interface level
  1204. !
  1205. integer, intent(in) :: pcols, plev, plevp
  1206. real(r8), intent(in) :: aer_mpp(pcols,plevp)
  1207. ! Output arguments
  1208. !
  1209. ! [fraction] Total volcanic transmission between interfaces k1 and k2
  1210. !
  1211. real(r8), intent(out) :: aer_trn_ttl(pcols,plevp,plevp,bnd_nbr_LW)
  1212. !-------------------------------------------------------------------------
  1213. ! Local variables
  1214. integer bnd_idx ! LW band index
  1215. integer i ! lon index
  1216. integer k1 ! lev index
  1217. integer k2 ! lev index
  1218. real(r8) aer_pth_dlt ! [kg m-2] Volcanics path between interface
  1219. ! levels k1 and k2
  1220. real(r8) odap_aer_ttl ! [fraction] Total path absorption optical
  1221. ! depth
  1222. !-------------------------------------------------------------------------
  1223. if (strat_volcanic) then
  1224. do bnd_idx=1,bnd_nbr_LW
  1225. do i=1,pcols
  1226. aer_trn_ttl(i,1,1,bnd_idx)=1.0
  1227. end do
  1228. do k1=2,plevp
  1229. do i=1,pcols
  1230. aer_trn_ttl(i,k1,k1,bnd_idx)=1.0
  1231. aer_pth_dlt = abs(aer_mpp(i,k1) - aer_mpp(i,1))
  1232. odap_aer_ttl = abs_cff_mss_aer(bnd_idx) * aer_pth_dlt
  1233. aer_trn_ttl(i,1,k1,bnd_idx) = exp(-1.66 * odap_aer_ttl)
  1234. end do
  1235. end do
  1236. do k1=2,plev
  1237. do k2=k1+1,plevp
  1238. do i=1,pcols
  1239. aer_trn_ttl(i,k1,k2,bnd_idx) = &
  1240. aer_trn_ttl(i,1,k2,bnd_idx) / &
  1241. aer_trn_ttl(i,1,k1,bnd_idx)
  1242. end do
  1243. end do
  1244. end do
  1245. do k1=2,plevp
  1246. do k2=1,k1-1
  1247. do i=1,pcols
  1248. aer_trn_ttl(i,k1,k2,bnd_idx)=aer_trn_ttl(i,k2,k1,bnd_idx)
  1249. end do
  1250. end do
  1251. end do
  1252. end do
  1253. else
  1254. aer_trn_ttl = 1.0
  1255. endif
  1256. return
  1257. end subroutine aer_trn
  1258. subroutine aer_pth(aer_mass, aer_mpp, ncol, pcols, plev, plevp)
  1259. !------------------------------------------------------
  1260. ! Purpose: convert mass per layer to cumulative mass from Top
  1261. !------------------------------------------------------
  1262. ! use shr_kind_mod, only: r8 => shr_kind_r8
  1263. ! use ppgrid
  1264. ! use pmgrid
  1265. implicit none
  1266. !#include <crdcon.h>
  1267. ! Parameters
  1268. ! Input
  1269. integer, intent(in) :: pcols, plev, plevp
  1270. real(r8), intent(in):: aer_mass(pcols,plev) ! Rad level aerosol mass mixing ratio
  1271. integer, intent(in):: ncol
  1272. !
  1273. ! Output
  1274. real(r8), intent(out):: aer_mpp(pcols,plevp) ! [kg m-2] Volcanics path above kth interface
  1275. !
  1276. ! Local
  1277. integer i ! Column index
  1278. integer k ! Level index
  1279. !------------------------------------------------------
  1280. !------------------------------------------------------
  1281. aer_mpp(1:ncol,1) = 0._r8
  1282. do k=2,plevp
  1283. aer_mpp(1:ncol,k) = aer_mpp(1:ncol,k-1) + aer_mass(1:ncol,k-1)
  1284. enddo
  1285. !
  1286. return
  1287. end subroutine aer_pth
  1288. subroutine radctl(j, lchnk ,ncol , pcols, pver, pverp, pverr, pverrp, ppcnst, pcnst, &
  1289. lwups ,emis , &
  1290. pmid ,pint ,pmln ,piln ,pdel ,t , &
  1291. ! qm1 ,cld ,cicewp ,cliqwp ,coszrs, clat, &
  1292. qm1 ,cld ,cicewp ,cliqwp ,tauxcl, tauxci, coszrs, clat, &
  1293. asdir ,asdif ,aldir ,aldif ,solcon, GMT,JULDAY,JULIAN,DT,XTIME, &
  1294. pin, ozmixmj, ozmix, levsiz, num_months, &
  1295. m_psp, m_psn, aerosoljp, aerosoljn, m_hybi, paerlev, naer_c, pmxrgn , &
  1296. nmxrgn , &
  1297. dolw, dosw, doabsems, abstot, absnxt, emstot, &
  1298. fsup ,fsupc ,fsdn ,fsdnc , &
  1299. flup ,flupc ,fldn ,fldnc , &
  1300. swcf ,lwcf ,flut , &
  1301. fsns ,fsnt ,flns ,flnt , &
  1302. qrs ,qrl ,flwds ,rel ,rei , &
  1303. sols ,soll ,solsd ,solld , &
  1304. landfrac,zm ,fsds )
  1305. !-----------------------------------------------------------------------
  1306. !
  1307. ! Purpose:
  1308. ! Driver for radiation computation.
  1309. !
  1310. ! Method:
  1311. ! Radiation uses cgs units, so conversions must be done from
  1312. ! model fields to radiation fields.
  1313. !
  1314. ! Author: CCM1, CMS Contact: J. Truesdale
  1315. !
  1316. !-----------------------------------------------------------------------
  1317. ! use shr_kind_mod, only: r8 => shr_kind_r8
  1318. ! use ppgrid
  1319. ! use pspect
  1320. ! use commap
  1321. ! use history, only: outfld
  1322. ! use constituents, only: ppcnst, cnst_get_ind
  1323. ! use prescribed_aerosols, only: get_aerosol, naer_all, aerosol_diagnostics, &
  1324. ! aerosol_indirect, get_rf_scales, get_int_scales, radforce, idxVOLC
  1325. ! use physics_types, only: physics_state
  1326. ! use wv_saturation, only: aqsat
  1327. ! use chemistry, only: trace_gas
  1328. ! use physconst, only: cpair, epsilo
  1329. ! use aer_optics, only: idxVIS
  1330. ! use aerosol_intr, only: set_aerosol_from_prognostics
  1331. implicit none
  1332. !
  1333. ! Input arguments
  1334. !
  1335. integer, intent(in) :: lchnk,j ! chunk identifier
  1336. integer, intent(in) :: ncol ! number of atmospheric columns
  1337. integer, intent(in) :: levsiz ! number of ozone data levels
  1338. integer, intent(in) :: num_months ! 12 months
  1339. integer, intent(in) :: paerlev,naer_c ! aerosol vertical level and # species
  1340. integer, intent(in) :: pcols, pver, pverp, pverr, pverrp, ppcnst, pcnst
  1341. logical, intent(in) :: dolw,dosw,doabsems
  1342. integer nspint ! Num of spctrl intervals across solar spectrum
  1343. integer naer_groups ! Num of aerosol groups for optical diagnostics
  1344. parameter ( nspint = 19 )
  1345. parameter ( naer_groups = 7 ) ! current groupings are sul, sslt, all carbons, all dust, background, and all aerosols
  1346. real(r8), intent(in) :: lwups(pcols) ! Longwave up flux at surface
  1347. real(r8), intent(in) :: emis(pcols,pver) ! Cloud emissivity
  1348. real(r8), intent(in) :: pmid(pcols,pver) ! Model level pressures
  1349. real(r8), intent(in) :: pint(pcols,pverp) ! Model interface pressures
  1350. real(r8), intent(in) :: pmln(pcols,pver) ! Natural log of pmid
  1351. real(r8), intent(in) :: rel(pcols,pver) ! liquid effective drop size (microns)
  1352. real(r8), intent(in) :: rei(pcols,pver) ! ice effective drop size (microns)
  1353. real(r8), intent(in) :: piln(pcols,pverp) ! Natural log of pint
  1354. real(r8), intent(in) :: pdel(pcols,pverp) ! Pressure difference across layer
  1355. real(r8), intent(in) :: t(pcols,pver) ! Model level temperatures
  1356. real(r8), intent(in) :: qm1(pcols,pver,ppcnst) ! Specific humidity and tracers
  1357. real(r8), intent(in) :: cld(pcols,pver) ! Fractional cloud cover
  1358. real(r8), intent(in) :: cicewp(pcols,pver) ! in-cloud cloud ice water path
  1359. real(r8), intent(in) :: cliqwp(pcols,pver) ! in-cloud cloud liquid water path
  1360. real(r8), intent(inout) :: tauxcl(pcols,0:pver) ! cloud water optical depth
  1361. real(r8), intent(inout) :: tauxci(pcols,0:pver) ! cloud ice optical depth
  1362. real(r8), intent(in) :: coszrs(pcols) ! Cosine solar zenith angle
  1363. real(r8), intent(in) :: clat(pcols) ! latitude in radians for columns
  1364. real(r8), intent(in) :: asdir(pcols) ! albedo shortwave direct
  1365. real(r8), intent(in) :: asdif(pcols) ! albedo shortwave diffuse
  1366. real(r8), intent(in) :: aldir(pcols) ! albedo longwave direct
  1367. real(r8), intent(in) :: aldif(pcols) ! albedo longwave diffuse
  1368. real(r8), intent(in) :: landfrac(pcols) ! land fraction
  1369. real(r8), intent(in) :: zm(pcols,pver) ! Height of midpoints (above surface)
  1370. real(r8), intent(in) :: pin(levsiz) ! Pressure levels of ozone data
  1371. real(r8), intent(in) :: ozmixmj(pcols,levsiz,num_months) ! monthly ozone mixing ratio
  1372. real(r8), intent(inout) :: ozmix(pcols,levsiz) ! Ozone data
  1373. real, intent(in) :: solcon ! solar constant with eccentricity factor
  1374. REAL, INTENT(IN ) :: XTIME,GMT
  1375. INTEGER, INTENT(IN ) :: JULDAY
  1376. REAL, INTENT(IN ) :: JULIAN
  1377. REAL, INTENT(IN ) :: DT
  1378. real(r8), intent(in) :: m_psp(pcols),m_psn(pcols) ! MATCH surface pressure
  1379. real(r8), intent(in) :: aerosoljp(pcols,paerlev,naer_c) ! aerosol concentrations
  1380. real(r8), intent(in) :: aerosoljn(pcols,paerlev,naer_c) ! aerosol concentrations
  1381. real(r8), intent(in) :: m_hybi(paerlev)
  1382. ! type(physics_state), intent(in) :: state
  1383. real(r8), intent(inout) :: pmxrgn(pcols,pverp) ! Maximum values of pmid for each
  1384. ! maximally overlapped region.
  1385. ! 0->pmxrgn(i,1) is range of pmid for
  1386. ! 1st region, pmxrgn(i,1)->pmxrgn(i,2) for
  1387. ! 2nd region, etc
  1388. integer, intent(inout) :: nmxrgn(pcols) ! Number of maximally overlapped regions
  1389. real(r8) :: pmxrgnrf(pcols,pverp) ! temporary copy of pmxrgn
  1390. integer :: nmxrgnrf(pcols) ! temporary copy of nmxrgn
  1391. !
  1392. ! Output solar arguments
  1393. !
  1394. real(r8), intent(out) :: fsns(pcols) ! Surface absorbed solar flux
  1395. real(r8), intent(out) :: fsnt(pcols) ! Net column abs solar flux at model top
  1396. real(r8), intent(out) :: flns(pcols) ! Srf longwave cooling (up-down) flux
  1397. real(r8), intent(out) :: flnt(pcols) ! Net outgoing lw flux at model top
  1398. real(r8), intent(out) :: sols(pcols) ! Downward solar rad onto surface (sw direct)
  1399. real(r8), intent(out) :: soll(pcols) ! Downward solar rad onto surface (lw direct)
  1400. real(r8), intent(out) :: solsd(pcols) ! Downward solar rad onto surface (sw diffuse)
  1401. real(r8), intent(out) :: solld(pcols) ! Downward solar rad onto surface (lw diffuse)
  1402. real(r8), intent(out) :: qrs(pcols,pver) ! Solar heating rate
  1403. real(r8), intent(out) :: fsds(pcols) ! Flux Shortwave Downwelling Surface
  1404. ! Added outputs of total and clearsky fluxes etc
  1405. real(r8), intent(out) :: fsup(pcols,pverp) ! Upward total sky solar
  1406. real(r8), intent(out) :: fsupc(pcols,pverp) ! Upward clear sky solar
  1407. real(r8), intent(out) :: fsdn(pcols,pverp) ! Downward total sky solar
  1408. real(r8), intent(out) :: fsdnc(pcols,pverp) ! Downward clear sky solar
  1409. real(r8), intent(out) :: flup(pcols,pverp) ! Upward total sky longwave
  1410. real(r8), intent(out) :: flupc(pcols,pverp) ! Upward clear sky longwave
  1411. real(r8), intent(out) :: fldn(pcols,pverp) ! Downward total sky longwave
  1412. real(r8), intent(out) :: fldnc(pcols,pverp) ! Downward clear sky longwave
  1413. real(r8), intent(out) :: swcf(pcols) ! Top of the atmosphere solar cloud forcing
  1414. real(r8), intent(out) :: lwcf(pcols) ! Top of the atmosphere longwave cloud forcing
  1415. real(r8), intent(out) :: flut(pcols) ! Top of the atmosphere outgoing longwave
  1416. !
  1417. ! Output longwave arguments
  1418. !
  1419. real(r8), intent(out) :: qrl(pcols,pver) ! Longwave cooling rate
  1420. real(r8), intent(out) :: flwds(pcols) ! Surface down longwave flux
  1421. real(r8), intent(inout) :: abstot(pcols,pverp,pverp) ! Total absorptivity
  1422. real(r8), intent(inout) :: absnxt(pcols,pver,4) ! Total nearest layer absorptivity
  1423. real(r8), intent(inout) :: emstot(pcols,pverp) ! Total emissivity
  1424. !
  1425. !---------------------------Local variables-----------------------------
  1426. !
  1427. integer i, k ! index
  1428. integer :: in2o, ich4, if11, if12 ! indexes of gases in constituent array
  1429. real(r8) solin(pcols) ! Solar incident flux
  1430. ! real(r8) fsds(pcols) ! Flux Shortwave Downwelling Surface
  1431. real(r8) fsntoa(pcols) ! Net solar flux at TOA
  1432. real(r8) fsntoac(pcols) ! Clear sky net solar flux at TOA
  1433. real(r8) fsnirt(pcols) ! Near-IR flux absorbed at toa
  1434. real(r8) fsnrtc(pcols) ! Clear sky near-IR flux absorbed at toa
  1435. real(r8) fsnirtsq(pcols) ! Near-IR flux absorbed at toa >= 0.7 microns
  1436. real(r8) fsntc(pcols) ! Clear sky total column abs solar flux
  1437. real(r8) fsnsc(pcols) ! Clear sky surface abs solar flux
  1438. real(r8) fsdsc(pcols) ! Clear sky surface downwelling solar flux
  1439. ! real(r8) flut(pcols) ! Upward flux at top of model
  1440. ! real(r8) lwcf(pcols) ! longwave cloud forcing
  1441. ! real(r8) swcf(pcols) ! shortwave cloud forcing
  1442. real(r8) flutc(pcols) ! Upward Clear Sky flux at top of model
  1443. real(r8) flntc(pcols) ! Clear sky lw flux at model top
  1444. real(r8) flnsc(pcols) ! Clear sky lw flux at srf (up-down)
  1445. real(r8) ftem(pcols,pver) ! temporary array for outfld
  1446. real(r8) pbr(pcols,pverr) ! Model mid-level pressures (dynes/cm2)
  1447. real(r8) pnm(pcols,pverrp) ! Model interface pressures (dynes/cm2)
  1448. real(r8) o3vmr(pcols,pverr) ! Ozone volume mixing ratio
  1449. real(r8) o3mmr(pcols,pverr) ! Ozone mass mixing ratio
  1450. real(r8) eccf ! Earth/sun distance factor
  1451. real(r8) n2o(pcols,pver) ! nitrous oxide mass mixing ratio
  1452. real(r8) ch4(pcols,pver) ! methane mass mixing ratio
  1453. real(r8) cfc11(pcols,pver) ! cfc11 mass mixing ratio
  1454. real(r8) cfc12(pcols,pver) ! cfc12 mass mixing ratio
  1455. real(r8) rh(pcols,pverr) ! level relative humidity (fraction)
  1456. real(r8) lwupcgs(pcols) ! Upward longwave flux in cgs units
  1457. real(r8) esat(pcols,pverr) ! saturation vapor pressure
  1458. real(r8) qsat(pcols,pverr) ! saturation specific humidity
  1459. real(r8) :: frc_day(pcols) ! = 1 for daylight, =0 for night colums
  1460. real(r8) :: aertau(pcols,nspint,naer_groups) ! Aerosol column optical depth
  1461. real(r8) :: aerssa(pcols,nspint,naer_groups) ! Aerosol column averaged single scattering albedo
  1462. real(r8) :: aerasm(pcols,nspint,naer_groups) ! Aerosol column averaged asymmetry parameter
  1463. real(r8) :: aerfwd(pcols,nspint,naer_groups) ! Aerosol column averaged forward scattering
  1464. real(r8) aerosol(pcols, pver, naer_all) ! aerosol mass mixing ratios
  1465. real(r8) scales(naer_all) ! scaling factors for aerosols
  1466. !
  1467. ! Interpolate ozone volume mixing ratio to model levels
  1468. !
  1469. ! WRF: added pin, levsiz, ozmix here
  1470. call oznint(julday,julian,dt,gmt,xtime,ozmixmj,ozmix,levsiz,num_months,pcols)
  1471. call radozn(lchnk ,ncol &
  1472. ,pcols, pver &
  1473. ,pmid ,pin, levsiz, ozmix, o3vmr )
  1474. ! call outfld('O3VMR ',o3vmr ,pcols, lchnk)
  1475. !
  1476. ! Set chunk dependent radiation input
  1477. !
  1478. call radinp(lchnk ,ncol ,pcols, pver, pverp, &
  1479. pmid ,pint ,o3vmr , pbr ,&
  1480. pnm ,eccf ,o3mmr )
  1481. !
  1482. ! Solar radiation computation
  1483. !
  1484. if (dosw) then
  1485. !
  1486. ! calculate heating with aerosols
  1487. !
  1488. call aqsat(t, pmid, esat, qsat, pcols, &
  1489. ncol, pver, 1, pver)
  1490. ! calculate relative humidity
  1491. ! rh(1:ncol,1:pver) = q(1:ncol,1:pver,1) / qsat(1:ncol,1:pver) * &
  1492. ! ((1.0 - epsilo) * qsat(1:ncol,1:pver) + epsilo) / &
  1493. ! ((1.0 - epsilo) * q(1:ncol,1:pver,1) + epsilo)
  1494. rh(1:ncol,1:pver) = qm1(1:ncol,1:pver,1) / qsat(1:ncol,1:pver) * &
  1495. ((1.0 - epsilo) * qsat(1:ncol,1:pver) + epsilo) / &
  1496. ((1.0 - epsilo) * qm1(1:ncol,1:pver,1) + epsilo)
  1497. if (radforce) then
  1498. pmxrgnrf = pmxrgn
  1499. nmxrgnrf = nmxrgn
  1500. call get_rf_scales(scales)
  1501. call get_aerosol(lchnk, julday, julian, dt, gmt, xtime, m_psp, m_psn, aerosoljp, &
  1502. aerosoljn, m_hybi, paerlev, naer, pint, pcols, pver, pverp, pverr, pverrp, aerosol, scales)
  1503. ! overwrite with prognostics aerosols
  1504. ! no feedback from prognostic aerosols
  1505. ! call set_aerosol_from_prognostics (ncol, q, aerosol)
  1506. call aerosol_indirect(ncol,lchnk,pcols,pver,ppcnst,landfrac,pmid,t,qm1,cld,zm,rel)
  1507. ! call t_startf('radcswmx_rf')
  1508. call radcswmx(j, lchnk ,ncol ,pcols, pver, pverp, &
  1509. pnm ,pbr ,qm1 ,rh ,o3mmr , &
  1510. aerosol ,cld ,cicewp ,cliqwp ,rel , &
  1511. ! rei ,eccf ,coszrs ,scon ,solin ,solcon , &
  1512. rei ,tauxcl ,tauxci ,eccf ,coszrs ,scon ,solin ,solcon , &
  1513. asdir ,asdif ,aldir ,aldif ,nmxrgnrf, &
  1514. pmxrgnrf,qrs ,fsnt ,fsntc ,fsntoa , &
  1515. fsntoac ,fsnirt ,fsnrtc ,fsnirtsq,fsns , &
  1516. fsnsc ,fsdsc ,fsds ,sols ,soll , &
  1517. solsd ,solld ,frc_day , &
  1518. fsup ,fsupc ,fsdn ,fsdnc , &
  1519. aertau ,aerssa ,aerasm ,aerfwd )
  1520. ! call t_stopf('radcswmx_rf')
  1521. !
  1522. ! Convert units of shortwave fields needed by rest of model from CGS to MKS
  1523. !
  1524. do i = 1, ncol
  1525. solin(i) = solin(i)*1.e-3
  1526. fsnt(i) = fsnt(i) *1.e-3
  1527. fsns(i) = fsns(i) *1.e-3
  1528. fsntc(i) = fsntc(i)*1.e-3
  1529. fsnsc(i) = fsnsc(i)*1.e-3
  1530. end do
  1531. ftem(:ncol,:pver) = qrs(:ncol,:pver)/cpair
  1532. !
  1533. ! Dump shortwave radiation information to history tape buffer (diagnostics)
  1534. !
  1535. ! call outfld('QRS_RF ',ftem ,pcols,lchnk)
  1536. ! call outfld('FSNT_RF ',fsnt ,pcols,lchnk)
  1537. ! call outfld('FSNS_RF ',fsns ,pcols,lchnk)
  1538. ! call outfld('FSNTC_RF',fsntc ,pcols,lchnk)
  1539. ! call outfld('FSNSC_RF',fsnsc ,pcols,lchnk)
  1540. endif ! if (radforce)
  1541. call get_int_scales(scales)
  1542. call get_aerosol(lchnk, julday, julian, dt, gmt, xtime, m_psp, m_psn, aerosoljp, aerosoljn, &
  1543. m_hybi, paerlev, naer, pint, pcols, pver, pverp, pverr, pverrp, aerosol, scales)
  1544. ! overwrite with prognostics aerosols
  1545. ! call set_aerosol_from_prognostics (ncol, q, aerosol)
  1546. call aerosol_indirect(ncol,lchnk,pcols,pver,ppcnst,landfrac,pmid,t,qm1,cld,zm,rel)
  1547. ! call t_startf('radcswmx')
  1548. call radcswmx(j, lchnk ,ncol ,pcols, pver, pverp, &
  1549. pnm ,pbr ,qm1 ,rh ,o3mmr , &
  1550. aerosol ,cld ,cicewp ,cliqwp ,rel , &
  1551. ! rei ,eccf ,coszrs ,scon ,solin ,solcon , &
  1552. rei ,tauxcl ,tauxci ,eccf ,coszrs ,scon ,solin ,solcon , &
  1553. asdir ,asdif ,aldir ,aldif ,nmxrgn , &
  1554. pmxrgn ,qrs ,fsnt ,fsntc ,fsntoa , &
  1555. fsntoac ,fsnirt ,fsnrtc ,fsnirtsq,fsns , &
  1556. fsnsc ,fsdsc ,fsds ,sols ,soll , &
  1557. solsd ,solld ,frc_day , &
  1558. fsup ,fsupc ,fsdn ,fsdnc , &
  1559. aertau ,aerssa ,aerasm ,aerfwd )
  1560. ! call t_stopf('radcswmx')
  1561. ! -- tls ---------------------------------------------------------------2
  1562. !
  1563. ! Convert units of shortwave fields needed by rest of model from CGS to MKS
  1564. !
  1565. do i=1,ncol
  1566. solin(i) = solin(i)*1.e-3
  1567. fsds(i) = fsds(i)*1.e-3
  1568. fsnirt(i)= fsnirt(i)*1.e-3
  1569. fsnrtc(i)= fsnrtc(i)*1.e-3
  1570. fsnirtsq(i)= fsnirtsq(i)*1.e-3
  1571. fsnt(i) = fsnt(i) *1.e-3
  1572. fsns(i) = fsns(i) *1.e-3
  1573. fsntc(i) = fsntc(i)*1.e-3
  1574. fsnsc(i) = fsnsc(i)*1.e-3
  1575. fsdsc(i) = fsdsc(i)*1.e-3
  1576. fsntoa(i)=fsntoa(i)*1.e-3
  1577. fsntoac(i)=fsntoac(i)*1.e-3
  1578. swcf(i) = fsntoa(i) - fsntoac(i)
  1579. end do
  1580. ftem(:ncol,:pver) = qrs(:ncol,:pver)/cpair
  1581. ! Added upward/downward total and clear sky fluxes
  1582. do k = 1, pverp
  1583. do i = 1, ncol
  1584. fsup(i,k) = fsup(i,k)*1.e-3
  1585. fsupc(i,k) = fsupc(i,k)*1.e-3
  1586. fsdn(i,k) = fsdn(i,k)*1.e-3
  1587. fsdnc(i,k) = fsdnc(i,k)*1.e-3
  1588. end do
  1589. end do
  1590. !
  1591. ! Dump shortwave radiation information to history tape buffer (diagnostics)
  1592. !
  1593. ! call outfld('frc_day ', frc_day, pcols, lchnk)
  1594. ! call outfld('SULOD_v ', aertau(:,idxVIS,1) ,pcols,lchnk)
  1595. ! call outfld('SSLTOD_v', aertau(:,idxVIS,2) ,pcols,lchnk)
  1596. ! call outfld('CAROD_v ', aertau(:,idxVIS,3) ,pcols,lchnk)
  1597. ! call outfld('DUSTOD_v', aertau(:,idxVIS,4) ,pcols,lchnk)
  1598. ! call outfld('BGOD_v ', aertau(:,idxVIS,5) ,pcols,lchnk)
  1599. ! call outfld('VOLCOD_v', aertau(:,idxVIS,6) ,pcols,lchnk)
  1600. ! call outfld('AEROD_v ', aertau(:,idxVIS,7) ,pcols,lchnk)
  1601. ! call outfld('AERSSA_v', aerssa(:,idxVIS,7) ,pcols,lchnk)
  1602. ! call outfld('AERASM_v', aerasm(:,idxVIS,7) ,pcols,lchnk)
  1603. ! call outfld('AERFWD_v', aerfwd(:,idxVIS,7) ,pcols,lchnk)
  1604. ! call aerosol_diagnostics (lchnk, ncol, pdel, aerosol)
  1605. ! call outfld('QRS ',ftem ,pcols,lchnk)
  1606. ! call outfld('SOLIN ',solin ,pcols,lchnk)
  1607. ! call outfld('FSDS ',fsds ,pcols,lchnk)
  1608. ! call outfld('FSNIRTOA',fsnirt,pcols,lchnk)
  1609. ! call outfld('FSNRTOAC',fsnrtc,pcols,lchnk)
  1610. ! call outfld('FSNRTOAS',fsnirtsq,pcols,lchnk)
  1611. ! call outfld('FSNT ',fsnt ,pcols,lchnk)
  1612. ! call outfld('FSNS ',fsns ,pcols,lchnk)
  1613. ! call outfld('FSNTC ',fsntc ,pcols,lchnk)
  1614. ! call outfld('FSNSC ',fsnsc ,pcols,lchnk)
  1615. ! call outfld('FSDSC ',fsdsc ,pcols,lchnk)
  1616. ! call outfld('FSNTOA ',fsntoa,pcols,lchnk)
  1617. ! call outfld('FSNTOAC ',fsntoac,pcols,lchnk)
  1618. ! call outfld('SOLS ',sols ,pcols,lchnk)
  1619. ! call outfld('SOLL ',soll ,pcols,lchnk)
  1620. ! call outfld('SOLSD ',solsd ,pcols,lchnk)
  1621. ! call outfld('SOLLD ',solld ,pcols,lchnk)
  1622. end if
  1623. !
  1624. ! Longwave radiation computation
  1625. !
  1626. if (dolw) then
  1627. call get_int_scales(scales)
  1628. call get_aerosol(lchnk, julday, julian, dt, gmt, xtime, m_psp, m_psn, aerosoljp, aerosoljn, &
  1629. m_hybi, paerlev, naer, pint, pcols, pver, pverp, pverr, pverrp, aerosol, scales)
  1630. !
  1631. ! Convert upward longwave flux units to CGS
  1632. !
  1633. do i=1,ncol
  1634. ! lwupcgs(i) = lwup(i)*1000.
  1635. lwupcgs(i) = lwups(i)
  1636. end do
  1637. !
  1638. ! Do longwave computation. If not implementing greenhouse gas code then
  1639. ! first specify trace gas mixing ratios. If greenhouse gas code then:
  1640. ! o ixtrcg => indx of advected n2o tracer
  1641. ! o ixtrcg+1 => indx of advected ch4 tracer
  1642. ! o ixtrcg+2 => indx of advected cfc11 tracer
  1643. ! o ixtrcg+3 => indx of advected cfc12 tracer
  1644. !
  1645. if (trace_gas) then
  1646. ! call cnst_get_ind('N2O' , in2o)
  1647. ! call cnst_get_ind('CH4' , ich4)
  1648. ! call cnst_get_ind('CFC11', if11)
  1649. ! call cnst_get_ind('CFC12', if12)
  1650. ! call t_startf("radclwmx")
  1651. call radclwmx(lchnk ,ncol ,pcols, pver, pverp , &
  1652. lwupcgs ,t ,qm1(1,1,1) ,o3vmr , &
  1653. pbr ,pnm ,pmln ,piln , &
  1654. qm1(1,1,in2o) ,qm1(1,1,ich4) , &
  1655. qm1(1,1,if11) ,qm1(1,1,if12) , &
  1656. cld ,emis ,pmxrgn ,nmxrgn ,qrl , &
  1657. doabsems, abstot, absnxt, emstot, &
  1658. flns ,flnt ,flnsc ,flntc ,flwds , &
  1659. flut ,flutc , &
  1660. flup ,flupc ,fldn ,fldnc , &
  1661. aerosol(:,:,idxVOLC))
  1662. ! call t_stopf("radclwmx")
  1663. else
  1664. call trcmix(lchnk ,ncol ,pcols, pver, &
  1665. pmid ,clat, n2o ,ch4 , &
  1666. cfc11 ,cfc12 )
  1667. ! call t_startf("radclwmx")
  1668. call radclwmx(lchnk ,ncol ,pcols, pver, pverp , &
  1669. lwupcgs ,t ,qm1(1,1,1) ,o3vmr , &
  1670. pbr ,pnm ,pmln ,piln , &
  1671. n2o ,ch4 ,cfc11 ,cfc12 , &
  1672. cld ,emis ,pmxrgn ,nmxrgn ,qrl , &
  1673. doabsems, abstot, absnxt, emstot, &
  1674. flns ,flnt ,flnsc ,flntc ,flwds , &
  1675. flut ,flutc , &
  1676. flup ,flupc ,fldn ,fldnc , &
  1677. aerosol(:,:,idxVOLC))
  1678. ! call t_stopf("radclwmx")
  1679. endif
  1680. !
  1681. ! Convert units of longwave fields needed by rest of model from CGS to MKS
  1682. !
  1683. do i=1,ncol
  1684. flnt(i) = flnt(i)*1.e-3
  1685. flut(i) = flut(i)*1.e-3
  1686. flutc(i) = flutc(i)*1.e-3
  1687. flns(i) = flns(i)*1.e-3
  1688. flntc(i) = flntc(i)*1.e-3
  1689. flnsc(i) = flnsc(i)*1.e-3
  1690. flwds(i) = flwds(i)*1.e-3
  1691. lwcf(i) = flutc(i) - flut(i)
  1692. end do
  1693. ! Added upward/downward total and clear sky fluxes
  1694. do k = 1, pverp
  1695. do i = 1, ncol
  1696. flup(i,k) = flup(i,k)*1.e-3
  1697. flupc(i,k) = flupc(i,k)*1.e-3
  1698. fldn(i,k) = fldn(i,k)*1.e-3
  1699. fldnc(i,k) = fldnc(i,k)*1.e-3
  1700. end do
  1701. end do
  1702. !
  1703. ! Dump longwave radiation information to history tape buffer (diagnostics)
  1704. !
  1705. ! call outfld('QRL ',qrl(:ncol,:)/cpair,ncol,lchnk)
  1706. ! call outfld('FLNT ',flnt ,pcols,lchnk)
  1707. ! call outfld('FLUT ',flut ,pcols,lchnk)
  1708. ! call outfld('FLUTC ',flutc ,pcols,lchnk)
  1709. ! call outfld('FLNTC ',flntc ,pcols,lchnk)
  1710. ! call outfld('FLNS ',flns ,pcols,lchnk)
  1711. ! call outfld('FLNSC ',flnsc ,pcols,lchnk)
  1712. ! call outfld('LWCF ',lwcf ,pcols,lchnk)
  1713. ! call outfld('SWCF ',swcf ,pcols,lchnk)
  1714. !
  1715. end if
  1716. !
  1717. return
  1718. end subroutine radctl
  1719. subroutine param_cldoptics_calc(ncol, pcols, pver, pverp, pverr, pverrp, ppcnst, &
  1720. q, cldn, landfrac, landm,icefrac, &
  1721. pdel, t, ps, pmid, pint, cicewp, cliqwp, emis, rel, rei, pmxrgn, nmxrgn, snowh )
  1722. !
  1723. ! Compute (liquid+ice) water path and cloud water/ice diagnostics
  1724. ! *** soon this code will compute liquid and ice paths from input liquid and ice mixing ratios
  1725. !
  1726. ! **** mixes interface and physics code temporarily
  1727. !-----------------------------------------------------------------------
  1728. ! use physics_types, only: physics_state
  1729. ! use history, only: outfld
  1730. ! use pkg_cldoptics, only: cldefr, cldems, cldovrlap, cldclw
  1731. implicit none
  1732. ! Arguments
  1733. integer, intent(in) :: ncol, pcols, pver, pverp, pverr, pverrp, ppcnst
  1734. real(r8), intent(in) :: q(pcols,pver,ppcnst) ! moisture arrays
  1735. real(r8), intent(in) :: cldn(pcols,pver) ! new cloud fraction
  1736. real(r8), intent(in) :: pdel(pcols,pver) ! pressure thickness
  1737. real(r8), intent(in) :: t(pcols,pver) ! temperature
  1738. real(r8), intent(in) :: pmid(pcols,pver) ! pressure
  1739. real(r8), intent(in) :: pint(pcols,pverp) ! pressure
  1740. real(r8), intent(in) :: ps(pcols) ! surface pressure
  1741. real(r8), intent(in) :: landfrac(pcols) ! Land fraction
  1742. real(r8), intent(in) :: icefrac(pcols) ! Ice fraction
  1743. real(r8), intent(in) :: landm(pcols) ! Land fraction ramped
  1744. real(r8), intent(in) :: snowh(pcols) ! Snow depth over land, water equivalent (m)
  1745. !!$ real(r8), intent(out) :: cwp (pcols,pver) ! in-cloud cloud (total) water path
  1746. real(r8), intent(out) :: cicewp(pcols,pver) ! in-cloud cloud ice water path
  1747. real(r8), intent(out) :: cliqwp(pcols,pver) ! in-cloud cloud liquid water path
  1748. real(r8), intent(out) :: emis (pcols,pver) ! cloud emissivity
  1749. real(r8), intent(out) :: rel (pcols,pver) ! effective drop radius (microns)
  1750. real(r8), intent(out) :: rei (pcols,pver) ! ice effective drop size (microns)
  1751. real(r8), intent(out) :: pmxrgn(pcols,pver+1) ! Maximum values of pressure for each
  1752. integer , intent(out) :: nmxrgn(pcols) ! Number of maximally overlapped regions
  1753. ! Local variables
  1754. real(r8) :: cwp (pcols,pver) ! in-cloud cloud (total) water path
  1755. !!$ real(r8) :: cicewp(pcols,pver) ! in-cloud cloud ice water path
  1756. !!$ real(r8) :: cliqwp(pcols,pver) ! in-cloud cloud liquid water path
  1757. real(r8) :: effcld(pcols,pver) ! effective cloud=cld*emis
  1758. real(r8) :: gicewp(pcols,pver) ! grid-box cloud ice water path
  1759. real(r8) :: gliqwp(pcols,pver) ! grid-box cloud liquid water path
  1760. real(r8) :: gwp (pcols,pver) ! grid-box cloud (total) water path
  1761. real(r8) :: hl (pcols) ! Liquid water scale height
  1762. real(r8) :: tgicewp(pcols) ! Vertically integrated ice water path
  1763. real(r8) :: tgliqwp(pcols) ! Vertically integrated liquid water path
  1764. real(r8) :: tgwp (pcols) ! Vertically integrated (total) cloud water path
  1765. real(r8) :: tpw (pcols) ! total precipitable water
  1766. real(r8) :: clwpold(pcols,pver) ! Presribed cloud liq. h2o path
  1767. real(r8) :: ficemr (pcols,pver) ! Ice fraction from ice and liquid mixing ratios
  1768. real(r8) :: rgrav ! inverse gravitational acceleration
  1769. integer :: i,k ! loop indexes
  1770. integer :: lchnk
  1771. !-----------------------------------------------------------------------
  1772. ! Compute liquid and ice water paths
  1773. tgicewp(:ncol) = 0.
  1774. tgliqwp(:ncol) = 0.
  1775. do k=1,pver
  1776. do i = 1,ncol
  1777. gicewp(i,k) = q(i,k,ixcldice)*pdel(i,k)/gravmks*1000.0 ! Grid box ice water path.
  1778. gliqwp(i,k) = q(i,k,ixcldliq)*pdel(i,k)/gravmks*1000.0 ! Grid box liquid water path.
  1779. !!$ gwp (i,k) = gicewp(i,k) + gliqwp(i,k)
  1780. cicewp(i,k) = gicewp(i,k) / max(0.01_r8,cldn(i,k)) ! In-cloud ice water path.
  1781. cliqwp(i,k) = gliqwp(i,k) / max(0.01_r8,cldn(i,k)) ! In-cloud liquid water path.
  1782. !!$ cwp (i,k) = gwp (i,k) / max(0.01_r8,cldn(i,k))
  1783. ficemr(i,k) = q(i,k,ixcldice) / &
  1784. max(1.e-10_r8,(q(i,k,ixcldice)+q(i,k,ixcldliq)))
  1785. tgicewp(i) = tgicewp(i) + gicewp(i,k)
  1786. tgliqwp(i) = tgliqwp(i) + gliqwp(i,k)
  1787. end do
  1788. end do
  1789. tgwp(:ncol) = tgicewp(:ncol) + tgliqwp(:ncol)
  1790. gwp(:ncol,:pver) = gicewp(:ncol,:pver) + gliqwp(:ncol,:pver)
  1791. cwp(:ncol,:pver) = cicewp(:ncol,:pver) + cliqwp(:ncol,:pver)
  1792. ! Compute total preciptable water in column (in mm)
  1793. tpw(:ncol) = 0.0
  1794. rgrav = 1.0/gravmks
  1795. do k=1,pver
  1796. do i=1,ncol
  1797. tpw(i) = tpw(i) + pdel(i,k)*q(i,k,1)*rgrav
  1798. end do
  1799. end do
  1800. ! Diagnostic liquid water path (old specified form)
  1801. ! call cldclw(lchnk, ncol, pcols, pver, pverp, state%zi, clwpold, tpw, hl)
  1802. ! Cloud water and ice particle sizes
  1803. call cldefr(lchnk, ncol, pcols, pver, pverp, landfrac, t, rel, rei, ps, pmid, landm, icefrac, snowh)
  1804. ! Cloud emissivity.
  1805. call cldems(lchnk, ncol, pcols, pver, pverp, cwp, ficemr, rei, emis)
  1806. ! Effective cloud cover
  1807. do k=1,pver
  1808. do i=1,ncol
  1809. effcld(i,k) = cldn(i,k)*emis(i,k)
  1810. end do
  1811. end do
  1812. ! Determine parameters for maximum/random overlap
  1813. call cldovrlap(lchnk, ncol, pcols, pver, pverp, pint, cldn, nmxrgn, pmxrgn)
  1814. ! call outfld('GCLDLWP' ,gwp , pcols,lchnk)
  1815. ! call outfld('TGCLDCWP',tgwp , pcols,lchnk)
  1816. ! call outfld('TGCLDLWP',tgliqwp, pcols,lchnk)
  1817. ! call outfld('TGCLDIWP',tgicewp, pcols,lchnk)
  1818. ! call outfld('ICLDLWP' ,cwp , pcols,lchnk)
  1819. ! call outfld('SETLWP' ,clwpold, pcols,lchnk)
  1820. ! call outfld('EFFCLD' ,effcld , pcols,lchnk)
  1821. ! call outfld('LWSH' ,hl , pcols,lchnk)
  1822. end subroutine param_cldoptics_calc
  1823. subroutine radabs(lchnk ,ncol ,pcols, pver, pverp, &
  1824. pbr ,pnm ,co2em ,co2eml ,tplnka , &
  1825. s2c ,tcg ,w ,h2otr ,plco2 , &
  1826. plh2o ,co2t ,tint ,tlayr ,plol , &
  1827. plos ,pmln ,piln ,ucfc11 ,ucfc12 , &
  1828. un2o0 ,un2o1 ,uch4 ,uco211 ,uco212 , &
  1829. uco213 ,uco221 ,uco222 ,uco223 ,uptype , &
  1830. bn2o0 ,bn2o1 ,bch4 ,abplnk1 ,abplnk2 , &
  1831. abstot ,absnxt ,plh2ob ,wb , &
  1832. aer_mpp ,aer_trn_ttl)
  1833. !-----------------------------------------------------------------------
  1834. !
  1835. ! Purpose:
  1836. ! Compute absorptivities for h2o, co2, o3, ch4, n2o, cfc11 and cfc12
  1837. !
  1838. ! Method:
  1839. ! h2o .... Uses nonisothermal emissivity method for water vapor from
  1840. ! Ramanathan, V. and P.Downey, 1986: A Nonisothermal
  1841. ! Emissivity and Absorptivity Formulation for Water Vapor
  1842. ! Journal of Geophysical Research, vol. 91., D8, pp 8649-8666
  1843. !
  1844. ! Implementation updated by Collins, Hackney, and Edwards (2001)
  1845. ! using line-by-line calculations based upon Hitran 1996 and
  1846. ! CKD 2.1 for absorptivity and emissivity
  1847. !
  1848. ! Implementation updated by Collins, Lee-Taylor, and Edwards (2003)
  1849. ! using line-by-line calculations based upon Hitran 2000 and
  1850. ! CKD 2.4 for absorptivity and emissivity
  1851. !
  1852. ! co2 .... Uses absorptance parameterization of the 15 micro-meter
  1853. ! (500 - 800 cm-1) band system of Carbon Dioxide, from
  1854. ! Kiehl, J.T. and B.P.Briegleb, 1991: A New Parameterization
  1855. ! of the Absorptance Due to the 15 micro-meter Band System
  1856. ! of Carbon Dioxide Jouranl of Geophysical Research,
  1857. ! vol. 96., D5, pp 9013-9019.
  1858. ! Parameterizations for the 9.4 and 10.4 mircon bands of CO2
  1859. ! are also included.
  1860. !
  1861. ! o3 .... Uses absorptance parameterization of the 9.6 micro-meter
  1862. ! band system of ozone, from Ramanathan, V. and R.Dickinson,
  1863. ! 1979: The Role of stratospheric ozone in the zonal and
  1864. ! seasonal radiative energy balance of the earth-troposphere
  1865. ! system. Journal of the Atmospheric Sciences, Vol. 36,
  1866. ! pp 1084-1104
  1867. !
  1868. ! ch4 .... Uses a broad band model for the 7.7 micron band of methane.
  1869. !
  1870. ! n20 .... Uses a broad band model for the 7.8, 8.6 and 17.0 micron
  1871. ! bands of nitrous oxide
  1872. !
  1873. ! cfc11 ... Uses a quasi-linear model for the 9.2, 10.7, 11.8 and 12.5
  1874. ! micron bands of CFC11
  1875. !
  1876. ! cfc12 ... Uses a quasi-linear model for the 8.6, 9.1, 10.8 and 11.2
  1877. ! micron bands of CFC12
  1878. !
  1879. !
  1880. ! Computes individual absorptivities for non-adjacent layers, accounting
  1881. ! for band overlap, and sums to obtain the total; then, computes the
  1882. ! nearest layer contribution.
  1883. !
  1884. ! Author: W. Collins (H2O absorptivity) and J. Kiehl
  1885. !
  1886. !-----------------------------------------------------------------------
  1887. !------------------------------Arguments--------------------------------
  1888. !
  1889. ! Input arguments
  1890. !
  1891. integer, intent(in) :: lchnk ! chunk identifier
  1892. integer, intent(in) :: ncol ! number of atmospheric columns
  1893. integer, intent(in) :: pcols, pver, pverp
  1894. real(r8), intent(in) :: pbr(pcols,pver) ! Prssr at mid-levels (dynes/cm2)
  1895. real(r8), intent(in) :: pnm(pcols,pverp) ! Prssr at interfaces (dynes/cm2)
  1896. real(r8), intent(in) :: co2em(pcols,pverp) ! Co2 emissivity function
  1897. real(r8), intent(in) :: co2eml(pcols,pver) ! Co2 emissivity function
  1898. real(r8), intent(in) :: tplnka(pcols,pverp) ! Planck fnctn level temperature
  1899. real(r8), intent(in) :: s2c(pcols,pverp) ! H2o continuum path length
  1900. real(r8), intent(in) :: tcg(pcols,pverp) ! H2o-mass-wgted temp. (Curtis-Godson approx.)
  1901. real(r8), intent(in) :: w(pcols,pverp) ! H2o prs wghted path
  1902. real(r8), intent(in) :: h2otr(pcols,pverp) ! H2o trnsmssn fnct for o3 overlap
  1903. real(r8), intent(in) :: plco2(pcols,pverp) ! Co2 prs wghted path length
  1904. real(r8), intent(in) :: plh2o(pcols,pverp) ! H2o prs wfhted path length
  1905. real(r8), intent(in) :: co2t(pcols,pverp) ! Tmp and prs wghted path length
  1906. real(r8), intent(in) :: tint(pcols,pverp) ! Interface temperatures
  1907. real(r8), intent(in) :: tlayr(pcols,pverp) ! K-1 level temperatures
  1908. real(r8), intent(in) :: plol(pcols,pverp) ! Ozone prs wghted path length
  1909. real(r8), intent(in) :: plos(pcols,pverp) ! Ozone path length
  1910. real(r8), intent(in) :: pmln(pcols,pver) ! Ln(pmidm1)
  1911. real(r8), intent(in) :: piln(pcols,pverp) ! Ln(pintm1)
  1912. real(r8), intent(in) :: plh2ob(nbands,pcols,pverp) ! Pressure weighted h2o path with
  1913. ! Hulst-Curtis-Godson temp. factor
  1914. ! for H2O bands
  1915. real(r8), intent(in) :: wb(nbands,pcols,pverp) ! H2o path length with
  1916. ! Hulst-Curtis-Godson temp. factor
  1917. ! for H2O bands
  1918. real(r8), intent(in) :: aer_mpp(pcols,pverp) ! STRAER path above kth interface level
  1919. real(r8), intent(in) :: aer_trn_ttl(pcols,pverp,pverp,bnd_nbr_LW) ! aer trn.
  1920. !
  1921. ! Trace gas variables
  1922. !
  1923. real(r8), intent(in) :: ucfc11(pcols,pverp) ! CFC11 path length
  1924. real(r8), intent(in) :: ucfc12(pcols,pverp) ! CFC12 path length
  1925. real(r8), intent(in) :: un2o0(pcols,pverp) ! N2O path length
  1926. real(r8), intent(in) :: un2o1(pcols,pverp) ! N2O path length (hot band)
  1927. real(r8), intent(in) :: uch4(pcols,pverp) ! CH4 path length
  1928. real(r8), intent(in) :: uco211(pcols,pverp) ! CO2 9.4 micron band path length
  1929. real(r8), intent(in) :: uco212(pcols,pverp) ! CO2 9.4 micron band path length
  1930. real(r8), intent(in) :: uco213(pcols,pverp) ! CO2 9.4 micron band path length
  1931. real(r8), intent(in) :: uco221(pcols,pverp) ! CO2 10.4 micron band path length
  1932. real(r8), intent(in) :: uco222(pcols,pverp) ! CO2 10.4 micron band path length
  1933. real(r8), intent(in) :: uco223(pcols,pverp) ! CO2 10.4 micron band path length
  1934. real(r8), intent(in) :: uptype(pcols,pverp) ! continuum path length
  1935. real(r8), intent(in) :: bn2o0(pcols,pverp) ! pressure factor for n2o
  1936. real(r8), intent(in) :: bn2o1(pcols,pverp) ! pressure factor for n2o
  1937. real(r8), intent(in) :: bch4(pcols,pverp) ! pressure factor for ch4
  1938. real(r8), intent(in) :: abplnk1(14,pcols,pverp) ! non-nearest layer Planck factor
  1939. real(r8), intent(in) :: abplnk2(14,pcols,pverp) ! nearest layer factor
  1940. !
  1941. ! Output arguments
  1942. !
  1943. real(r8), intent(out) :: abstot(pcols,pverp,pverp) ! Total absorptivity
  1944. real(r8), intent(out) :: absnxt(pcols,pver,4) ! Total nearest layer absorptivity
  1945. !
  1946. !---------------------------Local variables-----------------------------
  1947. !
  1948. integer i ! Longitude index
  1949. integer k ! Level index
  1950. integer k1 ! Level index
  1951. integer k2 ! Level index
  1952. integer kn ! Nearest level index
  1953. integer wvl ! Wavelength index
  1954. real(r8) abstrc(pcols) ! total trace gas absorptivity
  1955. real(r8) bplnk(14,pcols,4) ! Planck functions for sub-divided layers
  1956. real(r8) pnew(pcols) ! Effective pressure for H2O vapor linewidth
  1957. real(r8) pnewb(nbands) ! Effective pressure for h2o linewidth w/
  1958. ! Hulst-Curtis-Godson correction for
  1959. ! each band
  1960. real(r8) u(pcols) ! Pressure weighted H2O path length
  1961. real(r8) ub(nbands) ! Pressure weighted H2O path length with
  1962. ! Hulst-Curtis-Godson correction for
  1963. ! each band
  1964. real(r8) tbar(pcols,4) ! Mean layer temperature
  1965. real(r8) emm(pcols,4) ! Mean co2 emissivity
  1966. real(r8) o3emm(pcols,4) ! Mean o3 emissivity
  1967. real(r8) o3bndi ! Ozone band parameter
  1968. real(r8) temh2o(pcols,4) ! Mean layer temperature equivalent to tbar
  1969. real(r8) k21 ! Exponential coefficient used to calculate
  1970. ! ! rotation band transmissvty in the 650-800
  1971. ! ! cm-1 region (tr1)
  1972. real(r8) k22 ! Exponential coefficient used to calculate
  1973. ! ! rotation band transmissvty in the 500-650
  1974. ! ! cm-1 region (tr2)
  1975. real(r8) uc1(pcols) ! H2o continuum pathlength in 500-800 cm-1
  1976. real(r8) to3h2o(pcols) ! H2o trnsmsn for overlap with o3
  1977. real(r8) pi ! For co2 absorptivity computation
  1978. real(r8) sqti(pcols) ! Used to store sqrt of mean temperature
  1979. real(r8) et ! Co2 hot band factor
  1980. real(r8) et2 ! Co2 hot band factor squared
  1981. real(r8) et4 ! Co2 hot band factor to fourth power
  1982. real(r8) omet ! Co2 stimulated emission term
  1983. real(r8) f1co2 ! Co2 central band factor
  1984. real(r8) f2co2(pcols) ! Co2 weak band factor
  1985. real(r8) f3co2(pcols) ! Co2 weak band factor
  1986. real(r8) t1co2(pcols) ! Overlap factr weak bands on strong band
  1987. real(r8) sqwp ! Sqrt of co2 pathlength
  1988. real(r8) f1sqwp(pcols) ! Main co2 band factor
  1989. real(r8) oneme ! Co2 stimulated emission term
  1990. real(r8) alphat ! Part of the co2 stimulated emission term
  1991. real(r8) wco2 ! Constants used to define co2 pathlength
  1992. real(r8) posqt ! Effective pressure for co2 line width
  1993. real(r8) u7(pcols) ! Co2 hot band path length
  1994. real(r8) u8 ! Co2 hot band path length
  1995. real(r8) u9 ! Co2 hot band path length
  1996. real(r8) u13 ! Co2 hot band path length
  1997. real(r8) rbeta7(pcols) ! Inverse of co2 hot band line width par
  1998. real(r8) rbeta8 ! Inverse of co2 hot band line width par
  1999. real(r8) rbeta9 ! Inverse of co2 hot band line width par
  2000. real(r8) rbeta13 ! Inverse of co2 hot band line width par
  2001. real(r8) tpatha ! For absorptivity computation
  2002. real(r8) abso(pcols,4) ! Absorptivity for various gases/bands
  2003. real(r8) dtx(pcols) ! Planck temperature minus 250 K
  2004. real(r8) dty(pcols) ! Path temperature minus 250 K
  2005. real(r8) term7(pcols,2) ! Kl_inf(i) in eq(r8) of table A3a of R&D
  2006. real(r8) term8(pcols,2) ! Delta kl_inf(i) in eq(r8)
  2007. real(r8) tr1 ! Eqn(6) in table A2 of R&D for 650-800
  2008. real(r8) tr10(pcols) ! Eqn (6) times eq(4) in table A2
  2009. ! ! of R&D for 500-650 cm-1 region
  2010. real(r8) tr2 ! Eqn(6) in table A2 of R&D for 500-650
  2011. real(r8) tr5 ! Eqn(4) in table A2 of R&D for 650-800
  2012. real(r8) tr6 ! Eqn(4) in table A2 of R&D for 500-650
  2013. real(r8) tr9(pcols) ! Equation (6) times eq(4) in table A2
  2014. ! ! of R&D for 650-800 cm-1 region
  2015. real(r8) sqrtu(pcols) ! Sqrt of pressure weighted h20 pathlength
  2016. real(r8) fwk(pcols) ! Equation(33) in R&D far wing correction
  2017. real(r8) fwku(pcols) ! GU term in eqs(1) and (6) in table A2
  2018. real(r8) to3co2(pcols) ! P weighted temp in ozone band model
  2019. real(r8) dpnm(pcols) ! Pressure difference between two levels
  2020. real(r8) pnmsq(pcols,pverp) ! Pressure squared
  2021. real(r8) dw(pcols) ! Amount of h2o between two levels
  2022. real(r8) uinpl(pcols,4) ! Nearest layer subdivision factor
  2023. real(r8) winpl(pcols,4) ! Nearest layer subdivision factor
  2024. real(r8) zinpl(pcols,4) ! Nearest layer subdivision factor
  2025. real(r8) pinpl(pcols,4) ! Nearest layer subdivision factor
  2026. real(r8) dplh2o(pcols) ! Difference in press weighted h2o amount
  2027. real(r8) r293 ! 1/293
  2028. real(r8) r250 ! 1/250
  2029. real(r8) r3205 ! Line width factor for o3 (see R&Di)
  2030. real(r8) r300 ! 1/300
  2031. real(r8) rsslp ! Reciprocal of sea level pressure
  2032. real(r8) r2sslp ! 1/2 of rsslp
  2033. real(r8) ds2c ! Y in eq(7) in table A2 of R&D
  2034. real(r8) dplos ! Ozone pathlength eq(A2) in R&Di
  2035. real(r8) dplol ! Presure weighted ozone pathlength
  2036. real(r8) tlocal ! Local interface temperature
  2037. real(r8) beta ! Ozone mean line parameter eq(A3) in R&Di
  2038. ! (includes Voigt line correction factor)
  2039. real(r8) rphat ! Effective pressure for ozone beta
  2040. real(r8) tcrfac ! Ozone temperature factor table 1 R&Di
  2041. real(r8) tmp1 ! Ozone band factor see eq(A1) in R&Di
  2042. real(r8) u1 ! Effective ozone pathlength eq(A2) in R&Di
  2043. real(r8) realnu ! 1/beta factor in ozone band model eq(A1)
  2044. real(r8) tmp2 ! Ozone band factor see eq(A1) in R&Di
  2045. real(r8) u2 ! Effective ozone pathlength eq(A2) in R&Di
  2046. real(r8) rsqti ! Reciprocal of sqrt of path temperature
  2047. real(r8) tpath ! Path temperature used in co2 band model
  2048. real(r8) tmp3 ! Weak band factor see K&B
  2049. real(r8) rdpnmsq ! Reciprocal of difference in press^2
  2050. real(r8) rdpnm ! Reciprocal of difference in press
  2051. real(r8) p1 ! Mean pressure factor
  2052. real(r8) p2 ! Mean pressure factor
  2053. real(r8) dtym10 ! T - 260 used in eq(9) and (10) table A3a
  2054. real(r8) dplco2 ! Co2 path length
  2055. real(r8) te ! A_0 T factor in ozone model table 1 of R&Di
  2056. real(r8) denom ! Denominator in eq(r8) of table A3a of R&D
  2057. real(r8) th2o(pcols) ! transmission due to H2O
  2058. real(r8) tco2(pcols) ! transmission due to CO2
  2059. real(r8) to3(pcols) ! transmission due to O3
  2060. !
  2061. ! Transmission terms for various spectral intervals:
  2062. !
  2063. real(r8) trab2(pcols) ! H2o 500 - 800 cm-1
  2064. real(r8) absbnd ! Proportional to co2 band absorptance
  2065. real(r8) dbvtit(pcols,pverp)! Intrfc drvtv plnck fnctn for o3
  2066. real(r8) dbvtly(pcols,pver) ! Level drvtv plnck fnctn for o3
  2067. !
  2068. ! Variables for Collins/Hackney/Edwards (C/H/E) &
  2069. ! Collins/Lee-Taylor/Edwards (C/LT/E) H2O parameterization
  2070. !
  2071. ! Notation:
  2072. ! U = integral (P/P_0 dW) eq. 15 in Ramanathan/Downey 1986
  2073. ! P = atmospheric pressure
  2074. ! P_0 = reference atmospheric pressure
  2075. ! W = precipitable water path
  2076. ! T_e = emission temperature
  2077. ! T_p = path temperature
  2078. ! RH = path relative humidity
  2079. !
  2080. real(r8) fa ! asymptotic value of abs. as U->infinity
  2081. real(r8) a_star ! normalized absorptivity for non-window
  2082. real(r8) l_star ! interpolated line transmission
  2083. real(r8) c_star ! interpolated continuum transmission
  2084. real(r8) te1 ! emission temperature
  2085. real(r8) te2 ! te^2
  2086. real(r8) te3 ! te^3
  2087. real(r8) te4 ! te^4
  2088. real(r8) te5 ! te^5
  2089. real(r8) log_u ! log base 10 of U
  2090. real(r8) log_uc ! log base 10 of H2O continuum path
  2091. real(r8) log_p ! log base 10 of P
  2092. real(r8) t_p ! T_p
  2093. real(r8) t_e ! T_e (offset by T_p)
  2094. integer iu ! index for log10(U)
  2095. integer iu1 ! iu + 1
  2096. integer iuc ! index for log10(H2O continuum path)
  2097. integer iuc1 ! iuc + 1
  2098. integer ip ! index for log10(P)
  2099. integer ip1 ! ip + 1
  2100. integer itp ! index for T_p
  2101. integer itp1 ! itp + 1
  2102. integer ite ! index for T_e
  2103. integer ite1 ! ite + 1
  2104. integer irh ! index for RH
  2105. integer irh1 ! irh + 1
  2106. real(r8) dvar ! normalized variation in T_p/T_e/P/U
  2107. real(r8) uvar ! U * diffusivity factor
  2108. real(r8) uscl ! factor for lineary scaling as U->0
  2109. real(r8) wu ! weight for U
  2110. real(r8) wu1 ! 1 - wu
  2111. real(r8) wuc ! weight for H2O continuum path
  2112. real(r8) wuc1 ! 1 - wuc
  2113. real(r8) wp ! weight for P
  2114. real(r8) wp1 ! 1 - wp
  2115. real(r8) wtp ! weight for T_p
  2116. real(r8) wtp1 ! 1 - wtp
  2117. real(r8) wte ! weight for T_e
  2118. real(r8) wte1 ! 1 - wte
  2119. real(r8) wrh ! weight for RH
  2120. real(r8) wrh1 ! 1 - wrh
  2121. real(r8) w_0_0_ ! weight for Tp/Te combination
  2122. real(r8) w_0_1_ ! weight for Tp/Te combination
  2123. real(r8) w_1_0_ ! weight for Tp/Te combination
  2124. real(r8) w_1_1_ ! weight for Tp/Te combination
  2125. real(r8) w_0_00 ! weight for Tp/Te/RH combination
  2126. real(r8) w_0_01 ! weight for Tp/Te/RH combination
  2127. real(r8) w_0_10 ! weight for Tp/Te/RH combination
  2128. real(r8) w_0_11 ! weight for Tp/Te/RH combination
  2129. real(r8) w_1_00 ! weight for Tp/Te/RH combination
  2130. real(r8) w_1_01 ! weight for Tp/Te/RH combination
  2131. real(r8) w_1_10 ! weight for Tp/Te/RH combination
  2132. real(r8) w_1_11 ! weight for Tp/Te/RH combination
  2133. real(r8) w00_00 ! weight for P/Tp/Te/RH combination
  2134. real(r8) w00_01 ! weight for P/Tp/Te/RH combination
  2135. real(r8) w00_10 ! weight for P/Tp/Te/RH combination
  2136. real(r8) w00_11 ! weight for P/Tp/Te/RH combination
  2137. real(r8) w01_00 ! weight for P/Tp/Te/RH combination
  2138. real(r8) w01_01 ! weight for P/Tp/Te/RH combination
  2139. real(r8) w01_10 ! weight for P/Tp/Te/RH combination
  2140. real(r8) w01_11 ! weight for P/Tp/Te/RH combination
  2141. real(r8) w10_00 ! weight for P/Tp/Te/RH combination
  2142. real(r8) w10_01 ! weight for P/Tp/Te/RH combination
  2143. real(r8) w10_10 ! weight for P/Tp/Te/RH combination
  2144. real(r8) w10_11 ! weight for P/Tp/Te/RH combination
  2145. real(r8) w11_00 ! weight for P/Tp/Te/RH combination
  2146. real(r8) w11_01 ! weight for P/Tp/Te/RH combination
  2147. real(r8) w11_10 ! weight for P/Tp/Te/RH combination
  2148. real(r8) w11_11 ! weight for P/Tp/Te/RH combination
  2149. integer ib ! spectral interval:
  2150. ! 1 = 0-800 cm^-1 and 1200-2200 cm^-1
  2151. ! 2 = 800-1200 cm^-1
  2152. real(r8) pch2o ! H2O continuum path
  2153. real(r8) fch2o ! temp. factor for continuum
  2154. real(r8) uch2o ! U corresponding to H2O cont. path (window)
  2155. real(r8) fdif ! secant(zenith angle) for diffusivity approx.
  2156. real(r8) sslp_mks ! Sea-level pressure in MKS units
  2157. real(r8) esx ! saturation vapor pressure returned by vqsatd
  2158. real(r8) qsx ! saturation mixing ratio returned by vqsatd
  2159. real(r8) pnew_mks ! pnew in MKS units
  2160. real(r8) q_path ! effective specific humidity along path
  2161. real(r8) rh_path ! effective relative humidity along path
  2162. real(r8) omeps ! 1 - epsilo
  2163. integer iest ! index in estblh2o
  2164. integer bnd_idx ! LW band index
  2165. real(r8) aer_pth_dlt ! [kg m-2] STRAER path between interface levels k1 and k2
  2166. real(r8) aer_pth_ngh(pcols)
  2167. ! [kg m-2] STRAER path between neighboring layers
  2168. real(r8) odap_aer_ttl ! [fraction] Total path absorption optical depth
  2169. real(r8) aer_trn_ngh(pcols,bnd_nbr_LW)
  2170. ! [fraction] Total transmission between
  2171. ! nearest neighbor sub-levels
  2172. !
  2173. !--------------------------Statement function---------------------------
  2174. !
  2175. real(r8) dbvt,t ! Planck fnctn tmp derivative for o3
  2176. !
  2177. dbvt(t)=(-2.8911366682e-4+(2.3771251896e-6+1.1305188929e-10*t)*t)/ &
  2178. (1.0+(-6.1364820707e-3+1.5550319767e-5*t)*t)
  2179. !
  2180. !
  2181. !-----------------------------------------------------------------------
  2182. !
  2183. ! Initialize
  2184. !
  2185. do k2=1,ntoplw-1
  2186. do k1=1,ntoplw-1
  2187. abstot(:,k1,k2) = inf ! set unused portions for lf95 restart write
  2188. end do
  2189. end do
  2190. do k2=1,4
  2191. do k1=1,ntoplw-1
  2192. absnxt(:,k1,k2) = inf ! set unused portions for lf95 restart write
  2193. end do
  2194. end do
  2195. do k=ntoplw,pverp
  2196. abstot(:,k,k) = inf ! set unused portions for lf95 restart write
  2197. end do
  2198. do k=ntoplw,pver
  2199. do i=1,ncol
  2200. dbvtly(i,k) = dbvt(tlayr(i,k+1))
  2201. dbvtit(i,k) = dbvt(tint(i,k))
  2202. end do
  2203. end do
  2204. do i=1,ncol
  2205. dbvtit(i,pverp) = dbvt(tint(i,pverp))
  2206. end do
  2207. !
  2208. r293 = 1./293.
  2209. r250 = 1./250.
  2210. r3205 = 1./.3205
  2211. r300 = 1./300.
  2212. rsslp = 1./sslp
  2213. r2sslp = 1./(2.*sslp)
  2214. !
  2215. !Constants for computing U corresponding to H2O cont. path
  2216. !
  2217. fdif = 1.66
  2218. sslp_mks = sslp / 10.0
  2219. omeps = 1.0 - epsilo
  2220. !
  2221. ! Non-adjacent layer absorptivity:
  2222. !
  2223. ! abso(i,1) 0 - 800 cm-1 h2o rotation band
  2224. ! abso(i,1) 1200 - 2200 cm-1 h2o vibration-rotation band
  2225. ! abso(i,2) 800 - 1200 cm-1 h2o window
  2226. !
  2227. ! Separation between rotation and vibration-rotation dropped, so
  2228. ! only 2 slots needed for H2O absorptivity
  2229. !
  2230. ! 500-800 cm^-1 H2o continuum/line overlap already included
  2231. ! in abso(i,1). This used to be in abso(i,4)
  2232. !
  2233. ! abso(i,3) o3 9.6 micrometer band (nu3 and nu1 bands)
  2234. ! abso(i,4) co2 15 micrometer band system
  2235. !
  2236. do k=ntoplw,pverp
  2237. do i=1,ncol
  2238. pnmsq(i,k) = pnm(i,k)**2
  2239. dtx(i) = tplnka(i,k) - 250.
  2240. end do
  2241. end do
  2242. !
  2243. ! Non-nearest layer level loops
  2244. !
  2245. do k1=pverp,ntoplw,-1
  2246. do k2=pverp,ntoplw,-1
  2247. if (k1 == k2) cycle
  2248. do i=1,ncol
  2249. dplh2o(i) = plh2o(i,k1) - plh2o(i,k2)
  2250. u(i) = abs(dplh2o(i))
  2251. sqrtu(i) = sqrt(u(i))
  2252. ds2c = abs(s2c(i,k1) - s2c(i,k2))
  2253. dw(i) = abs(w(i,k1) - w(i,k2))
  2254. uc1(i) = (ds2c + 1.7e-3*u(i))*(1. + 2.*ds2c)/(1. + 15.*ds2c)
  2255. pch2o = ds2c
  2256. pnew(i) = u(i)/dw(i)
  2257. pnew_mks = pnew(i) * sslp_mks
  2258. !
  2259. ! Changed effective path temperature to std. Curtis-Godson form
  2260. !
  2261. tpatha = abs(tcg(i,k1) - tcg(i,k2))/dw(i)
  2262. t_p = min(max(tpatha, min_tp_h2o), max_tp_h2o)
  2263. iest = floor(t_p) - min_tp_h2o
  2264. esx = estblh2o(iest) + (estblh2o(iest+1)-estblh2o(iest)) * &
  2265. (t_p - min_tp_h2o - iest)
  2266. qsx = epsilo * esx / (pnew_mks - omeps * esx)
  2267. !
  2268. ! Compute effective RH along path
  2269. !
  2270. q_path = dw(i) / abs(pnm(i,k1) - pnm(i,k2)) / rga
  2271. !
  2272. ! Calculate effective u, pnew for each band using
  2273. ! Hulst-Curtis-Godson approximation:
  2274. ! Formulae: Goody and Yung, Atmospheric Radiation: Theoretical Basis,
  2275. ! 2nd edition, Oxford University Press, 1989.
  2276. ! Effective H2O path (w)
  2277. ! eq. 6.24, p. 228
  2278. ! Effective H2O path pressure (pnew = u/w):
  2279. ! eq. 6.29, p. 228
  2280. !
  2281. ub(1) = abs(plh2ob(1,i,k1) - plh2ob(1,i,k2)) / psi(t_p,1)
  2282. ub(2) = abs(plh2ob(2,i,k1) - plh2ob(2,i,k2)) / psi(t_p,2)
  2283. pnewb(1) = ub(1) / abs(wb(1,i,k1) - wb(1,i,k2)) * phi(t_p,1)
  2284. pnewb(2) = ub(2) / abs(wb(2,i,k1) - wb(2,i,k2)) * phi(t_p,2)
  2285. dtx(i) = tplnka(i,k2) - 250.
  2286. dty(i) = tpatha - 250.
  2287. fwk(i) = fwcoef + fwc1/(1. + fwc2*u(i))
  2288. fwku(i) = fwk(i)*u(i)
  2289. !
  2290. ! Define variables for C/H/E (now C/LT/E) fit
  2291. !
  2292. ! abso(i,1) 0 - 800 cm-1 h2o rotation band
  2293. ! abso(i,1) 1200 - 2200 cm-1 h2o vibration-rotation band
  2294. ! abso(i,2) 800 - 1200 cm-1 h2o window
  2295. !
  2296. ! Separation between rotation and vibration-rotation dropped, so
  2297. ! only 2 slots needed for H2O absorptivity
  2298. !
  2299. ! Notation:
  2300. ! U = integral (P/P_0 dW)
  2301. ! P = atmospheric pressure
  2302. ! P_0 = reference atmospheric pressure
  2303. ! W = precipitable water path
  2304. ! T_e = emission temperature
  2305. ! T_p = path temperature
  2306. ! RH = path relative humidity
  2307. !
  2308. !
  2309. ! Terms for asymptotic value of emissivity
  2310. !
  2311. te1 = tplnka(i,k2)
  2312. te2 = te1 * te1
  2313. te3 = te2 * te1
  2314. te4 = te3 * te1
  2315. te5 = te4 * te1
  2316. !
  2317. ! Band-independent indices for lines and continuum tables
  2318. !
  2319. dvar = (t_p - min_tp_h2o) / dtp_h2o
  2320. itp = min(max(int(aint(dvar,r8)) + 1, 1), n_tp - 1)
  2321. itp1 = itp + 1
  2322. wtp = dvar - floor(dvar)
  2323. wtp1 = 1.0 - wtp
  2324. t_e = min(max(tplnka(i,k2)-t_p, min_te_h2o), max_te_h2o)
  2325. dvar = (t_e - min_te_h2o) / dte_h2o
  2326. ite = min(max(int(aint(dvar,r8)) + 1, 1), n_te - 1)
  2327. ite1 = ite + 1
  2328. wte = dvar - floor(dvar)
  2329. wte1 = 1.0 - wte
  2330. rh_path = min(max(q_path / qsx, min_rh_h2o), max_rh_h2o)
  2331. dvar = (rh_path - min_rh_h2o) / drh_h2o
  2332. irh = min(max(int(aint(dvar,r8)) + 1, 1), n_rh - 1)
  2333. irh1 = irh + 1
  2334. wrh = dvar - floor(dvar)
  2335. wrh1 = 1.0 - wrh
  2336. w_0_0_ = wtp * wte
  2337. w_0_1_ = wtp * wte1
  2338. w_1_0_ = wtp1 * wte
  2339. w_1_1_ = wtp1 * wte1
  2340. w_0_00 = w_0_0_ * wrh
  2341. w_0_01 = w_0_0_ * wrh1
  2342. w_0_10 = w_0_1_ * wrh
  2343. w_0_11 = w_0_1_ * wrh1
  2344. w_1_00 = w_1_0_ * wrh
  2345. w_1_01 = w_1_0_ * wrh1
  2346. w_1_10 = w_1_1_ * wrh
  2347. w_1_11 = w_1_1_ * wrh1
  2348. !
  2349. ! H2O Continuum path for 0-800 and 1200-2200 cm^-1
  2350. !
  2351. ! Assume foreign continuum dominates total H2O continuum in these bands
  2352. ! per Clough et al, JGR, v. 97, no. D14 (Oct 20, 1992), p. 15776
  2353. ! Then the effective H2O path is just
  2354. ! U_c = integral[ f(P) dW ]
  2355. ! where
  2356. ! W = water-vapor mass and
  2357. ! f(P) = dependence of foreign continuum on pressure
  2358. ! = P / sslp
  2359. ! Then
  2360. ! U_c = U (the same effective H2O path as for lines)
  2361. !
  2362. !
  2363. ! Continuum terms for 800-1200 cm^-1
  2364. !
  2365. ! Assume self continuum dominates total H2O continuum for this band
  2366. ! per Clough et al, JGR, v. 97, no. D14 (Oct 20, 1992), p. 15776
  2367. ! Then the effective H2O self-continuum path is
  2368. ! U_c = integral[ h(e,T) dW ] (*eq. 1*)
  2369. ! where
  2370. ! W = water-vapor mass and
  2371. ! e = partial pressure of H2O along path
  2372. ! T = temperature along path
  2373. ! h(e,T) = dependence of foreign continuum on e,T
  2374. ! = e / sslp * f(T)
  2375. !
  2376. ! Replacing
  2377. ! e =~ q * P / epsilo
  2378. ! q = mixing ratio of H2O
  2379. ! epsilo = 0.622
  2380. !
  2381. ! and using the definition
  2382. ! U = integral [ (P / sslp) dW ]
  2383. ! = (P / sslp) W (homogeneous path)
  2384. !
  2385. ! the effective path length for the self continuum is
  2386. ! U_c = (q / epsilo) f(T) U (*eq. 2*)
  2387. !
  2388. ! Once values of T, U, and q have been calculated for the inhomogeneous
  2389. ! path, this sets U_c for the corresponding
  2390. ! homogeneous atmosphere. However, this need not equal the
  2391. ! value of U_c' defined by eq. 1 for the actual inhomogeneous atmosphere
  2392. ! under consideration.
  2393. !
  2394. ! Solution: hold T and q constant, solve for U' that gives U_c' by
  2395. ! inverting eq. (2):
  2396. !
  2397. ! U' = (U_c * epsilo) / (q * f(T))
  2398. !
  2399. fch2o = fh2oself(t_p)
  2400. uch2o = (pch2o * epsilo) / (q_path * fch2o)
  2401. !
  2402. ! Band-dependent indices for non-window
  2403. !
  2404. ib = 1
  2405. uvar = ub(ib) * fdif
  2406. log_u = min(log10(max(uvar, min_u_h2o)), max_lu_h2o)
  2407. dvar = (log_u - min_lu_h2o) / dlu_h2o
  2408. iu = min(max(int(aint(dvar,r8)) + 1, 1), n_u - 1)
  2409. iu1 = iu + 1
  2410. wu = dvar - floor(dvar)
  2411. wu1 = 1.0 - wu
  2412. log_p = min(log10(max(pnewb(ib), min_p_h2o)), max_lp_h2o)
  2413. dvar = (log_p - min_lp_h2o) / dlp_h2o
  2414. ip = min(max(int(aint(dvar,r8)) + 1, 1), n_p - 1)
  2415. ip1 = ip + 1
  2416. wp = dvar - floor(dvar)
  2417. wp1 = 1.0 - wp
  2418. w00_00 = wp * w_0_00
  2419. w00_01 = wp * w_0_01
  2420. w00_10 = wp * w_0_10
  2421. w00_11 = wp * w_0_11
  2422. w01_00 = wp * w_1_00
  2423. w01_01 = wp * w_1_01
  2424. w01_10 = wp * w_1_10
  2425. w01_11 = wp * w_1_11
  2426. w10_00 = wp1 * w_0_00
  2427. w10_01 = wp1 * w_0_01
  2428. w10_10 = wp1 * w_0_10
  2429. w10_11 = wp1 * w_0_11
  2430. w11_00 = wp1 * w_1_00
  2431. w11_01 = wp1 * w_1_01
  2432. w11_10 = wp1 * w_1_10
  2433. w11_11 = wp1 * w_1_11
  2434. !
  2435. ! Asymptotic value of absorptivity as U->infinity
  2436. !
  2437. fa = fat(1,ib) + &
  2438. fat(2,ib) * te1 + &
  2439. fat(3,ib) * te2 + &
  2440. fat(4,ib) * te3 + &
  2441. fat(5,ib) * te4 + &
  2442. fat(6,ib) * te5
  2443. a_star = &
  2444. ah2onw(ip , itp , iu , ite , irh ) * w11_11 * wu1 + &
  2445. ah2onw(ip , itp , iu , ite , irh1) * w11_10 * wu1 + &
  2446. ah2onw(ip , itp , iu , ite1, irh ) * w11_01 * wu1 + &
  2447. ah2onw(ip , itp , iu , ite1, irh1) * w11_00 * wu1 + &
  2448. ah2onw(ip , itp , iu1, ite , irh ) * w11_11 * wu + &
  2449. ah2onw(ip , itp , iu1, ite , irh1) * w11_10 * wu + &
  2450. ah2onw(ip , itp , iu1, ite1, irh ) * w11_01 * wu + &
  2451. ah2onw(ip , itp , iu1, ite1, irh1) * w11_00 * wu + &
  2452. ah2onw(ip , itp1, iu , ite , irh ) * w10_11 * wu1 + &
  2453. ah2onw(ip , itp1, iu , ite , irh1) * w10_10 * wu1 + &
  2454. ah2onw(ip , itp1, iu , ite1, irh ) * w10_01 * wu1 + &
  2455. ah2onw(ip , itp1, iu , ite1, irh1) * w10_00 * wu1 + &
  2456. ah2onw(ip , itp1, iu1, ite , irh ) * w10_11 * wu + &
  2457. ah2onw(ip , itp1, iu1, ite , irh1) * w10_10 * wu + &
  2458. ah2onw(ip , itp1, iu1, ite1, irh ) * w10_01 * wu + &
  2459. ah2onw(ip , itp1, iu1, ite1, irh1) * w10_00 * wu + &
  2460. ah2onw(ip1, itp , iu , ite , irh ) * w01_11 * wu1 + &
  2461. ah2onw(ip1, itp , iu , ite , irh1) * w01_10 * wu1 + &
  2462. ah2onw(ip1, itp , iu , ite1, irh ) * w01_01 * wu1 + &
  2463. ah2onw(ip1, itp , iu , ite1, irh1) * w01_00 * wu1 + &
  2464. ah2onw(ip1, itp , iu1, ite , irh ) * w01_11 * wu + &
  2465. ah2onw(ip1, itp , iu1, ite , irh1) * w01_10 * wu + &
  2466. ah2onw(ip1, itp , iu1, ite1, irh ) * w01_01 * wu + &
  2467. ah2onw(ip1, itp , iu1, ite1, irh1) * w01_00 * wu + &
  2468. ah2onw(ip1, itp1, iu , ite , irh ) * w00_11 * wu1 + &
  2469. ah2onw(ip1, itp1, iu , ite , irh1) * w00_10 * wu1 + &
  2470. ah2onw(ip1, itp1, iu , ite1, irh ) * w00_01 * wu1 + &
  2471. ah2onw(ip1, itp1, iu , ite1, irh1) * w00_00 * wu1 + &
  2472. ah2onw(ip1, itp1, iu1, ite , irh ) * w00_11 * wu + &
  2473. ah2onw(ip1, itp1, iu1, ite , irh1) * w00_10 * wu + &
  2474. ah2onw(ip1, itp1, iu1, ite1, irh ) * w00_01 * wu + &
  2475. ah2onw(ip1, itp1, iu1, ite1, irh1) * w00_00 * wu
  2476. abso(i,ib) = min(max(fa * (1.0 - (1.0 - a_star) * &
  2477. aer_trn_ttl(i,k1,k2,ib)), &
  2478. 0.0_r8), 1.0_r8)
  2479. !
  2480. ! Invoke linear limit for scaling wrt u below min_u_h2o
  2481. !
  2482. if (uvar < min_u_h2o) then
  2483. uscl = uvar / min_u_h2o
  2484. abso(i,ib) = abso(i,ib) * uscl
  2485. endif
  2486. !
  2487. ! Band-dependent indices for window
  2488. !
  2489. ib = 2
  2490. uvar = ub(ib) * fdif
  2491. log_u = min(log10(max(uvar, min_u_h2o)), max_lu_h2o)
  2492. dvar = (log_u - min_lu_h2o) / dlu_h2o
  2493. iu = min(max(int(aint(dvar,r8)) + 1, 1), n_u - 1)
  2494. iu1 = iu + 1
  2495. wu = dvar - floor(dvar)
  2496. wu1 = 1.0 - wu
  2497. log_p = min(log10(max(pnewb(ib), min_p_h2o)), max_lp_h2o)
  2498. dvar = (log_p - min_lp_h2o) / dlp_h2o
  2499. ip = min(max(int(aint(dvar,r8)) + 1, 1), n_p - 1)
  2500. ip1 = ip + 1
  2501. wp = dvar - floor(dvar)
  2502. wp1 = 1.0 - wp
  2503. w00_00 = wp * w_0_00
  2504. w00_01 = wp * w_0_01
  2505. w00_10 = wp * w_0_10
  2506. w00_11 = wp * w_0_11
  2507. w01_00 = wp * w_1_00
  2508. w01_01 = wp * w_1_01
  2509. w01_10 = wp * w_1_10
  2510. w01_11 = wp * w_1_11
  2511. w10_00 = wp1 * w_0_00
  2512. w10_01 = wp1 * w_0_01
  2513. w10_10 = wp1 * w_0_10
  2514. w10_11 = wp1 * w_0_11
  2515. w11_00 = wp1 * w_1_00
  2516. w11_01 = wp1 * w_1_01
  2517. w11_10 = wp1 * w_1_10
  2518. w11_11 = wp1 * w_1_11
  2519. log_uc = min(log10(max(uch2o * fdif, min_u_h2o)), max_lu_h2o)
  2520. dvar = (log_uc - min_lu_h2o) / dlu_h2o
  2521. iuc = min(max(int(aint(dvar,r8)) + 1, 1), n_u - 1)
  2522. iuc1 = iuc + 1
  2523. wuc = dvar - floor(dvar)
  2524. wuc1 = 1.0 - wuc
  2525. !
  2526. ! Asymptotic value of absorptivity as U->infinity
  2527. !
  2528. fa = fat(1,ib) + &
  2529. fat(2,ib) * te1 + &
  2530. fat(3,ib) * te2 + &
  2531. fat(4,ib) * te3 + &
  2532. fat(5,ib) * te4 + &
  2533. fat(6,ib) * te5
  2534. l_star = &
  2535. ln_ah2ow(ip , itp , iu , ite , irh ) * w11_11 * wu1 + &
  2536. ln_ah2ow(ip , itp , iu , ite , irh1) * w11_10 * wu1 + &
  2537. ln_ah2ow(ip , itp , iu , ite1, irh ) * w11_01 * wu1 + &
  2538. ln_ah2ow(ip , itp , iu , ite1, irh1) * w11_00 * wu1 + &
  2539. ln_ah2ow(ip , itp , iu1, ite , irh ) * w11_11 * wu + &
  2540. ln_ah2ow(ip , itp , iu1, ite , irh1) * w11_10 * wu + &
  2541. ln_ah2ow(ip , itp , iu1, ite1, irh ) * w11_01 * wu + &
  2542. ln_ah2ow(ip , itp , iu1, ite1, irh1) * w11_00 * wu + &
  2543. ln_ah2ow(ip , itp1, iu , ite , irh ) * w10_11 * wu1 + &
  2544. ln_ah2ow(ip , itp1, iu , ite , irh1) * w10_10 * wu1 + &
  2545. ln_ah2ow(ip , itp1, iu , ite1, irh ) * w10_01 * wu1 + &
  2546. ln_ah2ow(ip , itp1, iu , ite1, irh1) * w10_00 * wu1 + &
  2547. ln_ah2ow(ip , itp1, iu1, ite , irh ) * w10_11 * wu + &
  2548. ln_ah2ow(ip , itp1, iu1, ite , irh1) * w10_10 * wu + &
  2549. ln_ah2ow(ip , itp1, iu1, ite1, irh ) * w10_01 * wu + &
  2550. ln_ah2ow(ip , itp1, iu1, ite1, irh1) * w10_00 * wu + &
  2551. ln_ah2ow(ip1, itp , iu , ite , irh ) * w01_11 * wu1 + &
  2552. ln_ah2ow(ip1, itp , iu , ite , irh1) * w01_10 * wu1 + &
  2553. ln_ah2ow(ip1, itp , iu , ite1, irh ) * w01_01 * wu1 + &
  2554. ln_ah2ow(ip1, itp , iu , ite1, irh1) * w01_00 * wu1 + &
  2555. ln_ah2ow(ip1, itp , iu1, ite , irh ) * w01_11 * wu + &
  2556. ln_ah2ow(ip1, itp , iu1, ite , irh1) * w01_10 * wu + &
  2557. ln_ah2ow(ip1, itp , iu1, ite1, irh ) * w01_01 * wu + &
  2558. ln_ah2ow(ip1, itp , iu1, ite1, irh1) * w01_00 * wu + &
  2559. ln_ah2ow(ip1, itp1, iu , ite , irh ) * w00_11 * wu1 + &
  2560. ln_ah2ow(ip1, itp1, iu , ite , irh1) * w00_10 * wu1 + &
  2561. ln_ah2ow(ip1, itp1, iu , ite1, irh ) * w00_01 * wu1 + &
  2562. ln_ah2ow(ip1, itp1, iu , ite1, irh1) * w00_00 * wu1 + &
  2563. ln_ah2ow(ip1, itp1, iu1, ite , irh ) * w00_11 * wu + &
  2564. ln_ah2ow(ip1, itp1, iu1, ite , irh1) * w00_10 * wu + &
  2565. ln_ah2ow(ip1, itp1, iu1, ite1, irh ) * w00_01 * wu + &
  2566. ln_ah2ow(ip1, itp1, iu1, ite1, irh1) * w00_00 * wu
  2567. c_star = &
  2568. cn_ah2ow(ip , itp , iuc , ite , irh ) * w11_11 * wuc1 + &
  2569. cn_ah2ow(ip , itp , iuc , ite , irh1) * w11_10 * wuc1 + &
  2570. cn_ah2ow(ip , itp , iuc , ite1, irh ) * w11_01 * wuc1 + &
  2571. cn_ah2ow(ip , itp , iuc , ite1, irh1) * w11_00 * wuc1 + &
  2572. cn_ah2ow(ip , itp , iuc1, ite , irh ) * w11_11 * wuc + &
  2573. cn_ah2ow(ip , itp , iuc1, ite , irh1) * w11_10 * wuc + &
  2574. cn_ah2ow(ip , itp , iuc1, ite1, irh ) * w11_01 * wuc + &
  2575. cn_ah2ow(ip , itp , iuc1, ite1, irh1) * w11_00 * wuc + &
  2576. cn_ah2ow(ip , itp1, iuc , ite , irh ) * w10_11 * wuc1 + &
  2577. cn_ah2ow(ip , itp1, iuc , ite , irh1) * w10_10 * wuc1 + &
  2578. cn_ah2ow(ip , itp1, iuc , ite1, irh ) * w10_01 * wuc1 + &
  2579. cn_ah2ow(ip , itp1, iuc , ite1, irh1) * w10_00 * wuc1 + &
  2580. cn_ah2ow(ip , itp1, iuc1, ite , irh ) * w10_11 * wuc + &
  2581. cn_ah2ow(ip , itp1, iuc1, ite , irh1) * w10_10 * wuc + &
  2582. cn_ah2ow(ip , itp1, iuc1, ite1, irh ) * w10_01 * wuc + &
  2583. cn_ah2ow(ip , itp1, iuc1, ite1, irh1) * w10_00 * wuc + &
  2584. cn_ah2ow(ip1, itp , iuc , ite , irh ) * w01_11 * wuc1 + &
  2585. cn_ah2ow(ip1, itp , iuc , ite , irh1) * w01_10 * wuc1 + &
  2586. cn_ah2ow(ip1, itp , iuc , ite1, irh ) * w01_01 * wuc1 + &
  2587. cn_ah2ow(ip1, itp , iuc , ite1, irh1) * w01_00 * wuc1 + &
  2588. cn_ah2ow(ip1, itp , iuc1, ite , irh ) * w01_11 * wuc + &
  2589. cn_ah2ow(ip1, itp , iuc1, ite , irh1) * w01_10 * wuc + &
  2590. cn_ah2ow(ip1, itp , iuc1, ite1, irh ) * w01_01 * wuc + &
  2591. cn_ah2ow(ip1, itp , iuc1, ite1, irh1) * w01_00 * wuc + &
  2592. cn_ah2ow(ip1, itp1, iuc , ite , irh ) * w00_11 * wuc1 + &
  2593. cn_ah2ow(ip1, itp1, iuc , ite , irh1) * w00_10 * wuc1 + &
  2594. cn_ah2ow(ip1, itp1, iuc , ite1, irh ) * w00_01 * wuc1 + &
  2595. cn_ah2ow(ip1, itp1, iuc , ite1, irh1) * w00_00 * wuc1 + &
  2596. cn_ah2ow(ip1, itp1, iuc1, ite , irh ) * w00_11 * wuc + &
  2597. cn_ah2ow(ip1, itp1, iuc1, ite , irh1) * w00_10 * wuc + &
  2598. cn_ah2ow(ip1, itp1, iuc1, ite1, irh ) * w00_01 * wuc + &
  2599. cn_ah2ow(ip1, itp1, iuc1, ite1, irh1) * w00_00 * wuc
  2600. abso(i,ib) = min(max(fa * (1.0 - l_star * c_star * &
  2601. aer_trn_ttl(i,k1,k2,ib)), &
  2602. 0.0_r8), 1.0_r8)
  2603. !
  2604. ! Invoke linear limit for scaling wrt u below min_u_h2o
  2605. !
  2606. if (uvar < min_u_h2o) then
  2607. uscl = uvar / min_u_h2o
  2608. abso(i,ib) = abso(i,ib) * uscl
  2609. endif
  2610. end do
  2611. !
  2612. ! Line transmission in 800-1000 and 1000-1200 cm-1 intervals
  2613. !
  2614. do i=1,ncol
  2615. term7(i,1) = coefj(1,1) + coefj(2,1)*dty(i)*(1. + c16*dty(i))
  2616. term8(i,1) = coefk(1,1) + coefk(2,1)*dty(i)*(1. + c17*dty(i))
  2617. term7(i,2) = coefj(1,2) + coefj(2,2)*dty(i)*(1. + c26*dty(i))
  2618. term8(i,2) = coefk(1,2) + coefk(2,2)*dty(i)*(1. + c27*dty(i))
  2619. end do
  2620. !
  2621. ! 500 - 800 cm-1 h2o rotation band overlap with co2
  2622. !
  2623. do i=1,ncol
  2624. k21 = term7(i,1) + term8(i,1)/ &
  2625. (1. + (c30 + c31*(dty(i)-10.)*(dty(i)-10.))*sqrtu(i))
  2626. k22 = term7(i,2) + term8(i,2)/ &
  2627. (1. + (c28 + c29*(dty(i)-10.))*sqrtu(i))
  2628. tr1 = exp(-(k21*(sqrtu(i) + fc1*fwku(i))))
  2629. tr2 = exp(-(k22*(sqrtu(i) + fc1*fwku(i))))
  2630. tr1=tr1*aer_trn_ttl(i,k1,k2,idx_LW_0650_0800)
  2631. ! ! H2O line+STRAER trn 650--800 cm-1
  2632. tr2=tr2*aer_trn_ttl(i,k1,k2,idx_LW_0500_0650)
  2633. ! ! H2O line+STRAER trn 500--650 cm-1
  2634. tr5 = exp(-((coefh(1,3) + coefh(2,3)*dtx(i))*uc1(i)))
  2635. tr6 = exp(-((coefh(1,4) + coefh(2,4)*dtx(i))*uc1(i)))
  2636. tr9(i) = tr1*tr5
  2637. tr10(i) = tr2*tr6
  2638. th2o(i) = tr10(i)
  2639. trab2(i) = 0.65*tr9(i) + 0.35*tr10(i)
  2640. end do
  2641. if (k2 < k1) then
  2642. do i=1,ncol
  2643. to3h2o(i) = h2otr(i,k1)/h2otr(i,k2)
  2644. end do
  2645. else
  2646. do i=1,ncol
  2647. to3h2o(i) = h2otr(i,k2)/h2otr(i,k1)
  2648. end do
  2649. end if
  2650. !
  2651. ! abso(i,3) o3 9.6 micrometer band (nu3 and nu1 bands)
  2652. !
  2653. do i=1,ncol
  2654. dpnm(i) = pnm(i,k1) - pnm(i,k2)
  2655. to3co2(i) = (pnm(i,k1)*co2t(i,k1) - pnm(i,k2)*co2t(i,k2))/dpnm(i)
  2656. te = (to3co2(i)*r293)**.7
  2657. dplos = plos(i,k1) - plos(i,k2)
  2658. dplol = plol(i,k1) - plol(i,k2)
  2659. u1 = 18.29*abs(dplos)/te
  2660. u2 = .5649*abs(dplos)/te
  2661. rphat = dplol/dplos
  2662. tlocal = tint(i,k2)
  2663. tcrfac = sqrt(tlocal*r250)*te
  2664. beta = r3205*(rphat + dpfo3*tcrfac)
  2665. realnu = te/beta
  2666. tmp1 = u1/sqrt(4. + u1*(1. + realnu))
  2667. tmp2 = u2/sqrt(4. + u2*(1. + realnu))
  2668. o3bndi = 74.*te*log(1. + tmp1 + tmp2)
  2669. abso(i,3) = o3bndi*to3h2o(i)*dbvtit(i,k2)
  2670. to3(i) = 1.0/(1. + 0.1*tmp1 + 0.1*tmp2)
  2671. end do
  2672. !
  2673. ! abso(i,4) co2 15 micrometer band system
  2674. !
  2675. do i=1,ncol
  2676. sqwp = sqrt(abs(plco2(i,k1) - plco2(i,k2)))
  2677. et = exp(-480./to3co2(i))
  2678. sqti(i) = sqrt(to3co2(i))
  2679. rsqti = 1./sqti(i)
  2680. et2 = et*et
  2681. et4 = et2*et2
  2682. omet = 1. - 1.5*et2
  2683. f1co2 = 899.70*omet*(1. + 1.94774*et + 4.73486*et2)*rsqti
  2684. f1sqwp(i) = f1co2*sqwp
  2685. t1co2(i) = 1./(1. + (245.18*omet*sqwp*rsqti))
  2686. oneme = 1. - et2
  2687. alphat = oneme**3*rsqti
  2688. pi = abs(dpnm(i))
  2689. wco2 = 2.5221*co2vmr*pi*rga
  2690. u7(i) = 4.9411e4*alphat*et2*wco2
  2691. u8 = 3.9744e4*alphat*et4*wco2
  2692. u9 = 1.0447e5*alphat*et4*et2*wco2
  2693. u13 = 2.8388e3*alphat*et4*wco2
  2694. tpath = to3co2(i)
  2695. tlocal = tint(i,k2)
  2696. tcrfac = sqrt(tlocal*r250*tpath*r300)
  2697. posqt = ((pnm(i,k2) + pnm(i,k1))*r2sslp + dpfco2*tcrfac)*rsqti
  2698. rbeta7(i) = 1./(5.3228*posqt)
  2699. rbeta8 = 1./(10.6576*posqt)
  2700. rbeta9 = rbeta7(i)
  2701. rbeta13 = rbeta9
  2702. f2co2(i) = (u7(i)/sqrt(4. + u7(i)*(1. + rbeta7(i)))) + &
  2703. (u8 /sqrt(4. + u8*(1. + rbeta8))) + &
  2704. (u9 /sqrt(4. + u9*(1. + rbeta9)))
  2705. f3co2(i) = u13/sqrt(4. + u13*(1. + rbeta13))
  2706. end do
  2707. if (k2 >= k1) then
  2708. do i=1,ncol
  2709. sqti(i) = sqrt(tlayr(i,k2))
  2710. end do
  2711. end if
  2712. !
  2713. do i=1,ncol
  2714. tmp1 = log(1. + f1sqwp(i))
  2715. tmp2 = log(1. + f2co2(i))
  2716. tmp3 = log(1. + f3co2(i))
  2717. absbnd = (tmp1 + 2.*t1co2(i)*tmp2 + 2.*tmp3)*sqti(i)
  2718. abso(i,4) = trab2(i)*co2em(i,k2)*absbnd
  2719. tco2(i) = 1./(1.0+10.0*(u7(i)/sqrt(4. + u7(i)*(1. + rbeta7(i)))))
  2720. end do
  2721. !
  2722. ! Calculate absorptivity due to trace gases, abstrc
  2723. !
  2724. call trcab( lchnk ,ncol ,pcols, pverp, &
  2725. k1 ,k2 ,ucfc11 ,ucfc12 ,un2o0 , &
  2726. un2o1 ,uch4 ,uco211 ,uco212 ,uco213 , &
  2727. uco221 ,uco222 ,uco223 ,bn2o0 ,bn2o1 , &
  2728. bch4 ,to3co2 ,pnm ,dw ,pnew , &
  2729. s2c ,uptype ,u ,abplnk1 ,tco2 , &
  2730. th2o ,to3 ,abstrc , &
  2731. aer_trn_ttl)
  2732. !
  2733. ! Sum total absorptivity
  2734. !
  2735. do i=1,ncol
  2736. abstot(i,k1,k2) = abso(i,1) + abso(i,2) + &
  2737. abso(i,3) + abso(i,4) + abstrc(i)
  2738. end do
  2739. end do ! do k2 =
  2740. end do ! do k1 =
  2741. !
  2742. ! Adjacent layer absorptivity:
  2743. !
  2744. ! abso(i,1) 0 - 800 cm-1 h2o rotation band
  2745. ! abso(i,1) 1200 - 2200 cm-1 h2o vibration-rotation band
  2746. ! abso(i,2) 800 - 1200 cm-1 h2o window
  2747. !
  2748. ! Separation between rotation and vibration-rotation dropped, so
  2749. ! only 2 slots needed for H2O absorptivity
  2750. !
  2751. ! 500-800 cm^-1 H2o continuum/line overlap already included
  2752. ! in abso(i,1). This used to be in abso(i,4)
  2753. !
  2754. ! abso(i,3) o3 9.6 micrometer band (nu3 and nu1 bands)
  2755. ! abso(i,4) co2 15 micrometer band system
  2756. !
  2757. ! Nearest layer level loop
  2758. !
  2759. do k2=pver,ntoplw,-1
  2760. do i=1,ncol
  2761. tbar(i,1) = 0.5*(tint(i,k2+1) + tlayr(i,k2+1))
  2762. emm(i,1) = 0.5*(co2em(i,k2+1) + co2eml(i,k2))
  2763. tbar(i,2) = 0.5*(tlayr(i,k2+1) + tint(i,k2))
  2764. emm(i,2) = 0.5*(co2em(i,k2) + co2eml(i,k2))
  2765. tbar(i,3) = 0.5*(tbar(i,2) + tbar(i,1))
  2766. emm(i,3) = emm(i,1)
  2767. tbar(i,4) = tbar(i,3)
  2768. emm(i,4) = emm(i,2)
  2769. o3emm(i,1) = 0.5*(dbvtit(i,k2+1) + dbvtly(i,k2))
  2770. o3emm(i,2) = 0.5*(dbvtit(i,k2) + dbvtly(i,k2))
  2771. o3emm(i,3) = o3emm(i,1)
  2772. o3emm(i,4) = o3emm(i,2)
  2773. temh2o(i,1) = tbar(i,1)
  2774. temh2o(i,2) = tbar(i,2)
  2775. temh2o(i,3) = tbar(i,1)
  2776. temh2o(i,4) = tbar(i,2)
  2777. dpnm(i) = pnm(i,k2+1) - pnm(i,k2)
  2778. end do
  2779. !
  2780. ! Weighted Planck functions for trace gases
  2781. !
  2782. do wvl = 1,14
  2783. do i = 1,ncol
  2784. bplnk(wvl,i,1) = 0.5*(abplnk1(wvl,i,k2+1) + abplnk2(wvl,i,k2))
  2785. bplnk(wvl,i,2) = 0.5*(abplnk1(wvl,i,k2) + abplnk2(wvl,i,k2))
  2786. bplnk(wvl,i,3) = bplnk(wvl,i,1)
  2787. bplnk(wvl,i,4) = bplnk(wvl,i,2)
  2788. end do
  2789. end do
  2790. do i=1,ncol
  2791. rdpnmsq = 1./(pnmsq(i,k2+1) - pnmsq(i,k2))
  2792. rdpnm = 1./dpnm(i)
  2793. p1 = .5*(pbr(i,k2) + pnm(i,k2+1))
  2794. p2 = .5*(pbr(i,k2) + pnm(i,k2 ))
  2795. uinpl(i,1) = (pnmsq(i,k2+1) - p1**2)*rdpnmsq
  2796. uinpl(i,2) = -(pnmsq(i,k2 ) - p2**2)*rdpnmsq
  2797. uinpl(i,3) = -(pnmsq(i,k2 ) - p1**2)*rdpnmsq
  2798. uinpl(i,4) = (pnmsq(i,k2+1) - p2**2)*rdpnmsq
  2799. winpl(i,1) = (.5*( pnm(i,k2+1) - pbr(i,k2)))*rdpnm
  2800. winpl(i,2) = (.5*(-pnm(i,k2 ) + pbr(i,k2)))*rdpnm
  2801. winpl(i,3) = (.5*( pnm(i,k2+1) + pbr(i,k2)) - pnm(i,k2 ))*rdpnm
  2802. winpl(i,4) = (.5*(-pnm(i,k2 ) - pbr(i,k2)) + pnm(i,k2+1))*rdpnm
  2803. tmp1 = 1./(piln(i,k2+1) - piln(i,k2))
  2804. tmp2 = piln(i,k2+1) - pmln(i,k2)
  2805. tmp3 = piln(i,k2 ) - pmln(i,k2)
  2806. zinpl(i,1) = (.5*tmp2 )*tmp1
  2807. zinpl(i,2) = ( - .5*tmp3)*tmp1
  2808. zinpl(i,3) = (.5*tmp2 - tmp3)*tmp1
  2809. zinpl(i,4) = ( tmp2 - .5*tmp3)*tmp1
  2810. pinpl(i,1) = 0.5*(p1 + pnm(i,k2+1))
  2811. pinpl(i,2) = 0.5*(p2 + pnm(i,k2 ))
  2812. pinpl(i,3) = 0.5*(p1 + pnm(i,k2 ))
  2813. pinpl(i,4) = 0.5*(p2 + pnm(i,k2+1))
  2814. if(strat_volcanic) then
  2815. aer_pth_ngh(i) = abs(aer_mpp(i,k2)-aer_mpp(i,k2+1))
  2816. endif
  2817. end do
  2818. do kn=1,4
  2819. do i=1,ncol
  2820. u(i) = uinpl(i,kn)*abs(plh2o(i,k2) - plh2o(i,k2+1))
  2821. sqrtu(i) = sqrt(u(i))
  2822. dw(i) = abs(w(i,k2) - w(i,k2+1))
  2823. pnew(i) = u(i)/(winpl(i,kn)*dw(i))
  2824. pnew_mks = pnew(i) * sslp_mks
  2825. t_p = min(max(tbar(i,kn), min_tp_h2o), max_tp_h2o)
  2826. iest = floor(t_p) - min_tp_h2o
  2827. esx = estblh2o(iest) + (estblh2o(iest+1)-estblh2o(iest)) * &
  2828. (t_p - min_tp_h2o - iest)
  2829. qsx = epsilo * esx / (pnew_mks - omeps * esx)
  2830. q_path = dw(i) / ABS(dpnm(i)) / rga
  2831. ds2c = abs(s2c(i,k2) - s2c(i,k2+1))
  2832. uc1(i) = uinpl(i,kn)*ds2c
  2833. pch2o = uc1(i)
  2834. uc1(i) = (uc1(i) + 1.7e-3*u(i))*(1. + 2.*uc1(i))/(1. + 15.*uc1(i))
  2835. dtx(i) = temh2o(i,kn) - 250.
  2836. dty(i) = tbar(i,kn) - 250.
  2837. fwk(i) = fwcoef + fwc1/(1. + fwc2*u(i))
  2838. fwku(i) = fwk(i)*u(i)
  2839. if(strat_volcanic) then
  2840. aer_pth_dlt=uinpl(i,kn)*aer_pth_ngh(i)
  2841. do bnd_idx=1,bnd_nbr_LW
  2842. odap_aer_ttl=abs_cff_mss_aer(bnd_idx) * aer_pth_dlt
  2843. aer_trn_ngh(i,bnd_idx)=exp(-fdif * odap_aer_ttl)
  2844. end do
  2845. else
  2846. aer_trn_ngh(i,:) = 1.0
  2847. endif
  2848. !
  2849. ! Define variables for C/H/E (now C/LT/E) fit
  2850. !
  2851. ! abso(i,1) 0 - 800 cm-1 h2o rotation band
  2852. ! abso(i,1) 1200 - 2200 cm-1 h2o vibration-rotation band
  2853. ! abso(i,2) 800 - 1200 cm-1 h2o window
  2854. !
  2855. ! Separation between rotation and vibration-rotation dropped, so
  2856. ! only 2 slots needed for H2O absorptivity
  2857. !
  2858. ! Notation:
  2859. ! U = integral (P/P_0 dW)
  2860. ! P = atmospheric pressure
  2861. ! P_0 = reference atmospheric pressure
  2862. ! W = precipitable water path
  2863. ! T_e = emission temperature
  2864. ! T_p = path temperature
  2865. ! RH = path relative humidity
  2866. !
  2867. !
  2868. ! Terms for asymptotic value of emissivity
  2869. !
  2870. te1 = temh2o(i,kn)
  2871. te2 = te1 * te1
  2872. te3 = te2 * te1
  2873. te4 = te3 * te1
  2874. te5 = te4 * te1
  2875. !
  2876. ! Indices for lines and continuum tables
  2877. ! Note: because we are dealing with the nearest layer,
  2878. ! the Hulst-Curtis-Godson corrections
  2879. ! for inhomogeneous paths are not applied.
  2880. !
  2881. uvar = u(i)*fdif
  2882. log_u = min(log10(max(uvar, min_u_h2o)), max_lu_h2o)
  2883. dvar = (log_u - min_lu_h2o) / dlu_h2o
  2884. iu = min(max(int(aint(dvar,r8)) + 1, 1), n_u - 1)
  2885. iu1 = iu + 1
  2886. wu = dvar - floor(dvar)
  2887. wu1 = 1.0 - wu
  2888. log_p = min(log10(max(pnew(i), min_p_h2o)), max_lp_h2o)
  2889. dvar = (log_p - min_lp_h2o) / dlp_h2o
  2890. ip = min(max(int(aint(dvar,r8)) + 1, 1), n_p - 1)
  2891. ip1 = ip + 1
  2892. wp = dvar - floor(dvar)
  2893. wp1 = 1.0 - wp
  2894. dvar = (t_p - min_tp_h2o) / dtp_h2o
  2895. itp = min(max(int(aint(dvar,r8)) + 1, 1), n_tp - 1)
  2896. itp1 = itp + 1
  2897. wtp = dvar - floor(dvar)
  2898. wtp1 = 1.0 - wtp
  2899. t_e = min(max(temh2o(i,kn)-t_p,min_te_h2o),max_te_h2o)
  2900. dvar = (t_e - min_te_h2o) / dte_h2o
  2901. ite = min(max(int(aint(dvar,r8)) + 1, 1), n_te - 1)
  2902. ite1 = ite + 1
  2903. wte = dvar - floor(dvar)
  2904. wte1 = 1.0 - wte
  2905. rh_path = min(max(q_path / qsx, min_rh_h2o), max_rh_h2o)
  2906. dvar = (rh_path - min_rh_h2o) / drh_h2o
  2907. irh = min(max(int(aint(dvar,r8)) + 1, 1), n_rh - 1)
  2908. irh1 = irh + 1
  2909. wrh = dvar - floor(dvar)
  2910. wrh1 = 1.0 - wrh
  2911. w_0_0_ = wtp * wte
  2912. w_0_1_ = wtp * wte1
  2913. w_1_0_ = wtp1 * wte
  2914. w_1_1_ = wtp1 * wte1
  2915. w_0_00 = w_0_0_ * wrh
  2916. w_0_01 = w_0_0_ * wrh1
  2917. w_0_10 = w_0_1_ * wrh
  2918. w_0_11 = w_0_1_ * wrh1
  2919. w_1_00 = w_1_0_ * wrh
  2920. w_1_01 = w_1_0_ * wrh1
  2921. w_1_10 = w_1_1_ * wrh
  2922. w_1_11 = w_1_1_ * wrh1
  2923. w00_00 = wp * w_0_00
  2924. w00_01 = wp * w_0_01
  2925. w00_10 = wp * w_0_10
  2926. w00_11 = wp * w_0_11
  2927. w01_00 = wp * w_1_00
  2928. w01_01 = wp * w_1_01
  2929. w01_10 = wp * w_1_10
  2930. w01_11 = wp * w_1_11
  2931. w10_00 = wp1 * w_0_00
  2932. w10_01 = wp1 * w_0_01
  2933. w10_10 = wp1 * w_0_10
  2934. w10_11 = wp1 * w_0_11
  2935. w11_00 = wp1 * w_1_00
  2936. w11_01 = wp1 * w_1_01
  2937. w11_10 = wp1 * w_1_10
  2938. w11_11 = wp1 * w_1_11
  2939. !
  2940. ! Non-window absorptivity
  2941. !
  2942. ib = 1
  2943. fa = fat(1,ib) + &
  2944. fat(2,ib) * te1 + &
  2945. fat(3,ib) * te2 + &
  2946. fat(4,ib) * te3 + &
  2947. fat(5,ib) * te4 + &
  2948. fat(6,ib) * te5
  2949. a_star = &
  2950. ah2onw(ip , itp , iu , ite , irh ) * w11_11 * wu1 + &
  2951. ah2onw(ip , itp , iu , ite , irh1) * w11_10 * wu1 + &
  2952. ah2onw(ip , itp , iu , ite1, irh ) * w11_01 * wu1 + &
  2953. ah2onw(ip , itp , iu , ite1, irh1) * w11_00 * wu1 + &
  2954. ah2onw(ip , itp , iu1, ite , irh ) * w11_11 * wu + &
  2955. ah2onw(ip , itp , iu1, ite , irh1) * w11_10 * wu + &
  2956. ah2onw(ip , itp , iu1, ite1, irh ) * w11_01 * wu + &
  2957. ah2onw(ip , itp , iu1, ite1, irh1) * w11_00 * wu + &
  2958. ah2onw(ip , itp1, iu , ite , irh ) * w10_11 * wu1 + &
  2959. ah2onw(ip , itp1, iu , ite , irh1) * w10_10 * wu1 + &
  2960. ah2onw(ip , itp1, iu , ite1, irh ) * w10_01 * wu1 + &
  2961. ah2onw(ip , itp1, iu , ite1, irh1) * w10_00 * wu1 + &
  2962. ah2onw(ip , itp1, iu1, ite , irh ) * w10_11 * wu + &
  2963. ah2onw(ip , itp1, iu1, ite , irh1) * w10_10 * wu + &
  2964. ah2onw(ip , itp1, iu1, ite1, irh ) * w10_01 * wu + &
  2965. ah2onw(ip , itp1, iu1, ite1, irh1) * w10_00 * wu + &
  2966. ah2onw(ip1, itp , iu , ite , irh ) * w01_11 * wu1 + &
  2967. ah2onw(ip1, itp , iu , ite , irh1) * w01_10 * wu1 + &
  2968. ah2onw(ip1, itp , iu , ite1, irh ) * w01_01 * wu1 + &
  2969. ah2onw(ip1, itp , iu , ite1, irh1) * w01_00 * wu1 + &
  2970. ah2onw(ip1, itp , iu1, ite , irh ) * w01_11 * wu + &
  2971. ah2onw(ip1, itp , iu1, ite , irh1) * w01_10 * wu + &
  2972. ah2onw(ip1, itp , iu1, ite1, irh ) * w01_01 * wu + &
  2973. ah2onw(ip1, itp , iu1, ite1, irh1) * w01_00 * wu + &
  2974. ah2onw(ip1, itp1, iu , ite , irh ) * w00_11 * wu1 + &
  2975. ah2onw(ip1, itp1, iu , ite , irh1) * w00_10 * wu1 + &
  2976. ah2onw(ip1, itp1, iu , ite1, irh ) * w00_01 * wu1 + &
  2977. ah2onw(ip1, itp1, iu , ite1, irh1) * w00_00 * wu1 + &
  2978. ah2onw(ip1, itp1, iu1, ite , irh ) * w00_11 * wu + &
  2979. ah2onw(ip1, itp1, iu1, ite , irh1) * w00_10 * wu + &
  2980. ah2onw(ip1, itp1, iu1, ite1, irh ) * w00_01 * wu + &
  2981. ah2onw(ip1, itp1, iu1, ite1, irh1) * w00_00 * wu
  2982. abso(i,ib) = min(max(fa * (1.0 - (1.0 - a_star) * &
  2983. aer_trn_ngh(i,ib)), &
  2984. 0.0_r8), 1.0_r8)
  2985. !
  2986. ! Invoke linear limit for scaling wrt u below min_u_h2o
  2987. !
  2988. if (uvar < min_u_h2o) then
  2989. uscl = uvar / min_u_h2o
  2990. abso(i,ib) = abso(i,ib) * uscl
  2991. endif
  2992. !
  2993. ! Window absorptivity
  2994. !
  2995. ib = 2
  2996. fa = fat(1,ib) + &
  2997. fat(2,ib) * te1 + &
  2998. fat(3,ib) * te2 + &
  2999. fat(4,ib) * te3 + &
  3000. fat(5,ib) * te4 + &
  3001. fat(6,ib) * te5
  3002. a_star = &
  3003. ah2ow(ip , itp , iu , ite , irh ) * w11_11 * wu1 + &
  3004. ah2ow(ip , itp , iu , ite , irh1) * w11_10 * wu1 + &
  3005. ah2ow(ip , itp , iu , ite1, irh ) * w11_01 * wu1 + &
  3006. ah2ow(ip , itp , iu , ite1, irh1) * w11_00 * wu1 + &
  3007. ah2ow(ip , itp , iu1, ite , irh ) * w11_11 * wu + &
  3008. ah2ow(ip , itp , iu1, ite , irh1) * w11_10 * wu + &
  3009. ah2ow(ip , itp , iu1, ite1, irh ) * w11_01 * wu + &
  3010. ah2ow(ip , itp , iu1, ite1, irh1) * w11_00 * wu + &
  3011. ah2ow(ip , itp1, iu , ite , irh ) * w10_11 * wu1 + &
  3012. ah2ow(ip , itp1, iu , ite , irh1) * w10_10 * wu1 + &
  3013. ah2ow(ip , itp1, iu , ite1, irh ) * w10_01 * wu1 + &
  3014. ah2ow(ip , itp1, iu , ite1, irh1) * w10_00 * wu1 + &
  3015. ah2ow(ip , itp1, iu1, ite , irh ) * w10_11 * wu + &
  3016. ah2ow(ip , itp1, iu1, ite , irh1) * w10_10 * wu + &
  3017. ah2ow(ip , itp1, iu1, ite1, irh ) * w10_01 * wu + &
  3018. ah2ow(ip , itp1, iu1, ite1, irh1) * w10_00 * wu + &
  3019. ah2ow(ip1, itp , iu , ite , irh ) * w01_11 * wu1 + &
  3020. ah2ow(ip1, itp , iu , ite , irh1) * w01_10 * wu1 + &
  3021. ah2ow(ip1, itp , iu , ite1, irh ) * w01_01 * wu1 + &
  3022. ah2ow(ip1, itp , iu , ite1, irh1) * w01_00 * wu1 + &
  3023. ah2ow(ip1, itp , iu1, ite , irh ) * w01_11 * wu + &
  3024. ah2ow(ip1, itp , iu1, ite , irh1) * w01_10 * wu + &
  3025. ah2ow(ip1, itp , iu1, ite1, irh ) * w01_01 * wu + &
  3026. ah2ow(ip1, itp , iu1, ite1, irh1) * w01_00 * wu + &
  3027. ah2ow(ip1, itp1, iu , ite , irh ) * w00_11 * wu1 + &
  3028. ah2ow(ip1, itp1, iu , ite , irh1) * w00_10 * wu1 + &
  3029. ah2ow(ip1, itp1, iu , ite1, irh ) * w00_01 * wu1 + &
  3030. ah2ow(ip1, itp1, iu , ite1, irh1) * w00_00 * wu1 + &
  3031. ah2ow(ip1, itp1, iu1, ite , irh ) * w00_11 * wu + &
  3032. ah2ow(ip1, itp1, iu1, ite , irh1) * w00_10 * wu + &
  3033. ah2ow(ip1, itp1, iu1, ite1, irh ) * w00_01 * wu + &
  3034. ah2ow(ip1, itp1, iu1, ite1, irh1) * w00_00 * wu
  3035. abso(i,ib) = min(max(fa * (1.0 - (1.0 - a_star) * &
  3036. aer_trn_ngh(i,ib)), &
  3037. 0.0_r8), 1.0_r8)
  3038. !
  3039. ! Invoke linear limit for scaling wrt u below min_u_h2o
  3040. !
  3041. if (uvar < min_u_h2o) then
  3042. uscl = uvar / min_u_h2o
  3043. abso(i,ib) = abso(i,ib) * uscl
  3044. endif
  3045. end do
  3046. !
  3047. ! Line transmission in 800-1000 and 1000-1200 cm-1 intervals
  3048. !
  3049. do i=1,ncol
  3050. term7(i,1) = coefj(1,1) + coefj(2,1)*dty(i)*(1. + c16*dty(i))
  3051. term8(i,1) = coefk(1,1) + coefk(2,1)*dty(i)*(1. + c17*dty(i))
  3052. term7(i,2) = coefj(1,2) + coefj(2,2)*dty(i)*(1. + c26*dty(i))
  3053. term8(i,2) = coefk(1,2) + coefk(2,2)*dty(i)*(1. + c27*dty(i))
  3054. end do
  3055. !
  3056. ! 500 - 800 cm-1 h2o rotation band overlap with co2
  3057. !
  3058. do i=1,ncol
  3059. dtym10 = dty(i) - 10.
  3060. denom = 1. + (c30 + c31*dtym10*dtym10)*sqrtu(i)
  3061. k21 = term7(i,1) + term8(i,1)/denom
  3062. denom = 1. + (c28 + c29*dtym10 )*sqrtu(i)
  3063. k22 = term7(i,2) + term8(i,2)/denom
  3064. tr1 = exp(-(k21*(sqrtu(i) + fc1*fwku(i))))
  3065. tr2 = exp(-(k22*(sqrtu(i) + fc1*fwku(i))))
  3066. tr1=tr1*aer_trn_ngh(i,idx_LW_0650_0800)
  3067. ! ! H2O line+STRAER trn 650--800 cm-1
  3068. tr2=tr2*aer_trn_ngh(i,idx_LW_0500_0650)
  3069. ! ! H2O line+STRAER trn 500--650 cm-1
  3070. tr5 = exp(-((coefh(1,3) + coefh(2,3)*dtx(i))*uc1(i)))
  3071. tr6 = exp(-((coefh(1,4) + coefh(2,4)*dtx(i))*uc1(i)))
  3072. tr9(i) = tr1*tr5
  3073. tr10(i) = tr2*tr6
  3074. trab2(i)= 0.65*tr9(i) + 0.35*tr10(i)
  3075. th2o(i) = tr10(i)
  3076. end do
  3077. !
  3078. ! abso(i,3) o3 9.6 micrometer (nu3 and nu1 bands)
  3079. !
  3080. do i=1,ncol
  3081. te = (tbar(i,kn)*r293)**.7
  3082. dplos = abs(plos(i,k2+1) - plos(i,k2))
  3083. u1 = zinpl(i,kn)*18.29*dplos/te
  3084. u2 = zinpl(i,kn)*.5649*dplos/te
  3085. tlocal = tbar(i,kn)
  3086. tcrfac = sqrt(tlocal*r250)*te
  3087. beta = r3205*(pinpl(i,kn)*rsslp + dpfo3*tcrfac)
  3088. realnu = te/beta
  3089. tmp1 = u1/sqrt(4. + u1*(1. + realnu))
  3090. tmp2 = u2/sqrt(4. + u2*(1. + realnu))
  3091. o3bndi = 74.*te*log(1. + tmp1 + tmp2)
  3092. abso(i,3) = o3bndi*o3emm(i,kn)*(h2otr(i,k2+1)/h2otr(i,k2))
  3093. to3(i) = 1.0/(1. + 0.1*tmp1 + 0.1*tmp2)
  3094. end do
  3095. !
  3096. ! abso(i,4) co2 15 micrometer band system
  3097. !
  3098. do i=1,ncol
  3099. dplco2 = plco2(i,k2+1) - plco2(i,k2)
  3100. sqwp = sqrt(uinpl(i,kn)*dplco2)
  3101. et = exp(-480./tbar(i,kn))
  3102. sqti(i) = sqrt(tbar(i,kn))
  3103. rsqti = 1./sqti(i)
  3104. et2 = et*et
  3105. et4 = et2*et2
  3106. omet = (1. - 1.5*et2)
  3107. f1co2 = 899.70*omet*(1. + 1.94774*et + 4.73486*et2)*rsqti
  3108. f1sqwp(i)= f1co2*sqwp
  3109. t1co2(i) = 1./(1. + (245.18*omet*sqwp*rsqti))
  3110. oneme = 1. - et2
  3111. alphat = oneme**3*rsqti
  3112. pi = abs(dpnm(i))*winpl(i,kn)
  3113. wco2 = 2.5221*co2vmr*pi*rga
  3114. u7(i) = 4.9411e4*alphat*et2*wco2
  3115. u8 = 3.9744e4*alphat*et4*wco2
  3116. u9 = 1.0447e5*alphat*et4*et2*wco2
  3117. u13 = 2.8388e3*alphat*et4*wco2
  3118. tpath = tbar(i,kn)
  3119. tlocal = tbar(i,kn)
  3120. tcrfac = sqrt((tlocal*r250)*(tpath*r300))
  3121. posqt = (pinpl(i,kn)*rsslp + dpfco2*tcrfac)*rsqti
  3122. rbeta7(i)= 1./(5.3228*posqt)
  3123. rbeta8 = 1./(10.6576*posqt)
  3124. rbeta9 = rbeta7(i)
  3125. rbeta13 = rbeta9
  3126. f2co2(i) = u7(i)/sqrt(4. + u7(i)*(1. + rbeta7(i))) + &
  3127. u8 /sqrt(4. + u8*(1. + rbeta8)) + &
  3128. u9 /sqrt(4. + u9*(1. + rbeta9))
  3129. f3co2(i) = u13/sqrt(4. + u13*(1. + rbeta13))
  3130. tmp1 = log(1. + f1sqwp(i))
  3131. tmp2 = log(1. + f2co2(i))
  3132. tmp3 = log(1. + f3co2(i))
  3133. absbnd = (tmp1 + 2.*t1co2(i)*tmp2 + 2.*tmp3)*sqti(i)
  3134. abso(i,4)= trab2(i)*emm(i,kn)*absbnd
  3135. tco2(i) = 1.0/(1.0+ 10.0*u7(i)/sqrt(4. + u7(i)*(1. + rbeta7(i))))
  3136. end do ! do i =
  3137. !
  3138. ! Calculate trace gas absorptivity for nearest layer, abstrc
  3139. !
  3140. call trcabn(lchnk ,ncol ,pcols, pverp, &
  3141. k2 ,kn ,ucfc11 ,ucfc12 ,un2o0 , &
  3142. un2o1 ,uch4 ,uco211 ,uco212 ,uco213 , &
  3143. uco221 ,uco222 ,uco223 ,tbar ,bplnk , &
  3144. winpl ,pinpl ,tco2 ,th2o ,to3 , &
  3145. uptype ,dw ,s2c ,u ,pnew , &
  3146. abstrc ,uinpl , &
  3147. aer_trn_ngh)
  3148. !
  3149. ! Total next layer absorptivity:
  3150. !
  3151. do i=1,ncol
  3152. absnxt(i,k2,kn) = abso(i,1) + abso(i,2) + &
  3153. abso(i,3) + abso(i,4) + abstrc(i)
  3154. end do
  3155. end do ! do kn =
  3156. end do ! do k2 =
  3157. return
  3158. end subroutine radabs
  3159. subroutine radems(lchnk ,ncol ,pcols, pver, pverp, &
  3160. s2c ,tcg ,w ,tplnke ,plh2o , &
  3161. pnm ,plco2 ,tint ,tint4 ,tlayr , &
  3162. tlayr4 ,plol ,plos ,ucfc11 ,ucfc12 , &
  3163. un2o0 ,un2o1 ,uch4 ,uco211 ,uco212 , &
  3164. uco213 ,uco221 ,uco222 ,uco223 ,uptype , &
  3165. bn2o0 ,bn2o1 ,bch4 ,co2em ,co2eml , &
  3166. co2t ,h2otr ,abplnk1 ,abplnk2 ,emstot , &
  3167. plh2ob ,wb , &
  3168. aer_trn_ttl)
  3169. !-----------------------------------------------------------------------
  3170. !
  3171. ! Purpose:
  3172. ! Compute emissivity for H2O, CO2, O3, CH4, N2O, CFC11 and CFC12
  3173. !
  3174. ! Method:
  3175. ! H2O .... Uses nonisothermal emissivity method for water vapor from
  3176. ! Ramanathan, V. and P.Downey, 1986: A Nonisothermal
  3177. ! Emissivity and Absorptivity Formulation for Water Vapor
  3178. ! Jouranl of Geophysical Research, vol. 91., D8, pp 8649-8666
  3179. !
  3180. ! Implementation updated by Collins,Hackney, and Edwards 2001
  3181. ! using line-by-line calculations based upon Hitran 1996 and
  3182. ! CKD 2.1 for absorptivity and emissivity
  3183. !
  3184. ! Implementation updated by Collins, Lee-Taylor, and Edwards (2003)
  3185. ! using line-by-line calculations based upon Hitran 2000 and
  3186. ! CKD 2.4 for absorptivity and emissivity
  3187. !
  3188. ! CO2 .... Uses absorptance parameterization of the 15 micro-meter
  3189. ! (500 - 800 cm-1) band system of Carbon Dioxide, from
  3190. ! Kiehl, J.T. and B.P.Briegleb, 1991: A New Parameterization
  3191. ! of the Absorptance Due to the 15 micro-meter Band System
  3192. ! of Carbon Dioxide Jouranl of Geophysical Research,
  3193. ! vol. 96., D5, pp 9013-9019. Also includes the effects
  3194. ! of the 9.4 and 10.4 micron bands of CO2.
  3195. !
  3196. ! O3 .... Uses absorptance parameterization of the 9.6 micro-meter
  3197. ! band system of ozone, from Ramanathan, V. and R. Dickinson,
  3198. ! 1979: The Role of stratospheric ozone in the zonal and
  3199. ! seasonal radiative energy balance of the earth-troposphere
  3200. ! system. Journal of the Atmospheric Sciences, Vol. 36,
  3201. ! pp 1084-1104
  3202. !
  3203. ! ch4 .... Uses a broad band model for the 7.7 micron band of methane.
  3204. !
  3205. ! n20 .... Uses a broad band model for the 7.8, 8.6 and 17.0 micron
  3206. ! bands of nitrous oxide
  3207. !
  3208. ! cfc11 ... Uses a quasi-linear model for the 9.2, 10.7, 11.8 and 12.5
  3209. ! micron bands of CFC11
  3210. !
  3211. ! cfc12 ... Uses a quasi-linear model for the 8.6, 9.1, 10.8 and 11.2
  3212. ! micron bands of CFC12
  3213. !
  3214. !
  3215. ! Computes individual emissivities, accounting for band overlap, and
  3216. ! sums to obtain the total.
  3217. !
  3218. ! Author: W. Collins (H2O emissivity) and J. Kiehl
  3219. !
  3220. !-----------------------------------------------------------------------
  3221. !------------------------------Arguments--------------------------------
  3222. !
  3223. ! Input arguments
  3224. !
  3225. integer, intent(in) :: lchnk ! chunk identifier
  3226. integer, intent(in) :: ncol ! number of atmospheric columns
  3227. integer, intent(in) :: pcols, pver, pverp
  3228. real(r8), intent(in) :: s2c(pcols,pverp) ! H2o continuum path length
  3229. real(r8), intent(in) :: tcg(pcols,pverp) ! H2o-mass-wgted temp. (Curtis-Godson approx.)
  3230. real(r8), intent(in) :: w(pcols,pverp) ! H2o path length
  3231. real(r8), intent(in) :: tplnke(pcols) ! Layer planck temperature
  3232. real(r8), intent(in) :: plh2o(pcols,pverp) ! H2o prs wghted path length
  3233. real(r8), intent(in) :: pnm(pcols,pverp) ! Model interface pressure
  3234. real(r8), intent(in) :: plco2(pcols,pverp) ! Prs wghted path of co2
  3235. real(r8), intent(in) :: tint(pcols,pverp) ! Model interface temperatures
  3236. real(r8), intent(in) :: tint4(pcols,pverp) ! Tint to the 4th power
  3237. real(r8), intent(in) :: tlayr(pcols,pverp) ! K-1 model layer temperature
  3238. real(r8), intent(in) :: tlayr4(pcols,pverp) ! Tlayr to the 4th power
  3239. real(r8), intent(in) :: plol(pcols,pverp) ! Pressure wghtd ozone path
  3240. real(r8), intent(in) :: plos(pcols,pverp) ! Ozone path
  3241. real(r8), intent(in) :: plh2ob(nbands,pcols,pverp) ! Pressure weighted h2o path with
  3242. ! Hulst-Curtis-Godson temp. factor
  3243. ! for H2O bands
  3244. real(r8), intent(in) :: wb(nbands,pcols,pverp) ! H2o path length with
  3245. ! Hulst-Curtis-Godson temp. factor
  3246. ! for H2O bands
  3247. real(r8), intent(in) :: aer_trn_ttl(pcols,pverp,pverp,bnd_nbr_LW)
  3248. ! ! [fraction] Total strat. aerosol
  3249. ! ! transmission between interfaces k1 and k2
  3250. !
  3251. ! Trace gas variables
  3252. !
  3253. real(r8), intent(in) :: ucfc11(pcols,pverp) ! CFC11 path length
  3254. real(r8), intent(in) :: ucfc12(pcols,pverp) ! CFC12 path length
  3255. real(r8), intent(in) :: un2o0(pcols,pverp) ! N2O path length
  3256. real(r8), intent(in) :: un2o1(pcols,pverp) ! N2O path length (hot band)
  3257. real(r8), intent(in) :: uch4(pcols,pverp) ! CH4 path length
  3258. real(r8), intent(in) :: uco211(pcols,pverp) ! CO2 9.4 micron band path length
  3259. real(r8), intent(in) :: uco212(pcols,pverp) ! CO2 9.4 micron band path length
  3260. real(r8), intent(in) :: uco213(pcols,pverp) ! CO2 9.4 micron band path length
  3261. real(r8), intent(in) :: uco221(pcols,pverp) ! CO2 10.4 micron band path length
  3262. real(r8), intent(in) :: uco222(pcols,pverp) ! CO2 10.4 micron band path length
  3263. real(r8), intent(in) :: uco223(pcols,pverp) ! CO2 10.4 micron band path length
  3264. real(r8), intent(in) :: bn2o0(pcols,pverp) ! pressure factor for n2o
  3265. real(r8), intent(in) :: bn2o1(pcols,pverp) ! pressure factor for n2o
  3266. real(r8), intent(in) :: bch4(pcols,pverp) ! pressure factor for ch4
  3267. real(r8), intent(in) :: uptype(pcols,pverp) ! p-type continuum path length
  3268. !
  3269. ! Output arguments
  3270. !
  3271. real(r8), intent(out) :: emstot(pcols,pverp) ! Total emissivity
  3272. real(r8), intent(out) :: co2em(pcols,pverp) ! Layer co2 normalzd plnck funct drvtv
  3273. real(r8), intent(out) :: co2eml(pcols,pver) ! Intrfc co2 normalzd plnck func drvtv
  3274. real(r8), intent(out) :: co2t(pcols,pverp) ! Tmp and prs weighted path length
  3275. real(r8), intent(out) :: h2otr(pcols,pverp) ! H2o transmission over o3 band
  3276. real(r8), intent(out) :: abplnk1(14,pcols,pverp) ! non-nearest layer Plack factor
  3277. real(r8), intent(out) :: abplnk2(14,pcols,pverp) ! nearest layer factor
  3278. !
  3279. !---------------------------Local variables-----------------------------
  3280. !
  3281. integer i ! Longitude index
  3282. integer k ! Level index]
  3283. integer k1 ! Level index
  3284. !
  3285. ! Local variables for H2O:
  3286. !
  3287. real(r8) h2oems(pcols,pverp) ! H2o emissivity
  3288. real(r8) tpathe ! Used to compute h2o emissivity
  3289. real(r8) dtx(pcols) ! Planck temperature minus 250 K
  3290. real(r8) dty(pcols) ! Path temperature minus 250 K
  3291. !
  3292. ! The 500-800 cm^-1 emission in emis(i,4) has been combined
  3293. ! into the 0-800 cm^-1 emission in emis(i,1)
  3294. !
  3295. real(r8) emis(pcols,2) ! H2O emissivity
  3296. !
  3297. !
  3298. !
  3299. real(r8) term7(pcols,2) ! Kl_inf(i) in eq(r8) of table A3a of R&D
  3300. real(r8) term8(pcols,2) ! Delta kl_inf(i) in eq(r8)
  3301. real(r8) tr1(pcols) ! Equation(6) in table A2 for 650-800
  3302. real(r8) tr2(pcols) ! Equation(6) in table A2 for 500-650
  3303. real(r8) tr3(pcols) ! Equation(4) in table A2 for 650-800
  3304. real(r8) tr4(pcols) ! Equation(4),table A2 of R&D for 500-650
  3305. real(r8) tr7(pcols) ! Equation (6) times eq(4) in table A2
  3306. ! of R&D for 650-800 cm-1 region
  3307. real(r8) tr8(pcols) ! Equation (6) times eq(4) in table A2
  3308. ! of R&D for 500-650 cm-1 region
  3309. real(r8) k21(pcols) ! Exponential coefficient used to calc
  3310. ! rot band transmissivity in the 650-800
  3311. ! cm-1 region (tr1)
  3312. real(r8) k22(pcols) ! Exponential coefficient used to calc
  3313. ! rot band transmissivity in the 500-650
  3314. ! cm-1 region (tr2)
  3315. real(r8) u(pcols) ! Pressure weighted H2O path length
  3316. real(r8) ub(nbands) ! Pressure weighted H2O path length with
  3317. ! Hulst-Curtis-Godson correction for
  3318. ! each band
  3319. real(r8) pnew ! Effective pressure for h2o linewidth
  3320. real(r8) pnewb(nbands) ! Effective pressure for h2o linewidth w/
  3321. ! Hulst-Curtis-Godson correction for
  3322. ! each band
  3323. real(r8) uc1(pcols) ! H2o continuum pathlength 500-800 cm-1
  3324. real(r8) fwk ! Equation(33) in R&D far wing correction
  3325. real(r8) troco2(pcols,pverp) ! H2o overlap factor for co2 absorption
  3326. real(r8) emplnk(14,pcols) ! emissivity Planck factor
  3327. real(r8) emstrc(pcols,pverp) ! total trace gas emissivity
  3328. !
  3329. ! Local variables for CO2:
  3330. !
  3331. real(r8) co2ems(pcols,pverp) ! Co2 emissivity
  3332. real(r8) co2plk(pcols) ! Used to compute co2 emissivity
  3333. real(r8) sum(pcols) ! Used to calculate path temperature
  3334. real(r8) t1i ! Co2 hot band temperature factor
  3335. real(r8) sqti ! Sqrt of temperature
  3336. real(r8) pi ! Pressure used in co2 mean line width
  3337. real(r8) et ! Co2 hot band factor
  3338. real(r8) et2 ! Co2 hot band factor
  3339. real(r8) et4 ! Co2 hot band factor
  3340. real(r8) omet ! Co2 stimulated emission term
  3341. real(r8) ex ! Part of co2 planck function
  3342. real(r8) f1co2 ! Co2 weak band factor
  3343. real(r8) f2co2 ! Co2 weak band factor
  3344. real(r8) f3co2 ! Co2 weak band factor
  3345. real(r8) t1co2 ! Overlap factor weak bands strong band
  3346. real(r8) sqwp ! Sqrt of co2 pathlength
  3347. real(r8) f1sqwp ! Main co2 band factor
  3348. real(r8) oneme ! Co2 stimulated emission term
  3349. real(r8) alphat ! Part of the co2 stimulated emiss term
  3350. real(r8) wco2 ! Consts used to define co2 pathlength
  3351. real(r8) posqt ! Effective pressure for co2 line width
  3352. real(r8) rbeta7 ! Inverse of co2 hot band line width par
  3353. real(r8) rbeta8 ! Inverse of co2 hot band line width par
  3354. real(r8) rbeta9 ! Inverse of co2 hot band line width par
  3355. real(r8) rbeta13 ! Inverse of co2 hot band line width par
  3356. real(r8) tpath ! Path temp used in co2 band model
  3357. real(r8) tmp1 ! Co2 band factor
  3358. real(r8) tmp2 ! Co2 band factor
  3359. real(r8) tmp3 ! Co2 band factor
  3360. real(r8) tlayr5 ! Temperature factor in co2 Planck func
  3361. real(r8) rsqti ! Reciprocal of sqrt of temperature
  3362. real(r8) exm1sq ! Part of co2 Planck function
  3363. real(r8) u7 ! Absorber amt for various co2 band systems
  3364. real(r8) u8 ! Absorber amt for various co2 band systems
  3365. real(r8) u9 ! Absorber amt for various co2 band systems
  3366. real(r8) u13 ! Absorber amt for various co2 band systems
  3367. real(r8) r250 ! Inverse 250K
  3368. real(r8) r300 ! Inverse 300K
  3369. real(r8) rsslp ! Inverse standard sea-level pressure
  3370. !
  3371. ! Local variables for O3:
  3372. !
  3373. real(r8) o3ems(pcols,pverp) ! Ozone emissivity
  3374. real(r8) dbvtt(pcols) ! Tmp drvtv of planck fctn for tplnke
  3375. real(r8) dbvt,fo3,t,ux,vx
  3376. real(r8) te ! Temperature factor
  3377. real(r8) u1 ! Path length factor
  3378. real(r8) u2 ! Path length factor
  3379. real(r8) phat ! Effecitive path length pressure
  3380. real(r8) tlocal ! Local planck function temperature
  3381. real(r8) tcrfac ! Scaled temperature factor
  3382. real(r8) beta ! Absorption funct factor voigt effect
  3383. real(r8) realnu ! Absorption function factor
  3384. real(r8) o3bndi ! Band absorption factor
  3385. !
  3386. ! Transmission terms for various spectral intervals:
  3387. !
  3388. real(r8) absbnd ! Proportional to co2 band absorptance
  3389. real(r8) tco2(pcols) ! co2 overlap factor
  3390. real(r8) th2o(pcols) ! h2o overlap factor
  3391. real(r8) to3(pcols) ! o3 overlap factor
  3392. !
  3393. ! Variables for new H2O parameterization
  3394. !
  3395. ! Notation:
  3396. ! U = integral (P/P_0 dW) eq. 15 in Ramanathan/Downey 1986
  3397. ! P = atmospheric pressure
  3398. ! P_0 = reference atmospheric pressure
  3399. ! W = precipitable water path
  3400. ! T_e = emission temperature
  3401. ! T_p = path temperature
  3402. ! RH = path relative humidity
  3403. !
  3404. real(r8) fe ! asymptotic value of emis. as U->infinity
  3405. real(r8) e_star ! normalized non-window emissivity
  3406. real(r8) l_star ! interpolated line transmission
  3407. real(r8) c_star ! interpolated continuum transmission
  3408. real(r8) te1 ! emission temperature
  3409. real(r8) te2 ! te^2
  3410. real(r8) te3 ! te^3
  3411. real(r8) te4 ! te^4
  3412. real(r8) te5 ! te^5
  3413. real(r8) log_u ! log base 10 of U
  3414. real(r8) log_uc ! log base 10 of H2O continuum path
  3415. real(r8) log_p ! log base 10 of P
  3416. real(r8) t_p ! T_p
  3417. real(r8) t_e ! T_e (offset by T_p)
  3418. integer iu ! index for log10(U)
  3419. integer iu1 ! iu + 1
  3420. integer iuc ! index for log10(H2O continuum path)
  3421. integer iuc1 ! iuc + 1
  3422. integer ip ! index for log10(P)
  3423. integer ip1 ! ip + 1
  3424. integer itp ! index for T_p
  3425. integer itp1 ! itp + 1
  3426. integer ite ! index for T_e
  3427. integer ite1 ! ite + 1
  3428. integer irh ! index for RH
  3429. integer irh1 ! irh + 1
  3430. real(r8) dvar ! normalized variation in T_p/T_e/P/U
  3431. real(r8) uvar ! U * diffusivity factor
  3432. real(r8) uscl ! factor for lineary scaling as U->0
  3433. real(r8) wu ! weight for U
  3434. real(r8) wu1 ! 1 - wu
  3435. real(r8) wuc ! weight for H2O continuum path
  3436. real(r8) wuc1 ! 1 - wuc
  3437. real(r8) wp ! weight for P
  3438. real(r8) wp1 ! 1 - wp
  3439. real(r8) wtp ! weight for T_p
  3440. real(r8) wtp1 ! 1 - wtp
  3441. real(r8) wte ! weight for T_e
  3442. real(r8) wte1 ! 1 - wte
  3443. real(r8) wrh ! weight for RH
  3444. real(r8) wrh1 ! 1 - wrh
  3445. real(r8) w_0_0_ ! weight for Tp/Te combination
  3446. real(r8) w_0_1_ ! weight for Tp/Te combination
  3447. real(r8) w_1_0_ ! weight for Tp/Te combination
  3448. real(r8) w_1_1_ ! weight for Tp/Te combination
  3449. real(r8) w_0_00 ! weight for Tp/Te/RH combination
  3450. real(r8) w_0_01 ! weight for Tp/Te/RH combination
  3451. real(r8) w_0_10 ! weight for Tp/Te/RH combination
  3452. real(r8) w_0_11 ! weight for Tp/Te/RH combination
  3453. real(r8) w_1_00 ! weight for Tp/Te/RH combination
  3454. real(r8) w_1_01 ! weight for Tp/Te/RH combination
  3455. real(r8) w_1_10 ! weight for Tp/Te/RH combination
  3456. real(r8) w_1_11 ! weight for Tp/Te/RH combination
  3457. real(r8) w00_00 ! weight for P/Tp/Te/RH combination
  3458. real(r8) w00_01 ! weight for P/Tp/Te/RH combination
  3459. real(r8) w00_10 ! weight for P/Tp/Te/RH combination
  3460. real(r8) w00_11 ! weight for P/Tp/Te/RH combination
  3461. real(r8) w01_00 ! weight for P/Tp/Te/RH combination
  3462. real(r8) w01_01 ! weight for P/Tp/Te/RH combination
  3463. real(r8) w01_10 ! weight for P/Tp/Te/RH combination
  3464. real(r8) w01_11 ! weight for P/Tp/Te/RH combination
  3465. real(r8) w10_00 ! weight for P/Tp/Te/RH combination
  3466. real(r8) w10_01 ! weight for P/Tp/Te/RH combination
  3467. real(r8) w10_10 ! weight for P/Tp/Te/RH combination
  3468. real(r8) w10_11 ! weight for P/Tp/Te/RH combination
  3469. real(r8) w11_00 ! weight for P/Tp/Te/RH combination
  3470. real(r8) w11_01 ! weight for P/Tp/Te/RH combination
  3471. real(r8) w11_10 ! weight for P/Tp/Te/RH combination
  3472. real(r8) w11_11 ! weight for P/Tp/Te/RH combination
  3473. integer ib ! spectral interval:
  3474. ! 1 = 0-800 cm^-1 and 1200-2200 cm^-1
  3475. ! 2 = 800-1200 cm^-1
  3476. real(r8) pch2o ! H2O continuum path
  3477. real(r8) fch2o ! temp. factor for continuum
  3478. real(r8) uch2o ! U corresponding to H2O cont. path (window)
  3479. real(r8) fdif ! secant(zenith angle) for diffusivity approx.
  3480. real(r8) sslp_mks ! Sea-level pressure in MKS units
  3481. real(r8) esx ! saturation vapor pressure returned by vqsatd
  3482. real(r8) qsx ! saturation mixing ratio returned by vqsatd
  3483. real(r8) pnew_mks ! pnew in MKS units
  3484. real(r8) q_path ! effective specific humidity along path
  3485. real(r8) rh_path ! effective relative humidity along path
  3486. real(r8) omeps ! 1 - epsilo
  3487. integer iest ! index in estblh2o
  3488. !
  3489. !---------------------------Statement functions-------------------------
  3490. !
  3491. ! Derivative of planck function at 9.6 micro-meter wavelength, and
  3492. ! an absorption function factor:
  3493. !
  3494. !
  3495. dbvt(t)=(-2.8911366682e-4+(2.3771251896e-6+1.1305188929e-10*t)*t)/ &
  3496. (1.0+(-6.1364820707e-3+1.5550319767e-5*t)*t)
  3497. !
  3498. fo3(ux,vx)=ux/sqrt(4.+ux*(1.+vx))
  3499. !
  3500. !
  3501. !
  3502. !-----------------------------------------------------------------------
  3503. !
  3504. ! Initialize
  3505. !
  3506. r250 = 1./250.
  3507. r300 = 1./300.
  3508. rsslp = 1./sslp
  3509. !
  3510. ! Constants for computing U corresponding to H2O cont. path
  3511. !
  3512. fdif = 1.66
  3513. sslp_mks = sslp / 10.0
  3514. omeps = 1.0 - epsilo
  3515. !
  3516. ! Planck function for co2
  3517. !
  3518. do i=1,ncol
  3519. ex = exp(960./tplnke(i))
  3520. co2plk(i) = 5.e8/((tplnke(i)**4)*(ex - 1.))
  3521. co2t(i,ntoplw) = tplnke(i)
  3522. sum(i) = co2t(i,ntoplw)*pnm(i,ntoplw)
  3523. end do
  3524. k = ntoplw
  3525. do k1=pverp,ntoplw+1,-1
  3526. k = k + 1
  3527. do i=1,ncol
  3528. sum(i) = sum(i) + tlayr(i,k)*(pnm(i,k)-pnm(i,k-1))
  3529. ex = exp(960./tlayr(i,k1))
  3530. tlayr5 = tlayr(i,k1)*tlayr4(i,k1)
  3531. co2eml(i,k1-1) = 1.2e11*ex/(tlayr5*(ex - 1.)**2)
  3532. co2t(i,k) = sum(i)/pnm(i,k)
  3533. end do
  3534. end do
  3535. !
  3536. ! Initialize planck function derivative for O3
  3537. !
  3538. do i=1,ncol
  3539. dbvtt(i) = dbvt(tplnke(i))
  3540. end do
  3541. !
  3542. ! Calculate trace gas Planck functions
  3543. !
  3544. call trcplk(lchnk ,ncol ,pcols, pver, pverp, &
  3545. tint ,tlayr ,tplnke ,emplnk ,abplnk1 , &
  3546. abplnk2 )
  3547. !
  3548. ! Interface loop
  3549. !
  3550. do k1=ntoplw,pverp
  3551. !
  3552. ! H2O emissivity
  3553. !
  3554. ! emis(i,1) 0 - 800 cm-1 h2o rotation band
  3555. ! emis(i,1) 1200 - 2200 cm-1 h2o vibration-rotation band
  3556. ! emis(i,2) 800 - 1200 cm-1 h2o window
  3557. !
  3558. ! Separation between rotation and vibration-rotation dropped, so
  3559. ! only 2 slots needed for H2O emissivity
  3560. !
  3561. ! emis(i,3) = 0.0
  3562. !
  3563. ! For the p type continuum
  3564. !
  3565. do i=1,ncol
  3566. u(i) = plh2o(i,k1)
  3567. pnew = u(i)/w(i,k1)
  3568. pnew_mks = pnew * sslp_mks
  3569. !
  3570. ! Apply scaling factor for 500-800 continuum
  3571. !
  3572. uc1(i) = (s2c(i,k1) + 1.7e-3*plh2o(i,k1))*(1. + 2.*s2c(i,k1))/ &
  3573. (1. + 15.*s2c(i,k1))
  3574. pch2o = s2c(i,k1)
  3575. !
  3576. ! Changed effective path temperature to std. Curtis-Godson form
  3577. !
  3578. tpathe = tcg(i,k1)/w(i,k1)
  3579. t_p = min(max(tpathe, min_tp_h2o), max_tp_h2o)
  3580. iest = floor(t_p) - min_tp_h2o
  3581. esx = estblh2o(iest) + (estblh2o(iest+1)-estblh2o(iest)) * &
  3582. (t_p - min_tp_h2o - iest)
  3583. qsx = epsilo * esx / (pnew_mks - omeps * esx)
  3584. !
  3585. ! Compute effective RH along path
  3586. !
  3587. q_path = w(i,k1) / pnm(i,k1) / rga
  3588. !
  3589. ! Calculate effective u, pnew for each band using
  3590. ! Hulst-Curtis-Godson approximation:
  3591. ! Formulae: Goody and Yung, Atmospheric Radiation: Theoretical Basis,
  3592. ! 2nd edition, Oxford University Press, 1989.
  3593. ! Effective H2O path (w)
  3594. ! eq. 6.24, p. 228
  3595. ! Effective H2O path pressure (pnew = u/w):
  3596. ! eq. 6.29, p. 228
  3597. !
  3598. ub(1) = plh2ob(1,i,k1) / psi(t_p,1)
  3599. ub(2) = plh2ob(2,i,k1) / psi(t_p,2)
  3600. pnewb(1) = ub(1) / wb(1,i,k1) * phi(t_p,1)
  3601. pnewb(2) = ub(2) / wb(2,i,k1) * phi(t_p,2)
  3602. !
  3603. !
  3604. !
  3605. dtx(i) = tplnke(i) - 250.
  3606. dty(i) = tpathe - 250.
  3607. !
  3608. ! Define variables for C/H/E (now C/LT/E) fit
  3609. !
  3610. ! emis(i,1) 0 - 800 cm-1 h2o rotation band
  3611. ! emis(i,1) 1200 - 2200 cm-1 h2o vibration-rotation band
  3612. ! emis(i,2) 800 - 1200 cm-1 h2o window
  3613. !
  3614. ! Separation between rotation and vibration-rotation dropped, so
  3615. ! only 2 slots needed for H2O emissivity
  3616. !
  3617. ! emis(i,3) = 0.0
  3618. !
  3619. ! Notation:
  3620. ! U = integral (P/P_0 dW)
  3621. ! P = atmospheric pressure
  3622. ! P_0 = reference atmospheric pressure
  3623. ! W = precipitable water path
  3624. ! T_e = emission temperature
  3625. ! T_p = path temperature
  3626. ! RH = path relative humidity
  3627. !
  3628. ! Terms for asymptotic value of emissivity
  3629. !
  3630. te1 = tplnke(i)
  3631. te2 = te1 * te1
  3632. te3 = te2 * te1
  3633. te4 = te3 * te1
  3634. te5 = te4 * te1
  3635. !
  3636. ! Band-independent indices for lines and continuum tables
  3637. !
  3638. dvar = (t_p - min_tp_h2o) / dtp_h2o
  3639. itp = min(max(int(aint(dvar,r8)) + 1, 1), n_tp - 1)
  3640. itp1 = itp + 1
  3641. wtp = dvar - floor(dvar)
  3642. wtp1 = 1.0 - wtp
  3643. t_e = min(max(tplnke(i) - t_p, min_te_h2o), max_te_h2o)
  3644. dvar = (t_e - min_te_h2o) / dte_h2o
  3645. ite = min(max(int(aint(dvar,r8)) + 1, 1), n_te - 1)
  3646. ite1 = ite + 1
  3647. wte = dvar - floor(dvar)
  3648. wte1 = 1.0 - wte
  3649. rh_path = min(max(q_path / qsx, min_rh_h2o), max_rh_h2o)
  3650. dvar = (rh_path - min_rh_h2o) / drh_h2o
  3651. irh = min(max(int(aint(dvar,r8)) + 1, 1), n_rh - 1)
  3652. irh1 = irh + 1
  3653. wrh = dvar - floor(dvar)
  3654. wrh1 = 1.0 - wrh
  3655. w_0_0_ = wtp * wte
  3656. w_0_1_ = wtp * wte1
  3657. w_1_0_ = wtp1 * wte
  3658. w_1_1_ = wtp1 * wte1
  3659. w_0_00 = w_0_0_ * wrh
  3660. w_0_01 = w_0_0_ * wrh1
  3661. w_0_10 = w_0_1_ * wrh
  3662. w_0_11 = w_0_1_ * wrh1
  3663. w_1_00 = w_1_0_ * wrh
  3664. w_1_01 = w_1_0_ * wrh1
  3665. w_1_10 = w_1_1_ * wrh
  3666. w_1_11 = w_1_1_ * wrh1
  3667. !
  3668. ! H2O Continuum path for 0-800 and 1200-2200 cm^-1
  3669. !
  3670. ! Assume foreign continuum dominates total H2O continuum in these bands
  3671. ! per Clough et al, JGR, v. 97, no. D14 (Oct 20, 1992), p. 15776
  3672. ! Then the effective H2O path is just
  3673. ! U_c = integral[ f(P) dW ]
  3674. ! where
  3675. ! W = water-vapor mass and
  3676. ! f(P) = dependence of foreign continuum on pressure
  3677. ! = P / sslp
  3678. ! Then
  3679. ! U_c = U (the same effective H2O path as for lines)
  3680. !
  3681. !
  3682. ! Continuum terms for 800-1200 cm^-1
  3683. !
  3684. ! Assume self continuum dominates total H2O continuum for this band
  3685. ! per Clough et al, JGR, v. 97, no. D14 (Oct 20, 1992), p. 15776
  3686. ! Then the effective H2O self-continuum path is
  3687. ! U_c = integral[ h(e,T) dW ] (*eq. 1*)
  3688. ! where
  3689. ! W = water-vapor mass and
  3690. ! e = partial pressure of H2O along path
  3691. ! T = temperature along path
  3692. ! h(e,T) = dependence of foreign continuum on e,T
  3693. ! = e / sslp * f(T)
  3694. !
  3695. ! Replacing
  3696. ! e =~ q * P / epsilo
  3697. ! q = mixing ratio of H2O
  3698. ! epsilo = 0.622
  3699. !
  3700. ! and using the definition
  3701. ! U = integral [ (P / sslp) dW ]
  3702. ! = (P / sslp) W (homogeneous path)
  3703. !
  3704. ! the effective path length for the self continuum is
  3705. ! U_c = (q / epsilo) f(T) U (*eq. 2*)
  3706. !
  3707. ! Once values of T, U, and q have been calculated for the inhomogeneous
  3708. ! path, this sets U_c for the corresponding
  3709. ! homogeneous atmosphere. However, this need not equal the
  3710. ! value of U_c' defined by eq. 1 for the actual inhomogeneous atmosphere
  3711. ! under consideration.
  3712. !
  3713. ! Solution: hold T and q constant, solve for U' that gives U_c' by
  3714. ! inverting eq. (2):
  3715. !
  3716. ! U' = (U_c * epsilo) / (q * f(T))
  3717. !
  3718. fch2o = fh2oself(t_p)
  3719. uch2o = (pch2o * epsilo) / (q_path * fch2o)
  3720. !
  3721. ! Band-dependent indices for non-window
  3722. !
  3723. ib = 1
  3724. uvar = ub(ib) * fdif
  3725. log_u = min(log10(max(uvar, min_u_h2o)), max_lu_h2o)
  3726. dvar = (log_u - min_lu_h2o) / dlu_h2o
  3727. iu = min(max(int(aint(dvar,r8)) + 1, 1), n_u - 1)
  3728. iu1 = iu + 1
  3729. wu = dvar - floor(dvar)
  3730. wu1 = 1.0 - wu
  3731. log_p = min(log10(max(pnewb(ib), min_p_h2o)), max_lp_h2o)
  3732. dvar = (log_p - min_lp_h2o) / dlp_h2o
  3733. ip = min(max(int(aint(dvar,r8)) + 1, 1), n_p - 1)
  3734. ip1 = ip + 1
  3735. wp = dvar - floor(dvar)
  3736. wp1 = 1.0 - wp
  3737. w00_00 = wp * w_0_00
  3738. w00_01 = wp * w_0_01
  3739. w00_10 = wp * w_0_10
  3740. w00_11 = wp * w_0_11
  3741. w01_00 = wp * w_1_00
  3742. w01_01 = wp * w_1_01
  3743. w01_10 = wp * w_1_10
  3744. w01_11 = wp * w_1_11
  3745. w10_00 = wp1 * w_0_00
  3746. w10_01 = wp1 * w_0_01
  3747. w10_10 = wp1 * w_0_10
  3748. w10_11 = wp1 * w_0_11
  3749. w11_00 = wp1 * w_1_00
  3750. w11_01 = wp1 * w_1_01
  3751. w11_10 = wp1 * w_1_10
  3752. w11_11 = wp1 * w_1_11
  3753. !
  3754. ! Asymptotic value of emissivity as U->infinity
  3755. !
  3756. fe = fet(1,ib) + &
  3757. fet(2,ib) * te1 + &
  3758. fet(3,ib) * te2 + &
  3759. fet(4,ib) * te3 + &
  3760. fet(5,ib) * te4 + &
  3761. fet(6,ib) * te5
  3762. e_star = &
  3763. eh2onw(ip , itp , iu , ite , irh ) * w11_11 * wu1 + &
  3764. eh2onw(ip , itp , iu , ite , irh1) * w11_10 * wu1 + &
  3765. eh2onw(ip , itp , iu , ite1, irh ) * w11_01 * wu1 + &
  3766. eh2onw(ip , itp , iu , ite1, irh1) * w11_00 * wu1 + &
  3767. eh2onw(ip , itp , iu1, ite , irh ) * w11_11 * wu + &
  3768. eh2onw(ip , itp , iu1, ite , irh1) * w11_10 * wu + &
  3769. eh2onw(ip , itp , iu1, ite1, irh ) * w11_01 * wu + &
  3770. eh2onw(ip , itp , iu1, ite1, irh1) * w11_00 * wu + &
  3771. eh2onw(ip , itp1, iu , ite , irh ) * w10_11 * wu1 + &
  3772. eh2onw(ip , itp1, iu , ite , irh1) * w10_10 * wu1 + &
  3773. eh2onw(ip , itp1, iu , ite1, irh ) * w10_01 * wu1 + &
  3774. eh2onw(ip , itp1, iu , ite1, irh1) * w10_00 * wu1 + &
  3775. eh2onw(ip , itp1, iu1, ite , irh ) * w10_11 * wu + &
  3776. eh2onw(ip , itp1, iu1, ite , irh1) * w10_10 * wu + &
  3777. eh2onw(ip , itp1, iu1, ite1, irh ) * w10_01 * wu + &
  3778. eh2onw(ip , itp1, iu1, ite1, irh1) * w10_00 * wu + &
  3779. eh2onw(ip1, itp , iu , ite , irh ) * w01_11 * wu1 + &
  3780. eh2onw(ip1, itp , iu , ite , irh1) * w01_10 * wu1 + &
  3781. eh2onw(ip1, itp , iu , ite1, irh ) * w01_01 * wu1 + &
  3782. eh2onw(ip1, itp , iu , ite1, irh1) * w01_00 * wu1 + &
  3783. eh2onw(ip1, itp , iu1, ite , irh ) * w01_11 * wu + &
  3784. eh2onw(ip1, itp , iu1, ite , irh1) * w01_10 * wu + &
  3785. eh2onw(ip1, itp , iu1, ite1, irh ) * w01_01 * wu + &
  3786. eh2onw(ip1, itp , iu1, ite1, irh1) * w01_00 * wu + &
  3787. eh2onw(ip1, itp1, iu , ite , irh ) * w00_11 * wu1 + &
  3788. eh2onw(ip1, itp1, iu , ite , irh1) * w00_10 * wu1 + &
  3789. eh2onw(ip1, itp1, iu , ite1, irh ) * w00_01 * wu1 + &
  3790. eh2onw(ip1, itp1, iu , ite1, irh1) * w00_00 * wu1 + &
  3791. eh2onw(ip1, itp1, iu1, ite , irh ) * w00_11 * wu + &
  3792. eh2onw(ip1, itp1, iu1, ite , irh1) * w00_10 * wu + &
  3793. eh2onw(ip1, itp1, iu1, ite1, irh ) * w00_01 * wu + &
  3794. eh2onw(ip1, itp1, iu1, ite1, irh1) * w00_00 * wu
  3795. emis(i,ib) = min(max(fe * (1.0 - (1.0 - e_star) * &
  3796. aer_trn_ttl(i,k1,1,ib)), &
  3797. 0.0_r8), 1.0_r8)
  3798. !
  3799. ! Invoke linear limit for scaling wrt u below min_u_h2o
  3800. !
  3801. if (uvar < min_u_h2o) then
  3802. uscl = uvar / min_u_h2o
  3803. emis(i,ib) = emis(i,ib) * uscl
  3804. endif
  3805. !
  3806. ! Band-dependent indices for window
  3807. !
  3808. ib = 2
  3809. uvar = ub(ib) * fdif
  3810. log_u = min(log10(max(uvar, min_u_h2o)), max_lu_h2o)
  3811. dvar = (log_u - min_lu_h2o) / dlu_h2o
  3812. iu = min(max(int(aint(dvar,r8)) + 1, 1), n_u - 1)
  3813. iu1 = iu + 1
  3814. wu = dvar - floor(dvar)
  3815. wu1 = 1.0 - wu
  3816. log_p = min(log10(max(pnewb(ib), min_p_h2o)), max_lp_h2o)
  3817. dvar = (log_p - min_lp_h2o) / dlp_h2o
  3818. ip = min(max(int(aint(dvar,r8)) + 1, 1), n_p - 1)
  3819. ip1 = ip + 1
  3820. wp = dvar - floor(dvar)
  3821. wp1 = 1.0 - wp
  3822. w00_00 = wp * w_0_00
  3823. w00_01 = wp * w_0_01
  3824. w00_10 = wp * w_0_10
  3825. w00_11 = wp * w_0_11
  3826. w01_00 = wp * w_1_00
  3827. w01_01 = wp * w_1_01
  3828. w01_10 = wp * w_1_10
  3829. w01_11 = wp * w_1_11
  3830. w10_00 = wp1 * w_0_00
  3831. w10_01 = wp1 * w_0_01
  3832. w10_10 = wp1 * w_0_10
  3833. w10_11 = wp1 * w_0_11
  3834. w11_00 = wp1 * w_1_00
  3835. w11_01 = wp1 * w_1_01
  3836. w11_10 = wp1 * w_1_10
  3837. w11_11 = wp1 * w_1_11
  3838. log_uc = min(log10(max(uch2o * fdif, min_u_h2o)), max_lu_h2o)
  3839. dvar = (log_uc - min_lu_h2o) / dlu_h2o
  3840. iuc = min(max(int(aint(dvar,r8)) + 1, 1), n_u - 1)
  3841. iuc1 = iuc + 1
  3842. wuc = dvar - floor(dvar)
  3843. wuc1 = 1.0 - wuc
  3844. !
  3845. ! Asymptotic value of emissivity as U->infinity
  3846. !
  3847. fe = fet(1,ib) + &
  3848. fet(2,ib) * te1 + &
  3849. fet(3,ib) * te2 + &
  3850. fet(4,ib) * te3 + &
  3851. fet(5,ib) * te4 + &
  3852. fet(6,ib) * te5
  3853. l_star = &
  3854. ln_eh2ow(ip , itp , iu , ite , irh ) * w11_11 * wu1 + &
  3855. ln_eh2ow(ip , itp , iu , ite , irh1) * w11_10 * wu1 + &
  3856. ln_eh2ow(ip , itp , iu , ite1, irh ) * w11_01 * wu1 + &
  3857. ln_eh2ow(ip , itp , iu , ite1, irh1) * w11_00 * wu1 + &
  3858. ln_eh2ow(ip , itp , iu1, ite , irh ) * w11_11 * wu + &
  3859. ln_eh2ow(ip , itp , iu1, ite , irh1) * w11_10 * wu + &
  3860. ln_eh2ow(ip , itp , iu1, ite1, irh ) * w11_01 * wu + &
  3861. ln_eh2ow(ip , itp , iu1, ite1, irh1) * w11_00 * wu + &
  3862. ln_eh2ow(ip , itp1, iu , ite , irh ) * w10_11 * wu1 + &
  3863. ln_eh2ow(ip , itp1, iu , ite , irh1) * w10_10 * wu1 + &
  3864. ln_eh2ow(ip , itp1, iu , ite1, irh ) * w10_01 * wu1 + &
  3865. ln_eh2ow(ip , itp1, iu , ite1, irh1) * w10_00 * wu1 + &
  3866. ln_eh2ow(ip , itp1, iu1, ite , irh ) * w10_11 * wu + &
  3867. ln_eh2ow(ip , itp1, iu1, ite , irh1) * w10_10 * wu + &
  3868. ln_eh2ow(ip , itp1, iu1, ite1, irh ) * w10_01 * wu + &
  3869. ln_eh2ow(ip , itp1, iu1, ite1, irh1) * w10_00 * wu + &
  3870. ln_eh2ow(ip1, itp , iu , ite , irh ) * w01_11 * wu1 + &
  3871. ln_eh2ow(ip1, itp , iu , ite , irh1) * w01_10 * wu1 + &
  3872. ln_eh2ow(ip1, itp , iu , ite1, irh ) * w01_01 * wu1 + &
  3873. ln_eh2ow(ip1, itp , iu , ite1, irh1) * w01_00 * wu1 + &
  3874. ln_eh2ow(ip1, itp , iu1, ite , irh ) * w01_11 * wu + &
  3875. ln_eh2ow(ip1, itp , iu1, ite , irh1) * w01_10 * wu + &
  3876. ln_eh2ow(ip1, itp , iu1, ite1, irh ) * w01_01 * wu + &
  3877. ln_eh2ow(ip1, itp , iu1, ite1, irh1) * w01_00 * wu + &
  3878. ln_eh2ow(ip1, itp1, iu , ite , irh ) * w00_11 * wu1 + &
  3879. ln_eh2ow(ip1, itp1, iu , ite , irh1) * w00_10 * wu1 + &
  3880. ln_eh2ow(ip1, itp1, iu , ite1, irh ) * w00_01 * wu1 + &
  3881. ln_eh2ow(ip1, itp1, iu , ite1, irh1) * w00_00 * wu1 + &
  3882. ln_eh2ow(ip1, itp1, iu1, ite , irh ) * w00_11 * wu + &
  3883. ln_eh2ow(ip1, itp1, iu1, ite , irh1) * w00_10 * wu + &
  3884. ln_eh2ow(ip1, itp1, iu1, ite1, irh ) * w00_01 * wu + &
  3885. ln_eh2ow(ip1, itp1, iu1, ite1, irh1) * w00_00 * wu
  3886. c_star = &
  3887. cn_eh2ow(ip , itp , iuc , ite , irh ) * w11_11 * wuc1 + &
  3888. cn_eh2ow(ip , itp , iuc , ite , irh1) * w11_10 * wuc1 + &
  3889. cn_eh2ow(ip , itp , iuc , ite1, irh ) * w11_01 * wuc1 + &
  3890. cn_eh2ow(ip , itp , iuc , ite1, irh1) * w11_00 * wuc1 + &
  3891. cn_eh2ow(ip , itp , iuc1, ite , irh ) * w11_11 * wuc + &
  3892. cn_eh2ow(ip , itp , iuc1, ite , irh1) * w11_10 * wuc + &
  3893. cn_eh2ow(ip , itp , iuc1, ite1, irh ) * w11_01 * wuc + &
  3894. cn_eh2ow(ip , itp , iuc1, ite1, irh1) * w11_00 * wuc + &
  3895. cn_eh2ow(ip , itp1, iuc , ite , irh ) * w10_11 * wuc1 + &
  3896. cn_eh2ow(ip , itp1, iuc , ite , irh1) * w10_10 * wuc1 + &
  3897. cn_eh2ow(ip , itp1, iuc , ite1, irh ) * w10_01 * wuc1 + &
  3898. cn_eh2ow(ip , itp1, iuc , ite1, irh1) * w10_00 * wuc1 + &
  3899. cn_eh2ow(ip , itp1, iuc1, ite , irh ) * w10_11 * wuc + &
  3900. cn_eh2ow(ip , itp1, iuc1, ite , irh1) * w10_10 * wuc + &
  3901. cn_eh2ow(ip , itp1, iuc1, ite1, irh ) * w10_01 * wuc + &
  3902. cn_eh2ow(ip , itp1, iuc1, ite1, irh1) * w10_00 * wuc + &
  3903. cn_eh2ow(ip1, itp , iuc , ite , irh ) * w01_11 * wuc1 + &
  3904. cn_eh2ow(ip1, itp , iuc , ite , irh1) * w01_10 * wuc1 + &
  3905. cn_eh2ow(ip1, itp , iuc , ite1, irh ) * w01_01 * wuc1 + &
  3906. cn_eh2ow(ip1, itp , iuc , ite1, irh1) * w01_00 * wuc1 + &
  3907. cn_eh2ow(ip1, itp , iuc1, ite , irh ) * w01_11 * wuc + &
  3908. cn_eh2ow(ip1, itp , iuc1, ite , irh1) * w01_10 * wuc + &
  3909. cn_eh2ow(ip1, itp , iuc1, ite1, irh ) * w01_01 * wuc + &
  3910. cn_eh2ow(ip1, itp , iuc1, ite1, irh1) * w01_00 * wuc + &
  3911. cn_eh2ow(ip1, itp1, iuc , ite , irh ) * w00_11 * wuc1 + &
  3912. cn_eh2ow(ip1, itp1, iuc , ite , irh1) * w00_10 * wuc1 + &
  3913. cn_eh2ow(ip1, itp1, iuc , ite1, irh ) * w00_01 * wuc1 + &
  3914. cn_eh2ow(ip1, itp1, iuc , ite1, irh1) * w00_00 * wuc1 + &
  3915. cn_eh2ow(ip1, itp1, iuc1, ite , irh ) * w00_11 * wuc + &
  3916. cn_eh2ow(ip1, itp1, iuc1, ite , irh1) * w00_10 * wuc + &
  3917. cn_eh2ow(ip1, itp1, iuc1, ite1, irh ) * w00_01 * wuc + &
  3918. cn_eh2ow(ip1, itp1, iuc1, ite1, irh1) * w00_00 * wuc
  3919. emis(i,ib) = min(max(fe * (1.0 - l_star * c_star * &
  3920. aer_trn_ttl(i,k1,1,ib)), &
  3921. 0.0_r8), 1.0_r8)
  3922. !
  3923. ! Invoke linear limit for scaling wrt u below min_u_h2o
  3924. !
  3925. if (uvar < min_u_h2o) then
  3926. uscl = uvar / min_u_h2o
  3927. emis(i,ib) = emis(i,ib) * uscl
  3928. endif
  3929. !
  3930. ! Compute total emissivity for H2O
  3931. !
  3932. h2oems(i,k1) = emis(i,1)+emis(i,2)
  3933. end do
  3934. !
  3935. !
  3936. !
  3937. do i=1,ncol
  3938. term7(i,1) = coefj(1,1) + coefj(2,1)*dty(i)*(1.+c16*dty(i))
  3939. term8(i,1) = coefk(1,1) + coefk(2,1)*dty(i)*(1.+c17*dty(i))
  3940. term7(i,2) = coefj(1,2) + coefj(2,2)*dty(i)*(1.+c26*dty(i))
  3941. term8(i,2) = coefk(1,2) + coefk(2,2)*dty(i)*(1.+c27*dty(i))
  3942. end do
  3943. do i=1,ncol
  3944. !
  3945. ! 500 - 800 cm-1 rotation band overlap with co2
  3946. !
  3947. k21(i) = term7(i,1) + term8(i,1)/ &
  3948. (1. + (c30 + c31*(dty(i)-10.)*(dty(i)-10.))*sqrt(u(i)))
  3949. k22(i) = term7(i,2) + term8(i,2)/ &
  3950. (1. + (c28 + c29*(dty(i)-10.))*sqrt(u(i)))
  3951. fwk = fwcoef + fwc1/(1.+fwc2*u(i))
  3952. tr1(i) = exp(-(k21(i)*(sqrt(u(i)) + fc1*fwk*u(i))))
  3953. tr2(i) = exp(-(k22(i)*(sqrt(u(i)) + fc1*fwk*u(i))))
  3954. tr1(i)=tr1(i)*aer_trn_ttl(i,k1,1,idx_LW_0650_0800)
  3955. ! ! H2O line+aer trn 650--800 cm-1
  3956. tr2(i)=tr2(i)*aer_trn_ttl(i,k1,1,idx_LW_0500_0650)
  3957. ! ! H2O line+aer trn 500--650 cm-1
  3958. tr3(i) = exp(-((coefh(1,1) + coefh(2,1)*dtx(i))*uc1(i)))
  3959. tr4(i) = exp(-((coefh(1,2) + coefh(2,2)*dtx(i))*uc1(i)))
  3960. tr7(i) = tr1(i)*tr3(i)
  3961. tr8(i) = tr2(i)*tr4(i)
  3962. troco2(i,k1) = 0.65*tr7(i) + 0.35*tr8(i)
  3963. th2o(i) = tr8(i)
  3964. end do
  3965. !
  3966. ! CO2 emissivity for 15 micron band system
  3967. !
  3968. do i=1,ncol
  3969. t1i = exp(-480./co2t(i,k1))
  3970. sqti = sqrt(co2t(i,k1))
  3971. rsqti = 1./sqti
  3972. et = t1i
  3973. et2 = et*et
  3974. et4 = et2*et2
  3975. omet = 1. - 1.5*et2
  3976. f1co2 = 899.70*omet*(1. + 1.94774*et + 4.73486*et2)*rsqti
  3977. sqwp = sqrt(plco2(i,k1))
  3978. f1sqwp = f1co2*sqwp
  3979. t1co2 = 1./(1. + 245.18*omet*sqwp*rsqti)
  3980. oneme = 1. - et2
  3981. alphat = oneme**3*rsqti
  3982. wco2 = 2.5221*co2vmr*pnm(i,k1)*rga
  3983. u7 = 4.9411e4*alphat*et2*wco2
  3984. u8 = 3.9744e4*alphat*et4*wco2
  3985. u9 = 1.0447e5*alphat*et4*et2*wco2
  3986. u13 = 2.8388e3*alphat*et4*wco2
  3987. !
  3988. tpath = co2t(i,k1)
  3989. tlocal = tplnke(i)
  3990. tcrfac = sqrt((tlocal*r250)*(tpath*r300))
  3991. pi = pnm(i,k1)*rsslp + 2.*dpfco2*tcrfac
  3992. posqt = pi/(2.*sqti)
  3993. rbeta7 = 1./( 5.3288*posqt)
  3994. rbeta8 = 1./ (10.6576*posqt)
  3995. rbeta9 = rbeta7
  3996. rbeta13= rbeta9
  3997. f2co2 = (u7/sqrt(4. + u7*(1. + rbeta7))) + &
  3998. (u8/sqrt(4. + u8*(1. + rbeta8))) + &
  3999. (u9/sqrt(4. + u9*(1. + rbeta9)))
  4000. f3co2 = u13/sqrt(4. + u13*(1. + rbeta13))
  4001. tmp1 = log(1. + f1sqwp)
  4002. tmp2 = log(1. + f2co2)
  4003. tmp3 = log(1. + f3co2)
  4004. absbnd = (tmp1 + 2.*t1co2*tmp2 + 2.*tmp3)*sqti
  4005. tco2(i)=1.0/(1.0+10.0*(u7/sqrt(4. + u7*(1. + rbeta7))))
  4006. co2ems(i,k1) = troco2(i,k1)*absbnd*co2plk(i)
  4007. ex = exp(960./tint(i,k1))
  4008. exm1sq = (ex - 1.)**2
  4009. co2em(i,k1) = 1.2e11*ex/(tint(i,k1)*tint4(i,k1)*exm1sq)
  4010. end do
  4011. !
  4012. ! O3 emissivity
  4013. !
  4014. do i=1,ncol
  4015. h2otr(i,k1) = exp(-12.*s2c(i,k1))
  4016. h2otr(i,k1)=h2otr(i,k1)*aer_trn_ttl(i,k1,1,idx_LW_1000_1200)
  4017. te = (co2t(i,k1)/293.)**.7
  4018. u1 = 18.29*plos(i,k1)/te
  4019. u2 = .5649*plos(i,k1)/te
  4020. phat = plos(i,k1)/plol(i,k1)
  4021. tlocal = tplnke(i)
  4022. tcrfac = sqrt(tlocal*r250)*te
  4023. beta = (1./.3205)*((1./phat) + (dpfo3*tcrfac))
  4024. realnu = (1./beta)*te
  4025. o3bndi = 74.*te*(tplnke(i)/375.)*log(1. + fo3(u1,realnu) + fo3(u2,realnu))
  4026. o3ems(i,k1) = dbvtt(i)*h2otr(i,k1)*o3bndi
  4027. to3(i)=1.0/(1. + 0.1*fo3(u1,realnu) + 0.1*fo3(u2,realnu))
  4028. end do
  4029. !
  4030. ! Calculate trace gas emissivities
  4031. !
  4032. call trcems(lchnk ,ncol ,pcols, pverp, &
  4033. k1 ,co2t ,pnm ,ucfc11 ,ucfc12 , &
  4034. un2o0 ,un2o1 ,bn2o0 ,bn2o1 ,uch4 , &
  4035. bch4 ,uco211 ,uco212 ,uco213 ,uco221 , &
  4036. uco222 ,uco223 ,uptype ,w ,s2c , &
  4037. u ,emplnk ,th2o ,tco2 ,to3 , &
  4038. emstrc , &
  4039. aer_trn_ttl)
  4040. !
  4041. ! Total emissivity:
  4042. !
  4043. do i=1,ncol
  4044. emstot(i,k1) = h2oems(i,k1) + co2ems(i,k1) + o3ems(i,k1) &
  4045. + emstrc(i,k1)
  4046. end do
  4047. end do ! End of interface loop
  4048. return
  4049. end subroutine radems
  4050. subroutine radtpl(lchnk ,ncol ,pcols, pver, pverp, &
  4051. tnm ,lwupcgs ,qnm ,pnm ,plco2 ,plh2o , &
  4052. tplnka ,s2c ,tcg ,w ,tplnke , &
  4053. tint ,tint4 ,tlayr ,tlayr4 ,pmln , &
  4054. piln ,plh2ob ,wb )
  4055. !--------------------------------------------------------------------
  4056. !
  4057. ! Purpose:
  4058. ! Compute temperatures and path lengths for longwave radiation
  4059. !
  4060. ! Method:
  4061. ! <Describe the algorithm(s) used in the routine.>
  4062. ! <Also include any applicable external references.>
  4063. !
  4064. ! Author: CCM1
  4065. !
  4066. !--------------------------------------------------------------------
  4067. !------------------------------Arguments-----------------------------
  4068. !
  4069. ! Input arguments
  4070. !
  4071. integer, intent(in) :: lchnk ! chunk identifier
  4072. integer, intent(in) :: ncol ! number of atmospheric columns
  4073. integer, intent(in) :: pcols, pver, pverp
  4074. real(r8), intent(in) :: tnm(pcols,pver) ! Model level temperatures
  4075. real(r8), intent(in) :: lwupcgs(pcols) ! Surface longwave up flux
  4076. real(r8), intent(in) :: qnm(pcols,pver) ! Model level specific humidity
  4077. real(r8), intent(in) :: pnm(pcols,pverp) ! Pressure at model interfaces (dynes/cm2)
  4078. real(r8), intent(in) :: pmln(pcols,pver) ! Ln(pmidm1)
  4079. real(r8), intent(in) :: piln(pcols,pverp) ! Ln(pintm1)
  4080. !
  4081. ! Output arguments
  4082. !
  4083. real(r8), intent(out) :: plco2(pcols,pverp) ! Pressure weighted co2 path
  4084. real(r8), intent(out) :: plh2o(pcols,pverp) ! Pressure weighted h2o path
  4085. real(r8), intent(out) :: tplnka(pcols,pverp) ! Level temperature from interface temperatures
  4086. real(r8), intent(out) :: s2c(pcols,pverp) ! H2o continuum path length
  4087. real(r8), intent(out) :: tcg(pcols,pverp) ! H2o-mass-wgted temp. (Curtis-Godson approx.)
  4088. real(r8), intent(out) :: w(pcols,pverp) ! H2o path length
  4089. real(r8), intent(out) :: tplnke(pcols) ! Equal to tplnka
  4090. real(r8), intent(out) :: tint(pcols,pverp) ! Layer interface temperature
  4091. real(r8), intent(out) :: tint4(pcols,pverp) ! Tint to the 4th power
  4092. real(r8), intent(out) :: tlayr(pcols,pverp) ! K-1 level temperature
  4093. real(r8), intent(out) :: tlayr4(pcols,pverp) ! Tlayr to the 4th power
  4094. real(r8), intent(out) :: plh2ob(nbands,pcols,pverp)! Pressure weighted h2o path with
  4095. ! Hulst-Curtis-Godson temp. factor
  4096. ! for H2O bands
  4097. real(r8), intent(out) :: wb(nbands,pcols,pverp) ! H2o path length with
  4098. ! Hulst-Curtis-Godson temp. factor
  4099. ! for H2O bands
  4100. !
  4101. !---------------------------Local variables--------------------------
  4102. !
  4103. integer i ! Longitude index
  4104. integer k ! Level index
  4105. integer kp1 ! Level index + 1
  4106. real(r8) repsil ! Inver ratio mol weight h2o to dry air
  4107. real(r8) dy ! Thickness of layer for tmp interp
  4108. real(r8) dpnm ! Pressure thickness of layer
  4109. real(r8) dpnmsq ! Prs squared difference across layer
  4110. real(r8) dw ! Increment in H2O path length
  4111. real(r8) dplh2o ! Increment in plh2o
  4112. real(r8) cpwpl ! Const in co2 mix ratio to path length conversn
  4113. !--------------------------------------------------------------------
  4114. !
  4115. repsil = 1./epsilo
  4116. !
  4117. ! Compute co2 and h2o paths
  4118. !
  4119. cpwpl = amco2/amd * 0.5/(gravit*p0)
  4120. do i=1,ncol
  4121. plh2o(i,ntoplw) = rgsslp*qnm(i,ntoplw)*pnm(i,ntoplw)*pnm(i,ntoplw)
  4122. plco2(i,ntoplw) = co2vmr*cpwpl*pnm(i,ntoplw)*pnm(i,ntoplw)
  4123. end do
  4124. do k=ntoplw,pver
  4125. do i=1,ncol
  4126. plh2o(i,k+1) = plh2o(i,k) + rgsslp* &
  4127. (pnm(i,k+1)**2 - pnm(i,k)**2)*qnm(i,k)
  4128. plco2(i,k+1) = co2vmr*cpwpl*pnm(i,k+1)**2
  4129. end do
  4130. end do
  4131. !
  4132. ! Set the top and bottom intermediate level temperatures,
  4133. ! top level planck temperature and top layer temp**4.
  4134. !
  4135. ! Tint is lower interface temperature
  4136. ! (not available for bottom layer, so use ground temperature)
  4137. !
  4138. do i=1,ncol
  4139. tint4(i,pverp) = lwupcgs(i)/stebol
  4140. tint(i,pverp) = sqrt(sqrt(tint4(i,pverp)))
  4141. tplnka(i,ntoplw) = tnm(i,ntoplw)
  4142. tint(i,ntoplw) = tplnka(i,ntoplw)
  4143. tlayr4(i,ntoplw) = tplnka(i,ntoplw)**4
  4144. tint4(i,ntoplw) = tlayr4(i,ntoplw)
  4145. end do
  4146. !
  4147. ! Intermediate level temperatures are computed using temperature
  4148. ! at the full level below less dy*delta t,between the full level
  4149. !
  4150. do k=ntoplw+1,pver
  4151. do i=1,ncol
  4152. dy = (piln(i,k) - pmln(i,k))/(pmln(i,k-1) - pmln(i,k))
  4153. tint(i,k) = tnm(i,k) - dy*(tnm(i,k)-tnm(i,k-1))
  4154. tint4(i,k) = tint(i,k)**4
  4155. end do
  4156. end do
  4157. !
  4158. ! Now set the layer temp=full level temperatures and establish a
  4159. ! planck temperature for absorption (tplnka) which is the average
  4160. ! the intermediate level temperatures. Note that tplnka is not
  4161. ! equal to the full level temperatures.
  4162. !
  4163. do k=ntoplw+1,pverp
  4164. do i=1,ncol
  4165. tlayr(i,k) = tnm(i,k-1)
  4166. tlayr4(i,k) = tlayr(i,k)**4
  4167. tplnka(i,k) = .5*(tint(i,k) + tint(i,k-1))
  4168. end do
  4169. end do
  4170. !
  4171. ! Calculate tplank for emissivity calculation.
  4172. ! Assume isothermal tplnke i.e. all levels=ttop.
  4173. !
  4174. do i=1,ncol
  4175. tplnke(i) = tplnka(i,ntoplw)
  4176. tlayr(i,ntoplw) = tint(i,ntoplw)
  4177. end do
  4178. !
  4179. ! Now compute h2o path fields:
  4180. !
  4181. do i=1,ncol
  4182. !
  4183. ! Changed effective path temperature to std. Curtis-Godson form
  4184. !
  4185. tcg(i,ntoplw) = rga*qnm(i,ntoplw)*pnm(i,ntoplw)*tnm(i,ntoplw)
  4186. w(i,ntoplw) = sslp * (plh2o(i,ntoplw)*2.) / pnm(i,ntoplw)
  4187. !
  4188. ! Hulst-Curtis-Godson scaling for H2O path
  4189. !
  4190. wb(1,i,ntoplw) = w(i,ntoplw) * phi(tnm(i,ntoplw),1)
  4191. wb(2,i,ntoplw) = w(i,ntoplw) * phi(tnm(i,ntoplw),2)
  4192. !
  4193. ! Hulst-Curtis-Godson scaling for effective pressure along H2O path
  4194. !
  4195. plh2ob(1,i,ntoplw) = plh2o(i,ntoplw) * psi(tnm(i,ntoplw),1)
  4196. plh2ob(2,i,ntoplw) = plh2o(i,ntoplw) * psi(tnm(i,ntoplw),2)
  4197. s2c(i,ntoplw) = plh2o(i,ntoplw)*fh2oself(tnm(i,ntoplw))*qnm(i,ntoplw)*repsil
  4198. end do
  4199. do k=ntoplw,pver
  4200. do i=1,ncol
  4201. dpnm = pnm(i,k+1) - pnm(i,k)
  4202. dpnmsq = pnm(i,k+1)**2 - pnm(i,k)**2
  4203. dw = rga*qnm(i,k)*dpnm
  4204. kp1 = k+1
  4205. w(i,kp1) = w(i,k) + dw
  4206. !
  4207. ! Hulst-Curtis-Godson scaling for H2O path
  4208. !
  4209. wb(1,i,kp1) = wb(1,i,k) + dw * phi(tnm(i,k),1)
  4210. wb(2,i,kp1) = wb(2,i,k) + dw * phi(tnm(i,k),2)
  4211. !
  4212. ! Hulst-Curtis-Godson scaling for effective pressure along H2O path
  4213. !
  4214. dplh2o = plh2o(i,kp1) - plh2o(i,k)
  4215. plh2ob(1,i,kp1) = plh2ob(1,i,k) + dplh2o * psi(tnm(i,k),1)
  4216. plh2ob(2,i,kp1) = plh2ob(2,i,k) + dplh2o * psi(tnm(i,k),2)
  4217. !
  4218. ! Changed effective path temperature to std. Curtis-Godson form
  4219. !
  4220. tcg(i,kp1) = tcg(i,k) + dw*tnm(i,k)
  4221. s2c(i,kp1) = s2c(i,k) + rgsslp*dpnmsq*qnm(i,k)* &
  4222. fh2oself(tnm(i,k))*qnm(i,k)*repsil
  4223. end do
  4224. end do
  4225. !
  4226. return
  4227. end subroutine radtpl
  4228. subroutine radclwmx(lchnk ,ncol ,pcols, pver, pverp, &
  4229. lwupcgs ,tnm ,qnm ,o3vmr , &
  4230. pmid ,pint ,pmln ,piln , &
  4231. n2o ,ch4 ,cfc11 ,cfc12 , &
  4232. cld ,emis ,pmxrgn ,nmxrgn ,qrl , &
  4233. doabsems, abstot, absnxt, emstot, &
  4234. flns ,flnt ,flnsc ,flntc ,flwds , &
  4235. flut ,flutc , &
  4236. flup ,flupc ,fldn ,fldnc , &
  4237. aer_mass)
  4238. !-----------------------------------------------------------------------
  4239. !
  4240. ! Purpose:
  4241. ! Compute longwave radiation heating rates and boundary fluxes
  4242. !
  4243. ! Method:
  4244. ! Uses broad band absorptivity/emissivity method to compute clear sky;
  4245. ! assumes randomly overlapped clouds with variable cloud emissivity to
  4246. ! include effects of clouds.
  4247. !
  4248. ! Computes clear sky absorptivity/emissivity at lower frequency (in
  4249. ! general) than the model radiation frequency; uses previously computed
  4250. ! and stored values for efficiency
  4251. !
  4252. ! Note: This subroutine contains vertical indexing which proceeds
  4253. ! from bottom to top rather than the top to bottom indexing
  4254. ! used in the rest of the model.
  4255. !
  4256. ! Author: B. Collins
  4257. !
  4258. !-----------------------------------------------------------------------
  4259. ! use shr_kind_mod, only: r8 => shr_kind_r8
  4260. ! use ppgrid
  4261. ! use radae, only: nbands, radems, radabs, radtpl, abstot_3d, absnxt_3d, emstot_3d
  4262. ! use volcrad
  4263. implicit none
  4264. integer pverp2,pverp3,pverp4
  4265. ! parameter (pverp2=pver+2,pverp3=pver+3,pverp4=pver+4)
  4266. real(r8) cldmin
  4267. parameter (cldmin = 1.0d-80)
  4268. !------------------------------Commons----------------------------------
  4269. !-----------------------------------------------------------------------
  4270. !------------------------------Arguments--------------------------------
  4271. !
  4272. ! Input arguments
  4273. !
  4274. integer, intent(in) :: lchnk ! chunk identifier
  4275. integer, intent(in) :: pcols, pver, pverp
  4276. integer, intent(in) :: ncol ! number of atmospheric columns
  4277. ! maximally overlapped region.
  4278. ! 0->pmxrgn(i,1) is range of pmid for
  4279. ! 1st region, pmxrgn(i,1)->pmxrgn(i,2) for
  4280. ! 2nd region, etc
  4281. integer, intent(in) :: nmxrgn(pcols) ! Number of maximally overlapped regions
  4282. logical, intent(in) :: doabsems
  4283. real(r8), intent(in) :: pmxrgn(pcols,pverp) ! Maximum values of pmid for each
  4284. real(r8), intent(in) :: lwupcgs(pcols) ! Longwave up flux in CGS units
  4285. !
  4286. ! Input arguments which are only passed to other routines
  4287. !
  4288. real(r8), intent(in) :: tnm(pcols,pver) ! Level temperature
  4289. real(r8), intent(in) :: qnm(pcols,pver) ! Level moisture field
  4290. real(r8), intent(in) :: o3vmr(pcols,pver) ! ozone volume mixing ratio
  4291. real(r8), intent(in) :: pmid(pcols,pver) ! Level pressure
  4292. real(r8), intent(in) :: pint(pcols,pverp) ! Model interface pressure
  4293. real(r8), intent(in) :: pmln(pcols,pver) ! Ln(pmid)
  4294. real(r8), intent(in) :: piln(pcols,pverp) ! Ln(pint)
  4295. real(r8), intent(in) :: n2o(pcols,pver) ! nitrous oxide mass mixing ratio
  4296. real(r8), intent(in) :: ch4(pcols,pver) ! methane mass mixing ratio
  4297. real(r8), intent(in) :: cfc11(pcols,pver) ! cfc11 mass mixing ratio
  4298. real(r8), intent(in) :: cfc12(pcols,pver) ! cfc12 mass mixing ratio
  4299. real(r8), intent(in) :: cld(pcols,pver) ! Cloud cover
  4300. real(r8), intent(in) :: emis(pcols,pver) ! Cloud emissivity
  4301. real(r8), intent(in) :: aer_mass(pcols,pver) ! STRAER mass in layer
  4302. !
  4303. ! Output arguments
  4304. !
  4305. real(r8), intent(out) :: qrl(pcols,pver) ! Longwave heating rate
  4306. real(r8), intent(out) :: flns(pcols) ! Surface cooling flux
  4307. real(r8), intent(out) :: flnt(pcols) ! Net outgoing flux
  4308. real(r8), intent(out) :: flut(pcols) ! Upward flux at top of model
  4309. real(r8), intent(out) :: flnsc(pcols) ! Clear sky surface cooing
  4310. real(r8), intent(out) :: flntc(pcols) ! Net clear sky outgoing flux
  4311. real(r8), intent(out) :: flutc(pcols) ! Upward clear-sky flux at top of model
  4312. real(r8), intent(out) :: flwds(pcols) ! Down longwave flux at surface
  4313. ! Added downward/upward total and clear sky fluxes
  4314. real(r8), intent(out) :: flup(pcols,pverp) ! Total sky upward longwave flux
  4315. real(r8), intent(out) :: flupc(pcols,pverp) ! Clear sky upward longwave flux
  4316. real(r8), intent(out) :: fldn(pcols,pverp) ! Total sky downward longwave flux
  4317. real(r8), intent(out) :: fldnc(pcols,pverp) ! Clear sky downward longwave flux
  4318. !
  4319. real(r8), intent(inout) :: abstot(pcols,pverp,pverp) ! Total absorptivity
  4320. real(r8), intent(inout) :: absnxt(pcols,pver,4) ! Total nearest layer absorptivity
  4321. real(r8), intent(inout) :: emstot(pcols,pverp) ! Total emissivity
  4322. !---------------------------Local variables-----------------------------
  4323. !
  4324. integer i ! Longitude index
  4325. integer ilon ! Longitude index
  4326. integer ii ! Longitude index
  4327. integer iimx ! Longitude index (max overlap)
  4328. integer k ! Level index
  4329. integer k1 ! Level index
  4330. integer k2 ! Level index
  4331. integer k3 ! Level index
  4332. integer km ! Level index
  4333. integer km1 ! Level index
  4334. integer km3 ! Level index
  4335. integer km4 ! Level index
  4336. integer irgn ! Index for max-overlap regions
  4337. integer l ! Index for clouds to overlap
  4338. integer l1 ! Index for clouds to overlap
  4339. integer n ! Counter
  4340. !
  4341. real(r8) :: plco2(pcols,pverp) ! Path length co2
  4342. real(r8) :: plh2o(pcols,pverp) ! Path length h2o
  4343. real(r8) tmp(pcols) ! Temporary workspace
  4344. real(r8) tmp2(pcols) ! Temporary workspace
  4345. real(r8) absbt(pcols) ! Downward emission at model top
  4346. real(r8) plol(pcols,pverp) ! O3 pressure wghted path length
  4347. real(r8) plos(pcols,pverp) ! O3 path length
  4348. real(r8) aer_mpp(pcols,pverp) ! STRAER path above kth interface level
  4349. real(r8) co2em(pcols,pverp) ! Layer co2 normalized planck funct. derivative
  4350. real(r8) co2eml(pcols,pver) ! Interface co2 normalized planck funct. deriv.
  4351. real(r8) delt(pcols) ! Diff t**4 mid layer to top interface
  4352. real(r8) delt1(pcols) ! Diff t**4 lower intrfc to mid layer
  4353. real(r8) bk1(pcols) ! Absrptvty for vertical quadrature
  4354. real(r8) bk2(pcols) ! Absrptvty for vertical quadrature
  4355. real(r8) cldp(pcols,pverp) ! Cloud cover with extra layer
  4356. real(r8) ful(pcols,pverp) ! Total upwards longwave flux
  4357. real(r8) fsul(pcols,pverp) ! Clear sky upwards longwave flux
  4358. real(r8) fdl(pcols,pverp) ! Total downwards longwave flux
  4359. real(r8) fsdl(pcols,pverp) ! Clear sky downwards longwv flux
  4360. real(r8) fclb4(pcols,-1:pver) ! Sig t**4 for cld bottom interfc
  4361. real(r8) fclt4(pcols,0:pver) ! Sig t**4 for cloud top interfc
  4362. real(r8) s(pcols,pverp,pverp) ! Flx integral sum
  4363. real(r8) tplnka(pcols,pverp) ! Planck fnctn temperature
  4364. real(r8) s2c(pcols,pverp) ! H2o cont amount
  4365. real(r8) tcg(pcols,pverp) ! H2o-mass-wgted temp. (Curtis-Godson approx.)
  4366. real(r8) w(pcols,pverp) ! H2o path
  4367. real(r8) tplnke(pcols) ! Planck fnctn temperature
  4368. real(r8) h2otr(pcols,pverp) ! H2o trnmsn for o3 overlap
  4369. real(r8) co2t(pcols,pverp) ! Prs wghted temperature path
  4370. real(r8) tint(pcols,pverp) ! Interface temperature
  4371. real(r8) tint4(pcols,pverp) ! Interface temperature**4
  4372. real(r8) tlayr(pcols,pverp) ! Level temperature
  4373. real(r8) tlayr4(pcols,pverp) ! Level temperature**4
  4374. real(r8) plh2ob(nbands,pcols,pverp)! Pressure weighted h2o path with
  4375. ! Hulst-Curtis-Godson temp. factor
  4376. ! for H2O bands
  4377. real(r8) wb(nbands,pcols,pverp) ! H2o path length with
  4378. ! Hulst-Curtis-Godson temp. factor
  4379. ! for H2O bands
  4380. real(r8) cld0 ! previous cloud amt (for max overlap)
  4381. real(r8) cld1 ! next cloud amt (for max overlap)
  4382. real(r8) emx(0:pverp) ! Emissivity factors (max overlap)
  4383. real(r8) emx0 ! Emissivity factors for BCs (max overlap)
  4384. real(r8) trans ! 1 - emis
  4385. real(r8) asort(pver) ! 1 - cloud amounts to be sorted for max ovrlp.
  4386. real(r8) atmp ! Temporary storage for sort when nxs = 2
  4387. real(r8) maxcld(pcols) ! Maximum cloud at any layer
  4388. integer indx(pcols) ! index vector of gathered array values
  4389. !!$ integer indxmx(pcols+1,pverp)! index vector of gathered array values
  4390. integer indxmx(pcols,pverp)! index vector of gathered array values
  4391. ! (max overlap)
  4392. integer nrgn(pcols) ! Number of max overlap regions at longitude
  4393. integer npts ! number of values satisfying some criterion
  4394. integer ncolmx(pverp) ! number of columns with clds in region
  4395. integer kx1(pcols,pverp) ! Level index for top of max-overlap region
  4396. integer kx2(pcols,0:pverp)! Level index for bottom of max-overlap region
  4397. integer kxs(0:pverp,pcols,pverp)! Level indices for cld layers sorted by cld()
  4398. ! in descending order
  4399. integer nxs(pcols,pverp) ! Number of cloudy layers between kx1 and kx2
  4400. integer nxsk ! Number of cloudy layers between (kx1/kx2)&k
  4401. integer ksort(0:pverp) ! Level indices of cloud amounts to be sorted
  4402. ! for max ovrlp. calculation
  4403. integer ktmp ! Temporary storage for sort when nxs = 2
  4404. ! real aer_trn_ttl(pcols,pverp,pverp,bnd_nbr_LW) ! [fraction] Total
  4405. real(r8) aer_trn_ttl(pcols,pverp,pverp,bnd_nbr_LW) ! [fraction] Total
  4406. ! ! transmission between interfaces k1 and k2
  4407. !
  4408. ! Pointer variables to 3d structures
  4409. !
  4410. ! real(r8), pointer :: abstot(:,:,:)
  4411. ! real(r8), pointer :: absnxt(:,:,:)
  4412. ! real(r8), pointer :: emstot(:,:)
  4413. !
  4414. ! Trace gas variables
  4415. !
  4416. real(r8) ucfc11(pcols,pverp) ! CFC11 path length
  4417. real(r8) ucfc12(pcols,pverp) ! CFC12 path length
  4418. real(r8) un2o0(pcols,pverp) ! N2O path length
  4419. real(r8) un2o1(pcols,pverp) ! N2O path length (hot band)
  4420. real(r8) uch4(pcols,pverp) ! CH4 path length
  4421. real(r8) uco211(pcols,pverp) ! CO2 9.4 micron band path length
  4422. real(r8) uco212(pcols,pverp) ! CO2 9.4 micron band path length
  4423. real(r8) uco213(pcols,pverp) ! CO2 9.4 micron band path length
  4424. real(r8) uco221(pcols,pverp) ! CO2 10.4 micron band path length
  4425. real(r8) uco222(pcols,pverp) ! CO2 10.4 micron band path length
  4426. real(r8) uco223(pcols,pverp) ! CO2 10.4 micron band path length
  4427. real(r8) bn2o0(pcols,pverp) ! pressure factor for n2o
  4428. real(r8) bn2o1(pcols,pverp) ! pressure factor for n2o
  4429. real(r8) bch4(pcols,pverp) ! pressure factor for ch4
  4430. real(r8) uptype(pcols,pverp) ! p-type continuum path length
  4431. real(r8) abplnk1(14,pcols,pverp) ! non-nearest layer Plack factor
  4432. real(r8) abplnk2(14,pcols,pverp) ! nearest layer factor
  4433. !
  4434. !
  4435. !-----------------------------------------------------------------------
  4436. !
  4437. !
  4438. pverp2=pver+2
  4439. pverp3=pver+3
  4440. pverp4=pver+4
  4441. !
  4442. ! Set pointer variables
  4443. !
  4444. ! abstot => abstot_3d(:,:,:,lchnk)
  4445. ! absnxt => absnxt_3d(:,:,:,lchnk)
  4446. ! emstot => emstot_3d(:,:,lchnk)
  4447. !
  4448. ! accumulate mass path from top of atmosphere
  4449. !
  4450. call aer_pth(aer_mass, aer_mpp, ncol, pcols, pver, pverp)
  4451. !
  4452. ! Calculate some temperatures needed to derive absorptivity and
  4453. ! emissivity, as well as some h2o path lengths
  4454. !
  4455. call radtpl(lchnk ,ncol ,pcols, pver, pverp, &
  4456. tnm ,lwupcgs ,qnm ,pint ,plco2 ,plh2o , &
  4457. tplnka ,s2c ,tcg ,w ,tplnke , &
  4458. tint ,tint4 ,tlayr ,tlayr4 ,pmln , &
  4459. piln ,plh2ob ,wb )
  4460. if (doabsems) then
  4461. !
  4462. ! Compute ozone path lengths at frequency of a/e calculation.
  4463. !
  4464. call radoz2(lchnk, ncol, pcols, pver, pverp, o3vmr ,pint ,plol ,plos, ntoplw )
  4465. !
  4466. ! Compute trace gas path lengths
  4467. !
  4468. call trcpth(lchnk ,ncol ,pcols, pver, pverp, &
  4469. tnm ,pint ,cfc11 ,cfc12 ,n2o , &
  4470. ch4 ,qnm ,ucfc11 ,ucfc12 ,un2o0 , &
  4471. un2o1 ,uch4 ,uco211 ,uco212 ,uco213 , &
  4472. uco221 ,uco222 ,uco223 ,bn2o0 ,bn2o1 , &
  4473. bch4 ,uptype )
  4474. ! Compute transmission through STRAER absorption continuum
  4475. call aer_trn(aer_mpp, aer_trn_ttl, pcols, pver, pverp)
  4476. !
  4477. !
  4478. ! Compute total emissivity:
  4479. !
  4480. call radems(lchnk ,ncol ,pcols, pver, pverp, &
  4481. s2c ,tcg ,w ,tplnke ,plh2o , &
  4482. pint ,plco2 ,tint ,tint4 ,tlayr , &
  4483. tlayr4 ,plol ,plos ,ucfc11 ,ucfc12 , &
  4484. un2o0 ,un2o1 ,uch4 ,uco211 ,uco212 , &
  4485. uco213 ,uco221 ,uco222 ,uco223 ,uptype , &
  4486. bn2o0 ,bn2o1 ,bch4 ,co2em ,co2eml , &
  4487. co2t ,h2otr ,abplnk1 ,abplnk2 ,emstot , &
  4488. plh2ob ,wb , &
  4489. aer_trn_ttl)
  4490. !
  4491. ! Compute total absorptivity:
  4492. !
  4493. call radabs(lchnk ,ncol ,pcols, pver, pverp, &
  4494. pmid ,pint ,co2em ,co2eml ,tplnka , &
  4495. s2c ,tcg ,w ,h2otr ,plco2 , &
  4496. plh2o ,co2t ,tint ,tlayr ,plol , &
  4497. plos ,pmln ,piln ,ucfc11 ,ucfc12 , &
  4498. un2o0 ,un2o1 ,uch4 ,uco211 ,uco212 , &
  4499. uco213 ,uco221 ,uco222 ,uco223 ,uptype , &
  4500. bn2o0 ,bn2o1 ,bch4 ,abplnk1 ,abplnk2 , &
  4501. abstot ,absnxt ,plh2ob ,wb , &
  4502. aer_mpp ,aer_trn_ttl)
  4503. end if
  4504. !
  4505. ! Compute sums used in integrals (all longitude points)
  4506. !
  4507. ! Definition of bk1 & bk2 depends on finite differencing. for
  4508. ! trapezoidal rule bk1=bk2. trapezoidal rule applied for nonadjacent
  4509. ! layers only.
  4510. !
  4511. ! delt=t**4 in layer above current sigma level km.
  4512. ! delt1=t**4 in layer below current sigma level km.
  4513. !
  4514. do i=1,ncol
  4515. delt(i) = tint4(i,pver) - tlayr4(i,pverp)
  4516. delt1(i) = tlayr4(i,pverp) - tint4(i,pverp)
  4517. s(i,pverp,pverp) = stebol*(delt1(i)*absnxt(i,pver,1) + delt (i)*absnxt(i,pver,4))
  4518. s(i,pver,pverp) = stebol*(delt (i)*absnxt(i,pver,2) + delt1(i)*absnxt(i,pver,3))
  4519. end do
  4520. do k=ntoplw,pver-1
  4521. do i=1,ncol
  4522. bk2(i) = (abstot(i,k,pver) + abstot(i,k,pverp))*0.5
  4523. bk1(i) = bk2(i)
  4524. s(i,k,pverp) = stebol*(bk2(i)*delt(i) + bk1(i)*delt1(i))
  4525. end do
  4526. end do
  4527. !
  4528. ! All k, km>1
  4529. !
  4530. do km=pver,ntoplw+1,-1
  4531. do i=1,ncol
  4532. delt(i) = tint4(i,km-1) - tlayr4(i,km)
  4533. delt1(i) = tlayr4(i,km) - tint4(i,km)
  4534. end do
  4535. do k=pverp,ntoplw,-1
  4536. if (k == km) then
  4537. do i=1,ncol
  4538. bk2(i) = absnxt(i,km-1,4)
  4539. bk1(i) = absnxt(i,km-1,1)
  4540. end do
  4541. else if (k == km-1) then
  4542. do i=1,ncol
  4543. bk2(i) = absnxt(i,km-1,2)
  4544. bk1(i) = absnxt(i,km-1,3)
  4545. end do
  4546. else
  4547. do i=1,ncol
  4548. bk2(i) = (abstot(i,k,km-1) + abstot(i,k,km))*0.5
  4549. bk1(i) = bk2(i)
  4550. end do
  4551. end if
  4552. do i=1,ncol
  4553. s(i,k,km) = s(i,k,km+1) + stebol*(bk2(i)*delt(i) + bk1(i)*delt1(i))
  4554. end do
  4555. end do
  4556. end do
  4557. !
  4558. ! Computation of clear sky fluxes always set first level of fsul
  4559. !
  4560. do i=1,ncol
  4561. fsul(i,pverp) = lwupcgs(i)
  4562. end do
  4563. !
  4564. ! Downward clear sky fluxes store intermediate quantities in down flux
  4565. ! Initialize fluxes to clear sky values.
  4566. !
  4567. do i=1,ncol
  4568. tmp(i) = fsul(i,pverp) - stebol*tint4(i,pverp)
  4569. fsul(i,ntoplw) = fsul(i,pverp) - abstot(i,ntoplw,pverp)*tmp(i) + s(i,ntoplw,ntoplw+1)
  4570. fsdl(i,ntoplw) = stebol*(tplnke(i)**4)*emstot(i,ntoplw)
  4571. end do
  4572. !
  4573. ! fsdl(i,pverp) assumes isothermal layer
  4574. !
  4575. do k=ntoplw+1,pver
  4576. do i=1,ncol
  4577. fsul(i,k) = fsul(i,pverp) - abstot(i,k,pverp)*tmp(i) + s(i,k,k+1)
  4578. fsdl(i,k) = stebol*(tplnke(i)**4)*emstot(i,k) - (s(i,k,ntoplw+1) - s(i,k,k+1))
  4579. end do
  4580. end do
  4581. !
  4582. ! Store the downward emission from level 1 = total gas emission * sigma
  4583. ! t**4. fsdl does not yet include all terms
  4584. !
  4585. do i=1,ncol
  4586. absbt(i) = stebol*(tplnke(i)**4)*emstot(i,pverp)
  4587. fsdl(i,pverp) = absbt(i) - s(i,pverp,ntoplw+1)
  4588. end do
  4589. !
  4590. !----------------------------------------------------------------------
  4591. ! Modifications for clouds -- max/random overlap assumption
  4592. !
  4593. ! The column is divided into sets of adjacent layers, called regions,
  4594. ! in which the clouds are maximally overlapped. The clouds are
  4595. ! randomly overlapped between different regions. The number of
  4596. ! regions in a column is set by nmxrgn, and the range of pressures
  4597. ! included in each region is set by pmxrgn. The max/random overlap
  4598. ! can be written in terms of the solutions of random overlap with
  4599. ! cloud amounts = 1. The random overlap assumption is equivalent to
  4600. ! setting the flux boundary conditions (BCs) at the edges of each region
  4601. ! equal to the mean all-sky flux at those boundaries. Since the
  4602. ! emissivity array for propogating BCs is only computed for the
  4603. ! TOA BC, the flux BCs elsewhere in the atmosphere have to be formulated
  4604. ! in terms of solutions to the random overlap equations. This is done
  4605. ! by writing the flux BCs as the sum of a clear-sky flux and emission
  4606. ! from a cloud outside the region weighted by an emissivity. This
  4607. ! emissivity is determined from the location of the cloud and the
  4608. ! flux BC.
  4609. !
  4610. ! Copy cloud amounts to buffer with extra layer (needed for overlap logic)
  4611. !
  4612. cldp(:ncol,ntoplw:pver) = cld(:ncol,ntoplw:pver)
  4613. cldp(:ncol,pverp) = 0.0
  4614. !
  4615. !
  4616. ! Select only those locations where there are no clouds
  4617. ! (maximum cloud fraction <= 1.e-3 treated as clear)
  4618. ! Set all-sky fluxes to clear-sky values.
  4619. !
  4620. maxcld(1:ncol) = maxval(cldp(1:ncol,ntoplw:pver),dim=2)
  4621. npts = 0
  4622. do i=1,ncol
  4623. if (maxcld(i) < cldmin) then
  4624. npts = npts + 1
  4625. indx(npts) = i
  4626. end if
  4627. end do
  4628. do ii = 1, npts
  4629. i = indx(ii)
  4630. do k = ntoplw, pverp
  4631. fdl(i,k) = fsdl(i,k)
  4632. ful(i,k) = fsul(i,k)
  4633. end do
  4634. end do
  4635. !
  4636. ! Select only those locations where there are clouds
  4637. !
  4638. npts = 0
  4639. do i=1,ncol
  4640. if (maxcld(i) >= cldmin) then
  4641. npts = npts + 1
  4642. indx(npts) = i
  4643. end if
  4644. end do
  4645. !
  4646. ! Initialize all-sky fluxes. fdl(i,1) & ful(i,pverp) are boundary conditions
  4647. !
  4648. do ii = 1, npts
  4649. i = indx(ii)
  4650. fdl(i,ntoplw) = fsdl(i,ntoplw)
  4651. fdl(i,pverp) = 0.0
  4652. ful(i,ntoplw) = 0.0
  4653. ful(i,pverp) = fsul(i,pverp)
  4654. do k = ntoplw+1, pver
  4655. fdl(i,k) = 0.0
  4656. ful(i,k) = 0.0
  4657. end do
  4658. !
  4659. ! Initialize Planck emission from layer boundaries
  4660. !
  4661. do k = ntoplw, pver
  4662. fclt4(i,k-1) = stebol*tint4(i,k)
  4663. fclb4(i,k-1) = stebol*tint4(i,k+1)
  4664. enddo
  4665. fclb4(i,ntoplw-2) = stebol*tint4(i,ntoplw)
  4666. fclt4(i,pver) = stebol*tint4(i,pverp)
  4667. !
  4668. ! Initialize indices for layers to be max-overlapped
  4669. !
  4670. do irgn = 0, nmxrgn(i)
  4671. kx2(i,irgn) = ntoplw-1
  4672. end do
  4673. nrgn(i) = 0
  4674. end do
  4675. !----------------------------------------------------------------------
  4676. ! INDEX CALCULATIONS FOR MAX OVERLAP
  4677. do ii = 1, npts
  4678. ilon = indx(ii)
  4679. !
  4680. ! Outermost loop over regions (sets of adjacent layers) to be max overlapped
  4681. !
  4682. do irgn = 1, nmxrgn(ilon)
  4683. !
  4684. ! Calculate min/max layer indices inside region.
  4685. !
  4686. n = 0
  4687. if (kx2(ilon,irgn-1) < pver) then
  4688. nrgn(ilon) = irgn
  4689. k1 = kx2(ilon,irgn-1)+1
  4690. kx1(ilon,irgn) = k1
  4691. kx2(ilon,irgn) = 0
  4692. do k2 = pver, k1, -1
  4693. if (pmid(ilon,k2) <= pmxrgn(ilon,irgn)) then
  4694. kx2(ilon,irgn) = k2
  4695. exit
  4696. end if
  4697. end do
  4698. !
  4699. ! Identify columns with clouds in the given region.
  4700. !
  4701. do k = k1, k2
  4702. if (cldp(ilon,k) >= cldmin) then
  4703. n = n+1
  4704. indxmx(n,irgn) = ilon
  4705. exit
  4706. endif
  4707. end do
  4708. endif
  4709. ncolmx(irgn) = n
  4710. !
  4711. ! Dummy value for handling clear-sky regions
  4712. !
  4713. !!$ indxmx(ncolmx(irgn)+1,irgn) = ncol+1
  4714. !
  4715. ! Outer loop over columns with clouds in the max-overlap region
  4716. !
  4717. do iimx = 1, ncolmx(irgn)
  4718. i = indxmx(iimx,irgn)
  4719. !
  4720. ! Sort cloud areas and corresponding level indices.
  4721. !
  4722. n = 0
  4723. do k = kx1(i,irgn),kx2(i,irgn)
  4724. if (cldp(i,k) >= cldmin) then
  4725. n = n+1
  4726. ksort(n) = k
  4727. !
  4728. ! We need indices for clouds in order of largest to smallest, so
  4729. ! sort 1-cld in ascending order
  4730. !
  4731. asort(n) = 1.0-cldp(i,k)
  4732. end if
  4733. end do
  4734. nxs(i,irgn) = n
  4735. !
  4736. ! If nxs(i,irgn) eq 1, no need to sort.
  4737. ! If nxs(i,irgn) eq 2, sort by swapping if necessary
  4738. ! If nxs(i,irgn) ge 3, sort using local sort routine
  4739. !
  4740. if (nxs(i,irgn) == 2) then
  4741. if (asort(2) < asort(1)) then
  4742. ktmp = ksort(1)
  4743. ksort(1) = ksort(2)
  4744. ksort(2) = ktmp
  4745. atmp = asort(1)
  4746. asort(1) = asort(2)
  4747. asort(2) = atmp
  4748. endif
  4749. else if (nxs(i,irgn) >= 3) then
  4750. call sortarray(nxs(i,irgn),asort,ksort(1:))
  4751. endif
  4752. do l = 1, nxs(i,irgn)
  4753. kxs(l,i,irgn) = ksort(l)
  4754. end do
  4755. !
  4756. ! End loop over longitude i for fluxes
  4757. !
  4758. end do
  4759. !
  4760. ! End loop over regions irgn for max-overlap
  4761. !
  4762. end do
  4763. !
  4764. !----------------------------------------------------------------------
  4765. ! DOWNWARD FLUXES:
  4766. ! Outermost loop over regions (sets of adjacent layers) to be max overlapped
  4767. !
  4768. do irgn = 1, nmxrgn(ilon)
  4769. !
  4770. ! Compute clear-sky fluxes for regions without clouds
  4771. !
  4772. iimx = 1
  4773. if (ilon < indxmx(iimx,irgn) .and. irgn <= nrgn(ilon)) then
  4774. !
  4775. ! Calculate emissivity so that downward flux at upper boundary of region
  4776. ! can be cast in form of solution for downward flux from cloud above
  4777. ! that boundary. Then solutions for fluxes at other levels take form of
  4778. ! random overlap expressions. Try to locate "cloud" as close as possible
  4779. ! to TOA such that the "cloud" pseudo-emissivity is between 0 and 1.
  4780. !
  4781. k1 = kx1(ilon,irgn)
  4782. do km1 = ntoplw-2, k1-2
  4783. km4 = km1+3
  4784. k2 = k1
  4785. k3 = k2+1
  4786. tmp(ilon) = s(ilon,k2,min(k3,pverp))*min(1,pverp2-k3)
  4787. emx0 = (fdl(ilon,k1)-fsdl(ilon,k1))/ &
  4788. ((fclb4(ilon,km1)-s(ilon,k2,km4)+tmp(ilon))- fsdl(ilon,k1))
  4789. if (emx0 >= 0.0 .and. emx0 <= 1.0) exit
  4790. end do
  4791. km1 = min(km1,k1-2)
  4792. do k2 = kx1(ilon,irgn)+1, kx2(ilon,irgn)+1
  4793. k3 = k2+1
  4794. tmp(ilon) = s(ilon,k2,min(k3,pverp))*min(1,pverp2-k3)
  4795. fdl(ilon,k2) = (1.0-emx0)*fsdl(ilon,k2) + &
  4796. emx0*(fclb4(ilon,km1)-s(ilon,k2,km4)+tmp(ilon))
  4797. end do
  4798. else if (ilon==indxmx(iimx,irgn) .and. iimx<=ncolmx(irgn)) then
  4799. iimx = iimx+1
  4800. end if
  4801. !
  4802. ! Outer loop over columns with clouds in the max-overlap region
  4803. !
  4804. do iimx = 1, ncolmx(irgn)
  4805. i = indxmx(iimx,irgn)
  4806. !
  4807. ! Calculate emissivity so that downward flux at upper boundary of region
  4808. ! can be cast in form of solution for downward flux from cloud above that
  4809. ! boundary. Then solutions for fluxes at other levels take form of
  4810. ! random overlap expressions. Try to locate "cloud" as close as possible
  4811. ! to TOA such that the "cloud" pseudo-emissivity is between 0 and 1.
  4812. !
  4813. k1 = kx1(i,irgn)
  4814. do km1 = ntoplw-2,k1-2
  4815. km4 = km1+3
  4816. k2 = k1
  4817. k3 = k2 + 1
  4818. tmp(i) = s(i,k2,min(k3,pverp))*min(1,pverp2-k3)
  4819. tmp2(i) = s(i,k2,min(km4,pverp))*min(1,pverp2-km4)
  4820. emx0 = (fdl(i,k1)-fsdl(i,k1))/((fclb4(i,km1)-tmp2(i)+tmp(i))-fsdl(i,k1))
  4821. if (emx0 >= 0.0 .and. emx0 <= 1.0) exit
  4822. end do
  4823. km1 = min(km1,k1-2)
  4824. ksort(0) = km1 + 1
  4825. !
  4826. ! Loop to calculate fluxes at level k
  4827. !
  4828. nxsk = 0
  4829. do k = kx1(i,irgn), kx2(i,irgn)
  4830. !
  4831. ! Identify clouds (largest to smallest area) between kx1 and k
  4832. ! Since nxsk will increase with increasing k up to nxs(i,irgn), once
  4833. ! nxsk == nxs(i,irgn) then use the list constructed for previous k
  4834. !
  4835. if (nxsk < nxs(i,irgn)) then
  4836. nxsk = 0
  4837. do l = 1, nxs(i,irgn)
  4838. k1 = kxs(l,i,irgn)
  4839. if (k >= k1) then
  4840. nxsk = nxsk + 1
  4841. ksort(nxsk) = k1
  4842. endif
  4843. end do
  4844. endif
  4845. !
  4846. ! Dummy value of index to insure computation of cloud amt is valid for l=nxsk+1
  4847. !
  4848. ksort(nxsk+1) = pverp
  4849. !
  4850. ! Initialize iterated emissivity factors
  4851. !
  4852. do l = 1, nxsk
  4853. emx(l) = emis(i,ksort(l))
  4854. end do
  4855. !
  4856. ! Initialize iterated emissivity factor for bnd. condition at upper interface
  4857. !
  4858. emx(0) = emx0
  4859. !
  4860. ! Initialize previous cloud amounts
  4861. !
  4862. cld0 = 1.0
  4863. !
  4864. ! Indices for flux calculations
  4865. !
  4866. k2 = k+1
  4867. k3 = k2+1
  4868. tmp(i) = s(i,k2,min(k3,pverp))*min(1,pverp2-k3)
  4869. !
  4870. ! Loop over number of cloud levels inside region (biggest to smallest cld area)
  4871. !
  4872. do l = 1, nxsk+1
  4873. !
  4874. ! Calculate downward fluxes
  4875. !
  4876. cld1 = cldp(i,ksort(l))*min(1,nxsk+1-l)
  4877. if (cld0 /= cld1) then
  4878. fdl(i,k2) = fdl(i,k2)+(cld0-cld1)*fsdl(i,k2)
  4879. do l1 = 0, l - 1
  4880. km1 = ksort(l1)-1
  4881. km4 = km1+3
  4882. tmp2(i) = s(i,k2,min(km4,pverp))* min(1,pverp2-km4)
  4883. fdl(i,k2) = fdl(i,k2)+(cld0-cld1)*emx(l1)*(fclb4(i,km1)-tmp2(i)+tmp(i)- &
  4884. fsdl(i,k2))
  4885. end do
  4886. endif
  4887. cld0 = cld1
  4888. !
  4889. ! Multiply emissivity factors by current cloud transmissivity
  4890. !
  4891. if (l <= nxsk) then
  4892. k1 = ksort(l)
  4893. trans = 1.0-emis(i,k1)
  4894. !
  4895. ! Ideally the upper bound on l1 would be l-1, but the sort routine
  4896. ! scrambles the order of layers with identical cloud amounts
  4897. !
  4898. do l1 = 0, nxsk
  4899. if (ksort(l1) < k1) then
  4900. emx(l1) = emx(l1)*trans
  4901. endif
  4902. end do
  4903. end if
  4904. !
  4905. ! End loop over number l of cloud levels
  4906. !
  4907. end do
  4908. !
  4909. ! End loop over level k for fluxes
  4910. !
  4911. end do
  4912. !
  4913. ! End loop over longitude i for fluxes
  4914. !
  4915. end do
  4916. !
  4917. ! End loop over regions irgn for max-overlap
  4918. !
  4919. end do
  4920. !
  4921. !----------------------------------------------------------------------
  4922. ! UPWARD FLUXES:
  4923. ! Outermost loop over regions (sets of adjacent layers) to be max overlapped
  4924. !
  4925. do irgn = nmxrgn(ilon), 1, -1
  4926. !
  4927. ! Compute clear-sky fluxes for regions without clouds
  4928. !
  4929. iimx = 1
  4930. if (ilon < indxmx(iimx,irgn) .and. irgn <= nrgn(ilon)) then
  4931. !
  4932. ! Calculate emissivity so that upward flux at lower boundary of region
  4933. ! can be cast in form of solution for upward flux from cloud below that
  4934. ! boundary. Then solutions for fluxes at other levels take form of
  4935. ! random overlap expressions. Try to locate "cloud" as close as possible
  4936. ! to surface such that the "cloud" pseudo-emissivity is between 0 and 1.
  4937. ! Include allowance for surface emissivity (both numerator and denominator
  4938. ! equal 1)
  4939. !
  4940. k1 = kx2(ilon,irgn)+1
  4941. if (k1 < pverp) then
  4942. do km1 = pver-1,kx2(ilon,irgn),-1
  4943. km3 = km1+2
  4944. k2 = k1
  4945. k3 = k2+1
  4946. tmp(ilon) = s(ilon,k2,min(km3,pverp))* min(1,pverp2-km3)
  4947. emx0 = (ful(ilon,k1)-fsul(ilon,k1))/ &
  4948. ((fclt4(ilon,km1)+s(ilon,k2,k3)-tmp(ilon))- fsul(ilon,k1))
  4949. if (emx0 >= 0.0 .and. emx0 <= 1.0) exit
  4950. end do
  4951. km1 = max(km1,kx2(ilon,irgn))
  4952. else
  4953. km1 = k1-1
  4954. km3 = km1+2
  4955. emx0 = 1.0
  4956. endif
  4957. do k2 = kx1(ilon,irgn), kx2(ilon,irgn)
  4958. k3 = k2+1
  4959. !
  4960. ! If km3 == pver+2, one of the s integrals = 0 (integration limits both = p_s)
  4961. !
  4962. tmp(ilon) = s(ilon,k2,min(km3,pverp))* min(1,pverp2-km3)
  4963. ful(ilon,k2) =(1.0-emx0)*fsul(ilon,k2) + emx0* &
  4964. (fclt4(ilon,km1)+s(ilon,k2,k3)-tmp(ilon))
  4965. end do
  4966. else if (ilon==indxmx(iimx,irgn) .and. iimx<=ncolmx(irgn)) then
  4967. iimx = iimx+1
  4968. end if
  4969. !
  4970. ! Outer loop over columns with clouds in the max-overlap region
  4971. !
  4972. do iimx = 1, ncolmx(irgn)
  4973. i = indxmx(iimx,irgn)
  4974. !
  4975. ! Calculate emissivity so that upward flux at lower boundary of region
  4976. ! can be cast in form of solution for upward flux from cloud at that
  4977. ! boundary. Then solutions for fluxes at other levels take form of
  4978. ! random overlap expressions. Try to locate "cloud" as close as possible
  4979. ! to surface such that the "cloud" pseudo-emissivity is between 0 and 1.
  4980. ! Include allowance for surface emissivity (both numerator and denominator
  4981. ! equal 1)
  4982. !
  4983. k1 = kx2(i,irgn)+1
  4984. if (k1 < pverp) then
  4985. do km1 = pver-1,kx2(i,irgn),-1
  4986. km3 = km1+2
  4987. k2 = k1
  4988. k3 = k2+1
  4989. tmp(i) = s(i,k2,min(km3,pverp))*min(1,pverp2-km3)
  4990. emx0 = (ful(i,k1)-fsul(i,k1))/((fclt4(i,km1)+s(i,k2,k3)-tmp(i))-fsul(i,k1))
  4991. if (emx0 >= 0.0 .and. emx0 <= 1.0) exit
  4992. end do
  4993. km1 = max(km1,kx2(i,irgn))
  4994. else
  4995. emx0 = 1.0
  4996. km1 = k1-1
  4997. endif
  4998. ksort(0) = km1 + 1
  4999. !
  5000. ! Loop to calculate fluxes at level k
  5001. !
  5002. nxsk = 0
  5003. do k = kx2(i,irgn), kx1(i,irgn), -1
  5004. !
  5005. ! Identify clouds (largest to smallest area) between k and kx2
  5006. ! Since nxsk will increase with decreasing k up to nxs(i,irgn), once
  5007. ! nxsk == nxs(i,irgn) then use the list constructed for previous k
  5008. !
  5009. if (nxsk < nxs(i,irgn)) then
  5010. nxsk = 0
  5011. do l = 1, nxs(i,irgn)
  5012. k1 = kxs(l,i,irgn)
  5013. if (k <= k1) then
  5014. nxsk = nxsk + 1
  5015. ksort(nxsk) = k1
  5016. endif
  5017. end do
  5018. endif
  5019. !
  5020. ! Dummy value of index to insure computation of cloud amt is valid for l=nxsk+1
  5021. !
  5022. ksort(nxsk+1) = pverp
  5023. !
  5024. ! Initialize iterated emissivity factors
  5025. !
  5026. do l = 1, nxsk
  5027. emx(l) = emis(i,ksort(l))
  5028. end do
  5029. !
  5030. ! Initialize iterated emissivity factor for bnd. condition at lower interface
  5031. !
  5032. emx(0) = emx0
  5033. !
  5034. ! Initialize previous cloud amounts
  5035. !
  5036. cld0 = 1.0
  5037. !
  5038. ! Indices for flux calculations
  5039. !
  5040. k2 = k
  5041. k3 = k2+1
  5042. !
  5043. ! Loop over number of cloud levels inside region (biggest to smallest cld area)
  5044. !
  5045. do l = 1, nxsk+1
  5046. !
  5047. ! Calculate upward fluxes
  5048. !
  5049. cld1 = cldp(i,ksort(l))*min(1,nxsk+1-l)
  5050. if (cld0 /= cld1) then
  5051. ful(i,k2) = ful(i,k2)+(cld0-cld1)*fsul(i,k2)
  5052. do l1 = 0, l - 1
  5053. km1 = ksort(l1)-1
  5054. km3 = km1+2
  5055. !
  5056. ! If km3 == pver+2, one of the s integrals = 0 (integration limits both = p_s)
  5057. !
  5058. tmp(i) = s(i,k2,min(km3,pverp))* min(1,pverp2-km3)
  5059. ful(i,k2) = ful(i,k2)+(cld0-cld1)*emx(l1)* &
  5060. (fclt4(i,km1)+s(i,k2,k3)-tmp(i)- fsul(i,k2))
  5061. end do
  5062. endif
  5063. cld0 = cld1
  5064. !
  5065. ! Multiply emissivity factors by current cloud transmissivity
  5066. !
  5067. if (l <= nxsk) then
  5068. k1 = ksort(l)
  5069. trans = 1.0-emis(i,k1)
  5070. !
  5071. ! Ideally the upper bound on l1 would be l-1, but the sort routine
  5072. ! scrambles the order of layers with identical cloud amounts
  5073. !
  5074. do l1 = 0, nxsk
  5075. if (ksort(l1) > k1) then
  5076. emx(l1) = emx(l1)*trans
  5077. endif
  5078. end do
  5079. end if
  5080. !
  5081. ! End loop over number l of cloud levels
  5082. !
  5083. end do
  5084. !
  5085. ! End loop over level k for fluxes
  5086. !
  5087. end do
  5088. !
  5089. ! End loop over longitude i for fluxes
  5090. !
  5091. end do
  5092. !
  5093. ! End loop over regions irgn for max-overlap
  5094. !
  5095. end do
  5096. !
  5097. ! End outermost longitude loop
  5098. !
  5099. end do
  5100. !
  5101. ! End cloud modification loops
  5102. !
  5103. !----------------------------------------------------------------------
  5104. ! All longitudes: store history tape quantities
  5105. !
  5106. do i=1,ncol
  5107. flwds(i) = fdl (i,pverp )
  5108. flns(i) = ful (i,pverp ) - fdl (i,pverp )
  5109. flnsc(i) = fsul(i,pverp ) - fsdl(i,pverp )
  5110. flnt(i) = ful (i,ntoplw) - fdl (i,ntoplw)
  5111. flntc(i) = fsul(i,ntoplw) - fsdl(i,ntoplw)
  5112. flut(i) = ful (i,ntoplw)
  5113. flutc(i) = fsul(i,ntoplw)
  5114. end do
  5115. !
  5116. ! Computation of longwave heating (J/kg/s)
  5117. !
  5118. do k=ntoplw,pver
  5119. do i=1,ncol
  5120. qrl(i,k) = (ful(i,k) - fdl(i,k) - ful(i,k+1) + fdl(i,k+1))* &
  5121. 1.E-4*gravit/((pint(i,k) - pint(i,k+1)))
  5122. end do
  5123. end do
  5124. ! Return 0 above solution domain
  5125. if ( ntoplw > 1 )then
  5126. qrl(:ncol,:ntoplw-1) = 0.
  5127. end if
  5128. ! Added downward/upward total and clear sky fluxes
  5129. !
  5130. do k=ntoplw,pverp
  5131. do i=1,ncol
  5132. flup(i,k) = ful(i,k)
  5133. flupc(i,k) = fsul(i,k)
  5134. fldn(i,k) = fdl(i,k)
  5135. fldnc(i,k) = fsdl(i,k)
  5136. end do
  5137. end do
  5138. ! Return 0 above solution domain
  5139. if ( ntoplw > 1 )then
  5140. flup(:ncol,:ntoplw-1) = 0.
  5141. flupc(:ncol,:ntoplw-1) = 0.
  5142. fldn(:ncol,:ntoplw-1) = 0.
  5143. fldnc(:ncol,:ntoplw-1) = 0.
  5144. end if
  5145. !
  5146. return
  5147. end subroutine radclwmx
  5148. subroutine radcswmx(jj, lchnk ,ncol ,pcols, pver, pverp, &
  5149. pint ,pmid ,h2ommr ,rh ,o3mmr , &
  5150. aermmr ,cld ,cicewp ,cliqwp ,rel , &
  5151. ! rei ,eccf ,coszrs ,scon ,solin ,solcon, &
  5152. rei ,tauxcl ,tauxci ,eccf ,coszrs ,scon ,solin ,solcon, &
  5153. asdir ,asdif ,aldir ,aldif ,nmxrgn , &
  5154. pmxrgn ,qrs ,fsnt ,fsntc ,fsntoa , &
  5155. fsntoac ,fsnirtoa,fsnrtoac,fsnrtoaq,fsns , &
  5156. fsnsc ,fsdsc ,fsds ,sols ,soll , &
  5157. solsd ,solld ,frc_day , &
  5158. fsup ,fsupc ,fsdn ,fsdnc , &
  5159. aertau ,aerssa ,aerasm ,aerfwd )
  5160. !-----------------------------------------------------------------------
  5161. !
  5162. ! Purpose:
  5163. ! Solar radiation code
  5164. !
  5165. ! Method:
  5166. ! Basic method is Delta-Eddington as described in:
  5167. !
  5168. ! Briegleb, Bruce P., 1992: Delta-Eddington
  5169. ! Approximation for Solar Radiation in the NCAR Community Climate Model,
  5170. ! Journal of Geophysical Research, Vol 97, D7, pp7603-7612).
  5171. !
  5172. ! Five changes to the basic method described above are:
  5173. ! (1) addition of sulfate aerosols (Kiehl and Briegleb, 1993)
  5174. ! (2) the distinction between liquid and ice particle clouds
  5175. ! (Kiehl et al, 1996);
  5176. ! (3) provision for calculating TOA fluxes with spectral response to
  5177. ! match Nimbus-7 visible/near-IR radiometers (Collins, 1998);
  5178. ! (4) max-random overlap (Collins, 2001)
  5179. ! (5) The near-IR absorption by H2O was updated in 2003 by Collins,
  5180. ! Lee-Taylor, and Edwards for consistency with the new line data in
  5181. ! Hitran 2000 and the H2O continuum version CKD 2.4. Modifications
  5182. ! were optimized by reducing RMS errors in heating rates relative
  5183. ! to a series of benchmark calculations for the 5 standard AFGL
  5184. ! atmospheres. The benchmarks were performed using DISORT2 combined
  5185. ! with GENLN3. The near-IR scattering optical depths for Rayleigh
  5186. ! scattering were also adjusted, as well as the correction for
  5187. ! stratospheric heating by H2O.
  5188. !
  5189. ! The treatment of maximum-random overlap is described in the
  5190. ! comment block "INDEX CALCULATIONS FOR MAX OVERLAP".
  5191. !
  5192. ! Divides solar spectrum into 19 intervals from 0.2-5.0 micro-meters.
  5193. ! solar flux fractions specified for each interval. allows for
  5194. ! seasonally and diurnally varying solar input. Includes molecular,
  5195. ! cloud, aerosol, and surface scattering, along with h2o,o3,co2,o2,cloud,
  5196. ! and surface absorption. Computes delta-eddington reflections and
  5197. ! transmissions assuming homogeneously mixed layers. Adds the layers
  5198. ! assuming scattering between layers to be isotropic, and distinguishes
  5199. ! direct solar beam from scattered radiation.
  5200. !
  5201. ! Longitude loops are broken into 1 or 2 sections, so that only daylight
  5202. ! (i.e. coszrs > 0) computations are done.
  5203. !
  5204. ! Note that an extra layer above the model top layer is added.
  5205. !
  5206. ! cgs units are used.
  5207. !
  5208. ! Special diagnostic calculation of the clear sky surface and total column
  5209. ! absorbed flux is also done for cloud forcing diagnostics.
  5210. !
  5211. !-----------------------------------------------------------------------
  5212. ! use shr_kind_mod, only: r8 => shr_kind_r8
  5213. ! use ppgrid
  5214. ! use ghg_surfvals, only: co2mmr
  5215. ! use prescribed_aerosols, only: idxBG, idxSUL, idxSSLT, idxOCPHO, idxBCPHO, idxOCPHI, idxBCPHI, &
  5216. ! idxDUSTfirst, numDUST, idxVOLC, naer_all
  5217. ! use aer_optics, only: nrh, ndstsz, ksul, wsul, gsul, &
  5218. ! ksslt, wsslt, gsslt, kcphil, wcphil, gcphil, kcphob, wcphob, gcphob, &
  5219. ! kcb, wcb, gcb, kdst, wdst, gdst, kbg, wbg, gbg, kvolc, wvolc, gvolc
  5220. ! use abortutils, only: endrun
  5221. implicit none
  5222. integer nspint ! Num of spctrl intervals across solar spectrum
  5223. integer naer_groups ! Num of aerosol groups for optical diagnostics
  5224. parameter ( nspint = 19 )
  5225. parameter ( naer_groups = 7 ) ! current groupings are sul, sslt, all carbons, all dust, and all aerosols
  5226. !-----------------------Constants for new band (640-700 nm)-------------
  5227. !-------------Parameters for accelerating max-random solution-------------
  5228. !
  5229. ! The solution time scales like prod(j:1->N) (1 + n_j) where
  5230. ! N = number of max-overlap regions (nmxrgn)
  5231. ! n_j = number of unique cloud amounts in region j
  5232. !
  5233. ! Therefore the solution cost can be reduced by decreasing n_j.
  5234. ! cldmin reduces n_j by treating cloud amounts < cldmin as clear sky.
  5235. ! cldeps reduces n_j by treating cloud amounts identical to log(1/cldeps)
  5236. ! decimal places as identical
  5237. !
  5238. ! areamin reduces the cost by dropping configurations that occupy
  5239. ! a surface area < areamin of the model grid box. The surface area
  5240. ! for a configuration C(j,k_j), where j is the region number and k_j is the
  5241. ! index for a unique cloud amount (in descending order from biggest to
  5242. ! smallest clouds) in region j, is
  5243. !
  5244. ! A = prod(j:1->N) [C(j,k_j) - C(j,k_j+1)]
  5245. !
  5246. ! where C(j,0) = 1.0 and C(j,n_j+1) = 0.0.
  5247. !
  5248. ! nconfgmax reduces the cost and improves load balancing by setting an upper
  5249. ! bound on the number of cloud configurations in the solution. If the number
  5250. ! of configurations exceeds nconfgmax, the nconfgmax configurations with the
  5251. ! largest area are retained, and the fluxes are normalized by the total area
  5252. ! of these nconfgmax configurations. For the current max/random overlap
  5253. ! assumption (see subroutine cldovrlap), 30 levels, and cloud-amount
  5254. ! parameterization, the mean and RMS number of configurations are
  5255. ! both roughly 5. nconfgmax has been set to the mean+2*RMS number, or 15.
  5256. !
  5257. ! Minimum cloud amount (as a fraction of the grid-box area) to
  5258. ! distinguish from clear sky
  5259. !
  5260. real(r8) cldmin
  5261. parameter (cldmin = 1.0e-80_r8)
  5262. !
  5263. ! Minimimum horizontal area (as a fraction of the grid-box area) to retain
  5264. ! for a unique cloud configuration in the max-random solution
  5265. !
  5266. real(r8) areamin
  5267. parameter (areamin = 0.01_r8)
  5268. !
  5269. ! Decimal precision of cloud amount (0 -> preserve full resolution;
  5270. ! 10^-n -> preserve n digits of cloud amount)
  5271. !
  5272. real(r8) cldeps
  5273. parameter (cldeps = 0.0_r8)
  5274. !
  5275. ! Maximum number of configurations to include in solution
  5276. !
  5277. integer nconfgmax
  5278. parameter (nconfgmax = 15)
  5279. !------------------------------Commons----------------------------------
  5280. !
  5281. ! Input arguments
  5282. !
  5283. integer, intent(in) :: lchnk,jj ! chunk identifier
  5284. integer, intent(in) :: pcols, pver, pverp
  5285. integer, intent(in) :: ncol ! number of atmospheric columns
  5286. real(r8), intent(in) :: pmid(pcols,pver) ! Level pressure
  5287. real(r8), intent(in) :: pint(pcols,pverp) ! Interface pressure
  5288. real(r8), intent(in) :: h2ommr(pcols,pver) ! Specific humidity (h2o mass mix ratio)
  5289. real(r8), intent(in) :: o3mmr(pcols,pver) ! Ozone mass mixing ratio
  5290. real(r8), intent(in) :: aermmr(pcols,pver,naer_all) ! Aerosol mass mixing ratio
  5291. real(r8), intent(in) :: rh(pcols,pver) ! Relative humidity (fraction)
  5292. !
  5293. real(r8), intent(in) :: cld(pcols,pver) ! Fractional cloud cover
  5294. real(r8), intent(in) :: cicewp(pcols,pver) ! in-cloud cloud ice water path
  5295. real(r8), intent(in) :: cliqwp(pcols,pver) ! in-cloud cloud liquid water path
  5296. real(r8), intent(in) :: rel(pcols,pver) ! Liquid effective drop size (microns)
  5297. real(r8), intent(in) :: rei(pcols,pver) ! Ice effective drop size (microns)
  5298. !
  5299. real(r8), intent(in) :: eccf ! Eccentricity factor (1./earth-sun dist^2)
  5300. real, intent(in) :: solcon ! solar constant with eccentricity factor
  5301. real(r8), intent(in) :: coszrs(pcols) ! Cosine solar zenith angle
  5302. real(r8), intent(in) :: asdir(pcols) ! 0.2-0.7 micro-meter srfc alb: direct rad
  5303. real(r8), intent(in) :: aldir(pcols) ! 0.7-5.0 micro-meter srfc alb: direct rad
  5304. real(r8), intent(in) :: asdif(pcols) ! 0.2-0.7 micro-meter srfc alb: diffuse rad
  5305. real(r8), intent(in) :: aldif(pcols) ! 0.7-5.0 micro-meter srfc alb: diffuse rad
  5306. real(r8), intent(in) :: scon ! solar constant
  5307. !
  5308. ! IN/OUT arguments
  5309. !
  5310. real(r8), intent(inout) :: pmxrgn(pcols,pverp) ! Maximum values of pressure for each
  5311. ! ! maximally overlapped region.
  5312. ! ! 0->pmxrgn(i,1) is range of pressure for
  5313. ! ! 1st region,pmxrgn(i,1)->pmxrgn(i,2) for
  5314. ! ! 2nd region, etc
  5315. integer, intent(inout) :: nmxrgn(pcols) ! Number of maximally overlapped regions
  5316. !
  5317. ! Output arguments
  5318. !
  5319. real(r8), intent(out) :: solin(pcols) ! Incident solar flux
  5320. real(r8), intent(out) :: qrs(pcols,pver) ! Solar heating rate
  5321. real(r8), intent(out) :: fsns(pcols) ! Surface absorbed solar flux
  5322. real(r8), intent(out) :: fsnt(pcols) ! Total column absorbed solar flux
  5323. real(r8), intent(out) :: fsntoa(pcols) ! Net solar flux at TOA
  5324. real(r8), intent(out) :: fsds(pcols) ! Flux shortwave downwelling surface
  5325. !
  5326. real(r8), intent(out) :: fsnsc(pcols) ! Clear sky surface absorbed solar flux
  5327. real(r8), intent(out) :: fsdsc(pcols) ! Clear sky surface downwelling solar flux
  5328. real(r8), intent(out) :: fsntc(pcols) ! Clear sky total column absorbed solar flx
  5329. real(r8), intent(out) :: fsntoac(pcols) ! Clear sky net solar flx at TOA
  5330. real(r8), intent(out) :: sols(pcols) ! Direct solar rad on surface (< 0.7)
  5331. real(r8), intent(out) :: soll(pcols) ! Direct solar rad on surface (>= 0.7)
  5332. real(r8), intent(out) :: solsd(pcols) ! Diffuse solar rad on surface (< 0.7)
  5333. real(r8), intent(out) :: solld(pcols) ! Diffuse solar rad on surface (>= 0.7)
  5334. real(r8), intent(out) :: fsnirtoa(pcols) ! Near-IR flux absorbed at toa
  5335. real(r8), intent(out) :: fsnrtoac(pcols) ! Clear sky near-IR flux absorbed at toa
  5336. real(r8), intent(out) :: fsnrtoaq(pcols) ! Net near-IR flux at toa >= 0.7 microns
  5337. real(r8), intent(out) :: tauxcl(pcols,0:pver) ! water cloud extinction optical depth
  5338. real(r8), intent(out) :: tauxci(pcols,0:pver) ! ice cloud extinction optical depth
  5339. ! Added downward/upward total and clear sky fluxes
  5340. real(r8), intent(out) :: fsup(pcols,pverp) ! Total sky upward solar flux (spectrally summed)
  5341. real(r8), intent(out) :: fsupc(pcols,pverp) ! Clear sky upward solar flux (spectrally summed)
  5342. real(r8), intent(out) :: fsdn(pcols,pverp) ! Total sky downward solar flux (spectrally summed)
  5343. real(r8), intent(out) :: fsdnc(pcols,pverp) ! Clear sky downward solar flux (spectrally summed)
  5344. !
  5345. real(r8) , intent(out) :: frc_day(pcols) ! = 1 for daylight, =0 for night columns
  5346. real(r8) :: aertau(pcols,nspint,naer_groups) ! Aerosol column optical depth
  5347. real(r8) :: aerssa(pcols,nspint,naer_groups) ! Aerosol column averaged single scattering albedo
  5348. real(r8) :: aerasm(pcols,nspint,naer_groups) ! Aerosol column averaged asymmetry parameter
  5349. real(r8) :: aerfwd(pcols,nspint,naer_groups) ! Aerosol column averaged forward scattering
  5350. ! real(r8), intent(out) :: aertau(pcols,nspint,naer_groups) ! Aerosol column optical depth
  5351. ! real(r8), intent(out) :: aerssa(pcols,nspint,naer_groups) ! Aerosol column averaged single scattering albedo
  5352. ! real(r8), intent(out) :: aerasm(pcols,nspint,naer_groups) ! Aerosol column averaged asymmetry parameter
  5353. ! real(r8), intent(out) :: aerfwd(pcols,nspint,naer_groups) ! Aerosol column averaged forward scattering
  5354. !
  5355. !---------------------------Local variables-----------------------------
  5356. !
  5357. ! Max/random overlap variables
  5358. !
  5359. real(r8) asort(pverp) ! 1 - cloud amounts to be sorted for max ovrlp.
  5360. real(r8) atmp ! Temporary storage for sort when nxs = 2
  5361. real(r8) cld0 ! 1 - (cld amt) used to make wstr, cstr, nstr
  5362. real(r8) totwgt ! Total of xwgts = total fractional area of
  5363. ! grid-box covered by cloud configurations
  5364. ! included in solution to fluxes
  5365. real(r8) wgtv(nconfgmax) ! Weights for fluxes
  5366. ! 1st index is configuration number
  5367. real(r8) wstr(pverp,pverp) ! area weighting factors for streams
  5368. ! 1st index is for stream #,
  5369. ! 2nd index is for region #
  5370. real(r8) xexpt ! solar direct beam trans. for layer above
  5371. real(r8) xrdnd ! diffuse reflectivity for layer above
  5372. real(r8) xrupd ! diffuse reflectivity for layer below
  5373. real(r8) xrups ! direct-beam reflectivity for layer below
  5374. real(r8) xtdnt ! total trans for layers above
  5375. real(r8) xwgt ! product of cloud amounts
  5376. real(r8) yexpt ! solar direct beam trans. for layer above
  5377. real(r8) yrdnd ! diffuse reflectivity for layer above
  5378. real(r8) yrupd ! diffuse reflectivity for layer below
  5379. real(r8) ytdnd ! dif-beam transmission for layers above
  5380. real(r8) ytupd ! dif-beam transmission for layers below
  5381. real(r8) zexpt ! solar direct beam trans. for layer above
  5382. real(r8) zrdnd ! diffuse reflectivity for layer above
  5383. real(r8) zrupd ! diffuse reflectivity for layer below
  5384. real(r8) zrups ! direct-beam reflectivity for layer below
  5385. real(r8) ztdnt ! total trans for layers above
  5386. logical new_term ! Flag for configurations to include in fluxes
  5387. logical region_found ! flag for identifying regions
  5388. integer ccon(0:pverp,nconfgmax)
  5389. ! flags for presence of clouds
  5390. ! 1st index is for level # (including
  5391. ! layer above top of model and at surface)
  5392. ! 2nd index is for configuration #
  5393. integer cstr(0:pverp,pverp)
  5394. ! flags for presence of clouds
  5395. ! 1st index is for level # (including
  5396. ! layer above top of model and at surface)
  5397. ! 2nd index is for stream #
  5398. integer icond(0:pverp,nconfgmax)
  5399. ! Indices for copying rad. properties from
  5400. ! one identical downward cld config.
  5401. ! to another in adding method (step 2)
  5402. ! 1st index is for interface # (including
  5403. ! layer above top of model and at surface)
  5404. ! 2nd index is for configuration # range
  5405. integer iconu(0:pverp,nconfgmax)
  5406. ! Indices for copying rad. properties from
  5407. ! one identical upward configuration
  5408. ! to another in adding method (step 2)
  5409. ! 1st index is for interface # (including
  5410. ! layer above top of model and at surface)
  5411. ! 2nd index is for configuration # range
  5412. integer iconfig ! Counter for random-ovrlap configurations
  5413. integer irgn ! Index for max-overlap regions
  5414. integer is0 ! Lower end of stream index range
  5415. integer is1 ! Upper end of stream index range
  5416. integer isn ! Stream index
  5417. integer istr(pverp+1) ! index for stream #s during flux calculation
  5418. integer istrtd(0:pverp,0:nconfgmax+1)
  5419. ! indices into icond
  5420. ! 1st index is for interface # (including
  5421. ! layer above top of model and at surface)
  5422. ! 2nd index is for configuration # range
  5423. integer istrtu(0:pverp,0:nconfgmax+1)
  5424. ! indices into iconu
  5425. ! 1st index is for interface # (including
  5426. ! layer above top of model and at surface)
  5427. ! 2nd index is for configuration # range
  5428. integer j ! Configuration index
  5429. integer k1 ! Level index
  5430. integer k2 ! Level index
  5431. integer ksort(pverp) ! Level indices of cloud amounts to be sorted
  5432. integer ktmp ! Temporary storage for sort when nxs = 2
  5433. integer kx1(0:pverp) ! Level index for top of max-overlap region
  5434. integer kx2(0:pverp) ! Level index for bottom of max-overlap region
  5435. integer l ! Index
  5436. integer l0 ! Index
  5437. integer mrgn ! Counter for nrgn
  5438. integer mstr ! Counter for nstr
  5439. integer n0 ! Number of configurations with ccon(k,:)==0
  5440. integer n1 ! Number of configurations with ccon(k,:)==1
  5441. integer nconfig ! Number of random-ovrlap configurations
  5442. integer nconfigm ! Value of config before testing for areamin,
  5443. ! nconfgmax
  5444. integer npasses ! number of passes over the indexing loop
  5445. integer nrgn ! Number of max overlap regions at current
  5446. ! longitude
  5447. integer nstr(pverp) ! Number of unique cloud configurations
  5448. ! ("streams") in a max-overlapped region
  5449. ! 1st index is for region #
  5450. integer nuniq ! # of unique cloud configurations
  5451. integer nuniqd(0:pverp) ! # of unique cloud configurations: TOA
  5452. ! to level k
  5453. integer nuniqu(0:pverp) ! # of unique cloud configurations: surface
  5454. ! to level k
  5455. integer nxs ! Number of cloudy layers between k1 and k2
  5456. integer ptr0(nconfgmax) ! Indices of configurations with ccon(k,:)==0
  5457. integer ptr1(nconfgmax) ! Indices of configurations with ccon(k,:)==1
  5458. integer ptrc(nconfgmax) ! Pointer for configurations sorted by wgtv
  5459. ! integer findvalue ! Function for finding kth smallest element
  5460. ! in a vector
  5461. ! external findvalue
  5462. !
  5463. ! Other
  5464. !
  5465. integer ns ! Spectral loop index
  5466. integer i ! Longitude loop index
  5467. integer k ! Level loop index
  5468. integer km1 ! k - 1
  5469. integer kp1 ! k + 1
  5470. integer n ! Loop index for daylight
  5471. integer ndayc ! Number of daylight columns
  5472. integer idayc(pcols) ! Daytime column indices
  5473. integer indxsl ! Index for cloud particle properties
  5474. integer ksz ! dust size bin index
  5475. integer krh ! relative humidity bin index
  5476. integer kaer ! aerosol group index
  5477. real(r8) wrh ! weight for linear interpolation between lut points
  5478. real(r8) :: rhtrunc ! rh, truncated for the purposes of extrapolating
  5479. ! aerosol optical properties
  5480. real(r8) albdir(pcols,nspint) ! Current spc intrvl srf alb to direct rad
  5481. real(r8) albdif(pcols,nspint) ! Current spc intrvl srf alb to diffuse rad
  5482. !
  5483. real(r8) wgtint ! Weight for specific spectral interval
  5484. !
  5485. ! Diagnostic and accumulation arrays; note that sfltot, fswup, and
  5486. ! fswdn are not used in the computation,but are retained for future use.
  5487. !
  5488. real(r8) solflx ! Solar flux in current interval
  5489. real(r8) sfltot ! Spectrally summed total solar flux
  5490. real(r8) totfld(0:pver) ! Spectrally summed flux divergence
  5491. real(r8) fswup(0:pverp) ! Spectrally summed up flux
  5492. real(r8) fswdn(0:pverp) ! Spectrally summed down flux
  5493. real(r8) fswupc(0:pverp) ! Spectrally summed up clear sky flux
  5494. real(r8) fswdnc(0:pverp) ! Spectrally summed down clear sky flux
  5495. !
  5496. ! Cloud radiative property arrays
  5497. !
  5498. ! real(r8) tauxcl(pcols,0:pver) ! water cloud extinction optical depth
  5499. ! real(r8) tauxci(pcols,0:pver) ! ice cloud extinction optical depth
  5500. real(r8) wcl(pcols,0:pver) ! liquid cloud single scattering albedo
  5501. real(r8) gcl(pcols,0:pver) ! liquid cloud asymmetry parameter
  5502. real(r8) fcl(pcols,0:pver) ! liquid cloud forward scattered fraction
  5503. real(r8) wci(pcols,0:pver) ! ice cloud single scattering albedo
  5504. real(r8) gci(pcols,0:pver) ! ice cloud asymmetry parameter
  5505. real(r8) fci(pcols,0:pver) ! ice cloud forward scattered fraction
  5506. !
  5507. ! Aerosol mass paths by species
  5508. !
  5509. real(r8) usul(pcols,pver) ! sulfate (SO4)
  5510. real(r8) ubg(pcols,pver) ! background aerosol
  5511. real(r8) usslt(pcols,pver) ! sea-salt (SSLT)
  5512. real(r8) ucphil(pcols,pver) ! hydrophilic organic carbon (OCPHI)
  5513. real(r8) ucphob(pcols,pver) ! hydrophobic organic carbon (OCPHO)
  5514. real(r8) ucb(pcols,pver) ! black carbon (BCPHI + BCPHO)
  5515. real(r8) uvolc(pcols,pver) ! volcanic mass
  5516. real(r8) udst(ndstsz,pcols,pver) ! dust
  5517. !
  5518. ! local variables used for the external mixing of aerosol species
  5519. !
  5520. real(r8) tau_sul ! optical depth, sulfate
  5521. real(r8) tau_bg ! optical depth, background aerosol
  5522. real(r8) tau_sslt ! optical depth, sea-salt
  5523. real(r8) tau_cphil ! optical depth, hydrophilic carbon
  5524. real(r8) tau_cphob ! optical depth, hydrophobic carbon
  5525. real(r8) tau_cb ! optical depth, black carbon
  5526. real(r8) tau_volc ! optical depth, volcanic
  5527. real(r8) tau_dst(ndstsz) ! optical depth, dust, by size category
  5528. real(r8) tau_dst_tot ! optical depth, total dust
  5529. real(r8) tau_tot ! optical depth, total aerosol
  5530. real(r8) tau_w_sul ! optical depth * single scattering albedo, sulfate
  5531. real(r8) tau_w_bg ! optical depth * single scattering albedo, background aerosol
  5532. real(r8) tau_w_sslt ! optical depth * single scattering albedo, sea-salt
  5533. real(r8) tau_w_cphil ! optical depth * single scattering albedo, hydrophilic carbon
  5534. real(r8) tau_w_cphob ! optical depth * single scattering albedo, hydrophobic carbon
  5535. real(r8) tau_w_cb ! optical depth * single scattering albedo, black carbon
  5536. real(r8) tau_w_volc ! optical depth * single scattering albedo, volcanic
  5537. real(r8) tau_w_dst(ndstsz) ! optical depth * single scattering albedo, dust, by size
  5538. real(r8) tau_w_dst_tot ! optical depth * single scattering albedo, total dust
  5539. real(r8) tau_w_tot ! optical depth * single scattering albedo, total aerosol
  5540. real(r8) tau_w_g_sul ! optical depth * single scattering albedo * asymmetry parameter, sulfate
  5541. real(r8) tau_w_g_bg ! optical depth * single scattering albedo * asymmetry parameter, background aerosol
  5542. real(r8) tau_w_g_sslt ! optical depth * single scattering albedo * asymmetry parameter, sea-salt
  5543. real(r8) tau_w_g_cphil ! optical depth * single scattering albedo * asymmetry parameter, hydrophilic carbon
  5544. real(r8) tau_w_g_cphob ! optical depth * single scattering albedo * asymmetry parameter, hydrophobic carbon
  5545. real(r8) tau_w_g_cb ! optical depth * single scattering albedo * asymmetry parameter, black carbon
  5546. real(r8) tau_w_g_volc ! optical depth * single scattering albedo * asymmetry parameter, volcanic
  5547. real(r8) tau_w_g_dst(ndstsz) ! optical depth * single scattering albedo * asymmetry parameter, dust, by size
  5548. real(r8) tau_w_g_dst_tot ! optical depth * single scattering albedo * asymmetry parameter, total dust
  5549. real(r8) tau_w_g_tot ! optical depth * single scattering albedo * asymmetry parameter, total aerosol
  5550. real(r8) f_sul ! forward scattering fraction, sulfate
  5551. real(r8) f_bg ! forward scattering fraction, background aerosol
  5552. real(r8) f_sslt ! forward scattering fraction, sea-salt
  5553. real(r8) f_cphil ! forward scattering fraction, hydrophilic carbon
  5554. real(r8) f_cphob ! forward scattering fraction, hydrophobic carbon
  5555. real(r8) f_cb ! forward scattering fraction, black carbon
  5556. real(r8) f_volc ! forward scattering fraction, volcanic
  5557. real(r8) f_dst(ndstsz) ! forward scattering fraction, dust, by size
  5558. real(r8) f_dst_tot ! forward scattering fraction, total dust
  5559. real(r8) f_tot ! forward scattering fraction, total aerosol
  5560. real(r8) tau_w_f_sul ! optical depth * forward scattering fraction * single scattering albedo, sulfate
  5561. real(r8) tau_w_f_bg ! optical depth * forward scattering fraction * single scattering albedo, background
  5562. real(r8) tau_w_f_sslt ! optical depth * forward scattering fraction * single scattering albedo, sea-salt
  5563. real(r8) tau_w_f_cphil ! optical depth * forward scattering fraction * single scattering albedo, hydrophilic C
  5564. real(r8) tau_w_f_cphob ! optical depth * forward scattering fraction * single scattering albedo, hydrophobic C
  5565. real(r8) tau_w_f_cb ! optical depth * forward scattering fraction * single scattering albedo, black C
  5566. real(r8) tau_w_f_volc ! optical depth * forward scattering fraction * single scattering albedo, volcanic
  5567. real(r8) tau_w_f_dst(ndstsz) ! optical depth * forward scattering fraction * single scattering albedo, dust, by size
  5568. real(r8) tau_w_f_dst_tot ! optical depth * forward scattering fraction * single scattering albedo, total dust
  5569. real(r8) tau_w_f_tot ! optical depth * forward scattering fraction * single scattering albedo, total aerosol
  5570. real(r8) w_dst_tot ! single scattering albedo, total dust
  5571. real(r8) w_tot ! single scattering albedo, total aerosol
  5572. real(r8) g_dst_tot ! asymmetry parameter, total dust
  5573. real(r8) g_tot ! asymmetry parameter, total aerosol
  5574. real(r8) ksuli ! specific extinction interpolated between rh look-up-table points, sulfate
  5575. real(r8) ksslti ! specific extinction interpolated between rh look-up-table points, sea-salt
  5576. real(r8) kcphili ! specific extinction interpolated between rh look-up-table points, hydrophilic carbon
  5577. real(r8) wsuli ! single scattering albedo interpolated between rh look-up-table points, sulfate
  5578. real(r8) wsslti ! single scattering albedo interpolated between rh look-up-table points, sea-salt
  5579. real(r8) wcphili ! single scattering albedo interpolated between rh look-up-table points, hydrophilic carbon
  5580. real(r8) gsuli ! asymmetry parameter interpolated between rh look-up-table points, sulfate
  5581. real(r8) gsslti ! asymmetry parameter interpolated between rh look-up-table points, sea-salt
  5582. real(r8) gcphili ! asymmetry parameter interpolated between rh look-up-table points, hydrophilic carbon
  5583. !
  5584. ! Aerosol radiative property arrays
  5585. !
  5586. real(r8) tauxar(pcols,0:pver) ! aerosol extinction optical depth
  5587. real(r8) wa(pcols,0:pver) ! aerosol single scattering albedo
  5588. real(r8) ga(pcols,0:pver) ! aerosol assymetry parameter
  5589. real(r8) fa(pcols,0:pver) ! aerosol forward scattered fraction
  5590. !
  5591. ! Various arrays and other constants:
  5592. !
  5593. real(r8) pflx(pcols,0:pverp) ! Interface press, including extra layer
  5594. real(r8) zenfac(pcols) ! Square root of cos solar zenith angle
  5595. real(r8) sqrco2 ! Square root of the co2 mass mixg ratio
  5596. real(r8) tmp1 ! Temporary constant array
  5597. real(r8) tmp2 ! Temporary constant array
  5598. real(r8) pdel ! Pressure difference across layer
  5599. real(r8) path ! Mass path of layer
  5600. real(r8) ptop ! Lower interface pressure of extra layer
  5601. real(r8) ptho2 ! Used to compute mass path of o2
  5602. real(r8) ptho3 ! Used to compute mass path of o3
  5603. real(r8) pthco2 ! Used to compute mass path of co2
  5604. real(r8) pthh2o ! Used to compute mass path of h2o
  5605. real(r8) h2ostr ! Inverse sq. root h2o mass mixing ratio
  5606. real(r8) wavmid(nspint) ! Spectral interval middle wavelength
  5607. real(r8) trayoslp ! Rayleigh optical depth/standard pressure
  5608. real(r8) tmp1l ! Temporary constant array
  5609. real(r8) tmp2l ! Temporary constant array
  5610. real(r8) tmp3l ! Temporary constant array
  5611. real(r8) tmp1i ! Temporary constant array
  5612. real(r8) tmp2i ! Temporary constant array
  5613. real(r8) tmp3i ! Temporary constant array
  5614. real(r8) rdenom ! Multiple scattering term
  5615. real(r8) rdirexp ! layer direct ref times exp transmission
  5616. real(r8) tdnmexp ! total transmission - exp transmission
  5617. real(r8) psf(nspint) ! Frac of solar flux in spect interval
  5618. !
  5619. ! Layer absorber amounts; note that 0 refers to the extra layer added
  5620. ! above the top model layer
  5621. !
  5622. real(r8) uh2o(pcols,0:pver) ! Layer absorber amount of h2o
  5623. real(r8) uo3(pcols,0:pver) ! Layer absorber amount of o3
  5624. real(r8) uco2(pcols,0:pver) ! Layer absorber amount of co2
  5625. real(r8) uo2(pcols,0:pver) ! Layer absorber amount of o2
  5626. real(r8) uaer(pcols,0:pver) ! Layer aerosol amount
  5627. !
  5628. ! Total column absorber amounts:
  5629. !
  5630. real(r8) uth2o(pcols) ! Total column absorber amount of h2o
  5631. real(r8) uto3(pcols) ! Total column absorber amount of o3
  5632. real(r8) utco2(pcols) ! Total column absorber amount of co2
  5633. real(r8) uto2(pcols) ! Total column absorber amount of o2
  5634. !
  5635. ! These arrays are defined for pver model layers; 0 refers to the extra
  5636. ! layer on top:
  5637. !
  5638. real(r8) rdir(nspint,pcols,0:pver) ! Layer reflectivity to direct rad
  5639. real(r8) rdif(nspint,pcols,0:pver) ! Layer reflectivity to diffuse rad
  5640. real(r8) tdir(nspint,pcols,0:pver) ! Layer transmission to direct rad
  5641. real(r8) tdif(nspint,pcols,0:pver) ! Layer transmission to diffuse rad
  5642. real(r8) explay(nspint,pcols,0:pver) ! Solar beam exp trans. for layer
  5643. real(r8) rdirc(nspint,pcols,0:pver) ! Clear Layer reflec. to direct rad
  5644. real(r8) rdifc(nspint,pcols,0:pver) ! Clear Layer reflec. to diffuse rad
  5645. real(r8) tdirc(nspint,pcols,0:pver) ! Clear Layer trans. to direct rad
  5646. real(r8) tdifc(nspint,pcols,0:pver) ! Clear Layer trans. to diffuse rad
  5647. real(r8) explayc(nspint,pcols,0:pver) ! Solar beam exp trans. clear layer
  5648. real(r8) flxdiv ! Flux divergence for layer
  5649. !
  5650. !
  5651. ! Radiative Properties:
  5652. !
  5653. ! There are 1 classes of properties:
  5654. ! (1. All-sky bulk properties
  5655. ! (2. Clear-sky properties
  5656. !
  5657. ! The first set of properties are generated during step 2 of the solution.
  5658. !
  5659. ! These arrays are defined at model interfaces; in 1st index (for level #),
  5660. ! 0 is the top of the extra layer above the model top, and
  5661. ! pverp is the earth surface. 2nd index is for cloud configuration
  5662. ! defined over a whole column.
  5663. !
  5664. real(r8) exptdn(0:pverp,nconfgmax) ! Sol. beam trans from layers above
  5665. real(r8) rdndif(0:pverp,nconfgmax) ! Ref to dif rad for layers above
  5666. real(r8) rupdif(0:pverp,nconfgmax) ! Ref to dif rad for layers below
  5667. real(r8) rupdir(0:pverp,nconfgmax) ! Ref to dir rad for layers below
  5668. real(r8) tdntot(0:pverp,nconfgmax) ! Total trans for layers above
  5669. !
  5670. ! Bulk properties used during the clear-sky calculation.
  5671. !
  5672. real(r8) exptdnc(0:pverp) ! clr: Sol. beam trans from layers above
  5673. real(r8) rdndifc(0:pverp) ! clr: Ref to dif rad for layers above
  5674. real(r8) rupdifc(0:pverp) ! clr: Ref to dif rad for layers below
  5675. real(r8) rupdirc(0:pverp) ! clr: Ref to dir rad for layers below
  5676. real(r8) tdntotc(0:pverp) ! clr: Total trans for layers above
  5677. real(r8) fluxup(0:pverp) ! Up flux at model interface
  5678. real(r8) fluxdn(0:pverp) ! Down flux at model interface
  5679. real(r8) wexptdn ! Direct solar beam trans. to surface
  5680. ! moved to here from the module storage above, because these have to be thread-private. JM 20100217
  5681. real(r8) abarli ! A coefficient for current spectral band
  5682. real(r8) bbarli ! B coefficient for current spectral band
  5683. real(r8) cbarli ! C coefficient for current spectral band
  5684. real(r8) dbarli ! D coefficient for current spectral band
  5685. real(r8) ebarli ! E coefficient for current spectral band
  5686. real(r8) fbarli ! F coefficient for current spectral band
  5687. real(r8) abarii ! A coefficient for current spectral band
  5688. real(r8) bbarii ! B coefficient for current spectral band
  5689. real(r8) cbarii ! C coefficient for current spectral band
  5690. real(r8) dbarii ! D coefficient for current spectral band
  5691. real(r8) ebarii ! E coefficient for current spectral band
  5692. real(r8) fbarii ! F coefficient for current spectral band
  5693. ! JM 20100217
  5694. !
  5695. !-----------------------------------------------------------------------
  5696. ! START OF CALCULATION
  5697. !-----------------------------------------------------------------------
  5698. !
  5699. ! write (6, '(a, x, i3)') 'radcswmx : chunk identifier', lchnk
  5700. do i=1, ncol
  5701. !
  5702. ! Initialize output fields:
  5703. !
  5704. fsds(i) = 0.0_r8
  5705. fsnirtoa(i) = 0.0_r8
  5706. fsnrtoac(i) = 0.0_r8
  5707. fsnrtoaq(i) = 0.0_r8
  5708. fsns(i) = 0.0_r8
  5709. fsnsc(i) = 0.0_r8
  5710. fsdsc(i) = 0.0_r8
  5711. fsnt(i) = 0.0_r8
  5712. fsntc(i) = 0.0_r8
  5713. fsntoa(i) = 0.0_r8
  5714. fsntoac(i) = 0.0_r8
  5715. solin(i) = 0.0_r8
  5716. sols(i) = 0.0_r8
  5717. soll(i) = 0.0_r8
  5718. solsd(i) = 0.0_r8
  5719. solld(i) = 0.0_r8
  5720. ! initialize added downward/upward total and clear sky fluxes
  5721. do k=1,pverp
  5722. fsup(i,k) = 0.0_r8
  5723. fsupc(i,k) = 0.0_r8
  5724. fsdn(i,k) = 0.0_r8
  5725. fsdnc(i,k) = 0.0_r8
  5726. tauxcl(i,k-1) = 0.0_r8
  5727. tauxci(i,k-1) = 0.0_r8
  5728. end do
  5729. do k=1, pver
  5730. qrs(i,k) = 0.0_r8
  5731. end do
  5732. ! initialize aerosol diagnostic fields to 0.0
  5733. ! Average can be obtained by dividing <aerod>/<frc_day>
  5734. do kaer = 1, naer_groups
  5735. do ns = 1, nspint
  5736. frc_day(i) = 0.0_r8
  5737. aertau(i,ns,kaer) = 0.0_r8
  5738. aerssa(i,ns,kaer) = 0.0_r8
  5739. aerasm(i,ns,kaer) = 0.0_r8
  5740. aerfwd(i,ns,kaer) = 0.0_r8
  5741. end do
  5742. end do
  5743. end do
  5744. !
  5745. ! Compute starting, ending daytime loop indices:
  5746. ! *** Note this logic assumes day and night points are contiguous so
  5747. ! *** will not work in general with chunked data structure.
  5748. !
  5749. ndayc = 0
  5750. do i=1,ncol
  5751. if (coszrs(i) > 0.0_r8) then
  5752. ndayc = ndayc + 1
  5753. idayc(ndayc) = i
  5754. end if
  5755. end do
  5756. !
  5757. ! If night everywhere, return:
  5758. !
  5759. if (ndayc == 0) return
  5760. !
  5761. ! Perform other initializations
  5762. !
  5763. tmp1 = 0.5_r8/(gravit*sslp)
  5764. tmp2 = delta/gravit
  5765. sqrco2 = sqrt(co2mmr)
  5766. do n=1,ndayc
  5767. i=idayc(n)
  5768. !
  5769. ! Define solar incident radiation and interface pressures:
  5770. !
  5771. ! solin(i) = scon*eccf*coszrs(i)
  5772. !WRF use SOLCON (MKS) calculated outside
  5773. solin(i) = solcon*coszrs(i)*1000.
  5774. pflx(i,0) = 0._r8
  5775. do k=1,pverp
  5776. pflx(i,k) = pint(i,k)
  5777. end do
  5778. !
  5779. ! Compute optical paths:
  5780. !
  5781. ptop = pflx(i,1)
  5782. ptho2 = o2mmr * ptop / gravit
  5783. ptho3 = o3mmr(i,1) * ptop / gravit
  5784. pthco2 = sqrco2 * (ptop / gravit)
  5785. h2ostr = sqrt( 1._r8 / h2ommr(i,1) )
  5786. zenfac(i) = sqrt(coszrs(i))
  5787. pthh2o = ptop**2*tmp1 + (ptop*rga)* &
  5788. (h2ostr*zenfac(i)*delta)
  5789. uh2o(i,0) = h2ommr(i,1)*pthh2o
  5790. uco2(i,0) = zenfac(i)*pthco2
  5791. uo2 (i,0) = zenfac(i)*ptho2
  5792. uo3 (i,0) = ptho3
  5793. uaer(i,0) = 0.0_r8
  5794. do k=1,pver
  5795. pdel = pflx(i,k+1) - pflx(i,k)
  5796. path = pdel / gravit
  5797. ptho2 = o2mmr * path
  5798. ptho3 = o3mmr(i,k) * path
  5799. pthco2 = sqrco2 * path
  5800. h2ostr = sqrt(1.0_r8/h2ommr(i,k))
  5801. pthh2o = (pflx(i,k+1)**2 - pflx(i,k)**2)*tmp1 + pdel*h2ostr*zenfac(i)*tmp2
  5802. uh2o(i,k) = h2ommr(i,k)*pthh2o
  5803. uco2(i,k) = zenfac(i)*pthco2
  5804. uo2 (i,k) = zenfac(i)*ptho2
  5805. uo3 (i,k) = ptho3
  5806. usul(i,k) = aermmr(i,k,idxSUL) * path
  5807. ubg(i,k) = aermmr(i,k,idxBG) * path
  5808. usslt(i,k) = aermmr(i,k,idxSSLT) * path
  5809. if (usslt(i,k) .lt. 0.0) then ! usslt is sometimes small and negative, will be fixed
  5810. usslt(i,k) = 0.0
  5811. end if
  5812. ucphil(i,k) = aermmr(i,k,idxOCPHI) * path
  5813. ucphob(i,k) = aermmr(i,k,idxOCPHO) * path
  5814. ucb(i,k) = ( aermmr(i,k,idxBCPHO) + aermmr(i,k,idxBCPHI) ) * path
  5815. uvolc(i,k) = aermmr(i,k,idxVOLC)
  5816. do ksz = 1, ndstsz
  5817. udst(ksz,i,k) = aermmr(i,k,idxDUSTfirst-1+ksz) * path
  5818. end do
  5819. end do
  5820. !
  5821. ! Compute column absorber amounts for the clear sky computation:
  5822. !
  5823. uth2o(i) = 0.0_r8
  5824. uto3(i) = 0.0_r8
  5825. utco2(i) = 0.0_r8
  5826. uto2(i) = 0.0_r8
  5827. do k=1,pver
  5828. uth2o(i) = uth2o(i) + uh2o(i,k)
  5829. uto3(i) = uto3(i) + uo3(i,k)
  5830. utco2(i) = utco2(i) + uco2(i,k)
  5831. uto2(i) = uto2(i) + uo2(i,k)
  5832. end do
  5833. !
  5834. ! Set cloud properties for top (0) layer; so long as tauxcl is zero,
  5835. ! there is no cloud above top of model; the other cloud properties
  5836. ! are arbitrary:
  5837. !
  5838. tauxcl(i,0) = 0._r8
  5839. wcl(i,0) = 0.999999_r8
  5840. gcl(i,0) = 0.85_r8
  5841. fcl(i,0) = 0.725_r8
  5842. tauxci(i,0) = 0._r8
  5843. wci(i,0) = 0.999999_r8
  5844. gci(i,0) = 0.85_r8
  5845. fci(i,0) = 0.725_r8
  5846. !
  5847. ! Aerosol
  5848. !
  5849. tauxar(i,0) = 0._r8
  5850. wa(i,0) = 0.925_r8
  5851. ga(i,0) = 0.850_r8
  5852. fa(i,0) = 0.7225_r8
  5853. !
  5854. ! End do n=1,ndayc
  5855. !
  5856. end do
  5857. !
  5858. ! Begin spectral loop
  5859. !
  5860. do ns=1,nspint
  5861. !
  5862. ! Set index for cloud particle properties based on the wavelength,
  5863. ! according to A. Slingo (1989) equations 1-3:
  5864. ! Use index 1 (0.25 to 0.69 micrometers) for visible
  5865. ! Use index 2 (0.69 - 1.19 micrometers) for near-infrared
  5866. ! Use index 3 (1.19 to 2.38 micrometers) for near-infrared
  5867. ! Use index 4 (2.38 to 4.00 micrometers) for near-infrared
  5868. !
  5869. ! Note that the minimum wavelength is encoded (with .001, .002, .003)
  5870. ! in order to specify the index appropriate for the near-infrared
  5871. ! cloud absorption properties
  5872. !
  5873. if(wavmax(ns) <= 0.7_r8) then
  5874. indxsl = 1
  5875. else if(wavmin(ns) == 0.700_r8) then
  5876. indxsl = 2
  5877. else if(wavmin(ns) == 0.701_r8) then
  5878. indxsl = 3
  5879. else if(wavmin(ns) == 0.702_r8 .or. wavmin(ns) > 2.38_r8) then
  5880. indxsl = 4
  5881. end if
  5882. !
  5883. ! Set cloud extinction optical depth, single scatter albedo,
  5884. ! asymmetry parameter, and forward scattered fraction:
  5885. !
  5886. abarli = abarl(indxsl)
  5887. bbarli = bbarl(indxsl)
  5888. cbarli = cbarl(indxsl)
  5889. dbarli = dbarl(indxsl)
  5890. ebarli = ebarl(indxsl)
  5891. fbarli = fbarl(indxsl)
  5892. !
  5893. abarii = abari(indxsl)
  5894. bbarii = bbari(indxsl)
  5895. cbarii = cbari(indxsl)
  5896. dbarii = dbari(indxsl)
  5897. ebarii = ebari(indxsl)
  5898. fbarii = fbari(indxsl)
  5899. !
  5900. ! adjustfraction within spectral interval to allow for the possibility of
  5901. ! sub-divisions within a particular interval:
  5902. !
  5903. psf(ns) = 1.0_r8
  5904. if(ph2o(ns)/=0._r8) psf(ns) = psf(ns)*ph2o(ns)
  5905. if(pco2(ns)/=0._r8) psf(ns) = psf(ns)*pco2(ns)
  5906. if(po2 (ns)/=0._r8) psf(ns) = psf(ns)*po2 (ns)
  5907. do n=1,ndayc
  5908. i=idayc(n)
  5909. frc_day(i) = 1.0_r8
  5910. do kaer = 1, naer_groups
  5911. aertau(i,ns,kaer) = 0.0
  5912. aerssa(i,ns,kaer) = 0.0
  5913. aerasm(i,ns,kaer) = 0.0
  5914. aerfwd(i,ns,kaer) = 0.0
  5915. end do
  5916. do k=1,pver
  5917. !
  5918. ! liquid
  5919. !
  5920. tmp1l = abarli + bbarli/rel(i,k)
  5921. tmp2l = 1._r8 - cbarli - dbarli*rel(i,k)
  5922. tmp3l = fbarli*rel(i,k)
  5923. !
  5924. ! ice
  5925. !
  5926. tmp1i = abarii + bbarii/rei(i,k)
  5927. tmp2i = 1._r8 - cbarii - dbarii*rei(i,k)
  5928. tmp3i = fbarii*rei(i,k)
  5929. if (cld(i,k) >= cldmin .and. cld(i,k) >= cldeps) then
  5930. tauxcl(i,k) = cliqwp(i,k)*tmp1l
  5931. tauxci(i,k) = cicewp(i,k)*tmp1i
  5932. else
  5933. tauxcl(i,k) = 0.0
  5934. tauxci(i,k) = 0.0
  5935. endif
  5936. !
  5937. ! Do not let single scatter albedo be 1. Delta-eddington solution
  5938. ! for non-conservative case has different analytic form from solution
  5939. ! for conservative case, and raddedmx is written for non-conservative case.
  5940. !
  5941. wcl(i,k) = min(tmp2l,.999999_r8)
  5942. gcl(i,k) = ebarli + tmp3l
  5943. fcl(i,k) = gcl(i,k)*gcl(i,k)
  5944. !
  5945. wci(i,k) = min(tmp2i,.999999_r8)
  5946. gci(i,k) = ebarii + tmp3i
  5947. fci(i,k) = gci(i,k)*gci(i,k)
  5948. !
  5949. ! Set aerosol properties
  5950. ! Conversion factor to adjust aerosol extinction (m2/g)
  5951. !
  5952. rhtrunc = rh(i,k)
  5953. rhtrunc = min(rh(i,k),1._r8)
  5954. ! if(rhtrunc.lt.0._r8) call endrun ('RADCSWMX')
  5955. krh = min(floor( rhtrunc * nrh ) + 1, nrh - 1)
  5956. wrh = rhtrunc * nrh - krh
  5957. ! linear interpolation of optical properties between rh table points
  5958. ksuli = ksul(krh + 1, ns) * (wrh + 1) - ksul(krh, ns) * wrh
  5959. ksslti = ksslt(krh + 1, ns) * (wrh + 1) - ksslt(krh, ns) * wrh
  5960. kcphili = kcphil(krh + 1, ns) * (wrh + 1) - kcphil(krh, ns) * wrh
  5961. wsuli = wsul(krh + 1, ns) * (wrh + 1) - wsul(krh, ns) * wrh
  5962. wsslti = wsslt(krh + 1, ns) * (wrh + 1) - wsslt(krh, ns) * wrh
  5963. wcphili = wcphil(krh + 1, ns) * (wrh + 1) - wcphil(krh, ns) * wrh
  5964. gsuli = gsul(krh + 1, ns) * (wrh + 1) - gsul(krh, ns) * wrh
  5965. gsslti = gsslt(krh + 1, ns) * (wrh + 1) - gsslt(krh, ns) * wrh
  5966. gcphili = gcphil(krh + 1, ns) * (wrh + 1) - gcphil(krh, ns) * wrh
  5967. tau_sul = 1.e4 * ksuli * usul(i,k)
  5968. tau_sslt = 1.e4 * ksslti * usslt(i,k)
  5969. tau_cphil = 1.e4 * kcphili * ucphil(i,k)
  5970. tau_cphob = 1.e4 * kcphob(ns) * ucphob(i,k)
  5971. tau_cb = 1.e4 * kcb(ns) * ucb(i,k)
  5972. tau_volc = 1.e3 * kvolc(ns) * uvolc(i,k)
  5973. tau_dst(:) = 1.e4 * kdst(:,ns) * udst(:,i,k)
  5974. tau_bg = 1.e4 * kbg(ns) * ubg(i,k)
  5975. tau_w_sul = tau_sul * wsuli
  5976. tau_w_sslt = tau_sslt * wsslti
  5977. tau_w_cphil = tau_cphil * wcphili
  5978. tau_w_cphob = tau_cphob * wcphob(ns)
  5979. tau_w_cb = tau_cb * wcb(ns)
  5980. tau_w_volc = tau_volc * wvolc(ns)
  5981. tau_w_dst(:) = tau_dst(:) * wdst(:,ns)
  5982. tau_w_bg = tau_bg * wbg(ns)
  5983. tau_w_g_sul = tau_w_sul * gsuli
  5984. tau_w_g_sslt = tau_w_sslt * gsslti
  5985. tau_w_g_cphil = tau_w_cphil * gcphili
  5986. tau_w_g_cphob = tau_w_cphob * gcphob(ns)
  5987. tau_w_g_cb = tau_w_cb * gcb(ns)
  5988. tau_w_g_volc = tau_w_volc * gvolc(ns)
  5989. tau_w_g_dst(:) = tau_w_dst(:) * gdst(:,ns)
  5990. tau_w_g_bg = tau_w_bg * gbg(ns)
  5991. f_sul = gsuli * gsuli
  5992. f_sslt = gsslti * gsslti
  5993. f_cphil = gcphili * gcphili
  5994. f_cphob = gcphob(ns) * gcphob(ns)
  5995. f_cb = gcb(ns) * gcb(ns)
  5996. f_volc = gvolc(ns) * gvolc(ns)
  5997. f_dst(:) = gdst(:,ns) * gdst(:,ns)
  5998. f_bg = gbg(ns) * gbg(ns)
  5999. tau_w_f_sul = tau_w_sul * f_sul
  6000. tau_w_f_bg = tau_w_bg * f_bg
  6001. tau_w_f_sslt = tau_w_sslt * f_sslt
  6002. tau_w_f_cphil = tau_w_cphil * f_cphil
  6003. tau_w_f_cphob = tau_w_cphob * f_cphob
  6004. tau_w_f_cb = tau_w_cb * f_cb
  6005. tau_w_f_volc = tau_w_volc * f_volc
  6006. tau_w_f_dst(:) = tau_w_dst(:) * f_dst(:)
  6007. !
  6008. ! mix dust aerosol size bins
  6009. ! w_dst_tot, g_dst_tot, w_dst_tot are currently not used anywhere
  6010. ! but calculate them anyway for future use
  6011. !
  6012. tau_dst_tot = sum(tau_dst)
  6013. tau_w_dst_tot = sum(tau_w_dst)
  6014. tau_w_g_dst_tot = sum(tau_w_g_dst)
  6015. tau_w_f_dst_tot = sum(tau_w_f_dst)
  6016. if (tau_dst_tot .gt. 0.0) then
  6017. w_dst_tot = tau_w_dst_tot / tau_dst_tot
  6018. else
  6019. w_dst_tot = 0.0
  6020. endif
  6021. if (tau_w_dst_tot .gt. 0.0) then
  6022. g_dst_tot = tau_w_g_dst_tot / tau_w_dst_tot
  6023. f_dst_tot = tau_w_f_dst_tot / tau_w_dst_tot
  6024. else
  6025. g_dst_tot = 0.0
  6026. f_dst_tot = 0.0
  6027. endif
  6028. !
  6029. ! mix aerosols
  6030. !
  6031. tau_tot = tau_sul + tau_sslt &
  6032. + tau_cphil + tau_cphob + tau_cb + tau_dst_tot
  6033. tau_tot = tau_tot + tau_bg + tau_volc
  6034. tau_w_tot = tau_w_sul + tau_w_sslt &
  6035. + tau_w_cphil + tau_w_cphob + tau_w_cb + tau_w_dst_tot
  6036. tau_w_tot = tau_w_tot + tau_w_bg + tau_w_volc
  6037. tau_w_g_tot = tau_w_g_sul + tau_w_g_sslt &
  6038. + tau_w_g_cphil + tau_w_g_cphob + tau_w_g_cb + tau_w_g_dst_tot
  6039. tau_w_g_tot = tau_w_g_tot + tau_w_g_bg + tau_w_g_volc
  6040. tau_w_f_tot = tau_w_f_sul + tau_w_f_sslt &
  6041. + tau_w_f_cphil + tau_w_f_cphob + tau_w_f_cb + tau_w_f_dst_tot
  6042. tau_w_f_tot = tau_w_f_tot + tau_w_f_bg + tau_w_f_volc
  6043. if (tau_tot .gt. 0.0) then
  6044. w_tot = tau_w_tot / tau_tot
  6045. else
  6046. w_tot = 0.0
  6047. endif
  6048. if (tau_w_tot .gt. 0.0) then
  6049. g_tot = tau_w_g_tot / tau_w_tot
  6050. f_tot = tau_w_f_tot / tau_w_tot
  6051. else
  6052. g_tot = 0.0
  6053. f_tot = 0.0
  6054. endif
  6055. tauxar(i,k) = tau_tot
  6056. wa(i,k) = min(w_tot, 0.999999_r8)
  6057. if (g_tot.gt.1._r8) write(6,*) "g_tot > 1"
  6058. if (g_tot.lt.-1._r8) write(6,*) "g_tot < -1"
  6059. ! if (g_tot.gt.1._r8) call endrun ('RADCSWMX')
  6060. ! if (g_tot.lt.-1._r8) call endrun ('RADCSWMX')
  6061. ga(i,k) = g_tot
  6062. if (f_tot.gt.1._r8) write(6,*)"f_tot > 1"
  6063. if (f_tot.lt.0._r8) write(6,*)"f_tot < 0"
  6064. ! if (f_tot.gt.1._r8) call endrun ('RADCSWMX')
  6065. ! if (f_tot.lt.0._r8) call endrun ('RADCSWMX')
  6066. fa(i,k) = f_tot
  6067. aertau(i,ns,1) = aertau(i,ns,1) + tau_sul
  6068. aertau(i,ns,2) = aertau(i,ns,2) + tau_sslt
  6069. aertau(i,ns,3) = aertau(i,ns,3) + tau_cphil + tau_cphob + tau_cb
  6070. aertau(i,ns,4) = aertau(i,ns,4) + tau_dst_tot
  6071. aertau(i,ns,5) = aertau(i,ns,5) + tau_bg
  6072. aertau(i,ns,6) = aertau(i,ns,6) + tau_volc
  6073. aertau(i,ns,7) = aertau(i,ns,7) + tau_tot
  6074. aerssa(i,ns,1) = aerssa(i,ns,1) + tau_w_sul
  6075. aerssa(i,ns,2) = aerssa(i,ns,2) + tau_w_sslt
  6076. aerssa(i,ns,3) = aerssa(i,ns,3) + tau_w_cphil + tau_w_cphob + tau_w_cb
  6077. aerssa(i,ns,4) = aerssa(i,ns,4) + tau_w_dst_tot
  6078. aerssa(i,ns,5) = aerssa(i,ns,5) + tau_w_bg
  6079. aerssa(i,ns,6) = aerssa(i,ns,6) + tau_w_volc
  6080. aerssa(i,ns,7) = aerssa(i,ns,7) + tau_w_tot
  6081. aerasm(i,ns,1) = aerasm(i,ns,1) + tau_w_g_sul
  6082. aerasm(i,ns,2) = aerasm(i,ns,2) + tau_w_g_sslt
  6083. aerasm(i,ns,3) = aerasm(i,ns,3) + tau_w_g_cphil + tau_w_g_cphob + tau_w_g_cb
  6084. aerasm(i,ns,4) = aerasm(i,ns,4) + tau_w_g_dst_tot
  6085. aerasm(i,ns,5) = aerasm(i,ns,5) + tau_w_g_bg
  6086. aerasm(i,ns,6) = aerasm(i,ns,6) + tau_w_g_volc
  6087. aerasm(i,ns,7) = aerasm(i,ns,7) + tau_w_g_tot
  6088. aerfwd(i,ns,1) = aerfwd(i,ns,1) + tau_w_f_sul
  6089. aerfwd(i,ns,2) = aerfwd(i,ns,2) + tau_w_f_sslt
  6090. aerfwd(i,ns,3) = aerfwd(i,ns,3) + tau_w_f_cphil + tau_w_f_cphob + tau_w_f_cb
  6091. aerfwd(i,ns,4) = aerfwd(i,ns,4) + tau_w_f_dst_tot
  6092. aerfwd(i,ns,5) = aerfwd(i,ns,5) + tau_w_f_bg
  6093. aerfwd(i,ns,6) = aerfwd(i,ns,6) + tau_w_f_volc
  6094. aerfwd(i,ns,7) = aerfwd(i,ns,7) + tau_w_f_tot
  6095. !
  6096. ! End do k=1,pver
  6097. !
  6098. end do
  6099. ! normalize aerosol optical diagnostic fields
  6100. do kaer = 1, naer_groups
  6101. if (aerssa(i,ns,kaer) .gt. 0.0) then ! aerssa currently holds product of tau and ssa
  6102. aerasm(i,ns,kaer) = aerasm(i,ns,kaer) / aerssa(i,ns,kaer)
  6103. aerfwd(i,ns,kaer) = aerfwd(i,ns,kaer) / aerssa(i,ns,kaer)
  6104. else
  6105. aerasm(i,ns,kaer) = 0.0_r8
  6106. aerfwd(i,ns,kaer) = 0.0_r8
  6107. end if
  6108. if (aertau(i,ns,kaer) .gt. 0.0) then
  6109. aerssa(i,ns,kaer) = aerssa(i,ns,kaer) / aertau(i,ns,kaer)
  6110. else
  6111. aerssa(i,ns,kaer) = 0.0_r8
  6112. end if
  6113. end do
  6114. !
  6115. ! End do n=1,ndayc
  6116. !
  6117. end do
  6118. !
  6119. ! Set reflectivities for surface based on mid-point wavelength
  6120. !
  6121. wavmid(ns) = 0.5_r8*(wavmin(ns) + wavmax(ns))
  6122. !
  6123. ! Wavelength less than 0.7 micro-meter
  6124. !
  6125. if (wavmid(ns) < 0.7_r8 ) then
  6126. do n=1,ndayc
  6127. i=idayc(n)
  6128. albdir(i,ns) = asdir(i)
  6129. albdif(i,ns) = asdif(i)
  6130. end do
  6131. !
  6132. ! Wavelength greater than 0.7 micro-meter
  6133. !
  6134. else
  6135. do n=1,ndayc
  6136. i=idayc(n)
  6137. albdir(i,ns) = aldir(i)
  6138. albdif(i,ns) = aldif(i)
  6139. end do
  6140. end if
  6141. trayoslp = raytau(ns)/sslp
  6142. !
  6143. ! Layer input properties now completely specified; compute the
  6144. ! delta-Eddington solution reflectivities and transmissivities
  6145. ! for each layer
  6146. !
  6147. call raddedmx(pver, pverp, pcols, coszrs ,ndayc ,idayc , &
  6148. abh2o(ns),abo3(ns) ,abco2(ns),abo2(ns) , &
  6149. uh2o ,uo3 ,uco2 ,uo2 , &
  6150. trayoslp ,pflx ,ns , &
  6151. tauxcl ,wcl ,gcl ,fcl , &
  6152. tauxci ,wci ,gci ,fci , &
  6153. tauxar ,wa ,ga ,fa , &
  6154. rdir ,rdif ,tdir ,tdif ,explay , &
  6155. rdirc ,rdifc ,tdirc ,tdifc ,explayc )
  6156. !
  6157. ! End spectral loop
  6158. !
  6159. end do
  6160. !
  6161. !----------------------------------------------------------------------
  6162. !
  6163. ! Solution for max/random cloud overlap.
  6164. !
  6165. ! Steps:
  6166. ! (1. delta-Eddington solution for each layer (called above)
  6167. !
  6168. ! (2. The adding method is used to
  6169. ! compute the reflectivity and transmissivity to direct and diffuse
  6170. ! radiation from the top and bottom of the atmosphere for each
  6171. ! cloud configuration. This calculation is based upon the
  6172. ! max-random overlap assumption.
  6173. !
  6174. ! (3. to solve for the fluxes, combine the
  6175. ! bulk properties of the atmosphere above/below the region.
  6176. !
  6177. ! Index calculations for steps 2-3 are performed outside spectral
  6178. ! loop to avoid redundant calculations. Index calculations (with
  6179. ! application of areamin & nconfgmax conditions) are performed
  6180. ! first to identify the minimum subset of terms for the configurations
  6181. ! satisfying the areamin & nconfgmax conditions. This minimum set is
  6182. ! used to identify the corresponding minimum subset of terms in
  6183. ! steps 2 and 3.
  6184. !
  6185. do n=1,ndayc
  6186. i=idayc(n)
  6187. !----------------------------------------------------------------------
  6188. ! INDEX CALCULATIONS FOR MAX OVERLAP
  6189. !
  6190. ! The column is divided into sets of adjacent layers, called regions,
  6191. ! in which the clouds are maximally overlapped. The clouds are
  6192. ! randomly overlapped between different regions. The number of
  6193. ! regions in a column is set by nmxrgn, and the range of pressures
  6194. ! included in each region is set by pmxrgn.
  6195. !
  6196. ! The following calculations determine the number of unique cloud
  6197. ! configurations (assuming maximum overlap), called "streams",
  6198. ! within each region. Each stream consists of a vector of binary
  6199. ! clouds (either 0 or 100% cloud cover). Over the depth of the region,
  6200. ! each stream requires a separate calculation of radiative properties. These
  6201. ! properties are generated using the adding method from
  6202. ! the radiative properties for each layer calculated by raddedmx.
  6203. !
  6204. ! The upward and downward-propagating streams are treated
  6205. ! separately.
  6206. !
  6207. ! We will refer to a particular configuration of binary clouds
  6208. ! within a single max-overlapped region as a "stream". We will
  6209. ! refer to a particular arrangement of binary clouds over the entire column
  6210. ! as a "configuration".
  6211. !
  6212. ! This section of the code generates the following information:
  6213. ! (1. nrgn : the true number of max-overlap regions (need not = nmxrgn)
  6214. ! (2. nstr : the number of streams in a region (>=1)
  6215. ! (3. cstr : flags for presence of clouds at each layer in each stream
  6216. ! (4. wstr : the fractional horizontal area of a grid box covered
  6217. ! by each stream
  6218. ! (5. kx1,2 : level indices for top/bottom of each region
  6219. !
  6220. ! The max-overlap calculation proceeds in 3 stages:
  6221. ! (1. compute layer radiative properties in raddedmx.
  6222. ! (2. combine these properties between layers
  6223. ! (3. combine properties to compute fluxes at each interface.
  6224. !
  6225. ! Most of the indexing information calculated here is used in steps 2-3
  6226. ! after the call to raddedmx.
  6227. !
  6228. ! Initialize indices for layers to be max-overlapped
  6229. !
  6230. ! Loop to handle fix in totwgt=0. For original overlap config
  6231. ! from npasses = 0.
  6232. !
  6233. npasses = 0
  6234. do
  6235. do irgn = 0, nmxrgn(i)
  6236. kx2(irgn) = 0
  6237. end do
  6238. mrgn = 0
  6239. !
  6240. ! Outermost loop over regions (sets of adjacent layers) to be max overlapped
  6241. !
  6242. do irgn = 1, nmxrgn(i)
  6243. !
  6244. ! Calculate min/max layer indices inside region.
  6245. !
  6246. region_found = .false.
  6247. if (kx2(irgn-1) < pver) then
  6248. k1 = kx2(irgn-1)+1
  6249. kx1(irgn) = k1
  6250. kx2(irgn) = k1-1
  6251. do k2 = pver, k1, -1
  6252. if (pmid(i,k2) <= pmxrgn(i,irgn)) then
  6253. kx2(irgn) = k2
  6254. mrgn = mrgn+1
  6255. region_found = .true.
  6256. exit
  6257. end if
  6258. end do
  6259. else
  6260. exit
  6261. endif
  6262. if (region_found) then
  6263. !
  6264. ! Sort cloud areas and corresponding level indices.
  6265. !
  6266. nxs = 0
  6267. if (cldeps > 0) then
  6268. do k = k1,k2
  6269. if (cld(i,k) >= cldmin .and. cld(i,k) >= cldeps) then
  6270. nxs = nxs+1
  6271. ksort(nxs) = k
  6272. !
  6273. ! We need indices for clouds in order of largest to smallest, so
  6274. ! sort 1-cld in ascending order
  6275. !
  6276. asort(nxs) = 1.0_r8-(floor(cld(i,k)/cldeps)*cldeps)
  6277. end if
  6278. end do
  6279. else
  6280. do k = k1,k2
  6281. if (cld(i,k) >= cldmin) then
  6282. nxs = nxs+1
  6283. ksort(nxs) = k
  6284. !
  6285. ! We need indices for clouds in order of largest to smallest, so
  6286. ! sort 1-cld in ascending order
  6287. !
  6288. asort(nxs) = 1.0_r8-cld(i,k)
  6289. end if
  6290. end do
  6291. endif
  6292. !
  6293. ! If nxs eq 1, no need to sort.
  6294. ! If nxs eq 2, sort by swapping if necessary
  6295. ! If nxs ge 3, sort using local sort routine
  6296. !
  6297. if (nxs == 2) then
  6298. if (asort(2) < asort(1)) then
  6299. ktmp = ksort(1)
  6300. ksort(1) = ksort(2)
  6301. ksort(2) = ktmp
  6302. atmp = asort(1)
  6303. asort(1) = asort(2)
  6304. asort(2) = atmp
  6305. endif
  6306. else if (nxs >= 3) then
  6307. call sortarray(nxs,asort,ksort)
  6308. endif
  6309. !
  6310. ! Construct wstr, cstr, nstr for this region
  6311. !
  6312. cstr(k1:k2,1:nxs+1) = 0
  6313. mstr = 1
  6314. cld0 = 0.0_r8
  6315. do l = 1, nxs
  6316. if (asort(l) /= cld0) then
  6317. wstr(mstr,mrgn) = asort(l) - cld0
  6318. cld0 = asort(l)
  6319. mstr = mstr + 1
  6320. endif
  6321. cstr(ksort(l),mstr:nxs+1) = 1
  6322. end do
  6323. nstr(mrgn) = mstr
  6324. wstr(mstr,mrgn) = 1.0_r8 - cld0
  6325. !
  6326. ! End test of region_found = true
  6327. !
  6328. endif
  6329. !
  6330. ! End loop over regions irgn for max-overlap
  6331. !
  6332. end do
  6333. nrgn = mrgn
  6334. !
  6335. ! Finish construction of cstr for additional top layer
  6336. !
  6337. cstr(0,1:nstr(1)) = 0
  6338. !
  6339. ! INDEX COMPUTATIONS FOR STEP 2-3
  6340. ! This section of the code generates the following information:
  6341. ! (1. totwgt step 3 total frac. area of configurations satisfying
  6342. ! areamin & nconfgmax criteria
  6343. ! (2. wgtv step 3 frac. area of configurations
  6344. ! (3. ccon step 2 binary flag for clouds in each configuration
  6345. ! (4. nconfig steps 2-3 number of configurations
  6346. ! (5. nuniqu/d step 2 Number of unique cloud configurations for
  6347. ! up/downwelling rad. between surface/TOA
  6348. ! and level k
  6349. ! (6. istrtu/d step 2 Indices into iconu/d
  6350. ! (7. iconu/d step 2 Cloud configurations which are identical
  6351. ! for up/downwelling rad. between surface/TOA
  6352. ! and level k
  6353. !
  6354. ! Number of configurations (all permutations of streams in each region)
  6355. !
  6356. nconfigm = product(nstr(1: nrgn))
  6357. !
  6358. ! Construction of totwgt, wgtv, ccon, nconfig
  6359. !
  6360. istr(1: nrgn) = 1
  6361. nconfig = 0
  6362. totwgt = 0.0_r8
  6363. new_term = .true.
  6364. do iconfig = 1, nconfigm
  6365. xwgt = 1.0_r8
  6366. do mrgn = 1, nrgn
  6367. xwgt = xwgt * wstr(istr(mrgn),mrgn)
  6368. end do
  6369. if (xwgt >= areamin) then
  6370. nconfig = nconfig + 1
  6371. if (nconfig <= nconfgmax) then
  6372. j = nconfig
  6373. ptrc(nconfig) = nconfig
  6374. else
  6375. nconfig = nconfgmax
  6376. if (new_term) then
  6377. j = findvalue(1,nconfig,wgtv,ptrc)
  6378. endif
  6379. if (wgtv(j) < xwgt) then
  6380. totwgt = totwgt - wgtv(j)
  6381. new_term = .true.
  6382. else
  6383. new_term = .false.
  6384. endif
  6385. endif
  6386. if (new_term) then
  6387. wgtv(j) = xwgt
  6388. totwgt = totwgt + xwgt
  6389. do mrgn = 1, nrgn
  6390. ccon(kx1(mrgn):kx2(mrgn),j) = cstr(kx1(mrgn):kx2(mrgn),istr(mrgn))
  6391. end do
  6392. endif
  6393. endif
  6394. mrgn = nrgn
  6395. istr(mrgn) = istr(mrgn) + 1
  6396. do while (istr(mrgn) > nstr(mrgn) .and. mrgn > 1)
  6397. istr(mrgn) = 1
  6398. mrgn = mrgn - 1
  6399. istr(mrgn) = istr(mrgn) + 1
  6400. end do
  6401. !
  6402. ! End do iconfig = 1, nconfigm
  6403. !
  6404. end do
  6405. !
  6406. ! If totwgt = 0 implement maximum overlap and make another pass
  6407. ! if totwgt = 0 on this second pass then terminate.
  6408. !
  6409. if (totwgt > 0.) then
  6410. exit
  6411. else
  6412. npasses = npasses + 1
  6413. if (npasses >= 2 ) then
  6414. write(6,*)'RADCSWMX: Maximum overlap of column ','failed'
  6415. call endrun
  6416. endif
  6417. nmxrgn(i)=1
  6418. pmxrgn(i,1)=1.0e30
  6419. end if
  6420. !
  6421. ! End npasses = 0, do
  6422. !
  6423. end do
  6424. !
  6425. !
  6426. ! Finish construction of ccon
  6427. !
  6428. ccon(0,:) = 0
  6429. ccon(pverp,:) = 0
  6430. !
  6431. ! Construction of nuniqu/d, istrtu/d, iconu/d using binary tree
  6432. !
  6433. nuniqd(0) = 1
  6434. nuniqu(pverp) = 1
  6435. istrtd(0,1) = 1
  6436. istrtu(pverp,1) = 1
  6437. do j = 1, nconfig
  6438. icond(0,j)=j
  6439. iconu(pverp,j)=j
  6440. end do
  6441. istrtd(0,2) = nconfig+1
  6442. istrtu(pverp,2) = nconfig+1
  6443. do k = 1, pverp
  6444. km1 = k-1
  6445. nuniq = 0
  6446. istrtd(k,1) = 1
  6447. do l0 = 1, nuniqd(km1)
  6448. is0 = istrtd(km1,l0)
  6449. is1 = istrtd(km1,l0+1)-1
  6450. n0 = 0
  6451. n1 = 0
  6452. do isn = is0, is1
  6453. j = icond(km1,isn)
  6454. if (ccon(k,j) == 0) then
  6455. n0 = n0 + 1
  6456. ptr0(n0) = j
  6457. endif
  6458. if (ccon(k,j) == 1) then
  6459. n1 = n1 + 1
  6460. ptr1(n1) = j
  6461. endif
  6462. end do
  6463. if (n0 > 0) then
  6464. nuniq = nuniq + 1
  6465. istrtd(k,nuniq+1) = istrtd(k,nuniq)+n0
  6466. icond(k,istrtd(k,nuniq):istrtd(k,nuniq+1)-1) = ptr0(1:n0)
  6467. endif
  6468. if (n1 > 0) then
  6469. nuniq = nuniq + 1
  6470. istrtd(k,nuniq+1) = istrtd(k,nuniq)+n1
  6471. icond(k,istrtd(k,nuniq):istrtd(k,nuniq+1)-1) = ptr1(1:n1)
  6472. endif
  6473. end do
  6474. nuniqd(k) = nuniq
  6475. end do
  6476. do k = pver, 0, -1
  6477. kp1 = k+1
  6478. nuniq = 0
  6479. istrtu(k,1) = 1
  6480. do l0 = 1, nuniqu(kp1)
  6481. is0 = istrtu(kp1,l0)
  6482. is1 = istrtu(kp1,l0+1)-1
  6483. n0 = 0
  6484. n1 = 0
  6485. do isn = is0, is1
  6486. j = iconu(kp1,isn)
  6487. if (ccon(k,j) == 0) then
  6488. n0 = n0 + 1
  6489. ptr0(n0) = j
  6490. endif
  6491. if (ccon(k,j) == 1) then
  6492. n1 = n1 + 1
  6493. ptr1(n1) = j
  6494. endif
  6495. end do
  6496. if (n0 > 0) then
  6497. nuniq = nuniq + 1
  6498. istrtu(k,nuniq+1) = istrtu(k,nuniq)+n0
  6499. iconu(k,istrtu(k,nuniq):istrtu(k,nuniq+1)-1) = ptr0(1:n0)
  6500. endif
  6501. if (n1 > 0) then
  6502. nuniq = nuniq + 1
  6503. istrtu(k,nuniq+1) = istrtu(k,nuniq)+n1
  6504. iconu(k,istrtu(k,nuniq):istrtu(k,nuniq+1)-1) = ptr1(1:n1)
  6505. endif
  6506. end do
  6507. nuniqu(k) = nuniq
  6508. end do
  6509. !
  6510. !----------------------------------------------------------------------
  6511. ! End of index calculations
  6512. !----------------------------------------------------------------------
  6513. !----------------------------------------------------------------------
  6514. ! Start of flux calculations
  6515. !----------------------------------------------------------------------
  6516. !
  6517. ! Initialize spectrally integrated totals:
  6518. !
  6519. do k=0,pver
  6520. totfld(k) = 0.0_r8
  6521. fswup (k) = 0.0_r8
  6522. fswdn (k) = 0.0_r8
  6523. fswupc (k) = 0.0_r8
  6524. fswdnc (k) = 0.0_r8
  6525. end do
  6526. sfltot = 0.0_r8
  6527. fswup (pverp) = 0.0_r8
  6528. fswdn (pverp) = 0.0_r8
  6529. fswupc (pverp) = 0.0_r8
  6530. fswdnc (pverp) = 0.0_r8
  6531. !
  6532. ! Start spectral interval
  6533. !
  6534. do ns = 1,nspint
  6535. wgtint = nirwgt(ns)
  6536. !----------------------------------------------------------------------
  6537. ! STEP 2
  6538. !
  6539. !
  6540. ! Apply adding method to solve for radiative properties
  6541. !
  6542. ! First initialize the bulk properties at TOA
  6543. !
  6544. rdndif(0,1:nconfig) = 0.0_r8
  6545. exptdn(0,1:nconfig) = 1.0_r8
  6546. tdntot(0,1:nconfig) = 1.0_r8
  6547. !
  6548. ! Solve for properties involving downward propagation of radiation.
  6549. ! The bulk properties are:
  6550. !
  6551. ! (1. exptdn Sol. beam dwn. trans from layers above
  6552. ! (2. rdndif Ref to dif rad for layers above
  6553. ! (3. tdntot Total trans for layers above
  6554. !
  6555. do k = 1, pverp
  6556. km1 = k - 1
  6557. do l0 = 1, nuniqd(km1)
  6558. is0 = istrtd(km1,l0)
  6559. is1 = istrtd(km1,l0+1)-1
  6560. j = icond(km1,is0)
  6561. xexpt = exptdn(km1,j)
  6562. xrdnd = rdndif(km1,j)
  6563. tdnmexp = tdntot(km1,j) - xexpt
  6564. if (ccon(km1,j) == 1) then
  6565. !
  6566. ! If cloud in layer, use cloudy layer radiative properties
  6567. !
  6568. ytdnd = tdif(ns,i,km1)
  6569. yrdnd = rdif(ns,i,km1)
  6570. rdenom = 1._r8/(1._r8-yrdnd*xrdnd)
  6571. rdirexp = rdir(ns,i,km1)*xexpt
  6572. zexpt = xexpt * explay(ns,i,km1)
  6573. zrdnd = yrdnd + xrdnd*(ytdnd**2)*rdenom
  6574. ztdnt = xexpt*tdir(ns,i,km1) + ytdnd*(tdnmexp + xrdnd*rdirexp)*rdenom
  6575. else
  6576. !
  6577. ! If clear layer, use clear-sky layer radiative properties
  6578. !
  6579. ytdnd = tdifc(ns,i,km1)
  6580. yrdnd = rdifc(ns,i,km1)
  6581. rdenom = 1._r8/(1._r8-yrdnd*xrdnd)
  6582. rdirexp = rdirc(ns,i,km1)*xexpt
  6583. zexpt = xexpt * explayc(ns,i,km1)
  6584. zrdnd = yrdnd + xrdnd*(ytdnd**2)*rdenom
  6585. ztdnt = xexpt*tdirc(ns,i,km1) + ytdnd* &
  6586. (tdnmexp + xrdnd*rdirexp)*rdenom
  6587. endif
  6588. !
  6589. ! If 2 or more configurations share identical properties at a given level k,
  6590. ! the properties (at level k) are computed once and copied to
  6591. ! all the configurations for efficiency.
  6592. !
  6593. do isn = is0, is1
  6594. j = icond(km1,isn)
  6595. exptdn(k,j) = zexpt
  6596. rdndif(k,j) = zrdnd
  6597. tdntot(k,j) = ztdnt
  6598. end do
  6599. !
  6600. ! end do l0 = 1, nuniqd(k)
  6601. !
  6602. end do
  6603. !
  6604. ! end do k = 1, pverp
  6605. !
  6606. end do
  6607. !
  6608. ! Solve for properties involving upward propagation of radiation.
  6609. ! The bulk properties are:
  6610. !
  6611. ! (1. rupdif Ref to dif rad for layers below
  6612. ! (2. rupdir Ref to dir rad for layers below
  6613. !
  6614. ! Specify surface boundary conditions (surface albedos)
  6615. !
  6616. rupdir(pverp,1:nconfig) = albdir(i,ns)
  6617. rupdif(pverp,1:nconfig) = albdif(i,ns)
  6618. do k = pver, 0, -1
  6619. do l0 = 1, nuniqu(k)
  6620. is0 = istrtu(k,l0)
  6621. is1 = istrtu(k,l0+1)-1
  6622. j = iconu(k,is0)
  6623. xrupd = rupdif(k+1,j)
  6624. xrups = rupdir(k+1,j)
  6625. if (ccon(k,j) == 1) then
  6626. !
  6627. ! If cloud in layer, use cloudy layer radiative properties
  6628. !
  6629. yexpt = explay(ns,i,k)
  6630. yrupd = rdif(ns,i,k)
  6631. ytupd = tdif(ns,i,k)
  6632. rdenom = 1._r8/( 1._r8 - yrupd*xrupd)
  6633. tdnmexp = (tdir(ns,i,k)-yexpt)
  6634. rdirexp = xrups*yexpt
  6635. zrupd = yrupd + xrupd*(ytupd**2)*rdenom
  6636. zrups = rdir(ns,i,k) + ytupd*(rdirexp + xrupd*tdnmexp)*rdenom
  6637. else
  6638. !
  6639. ! If clear layer, use clear-sky layer radiative properties
  6640. !
  6641. yexpt = explayc(ns,i,k)
  6642. yrupd = rdifc(ns,i,k)
  6643. ytupd = tdifc(ns,i,k)
  6644. rdenom = 1._r8/( 1._r8 - yrupd*xrupd)
  6645. tdnmexp = (tdirc(ns,i,k)-yexpt)
  6646. rdirexp = xrups*yexpt
  6647. zrupd = yrupd + xrupd*(ytupd**2)*rdenom
  6648. zrups = rdirc(ns,i,k) + ytupd*(rdirexp + xrupd*tdnmexp)*rdenom
  6649. endif
  6650. !
  6651. ! If 2 or more configurations share identical properties at a given level k,
  6652. ! the properties (at level k) are computed once and copied to
  6653. ! all the configurations for efficiency.
  6654. !
  6655. do isn = is0, is1
  6656. j = iconu(k,isn)
  6657. rupdif(k,j) = zrupd
  6658. rupdir(k,j) = zrups
  6659. end do
  6660. !
  6661. ! end do l0 = 1, nuniqu(k)
  6662. !
  6663. end do
  6664. !
  6665. ! end do k = pver,0,-1
  6666. !
  6667. end do
  6668. !
  6669. !----------------------------------------------------------------------
  6670. !
  6671. ! STEP 3
  6672. !
  6673. ! Compute up and down fluxes for each interface k. This requires
  6674. ! adding up the contributions from all possible permutations
  6675. ! of streams in all max-overlap regions, weighted by the
  6676. ! product of the fractional areas of the streams in each region
  6677. ! (the random overlap assumption). The adding principle has been
  6678. ! used in step 2 to combine the bulk radiative properties
  6679. ! above and below the interface.
  6680. !
  6681. do k = 0,pverp
  6682. !
  6683. ! Initialize the fluxes
  6684. !
  6685. fluxup(k)=0.0_r8
  6686. fluxdn(k)=0.0_r8
  6687. do iconfig = 1, nconfig
  6688. xwgt = wgtv(iconfig)
  6689. xexpt = exptdn(k,iconfig)
  6690. xtdnt = tdntot(k,iconfig)
  6691. xrdnd = rdndif(k,iconfig)
  6692. xrupd = rupdif(k,iconfig)
  6693. xrups = rupdir(k,iconfig)
  6694. !
  6695. ! Flux computation
  6696. !
  6697. rdenom = 1._r8/(1._r8 - xrdnd * xrupd)
  6698. fluxup(k) = fluxup(k) + xwgt * &
  6699. ((xexpt * xrups + (xtdnt - xexpt) * xrupd) * rdenom)
  6700. fluxdn(k) = fluxdn(k) + xwgt * &
  6701. (xexpt + (xtdnt - xexpt + xexpt * xrups * xrdnd) * rdenom)
  6702. !
  6703. ! End do iconfig = 1, nconfig
  6704. !
  6705. end do
  6706. !
  6707. ! Normalize by total area covered by cloud configurations included
  6708. ! in solution
  6709. !
  6710. fluxup(k)=fluxup(k) / totwgt
  6711. fluxdn(k)=fluxdn(k) / totwgt
  6712. !
  6713. ! End do k = 0,pverp
  6714. !
  6715. end do
  6716. !
  6717. ! Initialize the direct-beam flux at surface
  6718. !
  6719. wexptdn = 0.0_r8
  6720. do iconfig = 1, nconfig
  6721. wexptdn = wexptdn + wgtv(iconfig) * exptdn(pverp,iconfig)
  6722. end do
  6723. wexptdn = wexptdn / totwgt
  6724. !
  6725. ! Monochromatic computation completed; accumulate in totals
  6726. !
  6727. solflx = solin(i)*frcsol(ns)*psf(ns)
  6728. fsnt(i) = fsnt(i) + solflx*(fluxdn(1) - fluxup(1))
  6729. fsntoa(i)= fsntoa(i) + solflx*(fluxdn(0) - fluxup(0))
  6730. fsns(i) = fsns(i) + solflx*(fluxdn(pverp)-fluxup(pverp))
  6731. sfltot = sfltot + solflx
  6732. fswup(0) = fswup(0) + solflx*fluxup(0)
  6733. fswdn(0) = fswdn(0) + solflx*fluxdn(0)
  6734. !
  6735. ! Down spectral fluxes need to be in mks; thus the .001 conversion factors
  6736. !
  6737. if (wavmid(ns) < 0.7_r8) then
  6738. sols(i) = sols(i) + wexptdn*solflx*0.001_r8
  6739. solsd(i) = solsd(i)+(fluxdn(pverp)-wexptdn)*solflx*0.001_r8
  6740. else
  6741. soll(i) = soll(i) + wexptdn*solflx*0.001_r8
  6742. solld(i) = solld(i)+(fluxdn(pverp)-wexptdn)*solflx*0.001_r8
  6743. fsnrtoaq(i) = fsnrtoaq(i) + solflx*(fluxdn(0) - fluxup(0))
  6744. end if
  6745. fsnirtoa(i) = fsnirtoa(i) + wgtint*solflx*(fluxdn(0) - fluxup(0))
  6746. do k=0,pver
  6747. !
  6748. ! Compute flux divergence in each layer using the interface up and down
  6749. ! fluxes:
  6750. !
  6751. kp1 = k+1
  6752. flxdiv = (fluxdn(k ) - fluxdn(kp1)) + (fluxup(kp1) - fluxup(k ))
  6753. totfld(k) = totfld(k) + solflx*flxdiv
  6754. fswdn(kp1) = fswdn(kp1) + solflx*fluxdn(kp1)
  6755. fswup(kp1) = fswup(kp1) + solflx*fluxup(kp1)
  6756. end do
  6757. !
  6758. ! Perform clear-sky calculation
  6759. !
  6760. exptdnc(0) = 1.0_r8
  6761. rdndifc(0) = 0.0_r8
  6762. tdntotc(0) = 1.0_r8
  6763. rupdirc(pverp) = albdir(i,ns)
  6764. rupdifc(pverp) = albdif(i,ns)
  6765. do k = 1, pverp
  6766. km1 = k - 1
  6767. xexpt = exptdnc(km1)
  6768. xrdnd = rdndifc(km1)
  6769. yrdnd = rdifc(ns,i,km1)
  6770. ytdnd = tdifc(ns,i,km1)
  6771. exptdnc(k) = xexpt*explayc(ns,i,km1)
  6772. rdenom = 1._r8/(1._r8 - yrdnd*xrdnd)
  6773. rdirexp = rdirc(ns,i,km1)*xexpt
  6774. tdnmexp = tdntotc(km1) - xexpt
  6775. tdntotc(k) = xexpt*tdirc(ns,i,km1) + ytdnd*(tdnmexp + xrdnd*rdirexp)* &
  6776. rdenom
  6777. rdndifc(k) = yrdnd + xrdnd*(ytdnd**2)*rdenom
  6778. end do
  6779. do k=pver,0,-1
  6780. xrupd = rupdifc(k+1)
  6781. yexpt = explayc(ns,i,k)
  6782. yrupd = rdifc(ns,i,k)
  6783. ytupd = tdifc(ns,i,k)
  6784. rdenom = 1._r8/( 1._r8 - yrupd*xrupd)
  6785. rupdirc(k) = rdirc(ns,i,k) + ytupd*(rupdirc(k+1)*yexpt + &
  6786. xrupd*(tdirc(ns,i,k)-yexpt))*rdenom
  6787. rupdifc(k) = yrupd + xrupd*ytupd**2*rdenom
  6788. end do
  6789. do k=0,1
  6790. rdenom = 1._r8/(1._r8 - rdndifc(k)*rupdifc(k))
  6791. fluxup(k) = (exptdnc(k)*rupdirc(k) + (tdntotc(k)-exptdnc(k))*rupdifc(k))* &
  6792. rdenom
  6793. fluxdn(k) = exptdnc(k) + &
  6794. (tdntotc(k) - exptdnc(k) + exptdnc(k)*rupdirc(k)*rdndifc(k))* &
  6795. rdenom
  6796. fswupc(k) = fswupc(k) + solflx*fluxup(k)
  6797. fswdnc(k) = fswdnc(k) + solflx*fluxdn(k)
  6798. end do
  6799. ! k = pverp
  6800. do k=2,pverp
  6801. rdenom = 1._r8/(1._r8 - rdndifc(k)*rupdifc(k))
  6802. fluxup(k) = (exptdnc(k)*rupdirc(k) + (tdntotc(k)-exptdnc(k))*rupdifc(k))* &
  6803. rdenom
  6804. fluxdn(k) = exptdnc(k) + (tdntotc(k) - exptdnc(k) + &
  6805. exptdnc(k)*rupdirc(k)*rdndifc(k))*rdenom
  6806. fswupc(k) = fswupc(k) + solflx*fluxup(k)
  6807. fswdnc(k) = fswdnc(k) + solflx*fluxdn(k)
  6808. end do
  6809. fsntc(i) = fsntc(i)+solflx*(fluxdn(1)-fluxup(1))
  6810. fsntoac(i) = fsntoac(i)+solflx*(fluxdn(0)-fluxup(0))
  6811. fsnsc(i) = fsnsc(i)+solflx*(fluxdn(pverp)-fluxup(pverp))
  6812. fsdsc(i) = fsdsc(i)+solflx*(fluxdn(pverp))
  6813. fsnrtoac(i) = fsnrtoac(i)+wgtint*solflx*(fluxdn(0)-fluxup(0))
  6814. !
  6815. ! End of clear sky calculation
  6816. !
  6817. !
  6818. ! End of spectral interval loop
  6819. !
  6820. end do
  6821. !
  6822. ! Compute solar heating rate (J/kg/s)
  6823. !
  6824. do k=1,pver
  6825. qrs(i,k) = -1.E-4*gravit*totfld(k)/(pint(i,k) - pint(i,k+1))
  6826. end do
  6827. ! Added downward/upward total and clear sky fluxes
  6828. do k=1,pverp
  6829. fsup(i,k) = fswup(k)
  6830. fsupc(i,k) = fswupc(k)
  6831. fsdn(i,k) = fswdn(k)
  6832. fsdnc(i,k) = fswdnc(k)
  6833. end do
  6834. !
  6835. ! Set the downwelling flux at the surface
  6836. !
  6837. fsds(i) = fswdn(pverp)
  6838. !
  6839. ! End do n=1,ndayc
  6840. !
  6841. end do
  6842. ! write (6, '(a, x, i3)') 'radcswmx : exiting, chunk identifier', lchnk
  6843. return
  6844. end subroutine radcswmx
  6845. subroutine raddedmx(pver, pverp, pcols, coszrs ,ndayc ,idayc ,abh2o , &
  6846. abo3 ,abco2 ,abo2 ,uh2o ,uo3 , &
  6847. uco2 ,uo2 ,trayoslp,pflx ,ns , &
  6848. tauxcl ,wcl ,gcl ,fcl ,tauxci , &
  6849. wci ,gci ,fci ,tauxar ,wa , &
  6850. ga ,fa ,rdir ,rdif ,tdir , &
  6851. tdif ,explay ,rdirc ,rdifc ,tdirc , &
  6852. tdifc ,explayc )
  6853. !-----------------------------------------------------------------------
  6854. !
  6855. ! Purpose:
  6856. ! Computes layer reflectivities and transmissivities, from the top down
  6857. ! to the surface using the delta-Eddington solutions for each layer
  6858. !
  6859. ! Method:
  6860. ! For more details , see Briegleb, Bruce P., 1992: Delta-Eddington
  6861. ! Approximation for Solar Radiation in the NCAR Community Climate Model,
  6862. ! Journal of Geophysical Research, Vol 97, D7, pp7603-7612).
  6863. !
  6864. ! Modified for maximum/random cloud overlap by Bill Collins and John
  6865. ! Truesdale
  6866. !
  6867. ! Author: Bill Collins
  6868. !
  6869. !-----------------------------------------------------------------------
  6870. ! use shr_kind_mod, only: r8 => shr_kind_r8
  6871. ! use ppgrid
  6872. implicit none
  6873. integer nspint ! Num of spctrl intervals across solar spectrum
  6874. parameter ( nspint = 19 )
  6875. !
  6876. ! Minimum total transmission below which no layer computation are done:
  6877. !
  6878. real(r8) trmin ! Minimum total transmission allowed
  6879. real(r8) wray ! Rayleigh single scatter albedo
  6880. real(r8) gray ! Rayleigh asymetry parameter
  6881. real(r8) fray ! Rayleigh forward scattered fraction
  6882. parameter (trmin = 1.e-3)
  6883. parameter (wray = 0.999999)
  6884. parameter (gray = 0.0)
  6885. parameter (fray = 0.1)
  6886. !
  6887. !------------------------------Arguments--------------------------------
  6888. !
  6889. ! Input arguments
  6890. !
  6891. integer, intent(in) :: pver, pverp, pcols
  6892. real(r8), intent(in) :: coszrs(pcols) ! Cosine zenith angle
  6893. real(r8), intent(in) :: trayoslp ! Tray/sslp
  6894. real(r8), intent(in) :: pflx(pcols,0:pverp) ! Interface pressure
  6895. real(r8), intent(in) :: abh2o ! Absorption coefficiant for h2o
  6896. real(r8), intent(in) :: abo3 ! Absorption coefficiant for o3
  6897. real(r8), intent(in) :: abco2 ! Absorption coefficiant for co2
  6898. real(r8), intent(in) :: abo2 ! Absorption coefficiant for o2
  6899. real(r8), intent(in) :: uh2o(pcols,0:pver) ! Layer absorber amount of h2o
  6900. real(r8), intent(in) :: uo3(pcols,0:pver) ! Layer absorber amount of o3
  6901. real(r8), intent(in) :: uco2(pcols,0:pver) ! Layer absorber amount of co2
  6902. real(r8), intent(in) :: uo2(pcols,0:pver) ! Layer absorber amount of o2
  6903. real(r8), intent(in) :: tauxcl(pcols,0:pver) ! Cloud extinction optical depth (liquid)
  6904. real(r8), intent(in) :: wcl(pcols,0:pver) ! Cloud single scattering albedo (liquid)
  6905. real(r8), intent(in) :: gcl(pcols,0:pver) ! Cloud asymmetry parameter (liquid)
  6906. real(r8), intent(in) :: fcl(pcols,0:pver) ! Cloud forward scattered fraction (liquid)
  6907. real(r8), intent(in) :: tauxci(pcols,0:pver) ! Cloud extinction optical depth (ice)
  6908. real(r8), intent(in) :: wci(pcols,0:pver) ! Cloud single scattering albedo (ice)
  6909. real(r8), intent(in) :: gci(pcols,0:pver) ! Cloud asymmetry parameter (ice)
  6910. real(r8), intent(in) :: fci(pcols,0:pver) ! Cloud forward scattered fraction (ice)
  6911. real(r8), intent(in) :: tauxar(pcols,0:pver) ! Aerosol extinction optical depth
  6912. real(r8), intent(in) :: wa(pcols,0:pver) ! Aerosol single scattering albedo
  6913. real(r8), intent(in) :: ga(pcols,0:pver) ! Aerosol asymmetry parameter
  6914. real(r8), intent(in) :: fa(pcols,0:pver) ! Aerosol forward scattered fraction
  6915. integer, intent(in) :: ndayc ! Number of daylight columns
  6916. integer, intent(in) :: idayc(pcols) ! Daylight column indices
  6917. integer, intent(in) :: ns ! Index of spectral interval
  6918. !
  6919. ! Input/Output arguments
  6920. !
  6921. ! Following variables are defined for each layer; 0 refers to extra
  6922. ! layer above top of model:
  6923. !
  6924. real(r8), intent(inout) :: rdir(nspint,pcols,0:pver) ! Layer reflectivity to direct rad
  6925. real(r8), intent(inout) :: rdif(nspint,pcols,0:pver) ! Layer reflectivity to diffuse rad
  6926. real(r8), intent(inout) :: tdir(nspint,pcols,0:pver) ! Layer transmission to direct rad
  6927. real(r8), intent(inout) :: tdif(nspint,pcols,0:pver) ! Layer transmission to diffuse rad
  6928. real(r8), intent(inout) :: explay(nspint,pcols,0:pver) ! Solar beam exp transm for layer
  6929. !
  6930. ! Corresponding quantities for clear-skies
  6931. !
  6932. real(r8), intent(inout) :: rdirc(nspint,pcols,0:pver) ! Clear layer reflec. to direct rad
  6933. real(r8), intent(inout) :: rdifc(nspint,pcols,0:pver) ! Clear layer reflec. to diffuse rad
  6934. real(r8), intent(inout) :: tdirc(nspint,pcols,0:pver) ! Clear layer trans. to direct rad
  6935. real(r8), intent(inout) :: tdifc(nspint,pcols,0:pver) ! Clear layer trans. to diffuse rad
  6936. real(r8), intent(inout) :: explayc(nspint,pcols,0:pver)! Solar beam exp transm clear layer
  6937. !
  6938. !---------------------------Local variables-----------------------------
  6939. !
  6940. integer i ! Column indices
  6941. integer k ! Level index
  6942. integer nn ! Index of column loops (max=ndayc)
  6943. real(r8) taugab(pcols) ! Layer total gas absorption optical depth
  6944. real(r8) tauray(pcols) ! Layer rayleigh optical depth
  6945. real(r8) taucsc ! Layer cloud scattering optical depth
  6946. real(r8) tautot ! Total layer optical depth
  6947. real(r8) wtot ! Total layer single scatter albedo
  6948. real(r8) gtot ! Total layer asymmetry parameter
  6949. real(r8) ftot ! Total layer forward scatter fraction
  6950. real(r8) wtau ! rayleigh layer scattering optical depth
  6951. real(r8) wt ! layer total single scattering albedo
  6952. real(r8) ts ! layer scaled extinction optical depth
  6953. real(r8) ws ! layer scaled single scattering albedo
  6954. real(r8) gs ! layer scaled asymmetry parameter
  6955. !
  6956. !---------------------------Statement functions-------------------------
  6957. !
  6958. ! Statement functions and other local variables
  6959. !
  6960. real(r8) alpha ! Term in direct reflect and transmissivity
  6961. real(r8) gamma ! Term in direct reflect and transmissivity
  6962. real(r8) el ! Term in alpha,gamma,n,u
  6963. real(r8) taus ! Scaled extinction optical depth
  6964. real(r8) omgs ! Scaled single particle scattering albedo
  6965. real(r8) asys ! Scaled asymmetry parameter
  6966. real(r8) u ! Term in diffuse reflect and
  6967. ! transmissivity
  6968. real(r8) n ! Term in diffuse reflect and
  6969. ! transmissivity
  6970. real(r8) lm ! Temporary for el
  6971. real(r8) ne ! Temporary for n
  6972. real(r8) w ! Dummy argument for statement function
  6973. real(r8) uu ! Dummy argument for statement function
  6974. real(r8) g ! Dummy argument for statement function
  6975. real(r8) e ! Dummy argument for statement function
  6976. real(r8) f ! Dummy argument for statement function
  6977. real(r8) t ! Dummy argument for statement function
  6978. real(r8) et ! Dummy argument for statement function
  6979. !
  6980. ! Intermediate terms for delta-eddington solution
  6981. !
  6982. real(r8) alp ! Temporary for alpha
  6983. real(r8) gam ! Temporary for gamma
  6984. real(r8) ue ! Temporary for u
  6985. real(r8) arg ! Exponential argument
  6986. real(r8) extins ! Extinction
  6987. real(r8) amg ! Alp - gam
  6988. real(r8) apg ! Alp + gam
  6989. !
  6990. alpha(w,uu,g,e) = .75_r8*w*uu*((1._r8 + g*(1._r8-w))/(1._r8 - e*e*uu*uu))
  6991. gamma(w,uu,g,e) = .50_r8*w*((3._r8*g*(1._r8-w)*uu*uu + 1._r8)/(1._r8-e*e*uu*uu))
  6992. el(w,g) = sqrt(3._r8*(1._r8-w)*(1._r8 - w*g))
  6993. taus(w,f,t) = (1._r8 - w*f)*t
  6994. omgs(w,f) = (1._r8 - f)*w/(1._r8 - w*f)
  6995. asys(g,f) = (g - f)/(1._r8 - f)
  6996. u(w,g,e) = 1.5_r8*(1._r8 - w*g)/e
  6997. n(uu,et) = ((uu+1._r8)*(uu+1._r8)/et ) - ((uu-1._r8)*(uu-1._r8)*et)
  6998. !
  6999. !-----------------------------------------------------------------------
  7000. !
  7001. ! Compute layer radiative properties
  7002. !
  7003. ! Compute radiative properties (reflectivity and transmissivity for
  7004. ! direct and diffuse radiation incident from above, under clear
  7005. ! and cloudy conditions) and transmission of direct radiation
  7006. ! (under clear and cloudy conditions) for each layer.
  7007. !
  7008. do k=0,pver
  7009. do nn=1,ndayc
  7010. i=idayc(nn)
  7011. tauray(i) = trayoslp*(pflx(i,k+1)-pflx(i,k))
  7012. taugab(i) = abh2o*uh2o(i,k) + abo3*uo3(i,k) + abco2*uco2(i,k) + abo2*uo2(i,k)
  7013. tautot = tauxcl(i,k) + tauxci(i,k) + tauray(i) + taugab(i) + tauxar(i,k)
  7014. taucsc = tauxcl(i,k)*wcl(i,k) + tauxci(i,k)*wci(i,k) + tauxar(i,k)*wa(i,k)
  7015. wtau = wray*tauray(i)
  7016. wt = wtau + taucsc
  7017. wtot = wt/tautot
  7018. gtot = (wtau*gray + gcl(i,k)*wcl(i,k)*tauxcl(i,k) &
  7019. + gci(i,k)*wci(i,k)*tauxci(i,k) + ga(i,k) *wa(i,k) *tauxar(i,k))/wt
  7020. ftot = (wtau*fray + fcl(i,k)*wcl(i,k)*tauxcl(i,k) &
  7021. + fci(i,k)*wci(i,k)*tauxci(i,k) + fa(i,k) *wa(i,k) *tauxar(i,k))/wt
  7022. ts = taus(wtot,ftot,tautot)
  7023. ws = omgs(wtot,ftot)
  7024. gs = asys(gtot,ftot)
  7025. lm = el(ws,gs)
  7026. alp = alpha(ws,coszrs(i),gs,lm)
  7027. gam = gamma(ws,coszrs(i),gs,lm)
  7028. ue = u(ws,gs,lm)
  7029. !
  7030. ! Limit argument of exponential to 25, in case lm very large:
  7031. !
  7032. arg = min(lm*ts,25._r8)
  7033. extins = exp(-arg)
  7034. ne = n(ue,extins)
  7035. rdif(ns,i,k) = (ue+1._r8)*(ue-1._r8)*(1._r8/extins - extins)/ne
  7036. tdif(ns,i,k) = 4._r8*ue/ne
  7037. !
  7038. ! Limit argument of exponential to 25, in case coszrs is very small:
  7039. !
  7040. arg = min(ts/coszrs(i),25._r8)
  7041. explay(ns,i,k) = exp(-arg)
  7042. apg = alp + gam
  7043. amg = alp - gam
  7044. rdir(ns,i,k) = amg*(tdif(ns,i,k)*explay(ns,i,k)-1._r8) + apg*rdif(ns,i,k)
  7045. tdir(ns,i,k) = apg*tdif(ns,i,k) + (amg*rdif(ns,i,k)-(apg-1._r8))*explay(ns,i,k)
  7046. !
  7047. ! Under rare conditions, reflectivies and transmissivities can be
  7048. ! negative; zero out any negative values
  7049. !
  7050. rdir(ns,i,k) = max(rdir(ns,i,k),0.0_r8)
  7051. tdir(ns,i,k) = max(tdir(ns,i,k),0.0_r8)
  7052. rdif(ns,i,k) = max(rdif(ns,i,k),0.0_r8)
  7053. tdif(ns,i,k) = max(tdif(ns,i,k),0.0_r8)
  7054. !
  7055. ! Clear-sky calculation
  7056. !
  7057. if (tauxcl(i,k) == 0.0_r8 .and. tauxci(i,k) == 0.0_r8) then
  7058. rdirc(ns,i,k) = rdir(ns,i,k)
  7059. tdirc(ns,i,k) = tdir(ns,i,k)
  7060. rdifc(ns,i,k) = rdif(ns,i,k)
  7061. tdifc(ns,i,k) = tdif(ns,i,k)
  7062. explayc(ns,i,k) = explay(ns,i,k)
  7063. else
  7064. tautot = tauray(i) + taugab(i) + tauxar(i,k)
  7065. taucsc = tauxar(i,k)*wa(i,k)
  7066. !
  7067. ! wtau already computed for all-sky
  7068. !
  7069. wt = wtau + taucsc
  7070. wtot = wt/tautot
  7071. gtot = (wtau*gray + ga(i,k)*wa(i,k)*tauxar(i,k))/wt
  7072. ftot = (wtau*fray + fa(i,k)*wa(i,k)*tauxar(i,k))/wt
  7073. ts = taus(wtot,ftot,tautot)
  7074. ws = omgs(wtot,ftot)
  7075. gs = asys(gtot,ftot)
  7076. lm = el(ws,gs)
  7077. alp = alpha(ws,coszrs(i),gs,lm)
  7078. gam = gamma(ws,coszrs(i),gs,lm)
  7079. ue = u(ws,gs,lm)
  7080. !
  7081. ! Limit argument of exponential to 25, in case lm very large:
  7082. !
  7083. arg = min(lm*ts,25._r8)
  7084. extins = exp(-arg)
  7085. ne = n(ue,extins)
  7086. rdifc(ns,i,k) = (ue+1._r8)*(ue-1._r8)*(1._r8/extins - extins)/ne
  7087. tdifc(ns,i,k) = 4._r8*ue/ne
  7088. !
  7089. ! Limit argument of exponential to 25, in case coszrs is very small:
  7090. !
  7091. arg = min(ts/coszrs(i),25._r8)
  7092. explayc(ns,i,k) = exp(-arg)
  7093. apg = alp + gam
  7094. amg = alp - gam
  7095. rdirc(ns,i,k) = amg*(tdifc(ns,i,k)*explayc(ns,i,k)-1._r8)+ &
  7096. apg*rdifc(ns,i,k)
  7097. tdirc(ns,i,k) = apg*tdifc(ns,i,k) + (amg*rdifc(ns,i,k) - (apg-1._r8))* &
  7098. explayc(ns,i,k)
  7099. !
  7100. ! Under rare conditions, reflectivies and transmissivities can be
  7101. ! negative; zero out any negative values
  7102. !
  7103. rdirc(ns,i,k) = max(rdirc(ns,i,k),0.0_r8)
  7104. tdirc(ns,i,k) = max(tdirc(ns,i,k),0.0_r8)
  7105. rdifc(ns,i,k) = max(rdifc(ns,i,k),0.0_r8)
  7106. tdifc(ns,i,k) = max(tdifc(ns,i,k),0.0_r8)
  7107. end if
  7108. end do
  7109. end do
  7110. return
  7111. end subroutine raddedmx
  7112. subroutine radinp(lchnk ,ncol , pcols, pver, pverp, &
  7113. pmid ,pint ,o3vmr , pmidrd ,&
  7114. pintrd ,eccf ,o3mmr )
  7115. !-----------------------------------------------------------------------
  7116. !
  7117. ! Purpose:
  7118. ! Set latitude and time dependent arrays for input to solar
  7119. ! and longwave radiation.
  7120. ! Convert model pressures to cgs, and compute ozone mixing ratio, needed for
  7121. ! the solar radiation.
  7122. !
  7123. ! Method:
  7124. ! <Describe the algorithm(s) used in the routine.>
  7125. ! <Also include any applicable external references.>
  7126. !
  7127. ! Author: CCM1, CMS Contact J. Kiehl
  7128. !
  7129. !-----------------------------------------------------------------------
  7130. ! use shr_kind_mod, only: r8 => shr_kind_r8
  7131. ! use ppgrid
  7132. ! use time_manager, only: get_curr_calday
  7133. implicit none
  7134. !------------------------------Arguments--------------------------------
  7135. !
  7136. ! Input arguments
  7137. !
  7138. integer, intent(in) :: lchnk ! chunk identifier
  7139. integer, intent(in) :: pcols, pver, pverp
  7140. integer, intent(in) :: ncol ! number of atmospheric columns
  7141. real(r8), intent(in) :: pmid(pcols,pver) ! Pressure at model mid-levels (pascals)
  7142. real(r8), intent(in) :: pint(pcols,pverp) ! Pressure at model interfaces (pascals)
  7143. real(r8), intent(in) :: o3vmr(pcols,pver) ! ozone volume mixing ratio
  7144. !
  7145. ! Output arguments
  7146. !
  7147. real(r8), intent(out) :: pmidrd(pcols,pver) ! Pressure at mid-levels (dynes/cm*2)
  7148. real(r8), intent(out) :: pintrd(pcols,pverp) ! Pressure at interfaces (dynes/cm*2)
  7149. real(r8), intent(out) :: eccf ! Earth-sun distance factor
  7150. real(r8), intent(out) :: o3mmr(pcols,pver) ! Ozone mass mixing ratio
  7151. !
  7152. !---------------------------Local variables-----------------------------
  7153. !
  7154. integer i ! Longitude loop index
  7155. integer k ! Vertical loop index
  7156. real(r8) :: calday ! current calendar day
  7157. real(r8) vmmr ! Ozone volume mixing ratio
  7158. real(r8) delta ! Solar declination angle
  7159. !
  7160. !-----------------------------------------------------------------------
  7161. !
  7162. ! calday = get_curr_calday()
  7163. eccf = 1. ! declared intent(out) so fill a value (not used in WRF)
  7164. ! call shr_orb_decl (calday ,eccen ,mvelpp ,lambm0 ,obliqr , &
  7165. ! delta ,eccf)
  7166. !
  7167. ! Convert pressure from pascals to dynes/cm2
  7168. !
  7169. do k=1,pver
  7170. do i=1,ncol
  7171. pmidrd(i,k) = pmid(i,k)*10.0
  7172. pintrd(i,k) = pint(i,k)*10.0
  7173. end do
  7174. end do
  7175. do i=1,ncol
  7176. pintrd(i,pverp) = pint(i,pverp)*10.0
  7177. end do
  7178. !
  7179. ! Convert ozone volume mixing ratio to mass mixing ratio:
  7180. !
  7181. vmmr = amo/amd
  7182. do k=1,pver
  7183. do i=1,ncol
  7184. o3mmr(i,k) = vmmr*o3vmr(i,k)
  7185. end do
  7186. end do
  7187. !
  7188. return
  7189. end subroutine radinp
  7190. subroutine radoz2(lchnk ,ncol ,pcols, pver, pverp, o3vmr ,pint ,plol ,plos, ntoplw )
  7191. !-----------------------------------------------------------------------
  7192. !
  7193. ! Purpose:
  7194. ! Computes the path length integrals to the model interfaces given the
  7195. ! ozone volume mixing ratio
  7196. !
  7197. ! Method:
  7198. ! <Describe the algorithm(s) used in the routine.>
  7199. ! <Also include any applicable external references.>
  7200. !
  7201. ! Author: CCM1, CMS Contact J. Kiehl
  7202. !
  7203. !-----------------------------------------------------------------------
  7204. ! use shr_kind_mod, only: r8 => shr_kind_r8
  7205. ! use ppgrid
  7206. ! use comozp
  7207. implicit none
  7208. !------------------------------Input arguments--------------------------
  7209. !
  7210. integer, intent(in) :: lchnk ! chunk identifier
  7211. integer, intent(in) :: ncol ! number of atmospheric columns
  7212. integer, intent(in) :: pcols, pver, pverp
  7213. real(r8), intent(in) :: o3vmr(pcols,pver) ! ozone volume mixing ratio
  7214. real(r8), intent(in) :: pint(pcols,pverp) ! Model interface pressures
  7215. integer, intent(in) :: ntoplw ! topmost level/layer longwave is solved for
  7216. !
  7217. !----------------------------Output arguments---------------------------
  7218. !
  7219. real(r8), intent(out) :: plol(pcols,pverp) ! Ozone prs weighted path length (cm)
  7220. real(r8), intent(out) :: plos(pcols,pverp) ! Ozone path length (cm)
  7221. !
  7222. !---------------------------Local workspace-----------------------------
  7223. !
  7224. integer i ! longitude index
  7225. integer k ! level index
  7226. !
  7227. !-----------------------------------------------------------------------
  7228. !
  7229. ! Evaluate the ozone path length integrals to interfaces;
  7230. ! factors of .1 and .01 to convert pressures from cgs to mks:
  7231. !
  7232. do i=1,ncol
  7233. plos(i,ntoplw) = 0.1 *cplos*o3vmr(i,ntoplw)*pint(i,ntoplw)
  7234. plol(i,ntoplw) = 0.01*cplol*o3vmr(i,ntoplw)*pint(i,ntoplw)*pint(i,ntoplw)
  7235. end do
  7236. do k=ntoplw+1,pverp
  7237. do i=1,ncol
  7238. plos(i,k) = plos(i,k-1) + 0.1*cplos*o3vmr(i,k-1)*(pint(i,k) - pint(i,k-1))
  7239. plol(i,k) = plol(i,k-1) + 0.01*cplol*o3vmr(i,k-1)* &
  7240. (pint(i,k)*pint(i,k) - pint(i,k-1)*pint(i,k-1))
  7241. end do
  7242. end do
  7243. !
  7244. return
  7245. end subroutine radoz2
  7246. subroutine radozn (lchnk, ncol, pcols, pver,pmid, pin, levsiz, ozmix, o3vmr)
  7247. !-----------------------------------------------------------------------
  7248. !
  7249. ! Purpose: Interpolate ozone from current time-interpolated values to model levels
  7250. !
  7251. ! Method: Use pressure values to determine interpolation levels
  7252. !
  7253. ! Author: Bruce Briegleb
  7254. !
  7255. !--------------------------------------------------------------------------
  7256. ! use shr_kind_mod, only: r8 => shr_kind_r8
  7257. ! use ppgrid
  7258. ! use phys_grid, only: get_lat_all_p, get_lon_all_p
  7259. ! use comozp
  7260. ! use abortutils, only: endrun
  7261. !--------------------------------------------------------------------------
  7262. implicit none
  7263. !--------------------------------------------------------------------------
  7264. !
  7265. ! Arguments
  7266. !
  7267. integer, intent(in) :: lchnk ! chunk identifier
  7268. integer, intent(in) :: pcols, pver
  7269. integer, intent(in) :: ncol ! number of atmospheric columns
  7270. integer, intent(in) :: levsiz ! number of ozone layers
  7271. real(r8), intent(in) :: pmid(pcols,pver) ! level pressures (mks)
  7272. real(r8), intent(in) :: pin(levsiz) ! ozone data level pressures (mks)
  7273. real(r8), intent(in) :: ozmix(pcols,levsiz) ! ozone mixing ratio
  7274. real(r8), intent(out) :: o3vmr(pcols,pver) ! ozone volume mixing ratio
  7275. !
  7276. ! local storage
  7277. !
  7278. integer i ! longitude index
  7279. integer k, kk, kkstart ! level indices
  7280. integer kupper(pcols) ! Level indices for interpolation
  7281. integer kount ! Counter
  7282. integer lats(pcols) ! latitude indices
  7283. integer lons(pcols) ! latitude indices
  7284. real(r8) dpu ! upper level pressure difference
  7285. real(r8) dpl ! lower level pressure difference
  7286. !
  7287. ! Initialize latitude indices
  7288. !
  7289. ! call get_lat_all_p(lchnk, ncol, lats)
  7290. ! call get_lon_all_p(lchnk, ncol, lons)
  7291. !
  7292. ! Initialize index array
  7293. !
  7294. do i=1,ncol
  7295. kupper(i) = 1
  7296. end do
  7297. do k=1,pver
  7298. !
  7299. ! Top level we need to start looking is the top level for the previous k
  7300. ! for all longitude points
  7301. !
  7302. kkstart = levsiz
  7303. do i=1,ncol
  7304. kkstart = min0(kkstart,kupper(i))
  7305. end do
  7306. kount = 0
  7307. !
  7308. ! Store level indices for interpolation
  7309. !
  7310. do kk=kkstart,levsiz-1
  7311. do i=1,ncol
  7312. if (pin(kk).lt.pmid(i,k) .and. pmid(i,k).le.pin(kk+1)) then
  7313. kupper(i) = kk
  7314. kount = kount + 1
  7315. end if
  7316. end do
  7317. !
  7318. ! If all indices for this level have been found, do the interpolation and
  7319. ! go to the next level
  7320. !
  7321. if (kount.eq.ncol) then
  7322. do i=1,ncol
  7323. dpu = pmid(i,k) - pin(kupper(i))
  7324. dpl = pin(kupper(i)+1) - pmid(i,k)
  7325. o3vmr(i,k) = (ozmix(i,kupper(i))*dpl + &
  7326. ozmix(i,kupper(i)+1)*dpu)/(dpl + dpu)
  7327. end do
  7328. goto 35
  7329. end if
  7330. end do
  7331. !
  7332. ! If we've fallen through the kk=1,levsiz-1 loop, we cannot interpolate and
  7333. ! must extrapolate from the bottom or top ozone data level for at least some
  7334. ! of the longitude points.
  7335. !
  7336. do i=1,ncol
  7337. if (pmid(i,k) .lt. pin(1)) then
  7338. o3vmr(i,k) = ozmix(i,1)*pmid(i,k)/pin(1)
  7339. else if (pmid(i,k) .gt. pin(levsiz)) then
  7340. o3vmr(i,k) = ozmix(i,levsiz)
  7341. else
  7342. dpu = pmid(i,k) - pin(kupper(i))
  7343. dpl = pin(kupper(i)+1) - pmid(i,k)
  7344. o3vmr(i,k) = (ozmix(i,kupper(i))*dpl + &
  7345. ozmix(i,kupper(i)+1)*dpu)/(dpl + dpu)
  7346. end if
  7347. end do
  7348. if (kount.gt.ncol) then
  7349. call endrun ('RADOZN: Bad ozone data: non-monotonicity suspected')
  7350. end if
  7351. 35 continue
  7352. end do
  7353. return
  7354. end subroutine radozn
  7355. #endif
  7356. end MODULE module_ra_cam