PageRenderTime 91ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/wrfv2_fire/phys/module_ra_cam_support.F

http://github.com/jbeezley/wrf-fire
FORTRAN Legacy | 3862 lines | 2179 code | 312 blank | 1371 comment | 68 complexity | 9fa69a80800b610363beb0ee62307edd MD5 | raw file
Possible License(s): AGPL-1.0
  1. MODULE module_ra_cam_support
  2. use module_cam_support, only: endrun
  3. implicit none
  4. integer, parameter :: r8 = 8
  5. real(r8), parameter:: inf = 1.e20 ! CAM sets this differently in infnan.F90
  6. integer, parameter:: bigint = O'17777777777' ! largest possible 32-bit integer
  7. integer :: ixcldliq
  8. integer :: ixcldice
  9. ! integer :: levsiz ! size of level dimension on dataset
  10. integer, parameter :: nbands = 2 ! Number of spectral bands
  11. integer, parameter :: naer_all = 12 + 1
  12. integer, parameter :: naer = 10 + 1
  13. integer, parameter :: bnd_nbr_LW=7
  14. integer, parameter :: ndstsz = 4 ! number of dust size bins
  15. integer :: idxSUL
  16. integer :: idxSSLT
  17. integer :: idxDUSTfirst
  18. integer :: idxCARBONfirst
  19. integer :: idxOCPHO
  20. integer :: idxBCPHO
  21. integer :: idxOCPHI
  22. integer :: idxBCPHI
  23. integer :: idxBG
  24. integer :: idxVOLC
  25. integer :: mxaerl ! Maximum level of background aerosol
  26. ! indices to sections of array that represent
  27. ! groups of aerosols
  28. integer, parameter :: &
  29. numDUST = 4, &
  30. numCARBON = 4
  31. ! portion of each species group to use in computation
  32. ! of relative radiative forcing.
  33. real(r8) :: sulscl_rf = 0._r8 !
  34. real(r8) :: carscl_rf = 0._r8
  35. real(r8) :: ssltscl_rf = 0._r8
  36. real(r8) :: dustscl_rf = 0._r8
  37. real(r8) :: bgscl_rf = 0._r8
  38. real(r8) :: volcscl_rf = 0._r8
  39. ! "background" aerosol species mmr.
  40. real(r8) :: tauback = 0._r8
  41. ! portion of each species group to use in computation
  42. ! of aerosol forcing in driving the climate
  43. real(r8) :: sulscl = 1._r8
  44. real(r8) :: carscl = 1._r8
  45. real(r8) :: ssltscl = 1._r8
  46. real(r8) :: dustscl = 1._r8
  47. real(r8) :: volcscl = 1._r8
  48. !From volcrad.F90 module
  49. integer, parameter :: idx_LW_0500_0650=3
  50. integer, parameter :: idx_LW_0650_0800=4
  51. integer, parameter :: idx_LW_0800_1000=5
  52. integer, parameter :: idx_LW_1000_1200=6
  53. integer, parameter :: idx_LW_1200_2000=7
  54. ! First two values represent the overlap of volcanics with the non-window
  55. ! (0-800, 1200-2200 cm^-1) and window (800-1200 cm^-1) regions.| Coefficients
  56. ! were derived using crm_volc_minimize.pro with spectral flux optimization
  57. ! on first iteration, total heating rate on subsequent iterations (2-9).
  58. ! Five profiles for HLS, HLW, MLS, MLW, and TRO conditions were given equal
  59. ! weight. RMS heating rate errors for a visible stratospheric optical
  60. ! depth of 1.0 are 0.02948 K/day.
  61. !
  62. real(r8) :: abs_cff_mss_aer(bnd_nbr_LW) = &
  63. (/ 70.257384, 285.282943, &
  64. 1.0273851e+02, 6.3073303e+01, 1.2039569e+02, &
  65. 3.6343643e+02, 2.7138528e+02 /)
  66. !From radae.F90 module
  67. real(r8), parameter:: min_tp_h2o = 160.0 ! min T_p for pre-calculated abs/emis
  68. real(r8), parameter:: max_tp_h2o = 349.999999 ! max T_p for pre-calculated abs/emis
  69. real(r8), parameter:: dtp_h2o = 21.111111111111 ! difference in adjacent elements of tp_h2o
  70. real(r8), parameter:: min_te_h2o = -120.0 ! min T_e-T_p for pre-calculated abs/emis
  71. real(r8), parameter:: max_te_h2o = 79.999999 ! max T_e-T_p for pre-calculated abs/emis
  72. real(r8), parameter:: dte_h2o = 10.0 ! difference in adjacent elements of te_h2o
  73. real(r8), parameter:: min_rh_h2o = 0.0 ! min RH for pre-calculated abs/emis
  74. real(r8), parameter:: max_rh_h2o = 1.19999999 ! max RH for pre-calculated abs/emis
  75. real(r8), parameter:: drh_h2o = 0.2 ! difference in adjacent elements of RH
  76. real(r8), parameter:: min_lu_h2o = -8.0 ! min log_10(U) for pre-calculated abs/emis
  77. real(r8), parameter:: min_u_h2o = 1.0e-8 ! min pressure-weighted path-length
  78. real(r8), parameter:: max_lu_h2o = 3.9999999 ! max log_10(U) for pre-calculated abs/emis
  79. real(r8), parameter:: dlu_h2o = 0.5 ! difference in adjacent elements of lu_h2o
  80. real(r8), parameter:: min_lp_h2o = -3.0 ! min log_10(P) for pre-calculated abs/emis
  81. real(r8), parameter:: min_p_h2o = 1.0e-3 ! min log_10(P) for pre-calculated abs/emis
  82. real(r8), parameter:: max_lp_h2o = -0.0000001 ! max log_10(P) for pre-calculated abs/emis
  83. real(r8), parameter:: dlp_h2o = 0.3333333333333 ! difference in adjacent elements of lp_h2o
  84. integer, parameter :: n_u = 25 ! Number of U in abs/emis tables
  85. integer, parameter :: n_p = 10 ! Number of P in abs/emis tables
  86. integer, parameter :: n_tp = 10 ! Number of T_p in abs/emis tables
  87. integer, parameter :: n_te = 21 ! Number of T_e in abs/emis tables
  88. integer, parameter :: n_rh = 7 ! Number of RH in abs/emis tables
  89. real(r8):: c16,c17,c26,c27,c28,c29,c30,c31
  90. real(r8):: fwcoef ! Farwing correction constant
  91. real(r8):: fwc1,fwc2 ! Farwing correction constants
  92. real(r8):: fc1 ! Farwing correction constant
  93. real(r8):: amco2 ! Molecular weight of co2 (g/mol)
  94. real(r8):: amd ! Molecular weight of dry air (g/mol)
  95. real(r8):: p0 ! Standard pressure (dynes/cm**2)
  96. ! These are now allocatable. JM 20090612
  97. real(r8), allocatable, dimension(:,:,:,:,:) :: ah2onw ! (n_p, n_tp, n_u, n_te, n_rh) ! absorptivity (non-window)
  98. real(r8), allocatable, dimension(:,:,:,:,:) :: eh2onw ! (n_p, n_tp, n_u, n_te, n_rh) ! emissivity (non-window)
  99. real(r8), allocatable, dimension(:,:,:,:,:) :: ah2ow ! (n_p, n_tp, n_u, n_te, n_rh) ! absorptivity (window, for adjacent layers)
  100. real(r8), allocatable, dimension(:,:,:,:,:) :: cn_ah2ow ! (n_p, n_tp, n_u, n_te, n_rh) ! continuum transmission for absorptivity (window)
  101. real(r8), allocatable, dimension(:,:,:,:,:) :: cn_eh2ow ! (n_p, n_tp, n_u, n_te, n_rh) ! continuum transmission for emissivity (window)
  102. real(r8), allocatable, dimension(:,:,:,:,:) :: ln_ah2ow ! (n_p, n_tp, n_u, n_te, n_rh) ! line-only transmission for absorptivity (window)
  103. real(r8), allocatable, dimension(:,:,:,:,:) :: ln_eh2ow ! (n_p, n_tp, n_u, n_te, n_rh) ! line-only transmission for emissivity (window)
  104. !
  105. ! Constant coefficients for water vapor overlap with trace gases.
  106. ! Reference: Ramanathan, V. and P.Downey, 1986: A Nonisothermal
  107. ! Emissivity and Absorptivity Formulation for Water Vapor
  108. ! Journal of Geophysical Research, vol. 91., D8, pp 8649-8666
  109. !
  110. real(r8):: coefh(2,4) = reshape( &
  111. (/ (/5.46557e+01,-7.30387e-02/), &
  112. (/1.09311e+02,-1.46077e-01/), &
  113. (/5.11479e+01,-6.82615e-02/), &
  114. (/1.02296e+02,-1.36523e-01/) /), (/2,4/) )
  115. !
  116. real(r8):: coefj(3,2) = reshape( &
  117. (/ (/2.82096e-02,2.47836e-04,1.16904e-06/), &
  118. (/9.27379e-02,8.04454e-04,6.88844e-06/) /), (/3,2/) )
  119. !
  120. real(r8):: coefk(3,2) = reshape( &
  121. (/ (/2.48852e-01,2.09667e-03,2.60377e-06/) , &
  122. (/1.03594e+00,6.58620e-03,4.04456e-06/) /), (/3,2/) )
  123. integer, parameter :: ntemp = 192 ! Number of temperatures in H2O sat. table for Tp
  124. real(r8) :: estblh2o(0:ntemp) ! saturation vapor pressure for H2O for Tp rang
  125. integer, parameter :: o_fa = 6 ! Degree+1 of poly of T_e for absorptivity as U->inf.
  126. integer, parameter :: o_fe = 6 ! Degree+1 of poly of T_e for emissivity as U->inf.
  127. !-----------------------------------------------------------------------------
  128. ! Data for f in C/H/E fit -- value of A and E as U->infinity
  129. ! New C/LT/E fit (Hitran 2K, CKD 2.4) -- no change
  130. ! These values are determined by integrals of Planck functions or
  131. ! derivatives of Planck functions only.
  132. !-----------------------------------------------------------------------------
  133. !
  134. ! fa/fe coefficients for 2 bands (0-800 & 1200-2200, 800-1200 cm^-1)
  135. !
  136. ! Coefficients of polynomial for f_a in T_e
  137. !
  138. real(r8), parameter:: fat(o_fa,nbands) = reshape( (/ &
  139. (/-1.06665373E-01, 2.90617375E-02, -2.70642049E-04, & ! 0-800&1200-2200 cm^-1
  140. 1.07595511E-06, -1.97419681E-09, 1.37763374E-12/), & ! 0-800&1200-2200 cm^-1
  141. (/ 1.10666537E+00, -2.90617375E-02, 2.70642049E-04, & ! 800-1200 cm^-1
  142. -1.07595511E-06, 1.97419681E-09, -1.37763374E-12/) /) & ! 800-1200 cm^-1
  143. , (/o_fa,nbands/) )
  144. !
  145. ! Coefficients of polynomial for f_e in T_e
  146. !
  147. real(r8), parameter:: fet(o_fe,nbands) = reshape( (/ &
  148. (/3.46148163E-01, 1.51240299E-02, -1.21846479E-04, & ! 0-800&1200-2200 cm^-1
  149. 4.04970123E-07, -6.15368936E-10, 3.52415071E-13/), & ! 0-800&1200-2200 cm^-1
  150. (/6.53851837E-01, -1.51240299E-02, 1.21846479E-04, & ! 800-1200 cm^-1
  151. -4.04970123E-07, 6.15368936E-10, -3.52415071E-13/) /) & ! 800-1200 cm^-1
  152. , (/o_fa,nbands/) )
  153. real(r8) :: gravit ! Acceleration of gravity (cgs)
  154. real(r8) :: rga ! 1./gravit
  155. real(r8) :: gravmks ! Acceleration of gravity (mks)
  156. real(r8) :: cpair ! Specific heat of dry air
  157. real(r8) :: epsilo ! Ratio of mol. wght of H2O to dry air
  158. real(r8) :: epsqs ! Ratio of mol. wght of H2O to dry air
  159. real(r8) :: sslp ! Standard sea-level pressure
  160. real(r8) :: stebol ! Stefan-Boltzmann's constant
  161. real(r8) :: rgsslp ! 0.5/(gravit*sslp)
  162. real(r8) :: dpfo3 ! Voigt correction factor for O3
  163. real(r8) :: dpfco2 ! Voigt correction factor for CO2
  164. real(r8) :: dayspy ! Number of days per 1 year
  165. real(r8) :: pie ! 3.14.....
  166. real(r8) :: mwdry ! molecular weight dry air ~ kg/kmole (shr_const_mwdair)
  167. real(r8) :: scon ! solar constant (not used in WRF)
  168. real(r8) :: co2mmr
  169. real(r8) :: mwco2 ! molecular weight of carbon dioxide
  170. real(r8) :: mwh2o ! molecular weight water vapor (shr_const_mwwv)
  171. real(r8) :: mwch4 ! molecular weight ch4
  172. real(r8) :: mwn2o ! molecular weight n2o
  173. real(r8) :: mwf11 ! molecular weight cfc11
  174. real(r8) :: mwf12 ! molecular weight cfc12
  175. real(r8) :: cappa ! R/Cp
  176. real(r8) :: rair ! Gas constant for dry air (J/K/kg)
  177. real(r8) :: tmelt ! freezing T of fresh water ~ K
  178. real(r8) :: r_universal ! Universal gas constant ~ J/K/kmole
  179. real(r8) :: latvap ! latent heat of evaporation ~ J/kg
  180. real(r8) :: latice ! latent heat of fusion ~ J/kg
  181. real(r8) :: zvir ! R_V/R_D - 1.
  182. integer plenest ! length of saturation vapor pressure table
  183. parameter (plenest=250)
  184. !
  185. ! Table of saturation vapor pressure values es from tmin degrees
  186. ! to tmax+1 degrees k in one degree increments. ttrice defines the
  187. ! transition region where es is a combination of ice & water values
  188. !
  189. real(r8) estbl(plenest) ! table values of saturation vapor pressure
  190. real(r8) tmin ! min temperature (K) for table
  191. real(r8) tmax ! max temperature (K) for table
  192. real(r8) pcf(6) ! polynomial coeffs -> es transition water to ice
  193. !real(r8), allocatable :: pin(:) ! ozone pressure level (levsiz)
  194. !real(r8), allocatable :: ozmix(:,:,:) ! mixing ratio
  195. !real(r8), allocatable, target :: abstot_3d(:,:,:,:) ! Non-adjacent layer absorptivites
  196. !real(r8), allocatable, target :: absnxt_3d(:,:,:,:) ! Nearest layer absorptivities
  197. !real(r8), allocatable, target :: emstot_3d(:,:,:) ! Total emissivity
  198. !From aer_optics.F90 module
  199. integer, parameter :: idxVIS = 8 ! index to visible band
  200. integer, parameter :: nrh = 1000 ! number of relative humidity values for look-up-table
  201. integer, parameter :: nspint = 19 ! number of spectral intervals
  202. ! These are now allocatable, JM 20090612
  203. real(r8), allocatable, dimension(:,:) :: ksul ! (nrh, nspint) ! sulfate specific extinction ( m^2 g-1 )
  204. real(r8), allocatable, dimension(:,:) :: wsul ! (nrh, nspint) ! sulfate single scattering albedo
  205. real(r8), allocatable, dimension(:,:) :: gsul ! (nrh, nspint) ! sulfate asymmetry parameter
  206. real(r8), allocatable, dimension(:,:) :: ksslt ! (nrh, nspint) ! sea-salt specific extinction ( m^2 g-1 )
  207. real(r8), allocatable, dimension(:,:) :: wsslt ! (nrh, nspint) ! sea-salt single scattering albedo
  208. real(r8), allocatable, dimension(:,:) :: gsslt ! (nrh, nspint) ! sea-salt asymmetry parameter
  209. real(r8), allocatable, dimension(:,:) :: kcphil ! (nrh, nspint) ! hydrophilic carbon specific extinction ( m^2 g-1 )
  210. real(r8), allocatable, dimension(:,:) :: wcphil ! (nrh, nspint) ! hydrophilic carbon single scattering albedo
  211. real(r8), allocatable, dimension(:,:) :: gcphil ! (nrh, nspint) ! hydrophilic carbon asymmetry parameter
  212. real(r8) :: kbg(nspint) ! background specific extinction ( m^2 g-1 )
  213. real(r8) :: wbg(nspint) ! background single scattering albedo
  214. real(r8) :: gbg(nspint) ! background asymmetry parameter
  215. real(r8) :: kcphob(nspint) ! hydrophobic carbon specific extinction ( m^2 g-1 )
  216. real(r8) :: wcphob(nspint) ! hydrophobic carbon single scattering albedo
  217. real(r8) :: gcphob(nspint) ! hydrophobic carbon asymmetry parameter
  218. real(r8) :: kcb(nspint) ! black carbon specific extinction ( m^2 g-1 )
  219. real(r8) :: wcb(nspint) ! black carbon single scattering albedo
  220. real(r8) :: gcb(nspint) ! black carbon asymmetry parameter
  221. real(r8) :: kvolc(nspint) ! volcanic specific extinction ( m^2 g-1)
  222. real(r8) :: wvolc(nspint) ! volcanic single scattering albedo
  223. real(r8) :: gvolc(nspint) ! volcanic asymmetry parameter
  224. real(r8) :: kdst(ndstsz, nspint) ! dust specific extinction ( m^2 g-1 )
  225. real(r8) :: wdst(ndstsz, nspint) ! dust single scattering albedo
  226. real(r8) :: gdst(ndstsz, nspint) ! dust asymmetry parameter
  227. !
  228. !From comozp.F90 module
  229. real(r8) cplos ! constant for ozone path length integral
  230. real(r8) cplol ! constant for ozone path length integral
  231. !From ghg_surfvals.F90 module
  232. real(r8) :: co2vmr = 3.550e-4 ! co2 volume mixing ratio
  233. real(r8) :: n2ovmr = 0.311e-6 ! n2o volume mixing ratio
  234. real(r8) :: ch4vmr = 1.714e-6 ! ch4 volume mixing ratio
  235. real(r8) :: f11vmr = 0.280e-9 ! cfc11 volume mixing ratio
  236. real(r8) :: f12vmr = 0.503e-9 ! cfc12 volume mixing ratio
  237. integer, parameter :: cyr = 233 ! number of years of co2 data
  238. integer :: yrdata(cyr) = &
  239. (/ 1869, 1870, 1871, 1872, 1873, 1874, 1875, &
  240. 1876, 1877, 1878, 1879, 1880, 1881, 1882, &
  241. 1883, 1884, 1885, 1886, 1887, 1888, 1889, &
  242. 1890, 1891, 1892, 1893, 1894, 1895, 1896, &
  243. 1897, 1898, 1899, 1900, 1901, 1902, 1903, &
  244. 1904, 1905, 1906, 1907, 1908, 1909, 1910, &
  245. 1911, 1912, 1913, 1914, 1915, 1916, 1917, &
  246. 1918, 1919, 1920, 1921, 1922, 1923, 1924, &
  247. 1925, 1926, 1927, 1928, 1929, 1930, 1931, &
  248. 1932, 1933, 1934, 1935, 1936, 1937, 1938, &
  249. 1939, 1940, 1941, 1942, 1943, 1944, 1945, &
  250. 1946, 1947, 1948, 1949, 1950, 1951, 1952, &
  251. 1953, 1954, 1955, 1956, 1957, 1958, 1959, &
  252. 1960, 1961, 1962, 1963, 1964, 1965, 1966, &
  253. 1967, 1968, 1969, 1970, 1971, 1972, 1973, &
  254. 1974, 1975, 1976, 1977, 1978, 1979, 1980, &
  255. 1981, 1982, 1983, 1984, 1985, 1986, 1987, &
  256. 1988, 1989, 1990, 1991, 1992, 1993, 1994, &
  257. 1995, 1996, 1997, 1998, 1999, 2000, 2001, &
  258. 2002, 2003, 2004, 2005, 2006, 2007, 2008, &
  259. 2009, 2010, 2011, 2012, 2013, 2014, 2015, &
  260. 2016, 2017, 2018, 2019, 2020, 2021, 2022, &
  261. 2023, 2024, 2025, 2026, 2027, 2028, 2029, &
  262. 2030, 2031, 2032, 2033, 2034, 2035, 2036, &
  263. 2037, 2038, 2039, 2040, 2041, 2042, 2043, &
  264. 2044, 2045, 2046, 2047, 2048, 2049, 2050, &
  265. 2051, 2052, 2053, 2054, 2055, 2056, 2057, &
  266. 2058, 2059, 2060, 2061, 2062, 2063, 2064, &
  267. 2065, 2066, 2067, 2068, 2069, 2070, 2071, &
  268. 2072, 2073, 2074, 2075, 2076, 2077, 2078, &
  269. 2079, 2080, 2081, 2082, 2083, 2084, 2085, &
  270. 2086, 2087, 2088, 2089, 2090, 2091, 2092, &
  271. 2093, 2094, 2095, 2096, 2097, 2098, 2099, &
  272. 2100, 2101 /)
  273. ! A2 future scenario
  274. real(r8) :: co2(cyr) = &
  275. (/ 289.263, 289.263, 289.416, 289.577, 289.745, 289.919, 290.102, &
  276. 290.293, 290.491, 290.696, 290.909, 291.129, 291.355, 291.587, 291.824, &
  277. 292.066, 292.313, 292.563, 292.815, 293.071, 293.328, 293.586, 293.843, &
  278. 294.098, 294.35, 294.598, 294.842, 295.082, 295.32, 295.558, 295.797, &
  279. 296.038, 296.284, 296.535, 296.794, 297.062, 297.338, 297.62, 297.91, &
  280. 298.204, 298.504, 298.806, 299.111, 299.419, 299.729, 300.04, 300.352, &
  281. 300.666, 300.98, 301.294, 301.608, 301.923, 302.237, 302.551, 302.863, &
  282. 303.172, 303.478, 303.779, 304.075, 304.366, 304.651, 304.93, 305.206, &
  283. 305.478, 305.746, 306.013, 306.28, 306.546, 306.815, 307.087, 307.365, &
  284. 307.65, 307.943, 308.246, 308.56, 308.887, 309.228, 309.584, 309.956, &
  285. 310.344, 310.749, 311.172, 311.614, 312.077, 312.561, 313.068, 313.599, &
  286. 314.154, 314.737, 315.347, 315.984, 316.646, 317.328, 318.026, 318.742, &
  287. 319.489, 320.282, 321.133, 322.045, 323.021, 324.06, 325.155, 326.299, &
  288. 327.484, 328.698, 329.933, 331.194, 332.499, 333.854, 335.254, 336.69, &
  289. 338.15, 339.628, 341.125, 342.65, 344.206, 345.797, 347.397, 348.98, &
  290. 350.551, 352.1, 354.3637, 355.7772, 357.1601, 358.5306, 359.9046, &
  291. 361.4157, 363.0445, 364.7761, 366.6064, 368.5322, 370.534, 372.5798, &
  292. 374.6564, 376.7656, 378.9087, 381.0864, 383.2994, 385.548, 387.8326, &
  293. 390.1536, 392.523, 394.9625, 397.4806, 400.075, 402.7444, 405.4875, &
  294. 408.3035, 411.1918, 414.1518, 417.1831, 420.2806, 423.4355, 426.6442, &
  295. 429.9076, 433.2261, 436.6002, 440.0303, 443.5168, 447.06, 450.6603, &
  296. 454.3059, 457.9756, 461.6612, 465.3649, 469.0886, 472.8335, 476.6008, &
  297. 480.3916, 484.2069, 488.0473, 491.9184, 495.8295, 499.7849, 503.7843, &
  298. 507.8278, 511.9155, 516.0476, 520.2243, 524.4459, 528.7127, 533.0213, &
  299. 537.3655, 541.7429, 546.1544, 550.6005, 555.0819, 559.5991, 564.1525, &
  300. 568.7429, 573.3701, 578.0399, 582.7611, 587.5379, 592.3701, 597.2572, &
  301. 602.1997, 607.1975, 612.2507, 617.3596, 622.524, 627.7528, 633.0616, &
  302. 638.457, 643.9384, 649.505, 655.1568, 660.8936, 666.7153, 672.6219, &
  303. 678.6133, 684.6945, 690.8745, 697.1569, 703.5416, 710.0284, 716.6172, &
  304. 723.308, 730.1008, 736.9958, 743.993, 751.0975, 758.3183, 765.6594, &
  305. 773.1207, 780.702, 788.4033, 796.2249, 804.1667, 812.2289, 820.4118, &
  306. 828.6444, 828.6444 /)
  307. integer :: ntoplw ! top level to solve for longwave cooling (WRF sets this to 1 for model top below 10 mb)
  308. logical :: masterproc = .true.
  309. logical :: ozncyc ! true => cycle ozone dataset
  310. ! logical :: dosw ! True => shortwave calculation this timestep
  311. ! logical :: dolw ! True => longwave calculation this timestep
  312. logical :: indirect ! True => include indirect radiative effects of sulfate aerosols
  313. ! logical :: doabsems ! True => abs/emiss calculation this timestep
  314. logical :: radforce = .false. ! True => calculate aerosol shortwave forcing
  315. logical :: trace_gas=.false. ! set true for chemistry
  316. logical :: strat_volcanic = .false. ! True => volcanic aerosol mass available
  317. real(r8) retab(95)
  318. !
  319. ! Tabulated values of re(T) in the temperature interval
  320. ! 180 K -- 274 K; hexagonal columns assumed:
  321. !
  322. data retab / &
  323. 5.92779, 6.26422, 6.61973, 6.99539, 7.39234, &
  324. 7.81177, 8.25496, 8.72323, 9.21800, 9.74075, 10.2930, &
  325. 10.8765, 11.4929, 12.1440, 12.8317, 13.5581, 14.2319, &
  326. 15.0351, 15.8799, 16.7674, 17.6986, 18.6744, 19.6955, &
  327. 20.7623, 21.8757, 23.0364, 24.2452, 25.5034, 26.8125, &
  328. 27.7895, 28.6450, 29.4167, 30.1088, 30.7306, 31.2943, &
  329. 31.8151, 32.3077, 32.7870, 33.2657, 33.7540, 34.2601, &
  330. 34.7892, 35.3442, 35.9255, 36.5316, 37.1602, 37.8078, &
  331. 38.4720, 39.1508, 39.8442, 40.5552, 41.2912, 42.0635, &
  332. 42.8876, 43.7863, 44.7853, 45.9170, 47.2165, 48.7221, &
  333. 50.4710, 52.4980, 54.8315, 57.4898, 60.4785, 63.7898, &
  334. 65.5604, 71.2885, 75.4113, 79.7368, 84.2351, 88.8833, &
  335. 93.6658, 98.5739, 103.603, 108.752, 114.025, 119.424, &
  336. 124.954, 130.630, 136.457, 142.446, 148.608, 154.956, &
  337. 161.503, 168.262, 175.248, 182.473, 189.952, 197.699, &
  338. 205.728, 214.055, 222.694, 231.661, 240.971, 250.639/
  339. !
  340. save retab
  341. contains
  342. subroutine sortarray(n, ain, indxa)
  343. !-----------------------------------------------
  344. !
  345. ! Purpose:
  346. ! Sort an array
  347. ! Alogrithm:
  348. ! Based on Shell's sorting method.
  349. !
  350. ! Author: T. Craig
  351. !-----------------------------------------------
  352. ! use shr_kind_mod, only: r8 => shr_kind_r8
  353. implicit none
  354. !
  355. ! Arguments
  356. !
  357. integer , intent(in) :: n ! total number of elements
  358. integer , intent(inout) :: indxa(n) ! array of integers
  359. real(r8), intent(inout) :: ain(n) ! array to sort
  360. !
  361. ! local variables
  362. !
  363. integer :: i, j ! Loop indices
  364. integer :: ni ! Starting increment
  365. integer :: itmp ! Temporary index
  366. real(r8):: atmp ! Temporary value to swap
  367. ni = 1
  368. do while(.TRUE.)
  369. ni = 3*ni + 1
  370. if (ni <= n) cycle
  371. exit
  372. end do
  373. do while(.TRUE.)
  374. ni = ni/3
  375. do i = ni + 1, n
  376. atmp = ain(i)
  377. itmp = indxa(i)
  378. j = i
  379. do while(.TRUE.)
  380. if (ain(j-ni) <= atmp) exit
  381. ain(j) = ain(j-ni)
  382. indxa(j) = indxa(j-ni)
  383. j = j - ni
  384. if (j > ni) cycle
  385. exit
  386. end do
  387. ain(j) = atmp
  388. indxa(j) = itmp
  389. end do
  390. if (ni > 1) cycle
  391. exit
  392. end do
  393. return
  394. end subroutine sortarray
  395. subroutine trcab(lchnk ,ncol ,pcols, pverp, &
  396. k1 ,k2 ,ucfc11 ,ucfc12 ,un2o0 , &
  397. un2o1 ,uch4 ,uco211 ,uco212 ,uco213 , &
  398. uco221 ,uco222 ,uco223 ,bn2o0 ,bn2o1 , &
  399. bch4 ,to3co2 ,pnm ,dw ,pnew , &
  400. s2c ,uptype ,dplh2o ,abplnk1 ,tco2 , &
  401. th2o ,to3 ,abstrc , &
  402. aer_trn_ttl)
  403. !-----------------------------------------------------------------------
  404. !
  405. ! Purpose:
  406. ! Calculate absorptivity for non nearest layers for CH4, N2O, CFC11 and
  407. ! CFC12.
  408. !
  409. ! Method:
  410. ! See CCM3 description for equations.
  411. !
  412. ! Author: J. Kiehl
  413. !
  414. !-----------------------------------------------------------------------
  415. ! use shr_kind_mod, only: r8 => shr_kind_r8
  416. ! use ppgrid
  417. ! use volcrad
  418. implicit none
  419. !------------------------------Arguments--------------------------------
  420. !
  421. ! Input arguments
  422. !
  423. integer, intent(in) :: lchnk ! chunk identifier
  424. integer, intent(in) :: ncol ! number of atmospheric columns
  425. integer, intent(in) :: pcols, pverp
  426. integer, intent(in) :: k1,k2 ! level indices
  427. !
  428. real(r8), intent(in) :: to3co2(pcols) ! pressure weighted temperature
  429. real(r8), intent(in) :: pnm(pcols,pverp) ! interface pressures
  430. real(r8), intent(in) :: ucfc11(pcols,pverp) ! CFC11 path length
  431. real(r8), intent(in) :: ucfc12(pcols,pverp) ! CFC12 path length
  432. real(r8), intent(in) :: un2o0(pcols,pverp) ! N2O path length
  433. !
  434. real(r8), intent(in) :: un2o1(pcols,pverp) ! N2O path length (hot band)
  435. real(r8), intent(in) :: uch4(pcols,pverp) ! CH4 path length
  436. real(r8), intent(in) :: uco211(pcols,pverp) ! CO2 9.4 micron band path length
  437. real(r8), intent(in) :: uco212(pcols,pverp) ! CO2 9.4 micron band path length
  438. real(r8), intent(in) :: uco213(pcols,pverp) ! CO2 9.4 micron band path length
  439. !
  440. real(r8), intent(in) :: uco221(pcols,pverp) ! CO2 10.4 micron band path length
  441. real(r8), intent(in) :: uco222(pcols,pverp) ! CO2 10.4 micron band path length
  442. real(r8), intent(in) :: uco223(pcols,pverp) ! CO2 10.4 micron band path length
  443. real(r8), intent(in) :: bn2o0(pcols,pverp) ! pressure factor for n2o
  444. real(r8), intent(in) :: bn2o1(pcols,pverp) ! pressure factor for n2o
  445. !
  446. real(r8), intent(in) :: bch4(pcols,pverp) ! pressure factor for ch4
  447. real(r8), intent(in) :: dw(pcols) ! h2o path length
  448. real(r8), intent(in) :: pnew(pcols) ! pressure
  449. real(r8), intent(in) :: s2c(pcols,pverp) ! continuum path length
  450. real(r8), intent(in) :: uptype(pcols,pverp) ! p-type h2o path length
  451. !
  452. real(r8), intent(in) :: dplh2o(pcols) ! p squared h2o path length
  453. real(r8), intent(in) :: abplnk1(14,pcols,pverp) ! Planck factor
  454. real(r8), intent(in) :: tco2(pcols) ! co2 transmission factor
  455. real(r8), intent(in) :: th2o(pcols) ! h2o transmission factor
  456. real(r8), intent(in) :: to3(pcols) ! o3 transmission factor
  457. real(r8), intent(in) :: aer_trn_ttl(pcols,pverp,pverp,bnd_nbr_LW) ! aer trn.
  458. !
  459. ! Output Arguments
  460. !
  461. real(r8), intent(out) :: abstrc(pcols) ! total trace gas absorptivity
  462. !
  463. !--------------------------Local Variables------------------------------
  464. !
  465. integer i,l ! loop counters
  466. real(r8) sqti(pcols) ! square root of mean temp
  467. real(r8) du1 ! cfc11 path length
  468. real(r8) du2 ! cfc12 path length
  469. real(r8) acfc1 ! cfc11 absorptivity 798 cm-1
  470. real(r8) acfc2 ! cfc11 absorptivity 846 cm-1
  471. !
  472. real(r8) acfc3 ! cfc11 absorptivity 933 cm-1
  473. real(r8) acfc4 ! cfc11 absorptivity 1085 cm-1
  474. real(r8) acfc5 ! cfc12 absorptivity 889 cm-1
  475. real(r8) acfc6 ! cfc12 absorptivity 923 cm-1
  476. real(r8) acfc7 ! cfc12 absorptivity 1102 cm-1
  477. !
  478. real(r8) acfc8 ! cfc12 absorptivity 1161 cm-1
  479. real(r8) du01 ! n2o path length
  480. real(r8) dbeta01 ! n2o pressure factor
  481. real(r8) dbeta11 ! "
  482. real(r8) an2o1 ! absorptivity of 1285 cm-1 n2o band
  483. !
  484. real(r8) du02 ! n2o path length
  485. real(r8) dbeta02 ! n2o pressure factor
  486. real(r8) an2o2 ! absorptivity of 589 cm-1 n2o band
  487. real(r8) du03 ! n2o path length
  488. real(r8) dbeta03 ! n2o pressure factor
  489. !
  490. real(r8) an2o3 ! absorptivity of 1168 cm-1 n2o band
  491. real(r8) duch4 ! ch4 path length
  492. real(r8) dbetac ! ch4 pressure factor
  493. real(r8) ach4 ! absorptivity of 1306 cm-1 ch4 band
  494. real(r8) du11 ! co2 path length
  495. !
  496. real(r8) du12 ! "
  497. real(r8) du13 ! "
  498. real(r8) dbetc1 ! co2 pressure factor
  499. real(r8) dbetc2 ! co2 pressure factor
  500. real(r8) aco21 ! absorptivity of 1064 cm-1 band
  501. !
  502. real(r8) du21 ! co2 path length
  503. real(r8) du22 ! "
  504. real(r8) du23 ! "
  505. real(r8) aco22 ! absorptivity of 961 cm-1 band
  506. real(r8) tt(pcols) ! temp. factor for h2o overlap factor
  507. !
  508. real(r8) psi1 ! "
  509. real(r8) phi1 ! "
  510. real(r8) p1 ! h2o overlap factor
  511. real(r8) w1 ! "
  512. real(r8) ds2c(pcols) ! continuum path length
  513. !
  514. real(r8) duptyp(pcols) ! p-type path length
  515. real(r8) tw(pcols,6) ! h2o transmission factor
  516. real(r8) g1(6) ! "
  517. real(r8) g2(6) ! "
  518. real(r8) g3(6) ! "
  519. !
  520. real(r8) g4(6) ! "
  521. real(r8) ab(6) ! h2o temp. factor
  522. real(r8) bb(6) ! "
  523. real(r8) abp(6) ! "
  524. real(r8) bbp(6) ! "
  525. !
  526. real(r8) tcfc3 ! transmission for cfc11 band
  527. real(r8) tcfc4 ! transmission for cfc11 band
  528. real(r8) tcfc6 ! transmission for cfc12 band
  529. real(r8) tcfc7 ! transmission for cfc12 band
  530. real(r8) tcfc8 ! transmission for cfc12 band
  531. !
  532. real(r8) tlw ! h2o transmission
  533. real(r8) tch4 ! ch4 transmission
  534. !
  535. !--------------------------Data Statements------------------------------
  536. !
  537. data g1 /0.0468556,0.0397454,0.0407664,0.0304380,0.0540398,0.0321962/
  538. data g2 /14.4832,4.30242,5.23523,3.25342,0.698935,16.5599/
  539. data g3 /26.1898,18.4476,15.3633,12.1927,9.14992,8.07092/
  540. data g4 /0.0261782,0.0369516,0.0307266,0.0243854,0.0182932,0.0161418/
  541. data ab /3.0857e-2,2.3524e-2,1.7310e-2,2.6661e-2,2.8074e-2,2.2915e-2/
  542. data bb /-1.3512e-4,-6.8320e-5,-3.2609e-5,-1.0228e-5,-9.5743e-5,-1.0304e-4/
  543. data abp/2.9129e-2,2.4101e-2,1.9821e-2,2.6904e-2,2.9458e-2,1.9892e-2/
  544. data bbp/-1.3139e-4,-5.5688e-5,-4.6380e-5,-8.0362e-5,-1.0115e-4,-8.8061e-5/
  545. !
  546. !--------------------------Statement Functions--------------------------
  547. !
  548. real(r8) func, u, b
  549. func(u,b) = u/sqrt(4.0 + u*(1.0 + 1.0 / b))
  550. !
  551. !------------------------------------------------------------------------
  552. !
  553. do i = 1,ncol
  554. sqti(i) = sqrt(to3co2(i))
  555. !
  556. ! h2o transmission
  557. !
  558. tt(i) = abs(to3co2(i) - 250.0)
  559. ds2c(i) = abs(s2c(i,k1) - s2c(i,k2))
  560. duptyp(i) = abs(uptype(i,k1) - uptype(i,k2))
  561. end do
  562. !
  563. do l = 1,6
  564. do i = 1,ncol
  565. psi1 = exp(abp(l)*tt(i) + bbp(l)*tt(i)*tt(i))
  566. phi1 = exp(ab(l)*tt(i) + bb(l)*tt(i)*tt(i))
  567. p1 = pnew(i)*(psi1/phi1)/sslp
  568. w1 = dw(i)*phi1
  569. tw(i,l) = exp(-g1(l)*p1*(sqrt(1.0 + g2(l)*(w1/p1)) - 1.0) - &
  570. g3(l)*ds2c(i)-g4(l)*duptyp(i))
  571. end do
  572. end do
  573. !
  574. do i=1,ncol
  575. tw(i,1)=tw(i,1)*(0.7*aer_trn_ttl(i,k1,k2,idx_LW_0650_0800)+&! l=1: 0750--0820 cm-1
  576. 0.3*aer_trn_ttl(i,k1,k2,idx_LW_0800_1000))
  577. tw(i,2)=tw(i,2)*aer_trn_ttl(i,k1,k2,idx_LW_0800_1000) ! l=2: 0820--0880 cm-1
  578. tw(i,3)=tw(i,3)*aer_trn_ttl(i,k1,k2,idx_LW_0800_1000) ! l=3: 0880--0900 cm-1
  579. tw(i,4)=tw(i,4)*aer_trn_ttl(i,k1,k2,idx_LW_0800_1000) ! l=4: 0900--1000 cm-1
  580. tw(i,5)=tw(i,5)*aer_trn_ttl(i,k1,k2,idx_LW_1000_1200) ! l=5: 1000--1120 cm-1
  581. tw(i,6)=tw(i,6)*aer_trn_ttl(i,k1,k2,idx_LW_1000_1200) ! l=6: 1120--1170 cm-1
  582. end do ! end loop over lon
  583. do i = 1,ncol
  584. du1 = abs(ucfc11(i,k1) - ucfc11(i,k2))
  585. du2 = abs(ucfc12(i,k1) - ucfc12(i,k2))
  586. !
  587. ! cfc transmissions
  588. !
  589. tcfc3 = exp(-175.005*du1)
  590. tcfc4 = exp(-1202.18*du1)
  591. tcfc6 = exp(-5786.73*du2)
  592. tcfc7 = exp(-2873.51*du2)
  593. tcfc8 = exp(-2085.59*du2)
  594. !
  595. ! Absorptivity for CFC11 bands
  596. !
  597. acfc1 = 50.0*(1.0 - exp(-54.09*du1))*tw(i,1)*abplnk1(7,i,k2)
  598. acfc2 = 60.0*(1.0 - exp(-5130.03*du1))*tw(i,2)*abplnk1(8,i,k2)
  599. acfc3 = 60.0*(1.0 - tcfc3)*tw(i,4)*tcfc6*abplnk1(9,i,k2)
  600. acfc4 = 100.0*(1.0 - tcfc4)*tw(i,5)*abplnk1(10,i,k2)
  601. !
  602. ! Absorptivity for CFC12 bands
  603. !
  604. acfc5 = 45.0*(1.0 - exp(-1272.35*du2))*tw(i,3)*abplnk1(11,i,k2)
  605. acfc6 = 50.0*(1.0 - tcfc6)* tw(i,4) * abplnk1(12,i,k2)
  606. acfc7 = 80.0*(1.0 - tcfc7)* tw(i,5) * tcfc4*abplnk1(13,i,k2)
  607. acfc8 = 70.0*(1.0 - tcfc8)* tw(i,6) * abplnk1(14,i,k2)
  608. !
  609. ! Emissivity for CH4 band 1306 cm-1
  610. !
  611. tlw = exp(-1.0*sqrt(dplh2o(i)))
  612. tlw=tlw*aer_trn_ttl(i,k1,k2,idx_LW_1200_2000)
  613. duch4 = abs(uch4(i,k1) - uch4(i,k2))
  614. dbetac = abs(bch4(i,k1) - bch4(i,k2))/duch4
  615. ach4 = 6.00444*sqti(i)*log(1.0 + func(duch4,dbetac))*tlw*abplnk1(3,i,k2)
  616. tch4 = 1.0/(1.0 + 0.02*func(duch4,dbetac))
  617. !
  618. ! Absorptivity for N2O bands
  619. !
  620. du01 = abs(un2o0(i,k1) - un2o0(i,k2))
  621. du11 = abs(un2o1(i,k1) - un2o1(i,k2))
  622. dbeta01 = abs(bn2o0(i,k1) - bn2o0(i,k2))/du01
  623. dbeta11 = abs(bn2o1(i,k1) - bn2o1(i,k2))/du11
  624. !
  625. ! 1285 cm-1 band
  626. !
  627. an2o1 = 2.35558*sqti(i)*log(1.0 + func(du01,dbeta01) &
  628. + func(du11,dbeta11))*tlw*tch4*abplnk1(4,i,k2)
  629. du02 = 0.100090*du01
  630. du12 = 0.0992746*du11
  631. dbeta02 = 0.964282*dbeta01
  632. !
  633. ! 589 cm-1 band
  634. !
  635. an2o2 = 2.65581*sqti(i)*log(1.0 + func(du02,dbeta02) + &
  636. func(du12,dbeta02))*th2o(i)*tco2(i)*abplnk1(5,i,k2)
  637. du03 = 0.0333767*du01
  638. dbeta03 = 0.982143*dbeta01
  639. !
  640. ! 1168 cm-1 band
  641. !
  642. an2o3 = 2.54034*sqti(i)*log(1.0 + func(du03,dbeta03))* &
  643. tw(i,6)*tcfc8*abplnk1(6,i,k2)
  644. !
  645. ! Emissivity for 1064 cm-1 band of CO2
  646. !
  647. du11 = abs(uco211(i,k1) - uco211(i,k2))
  648. du12 = abs(uco212(i,k1) - uco212(i,k2))
  649. du13 = abs(uco213(i,k1) - uco213(i,k2))
  650. dbetc1 = 2.97558*abs(pnm(i,k1) + pnm(i,k2))/(2.0*sslp*sqti(i))
  651. dbetc2 = 2.0*dbetc1
  652. aco21 = 3.7571*sqti(i)*log(1.0 + func(du11,dbetc1) &
  653. + func(du12,dbetc2) + func(du13,dbetc2)) &
  654. *to3(i)*tw(i,5)*tcfc4*tcfc7*abplnk1(2,i,k2)
  655. !
  656. ! Emissivity for 961 cm-1 band
  657. !
  658. du21 = abs(uco221(i,k1) - uco221(i,k2))
  659. du22 = abs(uco222(i,k1) - uco222(i,k2))
  660. du23 = abs(uco223(i,k1) - uco223(i,k2))
  661. aco22 = 3.8443*sqti(i)*log(1.0 + func(du21,dbetc1) &
  662. + func(du22,dbetc1) + func(du23,dbetc2)) &
  663. *tw(i,4)*tcfc3*tcfc6*abplnk1(1,i,k2)
  664. !
  665. ! total trace gas absorptivity
  666. !
  667. abstrc(i) = acfc1 + acfc2 + acfc3 + acfc4 + acfc5 + acfc6 + &
  668. acfc7 + acfc8 + an2o1 + an2o2 + an2o3 + ach4 + &
  669. aco21 + aco22
  670. end do
  671. !
  672. return
  673. !
  674. end subroutine trcab
  675. subroutine trcabn(lchnk ,ncol ,pcols, pverp, &
  676. k2 ,kn ,ucfc11 ,ucfc12 ,un2o0 , &
  677. un2o1 ,uch4 ,uco211 ,uco212 ,uco213 , &
  678. uco221 ,uco222 ,uco223 ,tbar ,bplnk , &
  679. winpl ,pinpl ,tco2 ,th2o ,to3 , &
  680. uptype ,dw ,s2c ,up2 ,pnew , &
  681. abstrc ,uinpl , &
  682. aer_trn_ngh)
  683. !-----------------------------------------------------------------------
  684. !
  685. ! Purpose:
  686. ! Calculate nearest layer absorptivity due to CH4, N2O, CFC11 and CFC12
  687. !
  688. ! Method:
  689. ! Equations in CCM3 description
  690. !
  691. ! Author: J. Kiehl
  692. !
  693. !-----------------------------------------------------------------------
  694. !
  695. ! use shr_kind_mod, only: r8 => shr_kind_r8
  696. ! use ppgrid
  697. ! use volcrad
  698. implicit none
  699. !------------------------------Arguments--------------------------------
  700. !
  701. ! Input arguments
  702. !
  703. integer, intent(in) :: lchnk ! chunk identifier
  704. integer, intent(in) :: ncol ! number of atmospheric columns
  705. integer, intent(in) :: pcols, pverp
  706. integer, intent(in) :: k2 ! level index
  707. integer, intent(in) :: kn ! level index
  708. !
  709. real(r8), intent(in) :: tbar(pcols,4) ! pressure weighted temperature
  710. real(r8), intent(in) :: ucfc11(pcols,pverp) ! CFC11 path length
  711. real(r8), intent(in) :: ucfc12(pcols,pverp) ! CFC12 path length
  712. real(r8), intent(in) :: un2o0(pcols,pverp) ! N2O path length
  713. real(r8), intent(in) :: un2o1(pcols,pverp) ! N2O path length (hot band)
  714. !
  715. real(r8), intent(in) :: uch4(pcols,pverp) ! CH4 path length
  716. real(r8), intent(in) :: uco211(pcols,pverp) ! CO2 9.4 micron band path length
  717. real(r8), intent(in) :: uco212(pcols,pverp) ! CO2 9.4 micron band path length
  718. real(r8), intent(in) :: uco213(pcols,pverp) ! CO2 9.4 micron band path length
  719. real(r8), intent(in) :: uco221(pcols,pverp) ! CO2 10.4 micron band path length
  720. !
  721. real(r8), intent(in) :: uco222(pcols,pverp) ! CO2 10.4 micron band path length
  722. real(r8), intent(in) :: uco223(pcols,pverp) ! CO2 10.4 micron band path length
  723. real(r8), intent(in) :: bplnk(14,pcols,4) ! weighted Planck fnc. for absorptivity
  724. real(r8), intent(in) :: winpl(pcols,4) ! fractional path length
  725. real(r8), intent(in) :: pinpl(pcols,4) ! pressure factor for subdivided layer
  726. !
  727. real(r8), intent(in) :: tco2(pcols) ! co2 transmission
  728. real(r8), intent(in) :: th2o(pcols) ! h2o transmission
  729. real(r8), intent(in) :: to3(pcols) ! o3 transmission
  730. real(r8), intent(in) :: dw(pcols) ! h2o path length
  731. real(r8), intent(in) :: pnew(pcols) ! pressure factor
  732. !
  733. real(r8), intent(in) :: s2c(pcols,pverp) ! h2o continuum factor
  734. real(r8), intent(in) :: uptype(pcols,pverp) ! p-type path length
  735. real(r8), intent(in) :: up2(pcols) ! p squared path length
  736. real(r8), intent(in) :: uinpl(pcols,4) ! Nearest layer subdivision factor
  737. real(r8), intent(in) :: aer_trn_ngh(pcols,bnd_nbr_LW)
  738. ! [fraction] Total transmission between
  739. ! nearest neighbor sub-levels
  740. !
  741. ! Output Arguments
  742. !
  743. real(r8), intent(out) :: abstrc(pcols) ! total trace gas absorptivity
  744. !
  745. !--------------------------Local Variables------------------------------
  746. !
  747. integer i,l ! loop counters
  748. !
  749. real(r8) sqti(pcols) ! square root of mean temp
  750. real(r8) rsqti(pcols) ! reciprocal of sqti
  751. real(r8) du1 ! cfc11 path length
  752. real(r8) du2 ! cfc12 path length
  753. real(r8) acfc1 ! absorptivity of cfc11 798 cm-1 band
  754. !
  755. real(r8) acfc2 ! absorptivity of cfc11 846 cm-1 band
  756. real(r8) acfc3 ! absorptivity of cfc11 933 cm-1 band
  757. real(r8) acfc4 ! absorptivity of cfc11 1085 cm-1 band
  758. real(r8) acfc5 ! absorptivity of cfc11 889 cm-1 band
  759. real(r8) acfc6 ! absorptivity of cfc11 923 cm-1 band
  760. !
  761. real(r8) acfc7 ! absorptivity of cfc11 1102 cm-1 band
  762. real(r8) acfc8 ! absorptivity of cfc11 1161 cm-1 band
  763. real(r8) du01 ! n2o path length
  764. real(r8) dbeta01 ! n2o pressure factors
  765. real(r8) dbeta11 ! "
  766. !
  767. real(r8) an2o1 ! absorptivity of the 1285 cm-1 n2o band
  768. real(r8) du02 ! n2o path length
  769. real(r8) dbeta02 ! n2o pressure factor
  770. real(r8) an2o2 ! absorptivity of the 589 cm-1 n2o band
  771. real(r8) du03 ! n2o path length
  772. !
  773. real(r8) dbeta03 ! n2o pressure factor
  774. real(r8) an2o3 ! absorptivity of the 1168 cm-1 n2o band
  775. real(r8) duch4 ! ch4 path length
  776. real(r8) dbetac ! ch4 pressure factor
  777. real(r8) ach4 ! absorptivity of the 1306 cm-1 ch4 band
  778. !
  779. real(r8) du11 ! co2 path length
  780. real(r8) du12 ! "
  781. real(r8) du13 ! "
  782. real(r8) dbetc1 ! co2 pressure factor
  783. real(r8) dbetc2 ! co2 pressure factor
  784. !
  785. real(r8) aco21 ! absorptivity of the 1064 cm-1 co2 band
  786. real(r8) du21 ! co2 path length
  787. real(r8) du22 ! "
  788. real(r8) du23 ! "
  789. real(r8) aco22 ! absorptivity of the 961 cm-1 co2 band
  790. !
  791. real(r8) tt(pcols) ! temp. factor for h2o overlap
  792. real(r8) psi1 ! "
  793. real(r8) phi1 ! "
  794. real(r8) p1 ! factor for h2o overlap
  795. real(r8) w1 ! "
  796. !
  797. real(r8) ds2c(pcols) ! continuum path length
  798. real(r8) duptyp(pcols) ! p-type path length
  799. real(r8) tw(pcols,6) ! h2o transmission overlap
  800. real(r8) g1(6) ! h2o overlap factor
  801. real(r8) g2(6) ! "
  802. !
  803. real(r8) g3(6) ! "
  804. real(r8) g4(6) ! "
  805. real(r8) ab(6) ! h2o temp. factor
  806. real(r8) bb(6) ! "
  807. real(r8) abp(6) ! "
  808. !
  809. real(r8) bbp(6) ! "
  810. real(r8) tcfc3 ! transmission of cfc11 band
  811. real(r8) tcfc4 ! transmission of cfc11 band
  812. real(r8) tcfc6 ! transmission of cfc12 band
  813. real(r8) tcfc7 ! "
  814. !
  815. real(r8) tcfc8 ! "
  816. real(r8) tlw ! h2o transmission
  817. real(r8) tch4 ! ch4 transmission
  818. !
  819. !--------------------------Data Statements------------------------------
  820. !
  821. data g1 /0.0468556,0.0397454,0.0407664,0.0304380,0.0540398,0.0321962/
  822. data g2 /14.4832,4.30242,5.23523,3.25342,0.698935,16.5599/
  823. data g3 /26.1898,18.4476,15.3633,12.1927,9.14992,8.07092/
  824. data g4 /0.0261782,0.0369516,0.0307266,0.0243854,0.0182932,0.0161418/
  825. data ab /3.0857e-2,2.3524e-2,1.7310e-2,2.6661e-2,2.8074e-2,2.2915e-2/
  826. data bb /-1.3512e-4,-6.8320e-5,-3.2609e-5,-1.0228e-5,-9.5743e-5,-1.0304e-4/
  827. data abp/2.9129e-2,2.4101e-2,1.9821e-2,2.6904e-2,2.9458e-2,1.9892e-2/
  828. data bbp/-1.3139e-4,-5.5688e-5,-4.6380e-5,-8.0362e-5,-1.0115e-4,-8.8061e-5/
  829. !
  830. !--------------------------Statement Functions--------------------------
  831. !
  832. real(r8) func, u, b
  833. func(u,b) = u/sqrt(4.0 + u*(1.0 + 1.0 / b))
  834. !
  835. !------------------------------------------------------------------
  836. !
  837. do i = 1,ncol
  838. sqti(i) = sqrt(tbar(i,kn))
  839. rsqti(i) = 1. / sqti(i)
  840. !
  841. ! h2o transmission
  842. !
  843. tt(i) = abs(tbar(i,kn) - 250.0)
  844. ds2c(i) = abs(s2c(i,k2+1) - s2c(i,k2))*uinpl(i,kn)
  845. duptyp(i) = abs(uptype(i,k2+1) - uptype(i,k2))*uinpl(i,kn)
  846. end do
  847. !
  848. do l = 1,6
  849. do i = 1,ncol
  850. psi1 = exp(abp(l)*tt(i)+bbp(l)*tt(i)*tt(i))
  851. phi1 = exp(ab(l)*tt(i)+bb(l)*tt(i)*tt(i))
  852. p1 = pnew(i) * (psi1/phi1) / sslp
  853. w1 = dw(i) * winpl(i,kn) * phi1
  854. tw(i,l) = exp(- g1(l)*p1*(sqrt(1.0+g2(l)*(w1/p1))-1.0) &
  855. - g3(l)*ds2c(i)-g4(l)*duptyp(i))
  856. end do
  857. end do
  858. !
  859. do i=1,ncol
  860. tw(i,1)=tw(i,1)*(0.7*aer_trn_ngh(i,idx_LW_0650_0800)+&! l=1: 0750--0820 cm-1
  861. 0.3*aer_trn_ngh(i,idx_LW_0800_1000))
  862. tw(i,2)=tw(i,2)*aer_trn_ngh(i,idx_LW_0800_1000) ! l=2: 0820--0880 cm-1
  863. tw(i,3)=tw(i,3)*aer_trn_ngh(i,idx_LW_0800_1000) ! l=3: 0880--0900 cm-1
  864. tw(i,4)=tw(i,4)*aer_trn_ngh(i,idx_LW_0800_1000) ! l=4: 0900--1000 cm-1
  865. tw(i,5)=tw(i,5)*aer_trn_ngh(i,idx_LW_1000_1200) ! l=5: 1000--1120 cm-1
  866. tw(i,6)=tw(i,6)*aer_trn_ngh(i,idx_LW_1000_1200) ! l=6: 1120--1170 cm-1
  867. end do ! end loop over lon
  868. do i = 1,ncol
  869. !
  870. du1 = abs(ucfc11(i,k2+1) - ucfc11(i,k2)) * winpl(i,kn)
  871. du2 = abs(ucfc12(i,k2+1) - ucfc12(i,k2)) * winpl(i,kn)
  872. !
  873. ! cfc transmissions
  874. !
  875. tcfc3 = exp(-175.005*du1)
  876. tcfc4 = exp(-1202.18*du1)
  877. tcfc6 = exp(-5786.73*du2)
  878. tcfc7 = exp(-2873.51*du2)
  879. tcfc8 = exp(-2085.59*du2)
  880. !
  881. ! Absorptivity for CFC11 bands
  882. !
  883. acfc1 = 50.0*(1.0 - exp(-54.09*du1)) * tw(i,1)*bplnk(7,i,kn)
  884. acfc2 = 60.0*(1.0 - exp(-5130.03*du1))*tw(i,2)*bplnk(8,i,kn)
  885. acfc3 = 60.0*(1.0 - tcfc3)*tw(i,4)*tcfc6 * bplnk(9,i,kn)
  886. acfc4 = 100.0*(1.0 - tcfc4)* tw(i,5) * bplnk(10,i,kn)
  887. !
  888. ! Absorptivity for CFC12 bands
  889. !
  890. acfc5 = 45.0*(1.0 - exp(-1272.35*du2))*tw(i,3)*bplnk(11,i,kn)
  891. acfc6 = 50.0*(1.0 - tcfc6)*tw(i,4)*bplnk(12,i,kn)
  892. acfc7 = 80.0*(1.0 - tcfc7)* tw(i,5)*tcfc4 *bplnk(13,i,kn)
  893. acfc8 = 70.0*(1.0 - tcfc8)*tw(i,6)*bplnk(14,i,kn)
  894. !
  895. ! Absorptivity for CH4 band 1306 cm-1
  896. !
  897. tlw = exp(-1.0*sqrt(up2(i)))
  898. tlw=tlw*aer_trn_ngh(i,idx_LW_1200_2000)
  899. duch4 = abs(uch4(i,k2+1) - uch4(i,k2)) * winpl(i,kn)
  900. dbetac = 2.94449 * pinpl(i,kn) * rsqti(i) / sslp
  901. ach4 = 6.00444*sqti(i)*log(1.0 + func(duch4,dbetac)) * tlw * bplnk(3,i,kn)
  902. tch4 = 1.0/(1.0 + 0.02*func(duch4,dbetac))
  903. !
  904. ! Absorptivity for N2O bands
  905. !
  906. du01 = abs(un2o0(i,k2+1) - un2o0(i,k2)) * winpl(i,kn)
  907. du11 = abs(un2o1(i,k2+1) - un2o1(i,k2)) * winpl(i,kn)
  908. dbeta01 = 19.399 * pinpl(i,kn) * rsqti(i) / sslp
  909. dbeta11 = dbeta01
  910. !
  911. ! 1285 cm-1 band
  912. !
  913. an2o1 = 2.35558*sqti(i)*log(1.0 + func(du01,dbeta01) &
  914. + func(du11,dbeta11)) * tlw * tch4 * bplnk(4,i,kn)
  915. du02 = 0.100090*du01
  916. du12 = 0.0992746*du11
  917. dbeta02 = 0.964282*dbeta01
  918. !
  919. ! 589 cm-1 band
  920. !
  921. an2o2 = 2.65581*sqti(i)*log(1.0 + func(du02,dbeta02) &
  922. + func(du12,dbeta02)) * tco2(i) * th2o(i) * bplnk(5,i,kn)
  923. du03 = 0.0333767*du01
  924. dbeta03 = 0.982143*dbeta01
  925. !
  926. ! 1168 cm-1 band
  927. !
  928. an2o3 = 2.54034*sqti(i)*log(1.0 + func(du03,dbeta03)) * &
  929. tw(i,6) * tcfc8 * bplnk(6,i,kn)
  930. !
  931. ! Absorptivity for 1064 cm-1 band of CO2
  932. !
  933. du11 = abs(uco211(i,k2+1) - uco211(i,k2)) * winpl(i,kn)
  934. du12 = abs(uco212(i,k2+1) - uco212(i,k2)) * winpl(i,kn)
  935. du13 = abs(uco213(i,k2+1) - uco213(i,k2)) * winpl(i,kn)
  936. dbetc1 = 2.97558 * pinpl(i,kn) * rsqti(i) / sslp
  937. dbetc2 = 2.0 * dbetc1
  938. aco21 = 3.7571*sqti(i)*log(1.0 + func(du11,dbetc1) &
  939. + func(du12,dbetc2) + func(du13,dbetc2)) &
  940. * to3(i) * tw(i,5) * tcfc4 * tcfc7 * bplnk(2,i,kn)
  941. !
  942. ! Absorptivity for 961 cm-1 band of co2
  943. !
  944. du21 = abs(uco221(i,k2+1) - uco221(i,k2)) * winpl(i,kn)
  945. du22 = abs(uco222(i,k2+1) - uco222(i,k2)) * winpl(i,kn)
  946. du23 = abs(uco223(i,k2+1) - uco223(i,k2)) * winpl(i,kn)
  947. aco22 = 3.8443*sqti(i)*log(1.0 + func(du21,dbetc1) &
  948. + func(du22,dbetc1) + func(du23,dbetc2)) &
  949. * tw(i,4) * tcfc3 * tcfc6 * bplnk(1,i,kn)
  950. !
  951. ! total trace gas absorptivity
  952. !
  953. abstrc(i) = acfc1 + acfc2 + acfc3 + acfc4 + acfc5 + acfc6 + &
  954. acfc7 + acfc8 + an2o1 + an2o2 + an2o3 + ach4 + &
  955. aco21 + aco22
  956. end do
  957. !
  958. return
  959. !
  960. end subroutine trcabn
  961. subroutine trcems(lchnk ,ncol ,pcols, pverp, &
  962. k ,co2t ,pnm ,ucfc11 ,ucfc12 , &
  963. un2o0 ,un2o1 ,bn2o0 ,bn2o1 ,uch4 , &
  964. bch4 ,uco211 ,uco212 ,uco213 ,uco221 , &
  965. uco222 ,uco223 ,uptype ,w ,s2c , &
  966. up2 ,emplnk ,th2o ,tco2 ,to3 , &
  967. emstrc , &
  968. aer_trn_ttl)
  969. !-----------------------------------------------------------------------
  970. !
  971. ! Purpose:
  972. ! Calculate emissivity for CH4, N2O, CFC11 and CFC12 bands.
  973. !
  974. ! Method:
  975. ! See CCM3 Description for equations.
  976. !
  977. ! Author: J. Kiehl
  978. !
  979. !-----------------------------------------------------------------------
  980. ! use shr_kind_mod, only: r8 => shr_kind_r8
  981. ! use ppgrid
  982. ! use volcrad
  983. implicit none
  984. !
  985. !------------------------------Arguments--------------------------------
  986. !
  987. ! Input arguments
  988. !
  989. integer, intent(in) :: lchnk ! chunk identifier
  990. integer, intent(in) :: ncol ! number of atmospheric columns
  991. integer, intent(in) :: pcols, pverp
  992. real(r8), intent(in) :: co2t(pcols,pverp) ! pressure weighted temperature
  993. real(r8), intent(in) :: pnm(pcols,pverp) ! interface pressure
  994. real(r8), intent(in) :: ucfc11(pcols,pverp) ! CFC11 path length
  995. real(r8), intent(in) :: ucfc12(pcols,pverp) ! CFC12 path length
  996. real(r8), intent(in) :: un2o0(pcols,pverp) ! N2O path length
  997. !
  998. real(r8), intent(in) :: un2o1(pcols,pverp) ! N2O path length (hot band)
  999. real(r8), intent(in) :: uch4(pcols,pverp) ! CH4 path length
  1000. real(r8), intent(in) :: uco211(pcols,pverp) ! CO2 9.4 micron band path length
  1001. real(r8), intent(in) :: uco212(pcols,pverp) ! CO2 9.4 micron band path length
  1002. real(r8), intent(in) :: uco213(pcols,pverp) ! CO2 9.4 micron band path length
  1003. !
  1004. real(r8), intent(in) :: uco221(pcols,pverp) ! CO2 10.4 micron band path length
  1005. real(r8), intent(in) :: uco222(pcols,pverp) ! CO2 10.4 micron band path length
  1006. real(r8), intent(in) :: uco223(pcols,pverp) ! CO2 10.4 micron band path length
  1007. real(r8), intent(in) :: uptype(pcols,pverp) ! continuum path length
  1008. real(r8), intent(in) :: bn2o0(pcols,pverp) ! pressure factor for n2o
  1009. !
  1010. real(r8), intent(in) :: bn2o1(pcols,pverp) ! pressure factor for n2o
  1011. real(r8), intent(in) :: bch4(pcols,pverp) ! pressure factor for ch4
  1012. real(r8), intent(in) :: emplnk(14,pcols) ! emissivity Planck factor
  1013. real(r8), intent(in) :: th2o(pcols) ! water vapor overlap factor
  1014. real(r8), intent(in) :: tco2(pcols) ! co2 overlap factor
  1015. !
  1016. real(r8), intent(in) :: to3(pcols) ! o3 overlap factor
  1017. real(r8), intent(in) :: s2c(pcols,pverp) ! h2o continuum path length
  1018. real(r8), intent(in) :: w(pcols,pverp) ! h2o path length
  1019. real(r8), intent(in) :: up2(pcols) ! pressure squared h2o path length
  1020. !
  1021. integer, intent(in) :: k ! level index
  1022. real(r8), intent(in) :: aer_trn_ttl(pcols,pverp,pverp,bnd_nbr_LW) ! aer trn.
  1023. !
  1024. ! Output Arguments
  1025. !
  1026. real(r8), intent(out) :: emstrc(pcols,pverp) ! total trace gas emissivity
  1027. !
  1028. !--------------------------Local Variables------------------------------
  1029. !
  1030. integer i,l ! loop counters
  1031. !
  1032. real(r8) sqti(pcols) ! square root of mean temp
  1033. real(r8) ecfc1 ! emissivity of cfc11 798 cm-1 band
  1034. real(r8) ecfc2 ! " " " 846 cm-1 band
  1035. real(r8) ecfc3 ! " " " 933 cm-1 band
  1036. real(r8) ecfc4 ! " " " 1085 cm-1 band
  1037. !
  1038. real(r8) ecfc5 ! " " cfc12 889 cm-1 band
  1039. real(r8) ecfc6 ! " " " 923 cm-1 band
  1040. real(r8) ecfc7 ! " " " 1102 cm-1 band
  1041. real(r8) ecfc8 ! " " " 1161 cm-1 band
  1042. real(r8) u01 ! n2o path length
  1043. !
  1044. real(r8) u11 ! n2o path length
  1045. real(r8) beta01 ! n2o pressure factor
  1046. real(r8) beta11 ! n2o pressure factor
  1047. real(r8) en2o1 ! emissivity of the 1285 cm-1 N2O band
  1048. real(r8) u02 ! n2o path length
  1049. !
  1050. real(r8) u12 ! n2o path length
  1051. real(r8) beta02 ! n2o pressure factor
  1052. real(r8) en2o2 ! emissivity of the 589 cm-1 N2O band
  1053. real(r8) u03 ! n2o path length
  1054. real(r8) beta03 ! n2o pressure factor
  1055. !
  1056. real(r8) en2o3 ! emissivity of the 1168 cm-1 N2O band
  1057. real(r8) betac ! ch4 pressure factor
  1058. real(r8) ech4 ! emissivity of 1306 cm-1 CH4 band
  1059. real(r8) betac1 ! co2 pressure factor
  1060. real(r8) betac2 ! co2 pressure factor
  1061. !
  1062. real(r8) eco21 ! emissivity of 1064 cm-1 CO2 band
  1063. real(r8) eco22 ! emissivity of 961 cm-1 CO2 band
  1064. real(r8) tt(pcols) ! temp. factor for h2o overlap factor
  1065. real(r8) psi1 ! narrow band h2o temp. factor
  1066. real(r8) phi1 ! "
  1067. !
  1068. real(r8) p1 ! h2o line overlap factor
  1069. real(r8) w1 ! "
  1070. real(r8) tw(pcols,6) ! h2o transmission overlap
  1071. real(r8) g1(6) ! h2o overlap factor
  1072. real(r8) g2(6) ! "
  1073. !
  1074. real(r8) g3(6) ! "
  1075. real(r8) g4(6) ! "
  1076. real(r8) ab(6) ! "
  1077. real(r8) bb(6) ! "
  1078. real(r8) abp(6) ! "
  1079. !
  1080. real(r8) bbp(6) ! "
  1081. real(r8) tcfc3 ! transmission for cfc11 band
  1082. real(r8) tcfc4 ! "
  1083. real(r8) tcfc6 ! transmission for cfc12 band
  1084. real(r8) tcfc7 ! "
  1085. !
  1086. real(r8) tcfc8 ! "
  1087. real(r8) tlw ! h2o overlap factor
  1088. real(r8) tch4 ! ch4 overlap factor
  1089. !
  1090. !--------------------------Data Statements------------------------------
  1091. !
  1092. data g1 /0.0468556,0.0397454,0.0407664,0.0304380,0.0540398,0.0321962/
  1093. data g2 /14.4832,4.30242,5.23523,3.25342,0.698935,16.5599/
  1094. data g3 /26.1898,18.4476,15.3633,12.1927,9.14992,8.07092/
  1095. data g4 /0.0261782,0.0369516,0.0307266,0.0243854,0.0182932,0.0161418/
  1096. data ab /3.0857e-2,2.3524e-2,1.7310e-2,2.6661e-2,2.8074e-2,2.2915e-2/
  1097. data bb /-1.3512e-4,-6.8320e-5,-3.2609e-5,-1.0228e-5,-9.5743e-5,-1.0304e-4/
  1098. data abp/2.9129e-2,2.4101e-2,1.9821e-2,2.6904e-2,2.9458e-2,1.9892e-2/
  1099. data bbp/-1.3139e-4,-5.5688e-5,-4.6380e-5,-8.0362e-5,-1.0115e-4,-8.8061e-5/
  1100. !
  1101. !--------------------------Statement Functions--------------------------
  1102. !
  1103. real(r8) func, u, b
  1104. func(u,b) = u/sqrt(4.0 + u*(1.0 + 1.0 / b))
  1105. !
  1106. !-----------------------------------------------------------------------
  1107. !
  1108. do i = 1,ncol
  1109. sqti(i) = sqrt(co2t(i,k))
  1110. !
  1111. ! Transmission for h2o
  1112. !
  1113. tt(i) = abs(co2t(i,k) - 250.0)
  1114. end do
  1115. !
  1116. do l = 1,6
  1117. do i = 1,ncol
  1118. psi1 = exp(abp(l)*tt(i)+bbp(l)*tt(i)*tt(i))
  1119. phi1 = exp(ab(l)*tt(i)+bb(l)*tt(i)*tt(i))
  1120. p1 = pnm(i,k) * (psi1/phi1) / sslp
  1121. w1 = w(i,k) * phi1
  1122. tw(i,l) = exp(- g1(l)*p1*(sqrt(1.0+g2(l)*(w1/p1))-1.0) &
  1123. - g3(l)*s2c(i,k)-g4(l)*uptype(i,k))
  1124. end do
  1125. end do
  1126. ! Overlap H2O tranmission with STRAER continuum in 6 trace gas
  1127. ! subbands
  1128. do i=1,ncol
  1129. tw(i,1)=tw(i,1)*(0.7*aer_trn_ttl(i,k,1,idx_LW_0650_0800)+&! l=1: 0750--0820 cm-1
  1130. 0.3*aer_trn_ttl(i,k,1,idx_LW_0800_1000))
  1131. tw(i,2)=tw(i,2)*aer_trn_ttl(i,k,1,idx_LW_0800_1000) ! l=2: 0820--0880 cm-1
  1132. tw(i,3)=tw(i,3)*aer_trn_ttl(i,k,1,idx_LW_0800_1000) ! l=3: 0880--0900 cm-1
  1133. tw(i,4)=tw(i,4)*aer_trn_ttl(i,k,1,idx_LW_0800_1000) ! l=4: 0900--1000 cm-1
  1134. tw(i,5)=tw(i,5)*aer_trn_ttl(i,k,1,idx_LW_1000_1200) ! l=5: 1000--1120 cm-1
  1135. tw(i,6)=tw(i,6)*aer_trn_ttl(i,k,1,idx_LW_1000_1200) ! l=6: 1120--1170 cm-1
  1136. end do ! end loop over lon
  1137. !
  1138. do i = 1,ncol
  1139. !
  1140. ! transmission due to cfc bands
  1141. !
  1142. tcfc3 = exp(-175.005*ucfc11(i,k))
  1143. tcfc4 = exp(-1202.18*ucfc11(i,k))
  1144. tcfc6 = exp(-5786.73*ucfc12(i,k))
  1145. tcfc7 = exp(-2873.51*ucfc12(i,k))
  1146. tcfc8 = exp(-2085.59*ucfc12(i,k))
  1147. !
  1148. ! Emissivity for CFC11 bands
  1149. !
  1150. ecfc1 = 50.0*(1.0 - exp(-54.09*ucfc11(i,k))) * tw(i,1) * emplnk(7,i)
  1151. ecfc2 = 60.0*(1.0 - exp(-5130.03*ucfc11(i,k)))* tw(i,2) * emplnk(8,i)
  1152. ecfc3 = 60.0*(1.0 - tcfc3)*tw(i,4)*tcfc6*emplnk(9,i)
  1153. ecfc4 = 100.0*(1.0 - tcfc4)*tw(i,5)*emplnk(10,i)
  1154. !
  1155. ! Emissivity for CFC12 bands
  1156. !
  1157. ecfc5 = 45.0*(1.0 - exp(-1272.35*ucfc12(i,k)))*tw(i,3)*emplnk(11,i)
  1158. ecfc6 = 50.0*(1.0 - tcfc6)*tw(i,4)*emplnk(12,i)
  1159. ecfc7 = 80.0*(1.0 - tcfc7)*tw(i,5)* tcfc4 * emplnk(13,i)
  1160. ecfc8 = 70.0*(1.0 - tcfc8)*tw(i,6) * emplnk(14,i)
  1161. !
  1162. ! Emissivity for CH4 band 1306 cm-1
  1163. !
  1164. tlw = exp(-1.0*sqrt(up2(i)))
  1165. ! Overlap H2O vibration rotation band with STRAER continuum
  1166. ! for CH4 1306 cm-1 and N2O 1285 cm-1 bands
  1167. tlw=tlw*aer_trn_ttl(i,k,1,idx_LW_1200_2000)
  1168. betac = bch4(i,k)/uch4(i,k)
  1169. ech4 = 6.00444*sqti(i)*log(1.0 + func(uch4(i,k),betac)) *tlw * emplnk(3,i)
  1170. tch4 = 1.0/(1.0 + 0.02*func(uch4(i,k),betac))
  1171. !
  1172. ! Emissivity for N2O bands
  1173. !
  1174. u01 = un2o0(i,k)
  1175. u11 = un2o1(i,k)
  1176. beta01 = bn2o0(i,k)/un2o0(i,k)
  1177. beta11 = bn2o1(i,k)/un2o1(i,k)
  1178. !
  1179. ! 1285 cm-1 band
  1180. !
  1181. en2o1 = 2.35558*sqti(i)*log(1.0 + func(u01,beta01) + &
  1182. func(u11,beta11))*tlw*tch4*emplnk(4,i)
  1183. u02 = 0.100090*u01
  1184. u12 = 0.0992746*u11
  1185. beta02 = 0.964282*beta01
  1186. !
  1187. ! 589 cm-1 band
  1188. !
  1189. en2o2 = 2.65581*sqti(i)*log(1.0 + func(u02,beta02) + &
  1190. func(u12,beta02)) * tco2(i) * th2o(i) * emplnk(5,i)
  1191. u03 = 0.0333767*u01
  1192. beta03 = 0.982143*beta01
  1193. !
  1194. ! 1168 cm-1 band
  1195. !
  1196. en2o3 = 2.54034*sqti(i)*log(1.0 + func(u03,beta03)) * &
  1197. tw(i,6) * tcfc8 * emplnk(6,i)
  1198. !
  1199. ! Emissivity for 1064 cm-1 band of CO2
  1200. !
  1201. betac1 = 2.97558*pnm(i,k) / (sslp*sqti(i))
  1202. betac2 = 2.0 * betac1
  1203. eco21 = 3.7571*sqti(i)*log(1.0 + func(uco211(i,k),betac1) &
  1204. + func(uco212(i,k),betac2) + func(uco213(i,k),betac2)) &
  1205. * to3(i) * tw(i,5) * tcfc4 * tcfc7 * emplnk(2,i)
  1206. !
  1207. ! Emissivity for 961 cm-1 band
  1208. !
  1209. eco22 = 3.8443*sqti(i)*log(1.0 + func(uco221(i,k),betac1) &
  1210. + func(uco222(i,k),betac1) + func(uco223(i,k),betac2)) &
  1211. * tw(i,4) * tcfc3 * tcfc6 * emplnk(1,i)
  1212. !
  1213. ! total trace gas emissivity
  1214. !
  1215. emstrc(i,k) = ecfc1 + ecfc2 + ecfc3 + ecfc4 + ecfc5 +ecfc6 + &
  1216. ecfc7 + ecfc8 + en2o1 + en2o2 + en2o3 + ech4 + &
  1217. eco21 + eco22
  1218. end do
  1219. !
  1220. return
  1221. !
  1222. end subroutine trcems
  1223. subroutine trcmix(lchnk ,ncol ,pcols, pver, &
  1224. pmid ,clat, n2o ,ch4 , &
  1225. cfc11 , cfc12 )
  1226. !-----------------------------------------------------------------------
  1227. !
  1228. ! Purpose:
  1229. ! Specify zonal mean mass mixing ratios of CH4, N2O, CFC11 and
  1230. ! CFC12
  1231. !
  1232. ! Method:
  1233. ! Distributions assume constant mixing ratio in the troposphere
  1234. ! and a decrease of mixing ratio in the stratosphere. Tropopause
  1235. ! defined by ptrop. The scale height of the particular trace gas
  1236. ! depends on latitude. This assumption produces a more realistic
  1237. ! stratospheric distribution of the various trace gases.
  1238. !
  1239. ! Author: J. Kiehl
  1240. !
  1241. !-----------------------------------------------------------------------
  1242. ! use shr_kind_mod, only: r8 => shr_kind_r8
  1243. ! use ppgrid
  1244. ! use phys_grid, only: get_rlat_all_p
  1245. ! use physconst, only: mwdry, mwch4, mwn2o, mwf11, mwf12
  1246. ! use ghg_surfvals, only: ch4vmr, n2ovmr, f11vmr, f12vmr
  1247. implicit none
  1248. !-----------------------------Arguments---------------------------------
  1249. !
  1250. ! Input
  1251. !
  1252. integer, intent(in) :: lchnk ! chunk identifier
  1253. integer, intent(in) :: ncol ! number of atmospheric columns
  1254. integer, intent(in) :: pcols, pver
  1255. real(r8), intent(in) :: pmid(pcols,pver) ! model pressures
  1256. real(r8), intent(in) :: clat(pcols) ! latitude in radians for columns
  1257. !
  1258. ! Output
  1259. !
  1260. real(r8), intent(out) :: n2o(pcols,pver) ! nitrous oxide mass mixing ratio
  1261. real(r8), intent(out) :: ch4(pcols,pver) ! methane mass mixing ratio
  1262. real(r8), intent(out) :: cfc11(pcols,pver) ! cfc11 mass mixing ratio
  1263. real(r8), intent(out) :: cfc12(pcols,pver) ! cfc12 mass mixing ratio
  1264. !
  1265. !--------------------------Local Variables------------------------------
  1266. real(r8) :: rmwn2o ! ratio of molecular weight n2o to dry air
  1267. real(r8) :: rmwch4 ! ratio of molecular weight ch4 to dry air
  1268. real(r8) :: rmwf11 ! ratio of molecular weight cfc11 to dry air
  1269. real(r8) :: rmwf12 ! ratio of molecular weight cfc12 to dry air
  1270. !
  1271. integer i ! longitude loop index
  1272. integer k ! level index
  1273. !
  1274. ! real(r8) clat(pcols) ! latitude in radians for columns
  1275. real(r8) coslat(pcols) ! cosine of latitude
  1276. real(r8) dlat ! latitude in degrees
  1277. real(r8) ptrop ! pressure level of tropopause
  1278. real(r8) pratio ! pressure divided by ptrop
  1279. !
  1280. real(r8) xn2o ! pressure scale height for n2o
  1281. real(r8) xch4 ! pressure scale height for ch4
  1282. real(r8) xcfc11 ! pressure scale height for cfc11
  1283. real(r8) xcfc12 ! pressure scale height for cfc12
  1284. !
  1285. real(r8) ch40 ! tropospheric mass mixing ratio for ch4
  1286. real(r8) n2o0 ! tropospheric mass mixing ratio for n2o
  1287. real(r8) cfc110 ! tropospheric mass mixing ratio for cfc11
  1288. real(r8) cfc120 ! tropospheric mass mixing ratio for cfc12
  1289. !
  1290. !-----------------------------------------------------------------------
  1291. rmwn2o = mwn2o/mwdry ! ratio of molecular weight n2o to dry air
  1292. rmwch4 = mwch4/mwdry ! ratio of molecular weight ch4 to dry air
  1293. rmwf11 = mwf11/mwdry ! ratio of molecular weight cfc11 to dry air
  1294. rmwf12 = mwf12/mwdry ! ratio of molecular weight cfc12 to dry air
  1295. !
  1296. ! get latitudes
  1297. !
  1298. ! call get_rlat_all_p(lchnk, ncol, clat)
  1299. do i = 1, ncol
  1300. coslat(i) = cos(clat(i))
  1301. end do
  1302. !
  1303. ! set tropospheric mass mixing ratios
  1304. !
  1305. ch40 = rmwch4 * ch4vmr
  1306. n2o0 = rmwn2o * n2ovmr
  1307. cfc110 = rmwf11 * f11vmr
  1308. cfc120 = rmwf12 * f12vmr
  1309. do i = 1, ncol
  1310. coslat(i) = cos(clat(i))
  1311. end do
  1312. !
  1313. do k = 1,pver
  1314. do i = 1,ncol
  1315. !
  1316. ! set stratospheric scale height factor for gases
  1317. dlat = abs(57.2958 * clat(i))
  1318. if(dlat.le.45.0) then
  1319. xn2o = 0.3478 + 0.00116 * dlat
  1320. xch4 = 0.2353
  1321. xcfc11 = 0.7273 + 0.00606 * dlat
  1322. xcfc12 = 0.4000 + 0.00222 * dlat
  1323. else
  1324. xn2o = 0.4000 + 0.013333 * (dlat - 45)
  1325. xch4 = 0.2353 + 0.0225489 * (dlat - 45)
  1326. xcfc11 = 1.00 + 0.013333 * (dlat - 45)
  1327. xcfc12 = 0.50 + 0.024444 * (dlat - 45)
  1328. end if
  1329. !
  1330. ! pressure of tropopause
  1331. ptrop = 250.0e2 - 150.0e2*coslat(i)**2.0
  1332. !
  1333. ! determine output mass mixing ratios
  1334. if (pmid(i,k) >= ptrop) then
  1335. ch4(i,k) = ch40
  1336. n2o(i,k) = n2o0
  1337. cfc11(i,k) = cfc110
  1338. cfc12(i,k) = cfc120
  1339. else
  1340. pratio = pmid(i,k)/ptrop
  1341. ch4(i,k) = ch40 * (pratio)**xch4
  1342. n2o(i,k) = n2o0 * (pratio)**xn2o
  1343. cfc11(i,k) = cfc110 * (pratio)**xcfc11
  1344. cfc12(i,k) = cfc120 * (pratio)**xcfc12
  1345. end if
  1346. end do
  1347. end do
  1348. !
  1349. return
  1350. !
  1351. end subroutine trcmix
  1352. subroutine trcplk(lchnk ,ncol ,pcols, pver, pverp, &
  1353. tint ,tlayr ,tplnke ,emplnk ,abplnk1 , &
  1354. abplnk2 )
  1355. !-----------------------------------------------------------------------
  1356. !
  1357. ! Purpose:
  1358. ! Calculate Planck factors for absorptivity and emissivity of
  1359. ! CH4, N2O, CFC11 and CFC12
  1360. !
  1361. ! Method:
  1362. ! Planck function and derivative evaluated at the band center.
  1363. !
  1364. ! Author: J. Kiehl
  1365. !
  1366. !-----------------------------------------------------------------------
  1367. ! use shr_kind_mod, only: r8 => shr_kind_r8
  1368. ! use ppgrid
  1369. implicit none
  1370. !------------------------------Arguments--------------------------------
  1371. !
  1372. ! Input arguments
  1373. !
  1374. integer, intent(in) :: lchnk ! chunk identifier
  1375. integer, intent(in) :: ncol ! number of atmospheric columns
  1376. integer, intent(in) :: pcols, pver, pverp
  1377. real(r8), intent(in) :: tint(pcols,pverp) ! interface temperatures
  1378. real(r8), intent(in) :: tlayr(pcols,pverp) ! k-1 level temperatures
  1379. real(r8), intent(in) :: tplnke(pcols) ! Top Layer temperature
  1380. !
  1381. ! output arguments
  1382. !
  1383. real(r8), intent(out) :: emplnk(14,pcols) ! emissivity Planck factor
  1384. real(r8), intent(out) :: abplnk1(14,pcols,pverp) ! non-nearest layer Plack factor
  1385. real(r8), intent(out) :: abplnk2(14,pcols,pverp) ! nearest layer factor
  1386. !
  1387. !--------------------------Local Variables------------------------------
  1388. !
  1389. integer wvl ! wavelength index
  1390. integer i,k ! loop counters
  1391. !
  1392. real(r8) f1(14) ! Planck function factor
  1393. real(r8) f2(14) ! "
  1394. real(r8) f3(14) ! "
  1395. !
  1396. !--------------------------Data Statements------------------------------
  1397. !
  1398. data f1 /5.85713e8,7.94950e8,1.47009e9,1.40031e9,1.34853e8, &
  1399. 1.05158e9,3.35370e8,3.99601e8,5.35994e8,8.42955e8, &
  1400. 4.63682e8,5.18944e8,8.83202e8,1.03279e9/
  1401. data f2 /2.02493e11,3.04286e11,6.90698e11,6.47333e11, &
  1402. 2.85744e10,4.41862e11,9.62780e10,1.21618e11, &
  1403. 1.79905e11,3.29029e11,1.48294e11,1.72315e11, &
  1404. 3.50140e11,4.31364e11/
  1405. data f3 /1383.0,1531.0,1879.0,1849.0,848.0,1681.0, &
  1406. 1148.0,1217.0,1343.0,1561.0,1279.0,1328.0, &
  1407. 1586.0,1671.0/
  1408. !
  1409. !-----------------------------------------------------------------------
  1410. !
  1411. ! Calculate emissivity Planck factor
  1412. !
  1413. do wvl = 1,14
  1414. do i = 1,ncol
  1415. emplnk(wvl,i) = f1(wvl)/(tplnke(i)**4.0*(exp(f3(wvl)/tplnke(i))-1.0))
  1416. end do
  1417. end do
  1418. !
  1419. ! Calculate absorptivity Planck factor for tint and tlayr temperatures
  1420. !
  1421. do wvl = 1,14
  1422. do k = ntoplw, pverp
  1423. do i = 1, ncol
  1424. !
  1425. ! non-nearlest layer function
  1426. !
  1427. abplnk1(wvl,i,k) = (f2(wvl)*exp(f3(wvl)/tint(i,k))) &
  1428. /(tint(i,k)**5.0*(exp(f3(wvl)/tint(i,k))-1.0)**2.0)
  1429. !
  1430. ! nearest layer function
  1431. !
  1432. abplnk2(wvl,i,k) = (f2(wvl)*exp(f3(wvl)/tlayr(i,k))) &
  1433. /(tlayr(i,k)**5.0*(exp(f3(wvl)/tlayr(i,k))-1.0)**2.0)
  1434. end do
  1435. end do
  1436. end do
  1437. !
  1438. return
  1439. end subroutine trcplk
  1440. subroutine trcpth(lchnk ,ncol ,pcols, pver, pverp, &
  1441. tnm ,pnm ,cfc11 ,cfc12 ,n2o , &
  1442. ch4 ,qnm ,ucfc11 ,ucfc12 ,un2o0 , &
  1443. un2o1 ,uch4 ,uco211 ,uco212 ,uco213 , &
  1444. uco221 ,uco222 ,uco223 ,bn2o0 ,bn2o1 , &
  1445. bch4 ,uptype )
  1446. !-----------------------------------------------------------------------
  1447. !
  1448. ! Purpose:
  1449. ! Calculate path lengths and pressure factors for CH4, N2O, CFC11
  1450. ! and CFC12.
  1451. !
  1452. ! Method:
  1453. ! See CCM3 description for details
  1454. !
  1455. ! Author: J. Kiehl
  1456. !
  1457. !-----------------------------------------------------------------------
  1458. ! use shr_kind_mod, only: r8 => shr_kind_r8
  1459. ! use ppgrid
  1460. ! use ghg_surfvals, only: co2mmr
  1461. implicit none
  1462. !------------------------------Arguments--------------------------------
  1463. !
  1464. ! Input arguments
  1465. !
  1466. integer, intent(in) :: lchnk ! chunk identifier
  1467. integer, intent(in) :: ncol ! number of atmospheric columns
  1468. integer, intent(in) :: pcols, pver, pverp
  1469. real(r8), intent(in) :: tnm(pcols,pver) ! Model level temperatures
  1470. real(r8), intent(in) :: pnm(pcols,pverp) ! Pres. at model interfaces (dynes/cm2)
  1471. real(r8), intent(in) :: qnm(pcols,pver) ! h2o specific humidity
  1472. real(r8), intent(in) :: cfc11(pcols,pver) ! CFC11 mass mixing ratio
  1473. !
  1474. real(r8), intent(in) :: cfc12(pcols,pver) ! CFC12 mass mixing ratio
  1475. real(r8), intent(in) :: n2o(pcols,pver) ! N2O mass mixing ratio
  1476. real(r8), intent(in) :: ch4(pcols,pver) ! CH4 mass mixing ratio
  1477. !
  1478. ! Output arguments
  1479. !
  1480. real(r8), intent(out) :: ucfc11(pcols,pverp) ! CFC11 path length
  1481. real(r8), intent(out) :: ucfc12(pcols,pverp) ! CFC12 path length
  1482. real(r8), intent(out) :: un2o0(pcols,pverp) ! N2O path length
  1483. real(r8), intent(out) :: un2o1(pcols,pverp) ! N2O path length (hot band)
  1484. real(r8), intent(out) :: uch4(pcols,pverp) ! CH4 path length
  1485. !
  1486. real(r8), intent(out) :: uco211(pcols,pverp) ! CO2 9.4 micron band path length
  1487. real(r8), intent(out) :: uco212(pcols,pverp) ! CO2 9.4 micron band path length
  1488. real(r8), intent(out) :: uco213(pcols,pverp) ! CO2 9.4 micron band path length
  1489. real(r8), intent(out) :: uco221(pcols,pverp) ! CO2 10.4 micron band path length
  1490. real(r8), intent(out) :: uco222(pcols,pverp) ! CO2 10.4 micron band path length
  1491. !
  1492. real(r8), intent(out) :: uco223(pcols,pverp) ! CO2 10.4 micron band path length
  1493. real(r8), intent(out) :: bn2o0(pcols,pverp) ! pressure factor for n2o
  1494. real(r8), intent(out) :: bn2o1(pcols,pverp) ! pressure factor for n2o
  1495. real(r8), intent(out) :: bch4(pcols,pverp) ! pressure factor for ch4
  1496. real(r8), intent(out) :: uptype(pcols,pverp) ! p-type continuum path length
  1497. !
  1498. !---------------------------Local variables-----------------------------
  1499. !
  1500. integer i ! Longitude index
  1501. integer k ! Level index
  1502. !
  1503. real(r8) co2fac(pcols,1) ! co2 factor
  1504. real(r8) alpha1(pcols) ! stimulated emission term
  1505. real(r8) alpha2(pcols) ! stimulated emission term
  1506. real(r8) rt(pcols) ! reciprocal of local temperature
  1507. real(r8) rsqrt(pcols) ! reciprocal of sqrt of temp
  1508. !
  1509. real(r8) pbar(pcols) ! mean pressure
  1510. real(r8) dpnm(pcols) ! difference in pressure
  1511. real(r8) diff ! diffusivity factor
  1512. !
  1513. !--------------------------Data Statements------------------------------
  1514. !
  1515. data diff /1.66/
  1516. !
  1517. !-----------------------------------------------------------------------
  1518. !
  1519. ! Calculate path lengths for the trace gases at model top
  1520. !
  1521. do i = 1,ncol
  1522. ucfc11(i,ntoplw) = 1.8 * cfc11(i,ntoplw) * pnm(i,ntoplw) * rga
  1523. ucfc12(i,ntoplw) = 1.8 * cfc12(i,ntoplw) * pnm(i,ntoplw) * rga
  1524. un2o0(i,ntoplw) = diff * 1.02346e5 * n2o(i,ntoplw) * pnm(i,ntoplw) * rga / sqrt(tnm(i,ntoplw))
  1525. un2o1(i,ntoplw) = diff * 2.01909 * un2o0(i,ntoplw) * exp(-847.36/tnm(i,ntoplw))
  1526. uch4(i,ntoplw) = diff * 8.60957e4 * ch4(i,ntoplw) * pnm(i,ntoplw) * rga / sqrt(tnm(i,ntoplw))
  1527. co2fac(i,1) = diff * co2mmr * pnm(i,ntoplw) * rga
  1528. alpha1(i) = (1.0 - exp(-1540.0/tnm(i,ntoplw)))**3.0/sqrt(tnm(i,ntoplw))
  1529. alpha2(i) = (1.0 - exp(-1360.0/tnm(i,ntoplw)))**3.0/sqrt(tnm(i,ntoplw))
  1530. uco211(i,ntoplw) = 3.42217e3 * co2fac(i,1) * alpha1(i) * exp(-1849.7/tnm(i,ntoplw))
  1531. uco212(i,ntoplw) = 6.02454e3 * co2fac(i,1) * alpha1(i) * exp(-2782.1/tnm(i,ntoplw))
  1532. uco213(i,ntoplw) = 5.53143e3 * co2fac(i,1) * alpha1(i) * exp(-3723.2/tnm(i,ntoplw))
  1533. uco221(i,ntoplw) = 3.88984e3 * co2fac(i,1) * alpha2(i) * exp(-1997.6/tnm(i,ntoplw))
  1534. uco222(i,ntoplw) = 3.67108e3 * co2fac(i,1) * alpha2(i) * exp(-3843.8/tnm(i,ntoplw))
  1535. uco223(i,ntoplw) = 6.50642e3 * co2fac(i,1) * alpha2(i) * exp(-2989.7/tnm(i,ntoplw))
  1536. bn2o0(i,ntoplw) = diff * 19.399 * pnm(i,ntoplw)**2.0 * n2o(i,ntoplw) * &
  1537. 1.02346e5 * rga / (sslp*tnm(i,ntoplw))
  1538. bn2o1(i,ntoplw) = bn2o0(i,ntoplw) * exp(-847.36/tnm(i,ntoplw)) * 2.06646e5
  1539. bch4(i,ntoplw) = diff * 2.94449 * ch4(i,ntoplw) * pnm(i,ntoplw)**2.0 * rga * &
  1540. 8.60957e4 / (sslp*tnm(i,ntoplw))
  1541. uptype(i,ntoplw) = diff * qnm(i,ntoplw) * pnm(i,ntoplw)**2.0 * &
  1542. exp(1800.0*(1.0/tnm(i,ntoplw) - 1.0/296.0)) * rga / sslp
  1543. end do
  1544. !
  1545. ! Calculate trace gas path lengths through model atmosphere
  1546. !
  1547. do k = ntoplw,pver
  1548. do i = 1,ncol
  1549. rt(i) = 1./tnm(i,k)
  1550. rsqrt(i) = sqrt(rt(i))
  1551. pbar(i) = 0.5 * (pnm(i,k+1) + pnm(i,k)) / sslp
  1552. dpnm(i) = (pnm(i,k+1) - pnm(i,k)) * rga
  1553. alpha1(i) = diff * rsqrt(i) * (1.0 - exp(-1540.0/tnm(i,k)))**3.0
  1554. alpha2(i) = diff * rsqrt(i) * (1.0 - exp(-1360.0/tnm(i,k)))**3.0
  1555. ucfc11(i,k+1) = ucfc11(i,k) + 1.8 * cfc11(i,k) * dpnm(i)
  1556. ucfc12(i,k+1) = ucfc12(i,k) + 1.8 * cfc12(i,k) * dpnm(i)
  1557. un2o0(i,k+1) = un2o0(i,k) + diff * 1.02346e5 * n2o(i,k) * rsqrt(i) * dpnm(i)
  1558. un2o1(i,k+1) = un2o1(i,k) + diff * 2.06646e5 * n2o(i,k) * &
  1559. rsqrt(i) * exp(-847.36/tnm(i,k)) * dpnm(i)
  1560. uch4(i,k+1) = uch4(i,k) + diff * 8.60957e4 * ch4(i,k) * rsqrt(i) * dpnm(i)
  1561. uco211(i,k+1) = uco211(i,k) + 1.15*3.42217e3 * alpha1(i) * &
  1562. co2mmr * exp(-1849.7/tnm(i,k)) * dpnm(i)
  1563. uco212(i,k+1) = uco212(i,k) + 1.15*6.02454e3 * alpha1(i) * &
  1564. co2mmr * exp(-2782.1/tnm(i,k)) * dpnm(i)
  1565. uco213(i,k+1) = uco213(i,k) + 1.15*5.53143e3 * alpha1(i) * &
  1566. co2mmr * exp(-3723.2/tnm(i,k)) * dpnm(i)
  1567. uco221(i,k+1) = uco221(i,k) + 1.15*3.88984e3 * alpha2(i) * &
  1568. co2mmr * exp(-1997.6/tnm(i,k)) * dpnm(i)
  1569. uco222(i,k+1) = uco222(i,k) + 1.15*3.67108e3 * alpha2(i) * &
  1570. co2mmr * exp(-3843.8/tnm(i,k)) * dpnm(i)
  1571. uco223(i,k+1) = uco223(i,k) + 1.15*6.50642e3 * alpha2(i) * &
  1572. co2mmr * exp(-2989.7/tnm(i,k)) * dpnm(i)
  1573. bn2o0(i,k+1) = bn2o0(i,k) + diff * 19.399 * pbar(i) * rt(i) &
  1574. * 1.02346e5 * n2o(i,k) * dpnm(i)
  1575. bn2o1(i,k+1) = bn2o1(i,k) + diff * 19.399 * pbar(i) * rt(i) &
  1576. * 2.06646e5 * exp(-847.36/tnm(i,k)) * n2o(i,k)*dpnm(i)
  1577. bch4(i,k+1) = bch4(i,k) + diff * 2.94449 * rt(i) * pbar(i) &
  1578. * 8.60957e4 * ch4(i,k) * dpnm(i)
  1579. uptype(i,k+1) = uptype(i,k) + diff *qnm(i,k) * &
  1580. exp(1800.0*(1.0/tnm(i,k) - 1.0/296.0)) * pbar(i) * dpnm(i)
  1581. end do
  1582. end do
  1583. !
  1584. return
  1585. end subroutine trcpth
  1586. subroutine aqsat(t ,p ,es ,qs ,ii , &
  1587. ilen ,kk ,kstart ,kend )
  1588. !-----------------------------------------------------------------------
  1589. !
  1590. ! Purpose:
  1591. ! Utility procedure to look up and return saturation vapor pressure from
  1592. ! precomputed table, calculate and return saturation specific humidity
  1593. ! (g/g),for input arrays of temperature and pressure (dimensioned ii,kk)
  1594. ! This routine is useful for evaluating only a selected region in the
  1595. ! vertical.
  1596. !
  1597. ! Method:
  1598. ! <Describe the algorithm(s) used in the routine.>
  1599. ! <Also include any applicable external references.>
  1600. !
  1601. ! Author: J. Hack
  1602. !
  1603. !------------------------------Arguments--------------------------------
  1604. !
  1605. ! Input arguments
  1606. !
  1607. integer, intent(in) :: ii ! I dimension of arrays t, p, es, qs
  1608. integer, intent(in) :: kk ! K dimension of arrays t, p, es, qs
  1609. integer, intent(in) :: ilen ! Length of vectors in I direction which
  1610. integer, intent(in) :: kstart ! Starting location in K direction
  1611. integer, intent(in) :: kend ! Ending location in K direction
  1612. real(r8), intent(in) :: t(ii,kk) ! Temperature
  1613. real(r8), intent(in) :: p(ii,kk) ! Pressure
  1614. !
  1615. ! Output arguments
  1616. !
  1617. real(r8), intent(out) :: es(ii,kk) ! Saturation vapor pressure
  1618. real(r8), intent(out) :: qs(ii,kk) ! Saturation specific humidity
  1619. !
  1620. !---------------------------Local workspace-----------------------------
  1621. !
  1622. real(r8) omeps ! 1 - 0.622
  1623. integer i, k ! Indices
  1624. !
  1625. !-----------------------------------------------------------------------
  1626. !
  1627. omeps = 1.0 - epsqs
  1628. do k=kstart,kend
  1629. do i=1,ilen
  1630. es(i,k) = estblf(t(i,k))
  1631. !
  1632. ! Saturation specific humidity
  1633. !
  1634. qs(i,k) = epsqs*es(i,k)/(p(i,k) - omeps*es(i,k))
  1635. !
  1636. ! The following check is to avoid the generation of negative values
  1637. ! that can occur in the upper stratosphere and mesosphere
  1638. !
  1639. qs(i,k) = min(1.0_r8,qs(i,k))
  1640. !
  1641. if (qs(i,k) < 0.0) then
  1642. qs(i,k) = 1.0
  1643. es(i,k) = p(i,k)
  1644. end if
  1645. end do
  1646. end do
  1647. !
  1648. return
  1649. end subroutine aqsat
  1650. !===============================================================================
  1651. subroutine cldefr(lchnk ,ncol ,pcols, pver, pverp, &
  1652. landfrac,t ,rel ,rei ,ps ,pmid , landm, icefrac, snowh)
  1653. !-----------------------------------------------------------------------
  1654. !
  1655. ! Purpose:
  1656. ! Compute cloud water and ice particle size
  1657. !
  1658. ! Method:
  1659. ! use empirical formulas to construct effective radii
  1660. !
  1661. ! Author: J.T. Kiehl, B. A. Boville, P. Rasch
  1662. !
  1663. !-----------------------------------------------------------------------
  1664. implicit none
  1665. !------------------------------Arguments--------------------------------
  1666. !
  1667. ! Input arguments
  1668. !
  1669. integer, intent(in) :: lchnk ! chunk identifier
  1670. integer, intent(in) :: ncol ! number of atmospheric columns
  1671. integer, intent(in) :: pcols, pver, pverp
  1672. real(r8), intent(in) :: landfrac(pcols) ! Land fraction
  1673. real(r8), intent(in) :: icefrac(pcols) ! Ice fraction
  1674. real(r8), intent(in) :: t(pcols,pver) ! Temperature
  1675. real(r8), intent(in) :: ps(pcols) ! Surface pressure
  1676. real(r8), intent(in) :: pmid(pcols,pver) ! Midpoint pressures
  1677. real(r8), intent(in) :: landm(pcols)
  1678. real(r8), intent(in) :: snowh(pcols) ! Snow depth over land, water equivalent (m)
  1679. !
  1680. ! Output arguments
  1681. !
  1682. real(r8), intent(out) :: rel(pcols,pver) ! Liquid effective drop size (microns)
  1683. real(r8), intent(out) :: rei(pcols,pver) ! Ice effective drop size (microns)
  1684. !
  1685. !++pjr
  1686. ! following Kiehl
  1687. call reltab(ncol, pcols, pver, t, landfrac, landm, icefrac, rel, snowh)
  1688. ! following Kristjansson and Mitchell
  1689. call reitab(ncol, pcols, pver, t, rei)
  1690. !--pjr
  1691. !
  1692. !
  1693. return
  1694. end subroutine cldefr
  1695. subroutine background(lchnk, ncol, pint, pcols, pverr, pverrp, mmr)
  1696. !-----------------------------------------------------------------------
  1697. !
  1698. ! Purpose:
  1699. ! Set global mean tropospheric aerosol background (or tuning) field
  1700. !
  1701. ! Method:
  1702. ! Specify aerosol mixing ratio.
  1703. ! Aerosol mass mixing ratio
  1704. ! is specified so that the column visible aerosol optical depth is a
  1705. ! specified global number (tauback). This means that the actual mixing
  1706. ! ratio depends on pressure thickness of the lowest three atmospheric
  1707. ! layers near the surface.
  1708. !
  1709. !-----------------------------------------------------------------------
  1710. ! use shr_kind_mod, only: r8 => shr_kind_r8
  1711. ! use aer_optics, only: kbg,idxVIS
  1712. ! use physconst, only: gravit
  1713. !-----------------------------------------------------------------------
  1714. implicit none
  1715. !-----------------------------------------------------------------------
  1716. !#include <ptrrgrid.h>
  1717. !------------------------------Arguments--------------------------------
  1718. !
  1719. ! Input arguments
  1720. !
  1721. integer, intent(in) :: lchnk ! chunk identifier
  1722. integer, intent(in) :: ncol ! number of atmospheric columns
  1723. integer, intent(in) :: pcols,pverr,pverrp
  1724. real(r8), intent(in) :: pint(pcols,pverrp) ! Interface pressure (mks)
  1725. !
  1726. ! Output arguments
  1727. !
  1728. real(r8), intent(out) :: mmr(pcols,pverr) ! "background" aerosol mass mixing ratio
  1729. !
  1730. !---------------------------Local variables-----------------------------
  1731. !
  1732. integer i ! Longitude index
  1733. integer k ! Level index
  1734. !
  1735. real(r8) mass2mmr ! Factor to convert mass to mass mixing ratio
  1736. real(r8) mass ! Mass of "background" aerosol as specified by tauback
  1737. !
  1738. !-----------------------------------------------------------------------
  1739. !
  1740. do i=1,ncol
  1741. mass2mmr = gravmks / (pint(i,pverrp)-pint(i,pverrp-mxaerl))
  1742. do k=1,pverr
  1743. !
  1744. ! Compute aerosol mass mixing ratio for specified levels (1.e3 factor is
  1745. ! for units conversion of the extinction coefficiant from m2/g to m2/kg)
  1746. !
  1747. if ( k >= pverrp-mxaerl ) then
  1748. ! kaervs is not consistent with the values in aer_optics
  1749. ! this ?should? be changed.
  1750. ! rhfac is also implemented differently
  1751. mass = tauback / (1.e3 * kbg(idxVIS))
  1752. mmr(i,k) = mass2mmr*mass
  1753. else
  1754. mmr(i,k) = 0._r8
  1755. endif
  1756. !
  1757. enddo
  1758. enddo
  1759. !
  1760. return
  1761. end subroutine background
  1762. subroutine scale_aerosols(AEROSOLt, pcols, pver, ncol, lchnk, scale)
  1763. !-----------------------------------------------------------------
  1764. ! scale each species as determined by scale factors
  1765. !-----------------------------------------------------------------
  1766. integer, intent(in) :: ncol, lchnk ! number of columns and chunk index
  1767. integer, intent(in) :: pcols, pver
  1768. real(r8), intent(in) :: scale(naer_all) ! scale each aerosol by this amount
  1769. real(r8), intent(inout) :: AEROSOLt(pcols, pver, naer_all) ! aerosols
  1770. integer m
  1771. do m = 1, naer_all
  1772. AEROSOLt(:ncol, :, m) = scale(m)*AEROSOLt(:ncol, :, m)
  1773. end do
  1774. return
  1775. end subroutine scale_aerosols
  1776. subroutine get_int_scales(scales)
  1777. real(r8), intent(out)::scales(naer_all) ! scale each aerosol by this amount
  1778. integer i ! index through species
  1779. !initialize
  1780. scales = 1.
  1781. scales(idxBG) = 1._r8
  1782. scales(idxSUL) = sulscl
  1783. scales(idxSSLT) = ssltscl
  1784. do i = idxCARBONfirst, idxCARBONfirst+numCARBON-1
  1785. scales(i) = carscl
  1786. enddo
  1787. do i = idxDUSTfirst, idxDUSTfirst+numDUST-1
  1788. scales(i) = dustscl
  1789. enddo
  1790. scales(idxVOLC) = volcscl
  1791. return
  1792. end subroutine get_int_scales
  1793. subroutine vert_interpolate (Match_ps, aerosolc, m_hybi, paerlev, naer_c, pint, n, AEROSOL_mmr, pcols, pver, pverp, ncol, c)
  1794. !--------------------------------------------------------------------
  1795. ! Input: match surface pressure, cam interface pressure,
  1796. ! month index, number of columns, chunk index
  1797. !
  1798. ! Output: Aerosol mass mixing ratio (AEROSOL_mmr)
  1799. !
  1800. ! Method:
  1801. ! interpolate column mass (cumulative) from match onto
  1802. ! cam's vertical grid (pressure coordinate)
  1803. ! convert back to mass mixing ratio
  1804. !
  1805. !--------------------------------------------------------------------
  1806. ! use physconst, only: gravit
  1807. integer, intent(in) :: paerlev,naer_c,pcols,pver,pverp
  1808. real(r8), intent(out) :: AEROSOL_mmr(pcols,pver,naer) ! aerosol mmr from MATCH
  1809. real(r8), intent(in) :: Match_ps(pcols) ! surface pressure at a particular month
  1810. real(r8), intent(in) :: pint(pcols,pverp) ! interface pressure from CAM
  1811. real(r8), intent(in) :: aerosolc(pcols,paerlev,naer_c)
  1812. real(r8), intent(in) :: m_hybi(paerlev)
  1813. integer, intent(in) :: ncol,c ! chunk index and number of columns
  1814. integer, intent(in) :: n ! prv or nxt month index
  1815. !
  1816. ! Local workspace
  1817. !
  1818. integer m ! index to aerosol species
  1819. integer kupper(pcols) ! last upper bound for interpolation
  1820. integer i, k, kk, kkstart, kount ! loop vars for interpolation
  1821. integer isv, ksv, msv ! loop indices to save
  1822. logical bad ! indicates a bad point found
  1823. logical lev_interp_comp ! interpolation completed for a level
  1824. real(r8) AEROSOL(pcols,pverp,naer) ! cumulative mass of aerosol in column beneath upper
  1825. ! interface of level in column at particular month
  1826. real(r8) dpl, dpu ! lower and upper intepolation factors
  1827. real(r8) v_coord ! vertical coordinate
  1828. real(r8) m_to_mmr ! mass to mass mixing ratio conversion factor
  1829. real(r8) AER_diff ! temp var for difference between aerosol masses
  1830. ! call t_startf ('vert_interpolate')
  1831. !
  1832. ! Initialize index array
  1833. !
  1834. do i=1,ncol
  1835. kupper(i) = 1
  1836. end do
  1837. !
  1838. ! assign total mass to topmost level
  1839. !
  1840. do i=1,ncol
  1841. do m=1,naer
  1842. AEROSOL(i,1,m) = AEROSOLc(i,1,m)
  1843. enddo
  1844. enddo
  1845. !
  1846. ! At every pressure level, interpolate onto that pressure level
  1847. !
  1848. do k=2,pver
  1849. !
  1850. ! Top level we need to start looking is the top level for the previous k
  1851. ! for all longitude points
  1852. !
  1853. kkstart = paerlev
  1854. do i=1,ncol
  1855. kkstart = min0(kkstart,kupper(i))
  1856. end do
  1857. kount = 0
  1858. !
  1859. ! Store level indices for interpolation
  1860. !
  1861. ! for the pressure interpolation should be comparing
  1862. ! pint(column,lev) with M_hybi(lev)*M_ps_cam_col(month,column,chunk)
  1863. !
  1864. lev_interp_comp = .false.
  1865. do kk=kkstart,paerlev-1
  1866. if(.not.lev_interp_comp) then
  1867. do i=1,ncol
  1868. v_coord = pint(i,k)
  1869. if (M_hybi(kk)*Match_ps(i) .lt. v_coord .and. v_coord .le. M_hybi(kk+1)*Match_ps(i)) then
  1870. kupper(i) = kk
  1871. kount = kount + 1
  1872. end if
  1873. end do
  1874. !
  1875. ! If all indices for this level have been found, do the interpolation and
  1876. ! go to the next level
  1877. !
  1878. ! Interpolate in pressure.
  1879. !
  1880. if (kount.eq.ncol) then
  1881. do i=1,ncol
  1882. do m=1,naer
  1883. dpu = pint(i,k) - M_hybi(kupper(i))*Match_ps(i)
  1884. dpl = M_hybi(kupper(i)+1)*Match_ps(i) - pint(i,k)
  1885. AEROSOL(i,k,m) = &
  1886. (AEROSOLc(i,kupper(i) ,m)*dpl + &
  1887. AEROSOLc(i,kupper(i)+1,m)*dpu)/(dpl + dpu)
  1888. enddo
  1889. enddo !i
  1890. lev_interp_comp = .true.
  1891. end if
  1892. end if
  1893. end do
  1894. !
  1895. ! If we've fallen through the kk=1,levsiz-1 loop, we cannot interpolate and
  1896. ! must extrapolate from the bottom or top pressure level for at least some
  1897. ! of the longitude points.
  1898. !
  1899. if(.not.lev_interp_comp) then
  1900. do i=1,ncol
  1901. do m=1,naer
  1902. if (pint(i,k) .lt. M_hybi(1)*Match_ps(i)) then
  1903. AEROSOL(i,k,m) = AEROSOLc(i,1,m)
  1904. else if (pint(i,k) .gt. M_hybi(paerlev)*Match_ps(i)) then
  1905. AEROSOL(i,k,m) = 0.0
  1906. else
  1907. dpu = pint(i,k) - M_hybi(kupper(i))*Match_ps(i)
  1908. dpl = M_hybi(kupper(i)+1)*Match_ps(i) - pint(i,k)
  1909. AEROSOL(i,k,m) = &
  1910. (AEROSOLc(i,kupper(i) ,m)*dpl + &
  1911. AEROSOLc(i,kupper(i)+1,m)*dpu)/(dpl + dpu)
  1912. end if
  1913. enddo
  1914. end do
  1915. if (kount.gt.ncol) then
  1916. call endrun ('VERT_INTERPOLATE: Bad data: non-monotonicity suspected in dependent variable')
  1917. end if
  1918. end if
  1919. end do
  1920. ! call t_startf ('vi_checks')
  1921. !
  1922. ! aerosol mass beneath lowest interface (pverp) must be 0
  1923. !
  1924. AEROSOL(1:ncol,pverp,:) = 0.
  1925. !
  1926. ! Set mass in layer to zero whenever it is less than
  1927. ! 1.e-40 kg/m^2 in the layer
  1928. !
  1929. do m = 1, naer
  1930. do k = 1, pver
  1931. do i = 1, ncol
  1932. if (AEROSOL(i,k,m) < 1.e-40_r8) AEROSOL(i,k,m) = 0.
  1933. end do
  1934. end do
  1935. end do
  1936. !
  1937. ! Set mass in layer to zero whenever it is less than
  1938. ! 10^-15 relative to column total mass
  1939. ! convert back to mass mixing ratios.
  1940. ! exit if mmr is negative
  1941. !
  1942. do m = 1, naer
  1943. do k = 1, pver
  1944. do i = 1, ncol
  1945. AER_diff = AEROSOL(i,k,m) - AEROSOL(i,k+1,m)
  1946. if( abs(AER_diff) < 1e-15*AEROSOL(i,1,m)) then
  1947. AER_diff = 0.
  1948. end if
  1949. m_to_mmr = gravmks / (pint(i,k+1)-pint(i,k))
  1950. AEROSOL_mmr(i,k,m)= AER_diff * m_to_mmr
  1951. if (AEROSOL_mmr(i,k,m) < 0) then
  1952. write(6,*)'vert_interpolate: mmr < 0, m, col, lev, mmr',m, i, k, AEROSOL_mmr(i,k,m)
  1953. write(6,*)'vert_interpolate: aerosol(k),(k+1)',AEROSOL(i,k,m),AEROSOL(i,k+1,m)
  1954. write(6,*)'vert_interpolate: pint(k+1),(k)',pint(i,k+1),pint(i,k)
  1955. write(6,*)'n,c',n,c
  1956. call endrun()
  1957. end if
  1958. end do
  1959. end do
  1960. end do
  1961. ! call t_stopf ('vi_checks')
  1962. ! call t_stopf ('vert_interpolate')
  1963. return
  1964. end subroutine vert_interpolate
  1965. !===============================================================================
  1966. subroutine cldems(lchnk ,ncol ,pcols, pver, pverp, clwp ,fice ,rei ,emis )
  1967. !-----------------------------------------------------------------------
  1968. !
  1969. ! Purpose:
  1970. ! Compute cloud emissivity using cloud liquid water path (g/m**2)
  1971. !
  1972. ! Method:
  1973. ! <Describe the algorithm(s) used in the routine.>
  1974. ! <Also include any applicable external references.>
  1975. !
  1976. ! Author: J.T. Kiehl
  1977. !
  1978. !-----------------------------------------------------------------------
  1979. implicit none
  1980. !------------------------------Parameters-------------------------------
  1981. !
  1982. real(r8) kabsl ! longwave liquid absorption coeff (m**2/g)
  1983. parameter (kabsl = 0.090361)
  1984. !
  1985. !------------------------------Arguments--------------------------------
  1986. !
  1987. ! Input arguments
  1988. !
  1989. integer, intent(in) :: lchnk ! chunk identifier
  1990. integer, intent(in) :: ncol ! number of atmospheric columns
  1991. integer, intent(in) :: pcols, pver, pverp
  1992. real(r8), intent(in) :: clwp(pcols,pver) ! cloud liquid water path (g/m**2)
  1993. real(r8), intent(in) :: rei(pcols,pver) ! ice effective drop size (microns)
  1994. real(r8), intent(in) :: fice(pcols,pver) ! fractional ice content within cloud
  1995. !
  1996. ! Output arguments
  1997. !
  1998. real(r8), intent(out) :: emis(pcols,pver) ! cloud emissivity (fraction)
  1999. !
  2000. !---------------------------Local workspace-----------------------------
  2001. !
  2002. integer i,k ! longitude, level indices
  2003. real(r8) kabs ! longwave absorption coeff (m**2/g)
  2004. real(r8) kabsi ! ice absorption coefficient
  2005. !
  2006. !-----------------------------------------------------------------------
  2007. !
  2008. do k=1,pver
  2009. do i=1,ncol
  2010. kabsi = 0.005 + 1./rei(i,k)
  2011. kabs = kabsl*(1.-fice(i,k)) + kabsi*fice(i,k)
  2012. emis(i,k) = 1. - exp(-1.66*kabs*clwp(i,k))
  2013. end do
  2014. end do
  2015. !
  2016. return
  2017. end subroutine cldems
  2018. !===============================================================================
  2019. subroutine cldovrlap(lchnk ,ncol ,pcols, pver, pverp, pint ,cld ,nmxrgn ,pmxrgn )
  2020. !-----------------------------------------------------------------------
  2021. !
  2022. ! Purpose:
  2023. ! Partitions each column into regions with clouds in neighboring layers.
  2024. ! This information is used to implement maximum overlap in these regions
  2025. ! with random overlap between them.
  2026. ! On output,
  2027. ! nmxrgn contains the number of regions in each column
  2028. ! pmxrgn contains the interface pressures for the lower boundaries of
  2029. ! each region!
  2030. ! Method:
  2031. !
  2032. ! Author: W. Collins
  2033. !
  2034. !-----------------------------------------------------------------------
  2035. implicit none
  2036. !
  2037. ! Input arguments
  2038. !
  2039. integer, intent(in) :: lchnk ! chunk identifier
  2040. integer, intent(in) :: ncol ! number of atmospheric columns
  2041. integer, intent(in) :: pcols, pver, pverp
  2042. real(r8), intent(in) :: pint(pcols,pverp) ! Interface pressure
  2043. real(r8), intent(in) :: cld(pcols,pver) ! Fractional cloud cover
  2044. !
  2045. ! Output arguments
  2046. !
  2047. real(r8), intent(out) :: pmxrgn(pcols,pverp)! Maximum values of pressure for each
  2048. ! maximally overlapped region.
  2049. ! 0->pmxrgn(i,1) is range of pressure for
  2050. ! 1st region,pmxrgn(i,1)->pmxrgn(i,2) for
  2051. ! 2nd region, etc
  2052. integer nmxrgn(pcols) ! Number of maximally overlapped regions
  2053. !
  2054. !---------------------------Local variables-----------------------------
  2055. !
  2056. integer i ! Longitude index
  2057. integer k ! Level index
  2058. integer n ! Max-overlap region counter
  2059. real(r8) pnm(pcols,pverp) ! Interface pressure
  2060. logical cld_found ! Flag for detection of cloud
  2061. logical cld_layer(pver) ! Flag for cloud in layer
  2062. !
  2063. !------------------------------------------------------------------------
  2064. !
  2065. do i = 1, ncol
  2066. cld_found = .false.
  2067. cld_layer(:) = cld(i,:) > 0.0_r8
  2068. pmxrgn(i,:) = 0.0
  2069. pnm(i,:)=pint(i,:)*10.
  2070. n = 1
  2071. do k = 1, pver
  2072. if (cld_layer(k) .and. .not. cld_found) then
  2073. cld_found = .true.
  2074. else if ( .not. cld_layer(k) .and. cld_found) then
  2075. cld_found = .false.
  2076. if (count(cld_layer(k:pver)) == 0) then
  2077. exit
  2078. endif
  2079. pmxrgn(i,n) = pnm(i,k)
  2080. n = n + 1
  2081. endif
  2082. end do
  2083. pmxrgn(i,n) = pnm(i,pverp)
  2084. nmxrgn(i) = n
  2085. end do
  2086. return
  2087. end subroutine cldovrlap
  2088. !===============================================================================
  2089. subroutine cldclw(lchnk ,ncol ,pcols, pver, pverp, zi ,clwp ,tpw ,hl )
  2090. !-----------------------------------------------------------------------
  2091. !
  2092. ! Purpose:
  2093. ! Evaluate cloud liquid water path clwp (g/m**2)
  2094. !
  2095. ! Method:
  2096. ! <Describe the algorithm(s) used in the routine.>
  2097. ! <Also include any applicable external references.>
  2098. !
  2099. ! Author: J.T. Kiehl
  2100. !
  2101. !-----------------------------------------------------------------------
  2102. implicit none
  2103. !
  2104. ! Input arguments
  2105. !
  2106. integer, intent(in) :: lchnk ! chunk identifier
  2107. integer, intent(in) :: ncol ! number of atmospheric columns
  2108. integer, intent(in) :: pcols, pver, pverp
  2109. real(r8), intent(in) :: zi(pcols,pverp) ! height at layer interfaces(m)
  2110. real(r8), intent(in) :: tpw(pcols) ! total precipitable water (mm)
  2111. !
  2112. ! Output arguments
  2113. !
  2114. real(r8) clwp(pcols,pver) ! cloud liquid water path (g/m**2)
  2115. real(r8) hl(pcols) ! liquid water scale height
  2116. real(r8) rhl(pcols) ! 1/hl
  2117. !
  2118. !---------------------------Local workspace-----------------------------
  2119. !
  2120. integer i,k ! longitude, level indices
  2121. real(r8) clwc0 ! reference liquid water concentration (g/m**3)
  2122. real(r8) emziohl(pcols,pverp) ! exp(-zi/hl)
  2123. !
  2124. !-----------------------------------------------------------------------
  2125. !
  2126. ! Set reference liquid water concentration
  2127. !
  2128. clwc0 = 0.21
  2129. !
  2130. ! Diagnose liquid water scale height from precipitable water
  2131. !
  2132. do i=1,ncol
  2133. hl(i) = 700.0*log(max(tpw(i)+1.0_r8,1.0_r8))
  2134. rhl(i) = 1.0/hl(i)
  2135. end do
  2136. !
  2137. ! Evaluate cloud liquid water path (vertical integral of exponential fn)
  2138. !
  2139. do k=1,pverp
  2140. do i=1,ncol
  2141. emziohl(i,k) = exp(-zi(i,k)*rhl(i))
  2142. end do
  2143. end do
  2144. do k=1,pver
  2145. do i=1,ncol
  2146. clwp(i,k) = clwc0*hl(i)*(emziohl(i,k+1) - emziohl(i,k))
  2147. end do
  2148. end do
  2149. !
  2150. return
  2151. end subroutine cldclw
  2152. !===============================================================================
  2153. subroutine reltab(ncol, pcols, pver, t, landfrac, landm, icefrac, rel, snowh)
  2154. !-----------------------------------------------------------------------
  2155. !
  2156. ! Purpose:
  2157. ! Compute cloud water size
  2158. !
  2159. ! Method:
  2160. ! analytic formula following the formulation originally developed by J. T. Kiehl
  2161. !
  2162. ! Author: Phil Rasch
  2163. !
  2164. !-----------------------------------------------------------------------
  2165. ! use physconst, only: tmelt
  2166. implicit none
  2167. !------------------------------Arguments--------------------------------
  2168. !
  2169. ! Input arguments
  2170. !
  2171. integer, intent(in) :: ncol
  2172. integer, intent(in) :: pcols, pver
  2173. real(r8), intent(in) :: landfrac(pcols) ! Land fraction
  2174. real(r8), intent(in) :: icefrac(pcols) ! Ice fraction
  2175. real(r8), intent(in) :: snowh(pcols) ! Snow depth over land, water equivalent (m)
  2176. real(r8), intent(in) :: landm(pcols) ! Land fraction ramping to zero over ocean
  2177. real(r8), intent(in) :: t(pcols,pver) ! Temperature
  2178. !
  2179. ! Output arguments
  2180. !
  2181. real(r8), intent(out) :: rel(pcols,pver) ! Liquid effective drop size (microns)
  2182. !
  2183. !---------------------------Local workspace-----------------------------
  2184. !
  2185. integer i,k ! Lon, lev indices
  2186. real(r8) rliqland ! liquid drop size if over land
  2187. real(r8) rliqocean ! liquid drop size if over ocean
  2188. real(r8) rliqice ! liquid drop size if over sea ice
  2189. !
  2190. !-----------------------------------------------------------------------
  2191. !
  2192. rliqocean = 14.0_r8
  2193. rliqice = 14.0_r8
  2194. rliqland = 8.0_r8
  2195. do k=1,pver
  2196. do i=1,ncol
  2197. ! jrm Reworked effective radius algorithm
  2198. ! Start with temperature-dependent value appropriate for continental air
  2199. ! Note: findmcnew has a pressure dependence here
  2200. rel(i,k) = rliqland + (rliqocean-rliqland) * min(1.0_r8,max(0.0_r8,(tmelt-t(i,k))*0.05))
  2201. ! Modify for snow depth over land
  2202. rel(i,k) = rel(i,k) + (rliqocean-rel(i,k)) * min(1.0_r8,max(0.0_r8,snowh(i)*10.))
  2203. ! Ramp between polluted value over land to clean value over ocean.
  2204. rel(i,k) = rel(i,k) + (rliqocean-rel(i,k)) * min(1.0_r8,max(0.0_r8,1.0-landm(i)))
  2205. ! Ramp between the resultant value and a sea ice value in the presence of ice.
  2206. rel(i,k) = rel(i,k) + (rliqice-rel(i,k)) * min(1.0_r8,max(0.0_r8,icefrac(i)))
  2207. ! end jrm
  2208. end do
  2209. end do
  2210. end subroutine reltab
  2211. !===============================================================================
  2212. subroutine reitab(ncol, pcols, pver, t, re)
  2213. !
  2214. integer, intent(in) :: ncol, pcols, pver
  2215. real(r8), intent(out) :: re(pcols,pver)
  2216. real(r8), intent(in) :: t(pcols,pver)
  2217. real(r8) corr
  2218. integer i
  2219. integer k
  2220. integer index
  2221. !
  2222. do k=1,pver
  2223. do i=1,ncol
  2224. index = int(t(i,k)-179.)
  2225. index = min(max(index,1),94)
  2226. corr = t(i,k) - int(t(i,k))
  2227. re(i,k) = retab(index)*(1.-corr) &
  2228. +retab(index+1)*corr
  2229. ! re(i,k) = amax1(amin1(re(i,k),30.),10.)
  2230. end do
  2231. end do
  2232. !
  2233. return
  2234. end subroutine reitab
  2235. function exp_interpol(x, f, y) result(g)
  2236. ! Purpose:
  2237. ! interpolates f(x) to point y
  2238. ! assuming f(x) = f(x0) exp a(x - x0)
  2239. ! where a = ( ln f(x1) - ln f(x0) ) / (x1 - x0)
  2240. ! x0 <= x <= x1
  2241. ! assumes x is monotonically increasing
  2242. ! Author: D. Fillmore
  2243. ! use shr_kind_mod, only: r8 => shr_kind_r8
  2244. implicit none
  2245. real(r8), intent(in), dimension(:) :: x ! grid points
  2246. real(r8), intent(in), dimension(:) :: f ! grid function values
  2247. real(r8), intent(in) :: y ! interpolation point
  2248. real(r8) :: g ! interpolated function value
  2249. integer :: k ! interpolation point index
  2250. integer :: n ! length of x
  2251. real(r8) :: a
  2252. n = size(x)
  2253. ! find k such that x(k) < y =< x(k+1)
  2254. ! set k = 1 if y <= x(1) and k = n-1 if y > x(n)
  2255. if (y <= x(1)) then
  2256. k = 1
  2257. else if (y >= x(n)) then
  2258. k = n - 1
  2259. else
  2260. k = 1
  2261. do while (y > x(k+1) .and. k < n)
  2262. k = k + 1
  2263. end do
  2264. end if
  2265. ! interpolate
  2266. a = ( log( f(k+1) / f(k) ) ) / ( x(k+1) - x(k) )
  2267. g = f(k) * exp( a * (y - x(k)) )
  2268. end function exp_interpol
  2269. function lin_interpol(x, f, y) result(g)
  2270. ! Purpose:
  2271. ! interpolates f(x) to point y
  2272. ! assuming f(x) = f(x0) + a * (x - x0)
  2273. ! where a = ( f(x1) - f(x0) ) / (x1 - x0)
  2274. ! x0 <= x <= x1
  2275. ! assumes x is monotonically increasing
  2276. ! Author: D. Fillmore
  2277. ! use shr_kind_mod, only: r8 => shr_kind_r8
  2278. implicit none
  2279. real(r8), intent(in), dimension(:) :: x ! grid points
  2280. real(r8), intent(in), dimension(:) :: f ! grid function values
  2281. real(r8), intent(in) :: y ! interpolation point
  2282. real(r8) :: g ! interpolated function value
  2283. integer :: k ! interpolation point index
  2284. integer :: n ! length of x
  2285. real(r8) :: a
  2286. n = size(x)
  2287. ! find k such that x(k) < y =< x(k+1)
  2288. ! set k = 1 if y <= x(1) and k = n-1 if y > x(n)
  2289. if (y <= x(1)) then
  2290. k = 1
  2291. else if (y >= x(n)) then
  2292. k = n - 1
  2293. else
  2294. k = 1
  2295. do while (y > x(k+1) .and. k < n)
  2296. k = k + 1
  2297. end do
  2298. end if
  2299. ! interpolate
  2300. a = ( f(k+1) - f(k) ) / ( x(k+1) - x(k) )
  2301. g = f(k) + a * (y - x(k))
  2302. end function lin_interpol
  2303. function lin_interpol2(x, f, y) result(g)
  2304. ! Purpose:
  2305. ! interpolates f(x) to point y
  2306. ! assuming f(x) = f(x0) + a * (x - x0)
  2307. ! where a = ( f(x1) - f(x0) ) / (x1 - x0)
  2308. ! x0 <= x <= x1
  2309. ! assumes x is monotonically increasing
  2310. ! Author: D. Fillmore :: J. Done changed from r8 to r4
  2311. implicit none
  2312. real, intent(in), dimension(:) :: x ! grid points
  2313. real, intent(in), dimension(:) :: f ! grid function values
  2314. real, intent(in) :: y ! interpolation point
  2315. real :: g ! interpolated function value
  2316. integer :: k ! interpolation point index
  2317. integer :: n ! length of x
  2318. real :: a
  2319. n = size(x)
  2320. ! find k such that x(k) < y =< x(k+1)
  2321. ! set k = 1 if y <= x(1) and k = n-1 if y > x(n)
  2322. if (y <= x(1)) then
  2323. k = 1
  2324. else if (y >= x(n)) then
  2325. k = n - 1
  2326. else
  2327. k = 1
  2328. do while (y > x(k+1) .and. k < n)
  2329. k = k + 1
  2330. end do
  2331. end if
  2332. ! interpolate
  2333. a = ( f(k+1) - f(k) ) / ( x(k+1) - x(k) )
  2334. g = f(k) + a * (y - x(k))
  2335. end function lin_interpol2
  2336. subroutine getfactors (cycflag, np1, cdayminus, cdayplus, cday, &
  2337. fact1, fact2)
  2338. !---------------------------------------------------------------------------
  2339. !
  2340. ! Purpose: Determine time interpolation factors (normally for a boundary dataset)
  2341. ! for linear interpolation.
  2342. !
  2343. ! Method: Assume 365 days per year. Output variable fact1 will be the weight to
  2344. ! apply to data at calendar time "cdayminus", and fact2 the weight to apply
  2345. ! to data at time "cdayplus". Combining these values will produce a result
  2346. ! valid at time "cday". Output arguments fact1 and fact2 will be between
  2347. ! 0 and 1, and fact1 + fact2 = 1 to roundoff.
  2348. !
  2349. ! Author: Jim Rosinski
  2350. !
  2351. !---------------------------------------------------------------------------
  2352. implicit none
  2353. !
  2354. ! Arguments
  2355. !
  2356. logical, intent(in) :: cycflag ! flag indicates whether dataset is being cycled yearly
  2357. integer, intent(in) :: np1 ! index points to forward time slice matching cdayplus
  2358. real(r8), intent(in) :: cdayminus ! calendar day of rearward time slice
  2359. real(r8), intent(in) :: cdayplus ! calendar day of forward time slice
  2360. real(r8), intent(in) :: cday ! calenar day to be interpolated to
  2361. real(r8), intent(out) :: fact1 ! time interpolation factor to apply to rearward time slice
  2362. real(r8), intent(out) :: fact2 ! time interpolation factor to apply to forward time slice
  2363. ! character(len=*), intent(in) :: str ! string to be added to print in case of error (normally the callers name)
  2364. !
  2365. ! Local workspace
  2366. !
  2367. real(r8) :: deltat ! time difference (days) between cdayminus and cdayplus
  2368. real(r8), parameter :: daysperyear = 365. ! number of days in a year
  2369. !
  2370. ! Initial sanity checks
  2371. !
  2372. ! if (np1 == 1 .and. .not. cycflag) then
  2373. ! call endrun ('GETFACTORS:'//str//' cycflag false and forward month index = Jan. not allowed')
  2374. ! end if
  2375. ! if (np1 < 1) then
  2376. ! call endrun ('GETFACTORS:'//str//' input arg np1 must be > 0')
  2377. ! end if
  2378. if (cycflag) then
  2379. if ((cday < 1.) .or. (cday > (daysperyear+1.))) then
  2380. write(6,*) 'GETFACTORS:', ' bad cday=',cday
  2381. call endrun ()
  2382. end if
  2383. else
  2384. if (cday < 1.) then
  2385. write(6,*) 'GETFACTORS:', ' bad cday=',cday
  2386. call endrun ()
  2387. end if
  2388. end if
  2389. !
  2390. ! Determine time interpolation factors. Account for December-January
  2391. ! interpolation if dataset is being cycled yearly.
  2392. !
  2393. if (cycflag .and. np1 == 1) then ! Dec-Jan interpolation
  2394. deltat = cdayplus + daysperyear - cdayminus
  2395. if (cday > cdayplus) then ! We are in December
  2396. fact1 = (cdayplus + daysperyear - cday)/deltat
  2397. fact2 = (cday - cdayminus)/deltat
  2398. else ! We are in January
  2399. fact1 = (cdayplus - cday)/deltat
  2400. fact2 = (cday + daysperyear - cdayminus)/deltat
  2401. end if
  2402. else
  2403. deltat = cdayplus - cdayminus
  2404. fact1 = (cdayplus - cday)/deltat
  2405. fact2 = (cday - cdayminus)/deltat
  2406. end if
  2407. if (.not. validfactors (fact1, fact2)) then
  2408. write(6,*) 'GETFACTORS: ', ' bad fact1 and/or fact2=', fact1, fact2
  2409. call endrun ()
  2410. end if
  2411. return
  2412. end subroutine getfactors
  2413. logical function validfactors (fact1, fact2)
  2414. !---------------------------------------------------------------------------
  2415. !
  2416. ! Purpose: check sanity of time interpolation factors to within 32-bit roundoff
  2417. !
  2418. !---------------------------------------------------------------------------
  2419. implicit none
  2420. real(r8), intent(in) :: fact1, fact2 ! time interpolation factors
  2421. validfactors = .true.
  2422. if (abs(fact1+fact2-1.) > 1.e-6 .or. &
  2423. fact1 > 1.000001 .or. fact1 < -1.e-6 .or. &
  2424. fact2 > 1.000001 .or. fact2 < -1.e-6) then
  2425. validfactors = .false.
  2426. end if
  2427. return
  2428. end function validfactors
  2429. subroutine get_rf_scales(scales)
  2430. real(r8), intent(out)::scales(naer_all) ! scale aerosols by this amount
  2431. integer i ! loop index
  2432. scales(idxBG) = bgscl_rf
  2433. scales(idxSUL) = sulscl_rf
  2434. scales(idxSSLT) = ssltscl_rf
  2435. do i = idxCARBONfirst, idxCARBONfirst+numCARBON-1
  2436. scales(i) = carscl_rf
  2437. enddo
  2438. do i = idxDUSTfirst, idxDUSTfirst+numDUST-1
  2439. scales(i) = dustscl_rf
  2440. enddo
  2441. scales(idxVOLC) = volcscl_rf
  2442. end subroutine get_rf_scales
  2443. function psi(tpx,iband)
  2444. !
  2445. ! History: First version for Hitran 1996 (C/H/E)
  2446. ! Current version for Hitran 2000 (C/LT/E)
  2447. ! Short function for Hulst-Curtis-Godson temperature factors for
  2448. ! computing effective H2O path
  2449. ! Line data for H2O: Hitran 2000, plus H2O patches v11.0 for 1341 missing
  2450. ! lines between 500 and 2820 cm^-1.
  2451. ! See cfa-www.harvard.edu/HITRAN
  2452. ! Isotopes of H2O: all
  2453. ! Line widths: air-broadened only (self set to 0)
  2454. ! Code for line strengths and widths: GENLN3
  2455. ! Reference: Edwards, D.P., 1992: GENLN2, A General Line-by-Line Atmospheric
  2456. ! Transmittance and Radiance Model, Version 3.0 Description
  2457. ! and Users Guide, NCAR/TN-367+STR, 147 pp.
  2458. !
  2459. ! Note: functions have been normalized by dividing by their values at
  2460. ! a path temperature of 160K
  2461. !
  2462. ! spectral intervals:
  2463. ! 1 = 0-800 cm^-1 and 1200-2200 cm^-1
  2464. ! 2 = 800-1200 cm^-1
  2465. !
  2466. ! Formulae: Goody and Yung, Atmospheric Radiation: Theoretical Basis,
  2467. ! 2nd edition, Oxford University Press, 1989.
  2468. ! Psi: function for pressure along path
  2469. ! eq. 6.30, p. 228
  2470. !
  2471. real(r8),intent(in):: tpx ! path temperature
  2472. integer, intent(in):: iband ! band to process
  2473. real(r8) psi ! psi for given band
  2474. real(r8),parameter :: psi_r0(nbands) = (/ 5.65308452E-01, -7.30087891E+01/)
  2475. real(r8),parameter :: psi_r1(nbands) = (/ 4.07519005E-03, 1.22199547E+00/)
  2476. real(r8),parameter :: psi_r2(nbands) = (/-1.04347237E-05, -7.12256227E-03/)
  2477. real(r8),parameter :: psi_r3(nbands) = (/ 1.23765354E-08, 1.47852825E-05/)
  2478. psi = (((psi_r3(iband) * tpx) + psi_r2(iband)) * tpx + psi_r1(iband)) * tpx + psi_r0(iband)
  2479. end function psi
  2480. function phi(tpx,iband)
  2481. !
  2482. ! History: First version for Hitran 1996 (C/H/E)
  2483. ! Current version for Hitran 2000 (C/LT/E)
  2484. ! Short function for Hulst-Curtis-Godson temperature factors for
  2485. ! computing effective H2O path
  2486. ! Line data for H2O: Hitran 2000, plus H2O patches v11.0 for 1341 missing
  2487. ! lines between 500 and 2820 cm^-1.
  2488. ! See cfa-www.harvard.edu/HITRAN
  2489. ! Isotopes of H2O: all
  2490. ! Line widths: air-broadened only (self set to 0)
  2491. ! Code for line strengths and widths: GENLN3
  2492. ! Reference: Edwards, D.P., 1992: GENLN2, A General Line-by-Line Atmospheric
  2493. ! Transmittance and Radiance Model, Version 3.0 Description
  2494. ! and Users Guide, NCAR/TN-367+STR, 147 pp.
  2495. !
  2496. ! Note: functions have been normalized by dividing by their values at
  2497. ! a path temperature of 160K
  2498. !
  2499. ! spectral intervals:
  2500. ! 1 = 0-800 cm^-1 and 1200-2200 cm^-1
  2501. ! 2 = 800-1200 cm^-1
  2502. !
  2503. ! Formulae: Goody and Yung, Atmospheric Radiation: Theoretical Basis,
  2504. ! 2nd edition, Oxford University Press, 1989.
  2505. ! Phi: function for H2O path
  2506. ! eq. 6.25, p. 228
  2507. !
  2508. real(r8),intent(in):: tpx ! path temperature
  2509. integer, intent(in):: iband ! band to process
  2510. real(r8) phi ! phi for given band
  2511. real(r8),parameter :: phi_r0(nbands) = (/ 9.60917711E-01, -2.21031342E+01/)
  2512. real(r8),parameter :: phi_r1(nbands) = (/ 4.86076751E-04, 4.24062610E-01/)
  2513. real(r8),parameter :: phi_r2(nbands) = (/-1.84806265E-06, -2.95543415E-03/)
  2514. real(r8),parameter :: phi_r3(nbands) = (/ 2.11239959E-09, 7.52470896E-06/)
  2515. phi = (((phi_r3(iband) * tpx) + phi_r2(iband)) * tpx + phi_r1(iband)) &
  2516. * tpx + phi_r0(iband)
  2517. end function phi
  2518. function fh2oself( temp )
  2519. !
  2520. ! Short function for H2O self-continuum temperature factor in
  2521. ! calculation of effective H2O self-continuum path length
  2522. !
  2523. ! H2O Continuum: CKD 2.4
  2524. ! Code for continuum: GENLN3
  2525. ! Reference: Edwards, D.P., 1992: GENLN2, A General Line-by-Line Atmospheric
  2526. ! Transmittance and Radiance Model, Version 3.0 Description
  2527. ! and Users Guide, NCAR/TN-367+STR, 147 pp.
  2528. !
  2529. ! In GENLN, the temperature scaling of the self-continuum is handled
  2530. ! by exponential interpolation/extrapolation from observations at
  2531. ! 260K and 296K by:
  2532. !
  2533. ! TFAC = (T(IPATH) - 296.0)/(260.0 - 296.0)
  2534. ! CSFFT = CSFF296*(CSFF260/CSFF296)**TFAC
  2535. !
  2536. ! For 800-1200 cm^-1, (CSFF260/CSFF296) ranges from ~2.1 to ~1.9
  2537. ! with increasing wavenumber. The ratio <CSFF260>/<CSFF296>,
  2538. ! where <> indicates average over wavenumber, is ~2.07
  2539. !
  2540. ! fh2oself is (<CSFF260>/<CSFF296>)**TFAC
  2541. !
  2542. real(r8),intent(in) :: temp ! path temperature
  2543. real(r8) fh2oself ! mean ratio of self-continuum at temp and 296K
  2544. fh2oself = 2.0727484**((296.0 - temp) / 36.0)
  2545. end function fh2oself
  2546. ! from wv_saturation.F90
  2547. subroutine esinti(epslon ,latvap ,latice ,rh2o ,cpair ,tmelt )
  2548. !-----------------------------------------------------------------------
  2549. !
  2550. ! Purpose:
  2551. ! Initialize es lookup tables
  2552. !
  2553. ! Method:
  2554. ! <Describe the algorithm(s) used in the routine.>
  2555. ! <Also include any applicable external references.>
  2556. !
  2557. ! Author: J. Hack
  2558. !
  2559. !-----------------------------------------------------------------------
  2560. ! use shr_kind_mod, only: r8 => shr_kind_r8
  2561. ! use wv_saturation, only: gestbl
  2562. implicit none
  2563. !------------------------------Arguments--------------------------------
  2564. !
  2565. ! Input arguments
  2566. !
  2567. real(r8), intent(in) :: epslon ! Ratio of h2o to dry air molecular weights
  2568. real(r8), intent(in) :: latvap ! Latent heat of vaporization
  2569. real(r8), intent(in) :: latice ! Latent heat of fusion
  2570. real(r8), intent(in) :: rh2o ! Gas constant for water vapor
  2571. real(r8), intent(in) :: cpair ! Specific heat of dry air
  2572. real(r8), intent(in) :: tmelt ! Melting point of water (K)
  2573. !
  2574. !---------------------------Local workspace-----------------------------
  2575. !
  2576. real(r8) tmn ! Minimum temperature entry in table
  2577. real(r8) tmx ! Maximum temperature entry in table
  2578. real(r8) trice ! Trans range from es over h2o to es over ice
  2579. logical ip ! Ice phase (true or false)
  2580. !
  2581. !-----------------------------------------------------------------------
  2582. !
  2583. ! Specify control parameters first
  2584. !
  2585. tmn = 173.16
  2586. tmx = 375.16
  2587. trice = 20.00
  2588. ip = .true.
  2589. !
  2590. ! Call gestbl to build saturation vapor pressure table.
  2591. !
  2592. call gestbl(tmn ,tmx ,trice ,ip ,epslon , &
  2593. latvap ,latice ,rh2o ,cpair ,tmelt )
  2594. !
  2595. return
  2596. end subroutine esinti
  2597. subroutine gestbl(tmn ,tmx ,trice ,ip ,epsil , &
  2598. latvap ,latice ,rh2o ,cpair ,tmeltx )
  2599. !-----------------------------------------------------------------------
  2600. !
  2601. ! Purpose:
  2602. ! Builds saturation vapor pressure table for later lookup procedure.
  2603. !
  2604. ! Method:
  2605. ! Uses Goff & Gratch (1946) relationships to generate the table
  2606. ! according to a set of free parameters defined below. Auxiliary
  2607. ! routines are also included for making rapid estimates (well with 1%)
  2608. ! of both es and d(es)/dt for the particular table configuration.
  2609. !
  2610. ! Author: J. Hack
  2611. !
  2612. !-----------------------------------------------------------------------
  2613. ! use pmgrid, only: masterproc
  2614. implicit none
  2615. !------------------------------Arguments--------------------------------
  2616. !
  2617. ! Input arguments
  2618. !
  2619. real(r8), intent(in) :: tmn ! Minimum temperature entry in es lookup table
  2620. real(r8), intent(in) :: tmx ! Maximum temperature entry in es lookup table
  2621. real(r8), intent(in) :: epsil ! Ratio of h2o to dry air molecular weights
  2622. real(r8), intent(in) :: trice ! Transition range from es over range to es over ice
  2623. real(r8), intent(in) :: latvap ! Latent heat of vaporization
  2624. real(r8), intent(in) :: latice ! Latent heat of fusion
  2625. real(r8), intent(in) :: rh2o ! Gas constant for water vapor
  2626. real(r8), intent(in) :: cpair ! Specific heat of dry air
  2627. real(r8), intent(in) :: tmeltx ! Melting point of water (K)
  2628. !
  2629. !---------------------------Local variables-----------------------------
  2630. !
  2631. real(r8) t ! Temperature
  2632. real(r8) rgasv
  2633. real(r8) cp
  2634. real(r8) hlatf
  2635. real(r8) ttrice
  2636. real(r8) hlatv
  2637. integer n ! Increment counter
  2638. integer lentbl ! Calculated length of lookup table
  2639. integer itype ! Ice phase: 0 -> no ice phase
  2640. ! 1 -> ice phase, no transition
  2641. ! -x -> ice phase, x degree transition
  2642. logical ip ! Ice phase logical flag
  2643. logical icephs
  2644. !
  2645. !-----------------------------------------------------------------------
  2646. !
  2647. ! Set es table parameters
  2648. !
  2649. tmin = tmn ! Minimum temperature entry in table
  2650. tmax = tmx ! Maximum temperature entry in table
  2651. ttrice = trice ! Trans. range from es over h2o to es over ice
  2652. icephs = ip ! Ice phase (true or false)
  2653. !
  2654. ! Set physical constants required for es calculation
  2655. !
  2656. epsqs = epsil
  2657. hlatv = latvap
  2658. hlatf = latice
  2659. rgasv = rh2o
  2660. cp = cpair
  2661. tmelt = tmeltx
  2662. !
  2663. lentbl = INT(tmax-tmin+2.000001)
  2664. if (lentbl .gt. plenest) then
  2665. write(6,9000) tmax, tmin, plenest
  2666. call endrun ('GESTBL') ! Abnormal termination
  2667. end if
  2668. !
  2669. ! Begin building es table.
  2670. ! Check whether ice phase requested.
  2671. ! If so, set appropriate transition range for temperature
  2672. !
  2673. if (icephs) then
  2674. if (ttrice /= 0.0) then
  2675. itype = -ttrice
  2676. else
  2677. itype = 1
  2678. end if
  2679. else
  2680. itype = 0
  2681. end if
  2682. !
  2683. t = tmin - 1.0
  2684. do n=1,lentbl
  2685. t = t + 1.0
  2686. call gffgch(t,estbl(n),itype)
  2687. end do
  2688. !
  2689. do n=lentbl+1,plenest
  2690. estbl(n) = -99999.0
  2691. end do
  2692. !
  2693. ! Table complete -- Set coefficients for polynomial approximation of
  2694. ! difference between saturation vapor press over water and saturation
  2695. ! pressure over ice for -ttrice < t < 0 (degrees C). NOTE: polynomial
  2696. ! is valid in the range -40 < t < 0 (degrees C).
  2697. !
  2698. ! --- Degree 5 approximation ---
  2699. !
  2700. pcf(1) = 5.04469588506e-01
  2701. pcf(2) = -5.47288442819e+00
  2702. pcf(3) = -3.67471858735e-01
  2703. pcf(4) = -8.95963532403e-03
  2704. pcf(5) = -7.78053686625e-05
  2705. !
  2706. ! --- Degree 6 approximation ---
  2707. !
  2708. !-----pcf(1) = 7.63285250063e-02
  2709. !-----pcf(2) = -5.86048427932e+00
  2710. !-----pcf(3) = -4.38660831780e-01
  2711. !-----pcf(4) = -1.37898276415e-02
  2712. !-----pcf(5) = -2.14444472424e-04
  2713. !-----pcf(6) = -1.36639103771e-06
  2714. !
  2715. if (masterproc) then
  2716. write(6,*)' *** SATURATION VAPOR PRESSURE TABLE COMPLETED ***'
  2717. end if
  2718. return
  2719. !
  2720. 9000 format('GESTBL: FATAL ERROR *********************************',/, &
  2721. ' TMAX AND TMIN REQUIRE A LARGER DIMENSION ON THE LENGTH', &
  2722. ' OF THE SATURATION VAPOR PRESSURE TABLE ESTBL(PLENEST)',/, &
  2723. ' TMAX, TMIN, AND PLENEST => ', 2f7.2, i3)
  2724. !
  2725. end subroutine gestbl
  2726. subroutine gffgch(t ,es ,itype )
  2727. !-----------------------------------------------------------------------
  2728. !
  2729. ! Purpose:
  2730. ! Computes saturation vapor pressure over water and/or over ice using
  2731. ! Goff & Gratch (1946) relationships.
  2732. ! <Say what the routine does>
  2733. !
  2734. ! Method:
  2735. ! T (temperature), and itype are input parameters, while es (saturation
  2736. ! vapor pressure) is an output parameter. The input parameter itype
  2737. ! serves two purposes: a value of zero indicates that saturation vapor
  2738. ! pressures over water are to be returned (regardless of temperature),
  2739. ! while a value of one indicates that saturation vapor pressures over
  2740. ! ice should be returned when t is less than freezing degrees. If itype
  2741. ! is negative, its absolute value is interpreted to define a temperature
  2742. ! transition region below freezing in which the returned
  2743. ! saturation vapor pressure is a weighted average of the respective ice
  2744. ! and water value. That is, in the temperature range 0 => -itype
  2745. ! degrees c, the saturation vapor pressures are assumed to be a weighted
  2746. ! average of the vapor pressure over supercooled water and ice (all
  2747. ! water at 0 c; all ice at -itype c). Maximum transition range => 40 c
  2748. !
  2749. ! Author: J. Hack
  2750. !
  2751. !-----------------------------------------------------------------------
  2752. ! use shr_kind_mod, only: r8 => shr_kind_r8
  2753. ! use physconst, only: tmelt
  2754. ! use abortutils, only: endrun
  2755. implicit none
  2756. !------------------------------Arguments--------------------------------
  2757. !
  2758. ! Input arguments
  2759. !
  2760. real(r8), intent(in) :: t ! Temperature
  2761. !
  2762. ! Output arguments
  2763. !
  2764. integer, intent(inout) :: itype ! Flag for ice phase and associated transition
  2765. real(r8), intent(out) :: es ! Saturation vapor pressure
  2766. !
  2767. !---------------------------Local variables-----------------------------
  2768. !
  2769. real(r8) e1 ! Intermediate scratch variable for es over water
  2770. real(r8) e2 ! Intermediate scratch variable for es over water
  2771. real(r8) eswtr ! Saturation vapor pressure over water
  2772. real(r8) f ! Intermediate scratch variable for es over water
  2773. real(r8) f1 ! Intermediate scratch variable for es over water
  2774. real(r8) f2 ! Intermediate scratch variable for es over water
  2775. real(r8) f3 ! Intermediate scratch variable for es over water
  2776. real(r8) f4 ! Intermediate scratch variable for es over water
  2777. real(r8) f5 ! Intermediate scratch variable for es over water
  2778. real(r8) ps ! Reference pressure (mb)
  2779. real(r8) t0 ! Reference temperature (freezing point of water)
  2780. real(r8) term1 ! Intermediate scratch variable for es over ice
  2781. real(r8) term2 ! Intermediate scratch variable for es over ice
  2782. real(r8) term3 ! Intermediate scratch variable for es over ice
  2783. real(r8) tr ! Transition range for es over water to es over ice
  2784. real(r8) ts ! Reference temperature (boiling point of water)
  2785. real(r8) weight ! Intermediate scratch variable for es transition
  2786. integer itypo ! Intermediate scratch variable for holding itype
  2787. !
  2788. !-----------------------------------------------------------------------
  2789. !
  2790. ! Check on whether there is to be a transition region for es
  2791. !
  2792. if (itype < 0) then
  2793. tr = abs(float(itype))
  2794. itypo = itype
  2795. itype = 1
  2796. else
  2797. tr = 0.0
  2798. itypo = itype
  2799. end if
  2800. if (tr > 40.0) then
  2801. write(6,900) tr
  2802. call endrun ('GFFGCH') ! Abnormal termination
  2803. end if
  2804. !
  2805. if(t < (tmelt - tr) .and. itype == 1) go to 10
  2806. !
  2807. ! Water
  2808. !
  2809. ps = 1013.246
  2810. ts = 373.16
  2811. e1 = 11.344*(1.0 - t/ts)
  2812. e2 = -3.49149*(ts/t - 1.0)
  2813. f1 = -7.90298*(ts/t - 1.0)
  2814. f2 = 5.02808*log10(ts/t)
  2815. f3 = -1.3816*(10.0**e1 - 1.0)/10000000.0
  2816. f4 = 8.1328*(10.0**e2 - 1.0)/1000.0
  2817. f5 = log10(ps)
  2818. f = f1 + f2 + f3 + f4 + f5
  2819. es = (10.0**f)*100.0
  2820. eswtr = es
  2821. !
  2822. if(t >= tmelt .or. itype == 0) go to 20
  2823. !
  2824. ! Ice
  2825. !
  2826. 10 continue
  2827. t0 = tmelt
  2828. term1 = 2.01889049/(t0/t)
  2829. term2 = 3.56654*log(t0/t)
  2830. term3 = 20.947031*(t0/t)
  2831. es = 575.185606e10*exp(-(term1 + term2 + term3))
  2832. !
  2833. if (t < (tmelt - tr)) go to 20
  2834. !
  2835. ! Weighted transition between water and ice
  2836. !
  2837. weight = min((tmelt - t)/tr,1.0_r8)
  2838. es = weight*es + (1.0 - weight)*eswtr
  2839. !
  2840. 20 continue
  2841. itype = itypo
  2842. return
  2843. !
  2844. 900 format('GFFGCH: FATAL ERROR ******************************',/, &
  2845. 'TRANSITION RANGE FOR WATER TO ICE SATURATION VAPOR', &
  2846. ' PRESSURE, TR, EXCEEDS MAXIMUM ALLOWABLE VALUE OF', &
  2847. ' 40.0 DEGREES C',/, ' TR = ',f7.2)
  2848. !
  2849. end subroutine gffgch
  2850. real(r8) function estblf( td )
  2851. !
  2852. ! Saturation vapor pressure table lookup
  2853. !
  2854. real(r8), intent(in) :: td ! Temperature for saturation lookup
  2855. !
  2856. real(r8) :: e ! intermediate variable for es look-up
  2857. real(r8) :: ai
  2858. integer :: i
  2859. !
  2860. e = max(min(td,tmax),tmin) ! partial pressure
  2861. i = int(e-tmin)+1
  2862. ai = aint(e-tmin)
  2863. estblf = (tmin+ai-e+1.)* &
  2864. estbl(i)-(tmin+ai-e)* &
  2865. estbl(i+1)
  2866. end function estblf
  2867. function findvalue(ix,n,ain,indxa)
  2868. !-----------------------------------------------------------------------
  2869. !
  2870. ! Purpose:
  2871. ! Subroutine for finding ix-th smallest value in the array
  2872. ! The elements are rearranged so that the ix-th smallest
  2873. ! element is in the ix place and all smaller elements are
  2874. ! moved to the elements up to ix (with random order).
  2875. !
  2876. ! Algorithm: Based on the quicksort algorithm.
  2877. !
  2878. ! Author: T. Craig
  2879. !
  2880. !-----------------------------------------------------------------------
  2881. ! use shr_kind_mod, only: r8 => shr_kind_r8
  2882. implicit none
  2883. !
  2884. ! arguments
  2885. !
  2886. integer, intent(in) :: ix ! element to search for
  2887. integer, intent(in) :: n ! total number of elements
  2888. integer, intent(inout):: indxa(n) ! array of integers
  2889. real(r8), intent(in) :: ain(n) ! array to search
  2890. !
  2891. integer findvalue ! return value
  2892. !
  2893. ! local variables
  2894. !
  2895. integer i,j
  2896. integer il,im,ir
  2897. integer ia
  2898. integer itmp
  2899. !
  2900. !---------------------------Routine-----------------------------
  2901. !
  2902. il=1
  2903. ir=n
  2904. do
  2905. if (ir-il <= 1) then
  2906. if (ir-il == 1) then
  2907. if (ain(indxa(ir)) < ain(indxa(il))) then
  2908. itmp=indxa(il)
  2909. indxa(il)=indxa(ir)
  2910. indxa(ir)=itmp
  2911. endif
  2912. endif
  2913. findvalue=indxa(ix)
  2914. return
  2915. else
  2916. im=(il+ir)/2
  2917. itmp=indxa(im)
  2918. indxa(im)=indxa(il+1)
  2919. indxa(il+1)=itmp
  2920. if (ain(indxa(il+1)) > ain(indxa(ir))) then
  2921. itmp=indxa(il+1)
  2922. indxa(il+1)=indxa(ir)
  2923. indxa(ir)=itmp
  2924. endif
  2925. if (ain(indxa(il)) > ain(indxa(ir))) then
  2926. itmp=indxa(il)
  2927. indxa(il)=indxa(ir)
  2928. indxa(ir)=itmp
  2929. endif
  2930. if (ain(indxa(il+1)) > ain(indxa(il))) then
  2931. itmp=indxa(il+1)
  2932. indxa(il+1)=indxa(il)
  2933. indxa(il)=itmp
  2934. endif
  2935. i=il+1
  2936. j=ir
  2937. ia=indxa(il)
  2938. do
  2939. do
  2940. i=i+1
  2941. if (ain(indxa(i)) >= ain(ia)) exit
  2942. end do
  2943. do
  2944. j=j-1
  2945. if (ain(indxa(j)) <= ain(ia)) exit
  2946. end do
  2947. if (j < i) exit
  2948. itmp=indxa(i)
  2949. indxa(i)=indxa(j)
  2950. indxa(j)=itmp
  2951. end do
  2952. indxa(il)=indxa(j)
  2953. indxa(j)=ia
  2954. if (j >= ix)ir=j-1
  2955. if (j <= ix)il=i
  2956. endif
  2957. end do
  2958. end function findvalue
  2959. subroutine radini(gravx ,cpairx ,epsilox ,stebolx, pstdx )
  2960. !-----------------------------------------------------------------------
  2961. !
  2962. ! Purpose:
  2963. ! Initialize various constants for radiation scheme; note that
  2964. ! the radiation scheme uses cgs units.
  2965. !
  2966. ! Method:
  2967. ! <Describe the algorithm(s) used in the routine.>
  2968. ! <Also include any applicable external references.>
  2969. !
  2970. ! Author: W. Collins (H2O parameterization) and J. Kiehl
  2971. !
  2972. !-----------------------------------------------------------------------
  2973. ! use shr_kind_mod, only: r8 => shr_kind_r8
  2974. ! use ppgrid, only: pver, pverp
  2975. ! use comozp, only: cplos, cplol
  2976. ! use pmgrid, only: masterproc, plev, plevp
  2977. ! use radae, only: radaeini
  2978. ! use physconst, only: mwdry, mwco2
  2979. #if ( defined SPMD )
  2980. ! use mpishorthand
  2981. #endif
  2982. implicit none
  2983. !------------------------------Arguments--------------------------------
  2984. !
  2985. ! Input arguments
  2986. !
  2987. real, intent(in) :: gravx ! Acceleration of gravity (MKS)
  2988. real, intent(in) :: cpairx ! Specific heat of dry air (MKS)
  2989. real, intent(in) :: epsilox ! Ratio of mol. wght of H2O to dry air
  2990. real, intent(in) :: stebolx ! Stefan-Boltzmann's constant (MKS)
  2991. real(r8), intent(in) :: pstdx ! Standard pressure (Pascals)
  2992. !
  2993. !---------------------------Local variables-----------------------------
  2994. !
  2995. integer k ! Loop variable
  2996. real(r8) v0 ! Volume of a gas at stp (m**3/kmol)
  2997. real(r8) p0 ! Standard pressure (pascals)
  2998. real(r8) amd ! Effective molecular weight of dry air (kg/kmol)
  2999. real(r8) goz ! Acceleration of gravity (m/s**2)
  3000. !
  3001. !-----------------------------------------------------------------------
  3002. !
  3003. ! Set general radiation consts; convert to cgs units where appropriate:
  3004. !
  3005. gravit = 100.*gravx
  3006. rga = 1./gravit
  3007. gravmks = gravx
  3008. cpair = 1.e4*cpairx
  3009. epsilo = epsilox
  3010. sslp = 1.013250e6
  3011. stebol = 1.e3*stebolx
  3012. rgsslp = 0.5/(gravit*sslp)
  3013. dpfo3 = 2.5e-3
  3014. dpfco2 = 5.0e-3
  3015. dayspy = 365.
  3016. pie = 4.*atan(1.)
  3017. !
  3018. ! Initialize ozone data.
  3019. !
  3020. v0 = 22.4136 ! Volume of a gas at stp (m**3/kmol)
  3021. p0 = 0.1*sslp ! Standard pressure (pascals)
  3022. amd = 28.9644 ! Molecular weight of dry air (kg/kmol)
  3023. goz = gravx ! Acceleration of gravity (m/s**2)
  3024. !
  3025. ! Constants for ozone path integrals (multiplication by 100 for unit
  3026. ! conversion to cgs from mks):
  3027. !
  3028. cplos = v0/(amd*goz) *100.0
  3029. cplol = v0/(amd*goz*p0)*0.5*100.0
  3030. !
  3031. ! Derived constants
  3032. ! If the top model level is above ~90 km (0.1 Pa), set the top level to compute
  3033. ! longwave cooling to about 80 km (1 Pa)
  3034. ! WRF: assume top level > 0.1 mb
  3035. ! if (hypm(1) .lt. 0.1) then
  3036. ! do k = 1, pver
  3037. ! if (hypm(k) .lt. 1.) ntoplw = k
  3038. ! end do
  3039. ! else
  3040. ntoplw = 1
  3041. ! end if
  3042. ! if (masterproc) then
  3043. ! write (6,*) 'RADINI: ntoplw =',ntoplw, ' pressure:',hypm(ntoplw)
  3044. ! endif
  3045. call radaeini( pstdx, mwdry, mwco2 )
  3046. return
  3047. end subroutine radini
  3048. subroutine oznini(ozmixm,pin,levsiz,num_months,XLAT, &
  3049. ids, ide, jds, jde, kds, kde, &
  3050. ims, ime, jms, jme, kms, kme, &
  3051. its, ite, jts, jte, kts, kte)
  3052. !
  3053. ! This subroutine assumes uniform distribution of ozone concentration.
  3054. ! It should be replaced by monthly climatology that varies latitudinally and vertically
  3055. !
  3056. IMPLICIT NONE
  3057. INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde, &
  3058. ims,ime, jms,jme, kms,kme, &
  3059. its,ite, jts,jte, kts,kte
  3060. INTEGER, INTENT(IN ) :: levsiz, num_months
  3061. REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN ) :: XLAT
  3062. REAL, DIMENSION( ims:ime, levsiz, jms:jme, num_months ), &
  3063. INTENT(OUT ) :: OZMIXM
  3064. REAL, DIMENSION(levsiz), INTENT(OUT ) :: PIN
  3065. ! Local
  3066. INTEGER, PARAMETER :: latsiz = 64
  3067. INTEGER, PARAMETER :: lonsiz = 1
  3068. INTEGER :: i, j, k, itf, jtf, ktf, m, pin_unit, lat_unit, oz_unit
  3069. REAL :: interp_pt
  3070. CHARACTER*256 :: message
  3071. REAL, DIMENSION( lonsiz, levsiz, latsiz, num_months ) :: &
  3072. OZMIXIN
  3073. REAL, DIMENSION(latsiz) :: lat_ozone
  3074. jtf=min0(jte,jde-1)
  3075. ktf=min0(kte,kde-1)
  3076. itf=min0(ite,ide-1)
  3077. !-- read in ozone pressure data
  3078. WRITE(message,*)'num_months = ',num_months
  3079. CALL wrf_debug(50,message)
  3080. pin_unit = 27
  3081. OPEN(pin_unit, FILE='ozone_plev.formatted',FORM='FORMATTED',STATUS='OLD')
  3082. do k = 1,levsiz
  3083. READ (pin_unit,*)pin(k)
  3084. end do
  3085. close(27)
  3086. do k=1,levsiz
  3087. pin(k) = pin(k)*100.
  3088. end do
  3089. !-- read in ozone lat data
  3090. lat_unit = 28
  3091. OPEN(lat_unit, FILE='ozone_lat.formatted',FORM='FORMATTED',STATUS='OLD')
  3092. do j = 1,latsiz
  3093. READ (lat_unit,*)lat_ozone(j)
  3094. end do
  3095. close(28)
  3096. !-- read in ozone data
  3097. oz_unit = 29
  3098. OPEN(oz_unit, FILE='ozone.formatted',FORM='FORMATTED',STATUS='OLD')
  3099. do m=2,num_months
  3100. do j=1,latsiz ! latsiz=64
  3101. do k=1,levsiz ! levsiz=59
  3102. do i=1,lonsiz ! lonsiz=1
  3103. READ (oz_unit,*)ozmixin(i,k,j,m)
  3104. enddo
  3105. enddo
  3106. enddo
  3107. enddo
  3108. close(29)
  3109. !-- latitudinally interpolate ozone data (and extend longitudinally)
  3110. !-- using function lin_interpol2(x, f, y) result(g)
  3111. ! Purpose:
  3112. ! interpolates f(x) to point y
  3113. ! assuming f(x) = f(x0) + a * (x - x0)
  3114. ! where a = ( f(x1) - f(x0) ) / (x1 - x0)
  3115. ! x0 <= x <= x1
  3116. ! assumes x is monotonically increasing
  3117. ! real, intent(in), dimension(:) :: x ! grid points
  3118. ! real, intent(in), dimension(:) :: f ! grid function values
  3119. ! real, intent(in) :: y ! interpolation point
  3120. ! real :: g ! interpolated function value
  3121. !---------------------------------------------------------------------------
  3122. do m=2,num_months
  3123. do j=jts,jtf
  3124. do k=1,levsiz
  3125. do i=its,itf
  3126. interp_pt=XLAT(i,j)
  3127. ozmixm(i,k,j,m)=lin_interpol2(lat_ozone(:),ozmixin(1,k,:,m),interp_pt)
  3128. enddo
  3129. enddo
  3130. enddo
  3131. enddo
  3132. ! Old code for fixed ozone
  3133. ! pin(1)=70.
  3134. ! DO k=2,levsiz
  3135. ! pin(k)=pin(k-1)+16.
  3136. ! ENDDO
  3137. ! DO k=1,levsiz
  3138. ! pin(k) = pin(k)*100.
  3139. ! end do
  3140. ! DO m=1,num_months
  3141. ! DO j=jts,jtf
  3142. ! DO i=its,itf
  3143. ! DO k=1,2
  3144. ! ozmixm(i,k,j,m)=1.e-6
  3145. ! ENDDO
  3146. ! DO k=3,levsiz
  3147. ! ozmixm(i,k,j,m)=1.e-7
  3148. ! ENDDO
  3149. ! ENDDO
  3150. ! ENDDO
  3151. ! ENDDO
  3152. END SUBROUTINE oznini
  3153. subroutine aerosol_init(m_psp,m_psn,m_hybi,aerosolcp,aerosolcn,paerlev,naer_c,shalf,pptop, &
  3154. ids, ide, jds, jde, kds, kde, &
  3155. ims, ime, jms, jme, kms, kme, &
  3156. its, ite, jts, jte, kts, kte)
  3157. !
  3158. ! This subroutine assumes a uniform aerosol distribution in both time and space.
  3159. ! It should be modified if aerosol data are available from WRF-CHEM or other sources
  3160. !
  3161. IMPLICIT NONE
  3162. INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde, &
  3163. ims,ime, jms,jme, kms,kme, &
  3164. its,ite, jts,jte, kts,kte
  3165. INTEGER, INTENT(IN ) :: paerlev,naer_c
  3166. REAL, intent(in) :: pptop
  3167. REAL, DIMENSION( kms:kme ), intent(in) :: shalf
  3168. REAL, DIMENSION( ims:ime, paerlev, jms:jme, naer_c ), &
  3169. INTENT(INOUT ) :: aerosolcn , aerosolcp
  3170. REAL, DIMENSION(paerlev), INTENT(OUT ) :: m_hybi
  3171. REAL, DIMENSION( ims:ime, jms:jme), INTENT(OUT ) :: m_psp,m_psn
  3172. REAL :: psurf
  3173. real, dimension(29) :: hybi
  3174. integer k ! index through vertical levels
  3175. INTEGER :: i, j, itf, jtf, ktf,m
  3176. data hybi/0, 0.0065700002014637, 0.0138600002974272, 0.023089999333024, &
  3177. 0.0346900001168251, 0.0491999983787537, 0.0672300010919571, &
  3178. 0.0894500017166138, 0.116539999842644, 0.149159997701645, &
  3179. 0.187830001115799, 0.232859998941422, 0.284209996461868, &
  3180. 0.341369986534119, 0.403340011835098, 0.468600004911423, &
  3181. 0.535290002822876, 0.601350009441376, 0.66482001543045, &
  3182. 0.724009990692139, 0.777729988098145, 0.825269997119904, &
  3183. 0.866419970989227, 0.901350021362305, 0.930540025234222, &
  3184. 0.954590022563934, 0.974179983139038, 0.990000009536743, 1/
  3185. jtf=min0(jte,jde-1)
  3186. ktf=min0(kte,kde-1)
  3187. itf=min0(ite,ide-1)
  3188. do k=1,paerlev
  3189. m_hybi(k)=hybi(k)
  3190. enddo
  3191. !
  3192. ! mxaerl = max number of levels (from bottom) for background aerosol
  3193. ! Limit background aerosol height to regions below 900 mb
  3194. !
  3195. psurf = 1.e05
  3196. mxaerl = 0
  3197. ! do k=pver,1,-1
  3198. do k=kms,kme-1
  3199. ! if (hypm(k) >= 9.e4) mxaerl = mxaerl + 1
  3200. if (shalf(k)*psurf+pptop >= 9.e4) mxaerl = mxaerl + 1
  3201. end do
  3202. mxaerl = max(mxaerl,1)
  3203. ! if (masterproc) then
  3204. write(6,*)'AEROSOLS: Background aerosol will be limited to ', &
  3205. 'bottom ',mxaerl,' model interfaces.'
  3206. ! 'bottom ',mxaerl,' model interfaces. Top interface is ', &
  3207. ! hypi(pverp-mxaerl),' pascals'
  3208. ! end if
  3209. DO j=jts,jtf
  3210. DO i=its,itf
  3211. m_psp(i,j)=psurf
  3212. m_psn(i,j)=psurf
  3213. ENDDO
  3214. ENDDO
  3215. DO j=jts,jtf
  3216. DO i=its,itf
  3217. DO k=1,paerlev
  3218. ! aerosolc arrays are upward cumulative (kg/m2) at each level
  3219. ! Here we assume uniform vertical distribution (aerosolc linear with hybi)
  3220. aerosolcp(i,k,j,idxSUL)=1.e-7*(1.-hybi(k))
  3221. aerosolcn(i,k,j,idxSUL)=1.e-7*(1.-hybi(k))
  3222. aerosolcp(i,k,j,idxSSLT)=1.e-22*(1.-hybi(k))
  3223. aerosolcn(i,k,j,idxSSLT)=1.e-22*(1.-hybi(k))
  3224. aerosolcp(i,k,j,idxDUSTfirst)=1.e-7*(1.-hybi(k))
  3225. aerosolcn(i,k,j,idxDUSTfirst)=1.e-7*(1.-hybi(k))
  3226. aerosolcp(i,k,j,idxDUSTfirst+1)=1.e-7*(1.-hybi(k))
  3227. aerosolcn(i,k,j,idxDUSTfirst+1)=1.e-7*(1.-hybi(k))
  3228. aerosolcp(i,k,j,idxDUSTfirst+2)=1.e-7*(1.-hybi(k))
  3229. aerosolcn(i,k,j,idxDUSTfirst+2)=1.e-7*(1.-hybi(k))
  3230. aerosolcp(i,k,j,idxDUSTfirst+3)=1.e-7*(1.-hybi(k))
  3231. aerosolcn(i,k,j,idxDUSTfirst+3)=1.e-7*(1.-hybi(k))
  3232. aerosolcp(i,k,j,idxOCPHO)=1.e-7*(1.-hybi(k))
  3233. aerosolcn(i,k,j,idxOCPHO)=1.e-7*(1.-hybi(k))
  3234. aerosolcp(i,k,j,idxBCPHO)=1.e-9*(1.-hybi(k))
  3235. aerosolcn(i,k,j,idxBCPHO)=1.e-9*(1.-hybi(k))
  3236. aerosolcp(i,k,j,idxOCPHI)=1.e-7*(1.-hybi(k))
  3237. aerosolcn(i,k,j,idxOCPHI)=1.e-7*(1.-hybi(k))
  3238. aerosolcp(i,k,j,idxBCPHI)=1.e-8*(1.-hybi(k))
  3239. aerosolcn(i,k,j,idxBCPHI)=1.e-8*(1.-hybi(k))
  3240. ENDDO
  3241. ENDDO
  3242. ENDDO
  3243. call aer_optics_initialize
  3244. END subroutine aerosol_init
  3245. subroutine aer_optics_initialize
  3246. USE module_wrf_error
  3247. ! use shr_kind_mod, only: r8 => shr_kind_r8
  3248. ! use pmgrid ! masterproc is here
  3249. ! use ioFileMod, only: getfil
  3250. !#if ( defined SPMD )
  3251. ! use mpishorthand
  3252. !#endif
  3253. implicit none
  3254. ! include 'netcdf.inc'
  3255. integer :: nrh_opac ! number of relative humidity values for OPAC data
  3256. integer :: nbnd ! number of spectral bands, should be identical to nspint
  3257. real(r8), parameter :: wgt_sscm = 6.0 / 7.0
  3258. integer :: krh_opac ! rh index for OPAC rh grid
  3259. integer :: krh ! another rh index
  3260. integer :: ksz ! dust size bin index
  3261. integer :: kbnd ! band index
  3262. real(r8) :: rh ! local relative humidity variable
  3263. integer, parameter :: irh=8
  3264. real(r8) :: rh_opac(irh) ! OPAC relative humidity grid
  3265. real(r8) :: ksul_opac(irh,nspint) ! sulfate extinction
  3266. real(r8) :: wsul_opac(irh,nspint) ! single scattering albedo
  3267. real(r8) :: gsul_opac(irh,nspint) ! asymmetry parameter
  3268. real(r8) :: ksslt_opac(irh,nspint) ! sea-salt
  3269. real(r8) :: wsslt_opac(irh,nspint)
  3270. real(r8) :: gsslt_opac(irh,nspint)
  3271. real(r8) :: kssam_opac(irh,nspint) ! sea-salt accumulation mode
  3272. real(r8) :: wssam_opac(irh,nspint)
  3273. real(r8) :: gssam_opac(irh,nspint)
  3274. real(r8) :: ksscm_opac(irh,nspint) ! sea-salt coarse mode
  3275. real(r8) :: wsscm_opac(irh,nspint)
  3276. real(r8) :: gsscm_opac(irh,nspint)
  3277. real(r8) :: kcphil_opac(irh,nspint) ! hydrophilic organic carbon
  3278. real(r8) :: wcphil_opac(irh,nspint)
  3279. real(r8) :: gcphil_opac(irh,nspint)
  3280. real(r8) :: dummy(nspint)
  3281. LOGICAL :: opened
  3282. LOGICAL , EXTERNAL :: wrf_dm_on_monitor
  3283. CHARACTER*80 errmess
  3284. INTEGER cam_aer_unit
  3285. integer :: i
  3286. ! read aerosol optics data
  3287. IF ( wrf_dm_on_monitor() ) THEN
  3288. DO i = 10,99
  3289. INQUIRE ( i , OPENED = opened )
  3290. IF ( .NOT. opened ) THEN
  3291. cam_aer_unit = i
  3292. GOTO 2010
  3293. ENDIF
  3294. ENDDO
  3295. cam_aer_unit = -1
  3296. 2010 CONTINUE
  3297. ENDIF
  3298. CALL wrf_dm_bcast_bytes ( cam_aer_unit , IWORDSIZE )
  3299. IF ( cam_aer_unit < 0 ) THEN
  3300. CALL wrf_error_fatal ( 'module_ra_cam: aer_optics_initialize: Can not find unused fortran unit to read in lookup table.' )
  3301. ENDIF
  3302. IF ( wrf_dm_on_monitor() ) THEN
  3303. OPEN(cam_aer_unit,FILE='CAM_AEROPT_DATA', &
  3304. FORM='UNFORMATTED',STATUS='OLD',ERR=9010)
  3305. call wrf_debug(50,'reading CAM_AEROPT_DATA')
  3306. ENDIF
  3307. #define DM_BCAST_MACRO(A) CALL wrf_dm_bcast_bytes ( A , size ( A ) * r8 )
  3308. IF ( wrf_dm_on_monitor() ) then
  3309. READ (cam_aer_unit,ERR=9010) dummy
  3310. READ (cam_aer_unit,ERR=9010) rh_opac
  3311. READ (cam_aer_unit,ERR=9010) ksul_opac
  3312. READ (cam_aer_unit,ERR=9010) wsul_opac
  3313. READ (cam_aer_unit,ERR=9010) gsul_opac
  3314. READ (cam_aer_unit,ERR=9010) kssam_opac
  3315. READ (cam_aer_unit,ERR=9010) wssam_opac
  3316. READ (cam_aer_unit,ERR=9010) gssam_opac
  3317. READ (cam_aer_unit,ERR=9010) ksscm_opac
  3318. READ (cam_aer_unit,ERR=9010) wsscm_opac
  3319. READ (cam_aer_unit,ERR=9010) gsscm_opac
  3320. READ (cam_aer_unit,ERR=9010) kcphil_opac
  3321. READ (cam_aer_unit,ERR=9010) wcphil_opac
  3322. READ (cam_aer_unit,ERR=9010) gcphil_opac
  3323. READ (cam_aer_unit,ERR=9010) kcb
  3324. READ (cam_aer_unit,ERR=9010) wcb
  3325. READ (cam_aer_unit,ERR=9010) gcb
  3326. READ (cam_aer_unit,ERR=9010) kdst
  3327. READ (cam_aer_unit,ERR=9010) wdst
  3328. READ (cam_aer_unit,ERR=9010) gdst
  3329. READ (cam_aer_unit,ERR=9010) kbg
  3330. READ (cam_aer_unit,ERR=9010) wbg
  3331. READ (cam_aer_unit,ERR=9010) gbg
  3332. READ (cam_aer_unit,ERR=9010) kvolc
  3333. READ (cam_aer_unit,ERR=9010) wvolc
  3334. READ (cam_aer_unit,ERR=9010) gvolc
  3335. endif
  3336. DM_BCAST_MACRO(rh_opac)
  3337. DM_BCAST_MACRO(ksul_opac)
  3338. DM_BCAST_MACRO(wsul_opac)
  3339. DM_BCAST_MACRO(gsul_opac)
  3340. DM_BCAST_MACRO(kssam_opac)
  3341. DM_BCAST_MACRO(wssam_opac)
  3342. DM_BCAST_MACRO(gssam_opac)
  3343. DM_BCAST_MACRO(ksscm_opac)
  3344. DM_BCAST_MACRO(wsscm_opac)
  3345. DM_BCAST_MACRO(gsscm_opac)
  3346. DM_BCAST_MACRO(kcphil_opac)
  3347. DM_BCAST_MACRO(wcphil_opac)
  3348. DM_BCAST_MACRO(gcphil_opac)
  3349. DM_BCAST_MACRO(kcb)
  3350. DM_BCAST_MACRO(wcb)
  3351. DM_BCAST_MACRO(gcb)
  3352. DM_BCAST_MACRO(kvolc)
  3353. DM_BCAST_MACRO(wvolc)
  3354. DM_BCAST_MACRO(gvolc)
  3355. DM_BCAST_MACRO(kdst)
  3356. DM_BCAST_MACRO(wdst)
  3357. DM_BCAST_MACRO(gdst)
  3358. DM_BCAST_MACRO(kbg)
  3359. DM_BCAST_MACRO(wbg)
  3360. DM_BCAST_MACRO(gbg)
  3361. IF ( wrf_dm_on_monitor() ) CLOSE (cam_aer_unit)
  3362. ! map OPAC aerosol species onto CAM aerosol species
  3363. ! CAM name OPAC name
  3364. ! sul or SO4 = suso sulfate soluble
  3365. ! sslt or SSLT = 1/7 ssam + 6/7 sscm sea-salt accumulation/coagulation mode
  3366. ! cphil or CPHI = waso water soluble (carbon)
  3367. ! cphob or CPHO = waso @ rh = 0
  3368. ! cb or BCPHI/BCPHO = soot
  3369. ksslt_opac(:,:) = (1.0 - wgt_sscm) * kssam_opac(:,:) + wgt_sscm * ksscm_opac(:,:)
  3370. wsslt_opac(:,:) = ( (1.0 - wgt_sscm) * kssam_opac(:,:) * wssam_opac(:,:) &
  3371. + wgt_sscm * ksscm_opac(:,:) * wsscm_opac(:,:) ) &
  3372. / ksslt_opac(:,:)
  3373. gsslt_opac(:,:) = ( (1.0 - wgt_sscm) * kssam_opac(:,:) * wssam_opac(:,:) * gssam_opac(:,:) &
  3374. + wgt_sscm * ksscm_opac(:,:) * wsscm_opac(:,:) * gsscm_opac(:,:) ) &
  3375. / ( ksslt_opac(:,:) * wsslt_opac(:,:) )
  3376. do i=1,nspint
  3377. kcphob(i) = kcphil_opac(1,i)
  3378. wcphob(i) = wcphil_opac(1,i)
  3379. gcphob(i) = gcphil_opac(1,i)
  3380. end do
  3381. ! interpolate optical properties of hygrospopic aerosol species
  3382. ! onto a uniform relative humidity grid
  3383. nbnd = nspint
  3384. do krh = 1, nrh
  3385. rh = 1.0_r8 / nrh * (krh - 1)
  3386. do kbnd = 1, nbnd
  3387. ksul(krh, kbnd) = exp_interpol( rh_opac, &
  3388. ksul_opac(:, kbnd) / ksul_opac(1, kbnd), rh ) * ksul_opac(1, kbnd)
  3389. wsul(krh, kbnd) = lin_interpol( rh_opac, &
  3390. wsul_opac(:, kbnd) / wsul_opac(1, kbnd), rh ) * wsul_opac(1, kbnd)
  3391. gsul(krh, kbnd) = lin_interpol( rh_opac, &
  3392. gsul_opac(:, kbnd) / gsul_opac(1, kbnd), rh ) * gsul_opac(1, kbnd)
  3393. ksslt(krh, kbnd) = exp_interpol( rh_opac, &
  3394. ksslt_opac(:, kbnd) / ksslt_opac(1, kbnd), rh ) * ksslt_opac(1, kbnd)
  3395. wsslt(krh, kbnd) = lin_interpol( rh_opac, &
  3396. wsslt_opac(:, kbnd) / wsslt_opac(1, kbnd), rh ) * wsslt_opac(1, kbnd)
  3397. gsslt(krh, kbnd) = lin_interpol( rh_opac, &
  3398. gsslt_opac(:, kbnd) / gsslt_opac(1, kbnd), rh ) * gsslt_opac(1, kbnd)
  3399. kcphil(krh, kbnd) = exp_interpol( rh_opac, &
  3400. kcphil_opac(:, kbnd) / kcphil_opac(1, kbnd), rh ) * kcphil_opac(1, kbnd)
  3401. wcphil(krh, kbnd) = lin_interpol( rh_opac, &
  3402. wcphil_opac(:, kbnd) / wcphil_opac(1, kbnd), rh ) * wcphil_opac(1, kbnd)
  3403. gcphil(krh, kbnd) = lin_interpol( rh_opac, &
  3404. gcphil_opac(:, kbnd) / gcphil_opac(1, kbnd), rh ) * gcphil_opac(1, kbnd)
  3405. end do
  3406. end do
  3407. RETURN
  3408. 9010 CONTINUE
  3409. WRITE( errmess , '(A35,I4)' ) 'module_ra_cam: error reading unit ',cam_aer_unit
  3410. CALL wrf_error_fatal(errmess)
  3411. END subroutine aer_optics_initialize
  3412. subroutine radaeini( pstdx, mwdryx, mwco2x )
  3413. USE module_wrf_error
  3414. !
  3415. ! Initialize radae module data
  3416. !
  3417. !
  3418. ! Input variables
  3419. !
  3420. real(r8), intent(in) :: pstdx ! Standard pressure (dynes/cm^2)
  3421. real(r8), intent(in) :: mwdryx ! Molecular weight of dry air
  3422. real(r8), intent(in) :: mwco2x ! Molecular weight of carbon dioxide
  3423. !
  3424. ! Variables for loading absorptivity/emissivity
  3425. !
  3426. integer ncid_ae ! NetCDF file id for abs/ems file
  3427. integer pdimid ! pressure dimension id
  3428. integer psize ! pressure dimension size
  3429. integer tpdimid ! path temperature dimension id
  3430. integer tpsize ! path temperature size
  3431. integer tedimid ! emission temperature dimension id
  3432. integer tesize ! emission temperature size
  3433. integer udimid ! u (H2O path) dimension id
  3434. integer usize ! u (H2O path) dimension size
  3435. integer rhdimid ! relative humidity dimension id
  3436. integer rhsize ! relative humidity dimension size
  3437. integer ah2onwid ! var. id for non-wndw abs.
  3438. integer eh2onwid ! var. id for non-wndw ems.
  3439. integer ah2owid ! var. id for wndw abs. (adjacent layers)
  3440. integer cn_ah2owid ! var. id for continuum trans. for wndw abs.
  3441. integer cn_eh2owid ! var. id for continuum trans. for wndw ems.
  3442. integer ln_ah2owid ! var. id for line trans. for wndw abs.
  3443. integer ln_eh2owid ! var. id for line trans. for wndw ems.
  3444. ! character*(NF_MAX_NAME) tmpname! dummy variable for var/dim names
  3445. character(len=256) locfn ! local filename
  3446. integer tmptype ! dummy variable for variable type
  3447. integer ndims ! number of dimensions
  3448. ! integer dims(NF_MAX_VAR_DIMS) ! vector of dimension ids
  3449. integer natt ! number of attributes
  3450. !
  3451. ! Variables for setting up H2O table
  3452. !
  3453. integer t ! path temperature
  3454. integer tmin ! mininum path temperature
  3455. integer tmax ! maximum path temperature
  3456. integer itype ! type of sat. pressure (=0 -> H2O only)
  3457. integer i
  3458. real(r8) tdbl
  3459. LOGICAL :: opened
  3460. LOGICAL , EXTERNAL :: wrf_dm_on_monitor
  3461. CHARACTER*80 errmess
  3462. INTEGER cam_abs_unit
  3463. !
  3464. ! Constants to set
  3465. !
  3466. p0 = pstdx
  3467. amd = mwdryx
  3468. amco2 = mwco2x
  3469. !
  3470. ! Coefficients for h2o emissivity and absorptivity for overlap of H2O
  3471. ! and trace gases.
  3472. !
  3473. c16 = coefj(3,1)/coefj(2,1)
  3474. c17 = coefk(3,1)/coefk(2,1)
  3475. c26 = coefj(3,2)/coefj(2,2)
  3476. c27 = coefk(3,2)/coefk(2,2)
  3477. c28 = .5
  3478. c29 = .002053
  3479. c30 = .1
  3480. c31 = 3.0e-5
  3481. !
  3482. ! Initialize further longwave constants referring to far wing
  3483. ! correction for overlap of H2O and trace gases; R&D refers to:
  3484. !
  3485. ! Ramanathan, V. and P.Downey, 1986: A Nonisothermal
  3486. ! Emissivity and Absorptivity Formulation for Water Vapor
  3487. ! Journal of Geophysical Research, vol. 91., D8, pp 8649-8666
  3488. !
  3489. fwcoef = .1 ! See eq(33) R&D
  3490. fwc1 = .30 ! See eq(33) R&D
  3491. fwc2 = 4.5 ! See eq(33) and eq(34) in R&D
  3492. fc1 = 2.6 ! See eq(34) R&D
  3493. IF ( wrf_dm_on_monitor() ) THEN
  3494. DO i = 10,99
  3495. INQUIRE ( i , OPENED = opened )
  3496. IF ( .NOT. opened ) THEN
  3497. cam_abs_unit = i
  3498. GOTO 2010
  3499. ENDIF
  3500. ENDDO
  3501. cam_abs_unit = -1
  3502. 2010 CONTINUE
  3503. ENDIF
  3504. CALL wrf_dm_bcast_bytes ( cam_abs_unit , IWORDSIZE )
  3505. IF ( cam_abs_unit < 0 ) THEN
  3506. CALL wrf_error_fatal ( 'module_ra_cam: radaeinit: Can not find unused fortran unit to read in lookup table.' )
  3507. ENDIF
  3508. IF ( wrf_dm_on_monitor() ) THEN
  3509. OPEN(cam_abs_unit,FILE='CAM_ABS_DATA', &
  3510. FORM='UNFORMATTED',STATUS='OLD',ERR=9010)
  3511. call wrf_debug(50,'reading CAM_ABS_DATA')
  3512. ENDIF
  3513. #define DM_BCAST_MACRO(A) CALL wrf_dm_bcast_bytes ( A , size ( A ) * r8 )
  3514. IF ( wrf_dm_on_monitor() ) then
  3515. READ (cam_abs_unit,ERR=9010) ah2onw
  3516. READ (cam_abs_unit,ERR=9010) eh2onw
  3517. READ (cam_abs_unit,ERR=9010) ah2ow
  3518. READ (cam_abs_unit,ERR=9010) cn_ah2ow
  3519. READ (cam_abs_unit,ERR=9010) cn_eh2ow
  3520. READ (cam_abs_unit,ERR=9010) ln_ah2ow
  3521. READ (cam_abs_unit,ERR=9010) ln_eh2ow
  3522. endif
  3523. DM_BCAST_MACRO(ah2onw)
  3524. DM_BCAST_MACRO(eh2onw)
  3525. DM_BCAST_MACRO(ah2ow)
  3526. DM_BCAST_MACRO(cn_ah2ow)
  3527. DM_BCAST_MACRO(cn_eh2ow)
  3528. DM_BCAST_MACRO(ln_ah2ow)
  3529. DM_BCAST_MACRO(ln_eh2ow)
  3530. IF ( wrf_dm_on_monitor() ) CLOSE (cam_abs_unit)
  3531. ! Set up table of H2O saturation vapor pressures for use in calculation
  3532. ! effective path RH. Need separate table from table in wv_saturation
  3533. ! because:
  3534. ! (1. Path temperatures can fall below minimum of that table; and
  3535. ! (2. Abs/Emissivity tables are derived with RH for water only.
  3536. !
  3537. tmin = nint(min_tp_h2o)
  3538. tmax = nint(max_tp_h2o)+1
  3539. itype = 0
  3540. do t = tmin, tmax
  3541. ! call gffgch(dble(t),estblh2o(t-tmin),itype)
  3542. tdbl = t
  3543. call gffgch(tdbl,estblh2o(t-tmin),itype)
  3544. end do
  3545. RETURN
  3546. 9010 CONTINUE
  3547. WRITE( errmess , '(A35,I4)' ) 'module_ra_cam: error reading unit ',cam_abs_unit
  3548. CALL wrf_error_fatal(errmess)
  3549. end subroutine radaeini
  3550. end MODULE module_ra_cam_support