PageRenderTime 82ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/wrfv2_fire/phys/module_ra_gsfcsw.F

http://github.com/jbeezley/wrf-fire
FORTRAN Legacy | 3138 lines | 1778 code | 504 blank | 856 comment | 46 complexity | 1aade0c232781669363b83e248af8e59 MD5 | raw file
Possible License(s): AGPL-1.0
  1. !Comment the following out to turn off aerosol-radiation
  2. !feedback between MOSAIC and GSFCSW. wig, 21-Feb-2005
  3. MODULE module_ra_gsfcsw
  4. REAL, PARAMETER, PRIVATE :: thresh=1.e-9
  5. REAL, SAVE :: center_lat
  6. ! Assign co2 and trace gases amount (units are parts/part by volumn)
  7. REAL, PARAMETER, PRIVATE :: co2 = 300.e-6
  8. CONTAINS
  9. SUBROUTINE GSFCSWRAD(rthraten,gsw,xlat,xlong &
  10. ,dz8w,rho_phy &
  11. ,alb,t3d,qv3d,qc3d,qr3d &
  12. ,qi3d,qs3d,qg3d,qndrop3d &
  13. ,p3d,p8w3d,pi3d,cldfra3d,rswtoa &
  14. ,gmt,cp,g,julday,xtime,declin,solcon &
  15. ,radfrq,degrad,taucldi,taucldc,warm_rain &
  16. ,tauaer300,tauaer400,tauaer600,tauaer999 & ! jcb
  17. ,gaer300,gaer400,gaer600,gaer999 & ! jcb
  18. ,waer300,waer400,waer600,waer999 & ! jcb
  19. ,aer_ra_feedback &
  20. ,f_qv,f_qc,f_qr,f_qi,f_qs,f_qg,f_qndrop &
  21. ,ids,ide, jds,jde, kds,kde &
  22. ,ims,ime, jms,jme, kms,kme &
  23. ,its,ite, jts,jte, kts,kte )
  24. !------------------------------------------------------------------
  25. IMPLICIT NONE
  26. !------------------------------------------------------------------
  27. INTEGER, PARAMETER :: np = 75
  28. INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde, &
  29. ims,ime, jms,jme, kms,kme, &
  30. its,ite, jts,jte, kts,kte
  31. LOGICAL, INTENT(IN ) :: warm_rain
  32. INTEGER, INTENT(IN ) :: JULDAY
  33. REAL, INTENT(IN ) :: RADFRQ,DEGRAD, &
  34. XTIME,DECLIN,SOLCON
  35. !
  36. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
  37. INTENT(IN ) :: P3D, &
  38. P8W3D, &
  39. pi3D, &
  40. T3D, &
  41. dz8w, &
  42. rho_phy, &
  43. CLDFRA3D
  44. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
  45. INTENT(INOUT) :: RTHRATEN
  46. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
  47. OPTIONAL, &
  48. INTENT(INOUT) :: taucldi, &
  49. taucldc
  50. !
  51. REAL, DIMENSION( ims:ime, jms:jme ), &
  52. INTENT(IN ) :: XLAT, &
  53. XLONG, &
  54. ALB
  55. !
  56. REAL, DIMENSION( ims:ime, jms:jme ), &
  57. INTENT(INOUT) :: GSW, &
  58. RSWTOA
  59. !
  60. REAL, INTENT(IN ) :: GMT,CP,G
  61. !
  62. !
  63. ! Optional
  64. !
  65. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), OPTIONAL , &
  66. INTENT(IN ) :: tauaer300,tauaer400,tauaer600,tauaer999, & ! jcb
  67. gaer300,gaer400,gaer600,gaer999, & ! jcb
  68. waer300,waer400,waer600,waer999 ! jcb
  69. INTEGER, INTENT(IN ), OPTIONAL :: aer_ra_feedback
  70. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
  71. OPTIONAL, &
  72. INTENT(IN ) :: &
  73. QV3D, &
  74. QC3D, &
  75. QR3D, &
  76. QI3D, &
  77. QS3D, &
  78. QG3D, &
  79. QNDROP3D
  80. LOGICAL, OPTIONAL, INTENT(IN ) :: &
  81. F_QV,F_QC,F_QR,F_QI,F_QS,F_QG, &
  82. F_QNDROP
  83. ! LOCAL VARS
  84. REAL, DIMENSION( its:ite ) :: &
  85. ts, &
  86. cosz, &
  87. fp, &
  88. rsuvbm, &
  89. rsuvdf, &
  90. rsirbm, &
  91. rsirdf, &
  92. p400, &
  93. p700
  94. INTEGER, DIMENSION( its:ite ) :: &
  95. ict, &
  96. icb
  97. REAL, DIMENSION( its:ite, kts-1:kte, 2 ) :: taucld
  98. REAL, DIMENSION( its:ite, kts-1:kte+1 ) :: flx, &
  99. flxd
  100. !
  101. REAL, DIMENSION( its:ite, kts-1:kte ) :: O3
  102. !
  103. REAL, DIMENSION( its:ite, kts-1:kte, 11 ) :: &
  104. taual, &
  105. ssaal, &
  106. asyal
  107. REAL, DIMENSION( its:ite, kts-1:kte, 2 ) :: &
  108. reff, &
  109. cwc
  110. REAL, DIMENSION( its: ite, kts-1:kte+1 ) :: &
  111. P8W2D
  112. REAL, DIMENSION( its: ite, kts-1:kte ) :: &
  113. TTEN2D, &
  114. qndrop2d, &
  115. SH2D, &
  116. P2D, &
  117. T2D, &
  118. fcld2D
  119. REAL, DIMENSION( np, 5 ) :: pres, &
  120. ozone
  121. REAL, DIMENSION( np ) :: p
  122. LOGICAL :: cldwater,overcast, predicate
  123. !
  124. INTEGER :: i,j,K,NK,ib,kk,mix,mkx
  125. ! iprof = 1 : mid-latitude summer profile
  126. ! = 2 : mid-latitude winter profile
  127. ! = 3 : sub-arctic summer profile
  128. ! = 4 : sub-arctic winter profile
  129. ! = 5 : tropical profile
  130. !
  131. INTEGER :: iprof, &
  132. is_summer, &
  133. ie_summer, &
  134. lattmp
  135. !
  136. REAL :: XLAT0,XLONG0
  137. REAL :: fac,latrmp
  138. REAL :: xt24,tloctm,hrang,xxlat
  139. real, dimension(11) :: midbands ! jcb
  140. data midbands/.2,.235,.27,.2875,.3025,.305,.3625,.55,1.92,1.745,6.135/ ! jcb
  141. real :: ang,slope ! jcb
  142. character(len=200) :: msg !wig
  143. real pi, third, relconst, lwpmin, rhoh2o
  144. !
  145. !--------------------------------------------------------------------------------
  146. ! data set 1
  147. ! mid-latitude summer (75 levels) : p(mb) o3(g/g)
  148. ! surface temp = 294.0
  149. !
  150. data (pres(i,1),i=1,np)/ &
  151. 0.0006244, 0.0008759, 0.0012286, 0.0017234, 0.0024174, &
  152. 0.0033909, 0.0047565, 0.0066720, 0.0093589, 0.0131278, &
  153. 0.0184145, 0.0258302, 0.0362323, 0.0508234, 0.0712906, &
  154. 0.1000000, 0.1402710, 0.1967600, 0.2759970, 0.3871430, &
  155. 0.5430, 0.7617, 1.0685, 1.4988, 2.1024, 2.9490, &
  156. 4.1366, 5.8025, 8.1392, 11.4170, 16.0147, 22.4640, &
  157. 31.5105, 44.2001, 62.0000, 85.7750, 109.5500, 133.3250, &
  158. 157.1000, 180.8750, 204.6500, 228.4250, 252.2000, 275.9750, &
  159. 299.7500, 323.5250, 347.3000, 371.0750, 394.8500, 418.6250, &
  160. 442.4000, 466.1750, 489.9500, 513.7250, 537.5000, 561.2750, &
  161. 585.0500, 608.8250, 632.6000, 656.3750, 680.1500, 703.9250, &
  162. 727.7000, 751.4750, 775.2500, 799.0250, 822.8000, 846.5750, &
  163. 870.3500, 894.1250, 917.9000, 941.6750, 965.4500, 989.2250, &
  164. 1013.0000/
  165. !
  166. data (ozone(i,1),i=1,np)/ &
  167. 0.1793E-06, 0.2228E-06, 0.2665E-06, 0.3104E-06, 0.3545E-06, &
  168. 0.3989E-06, 0.4435E-06, 0.4883E-06, 0.5333E-06, 0.5786E-06, &
  169. 0.6241E-06, 0.6698E-06, 0.7157E-06, 0.7622E-06, 0.8557E-06, &
  170. 0.1150E-05, 0.1462E-05, 0.1793E-05, 0.2143E-05, 0.2512E-05, &
  171. 0.2902E-05, 0.3313E-05, 0.4016E-05, 0.5193E-05, 0.6698E-05, &
  172. 0.8483E-05, 0.9378E-05, 0.9792E-05, 0.1002E-04, 0.1014E-04, &
  173. 0.9312E-05, 0.7834E-05, 0.6448E-05, 0.5159E-05, 0.3390E-05, &
  174. 0.1937E-05, 0.1205E-05, 0.8778E-06, 0.6935E-06, 0.5112E-06, &
  175. 0.3877E-06, 0.3262E-06, 0.2770E-06, 0.2266E-06, 0.2020E-06, &
  176. 0.1845E-06, 0.1679E-06, 0.1519E-06, 0.1415E-06, 0.1317E-06, &
  177. 0.1225E-06, 0.1137E-06, 0.1055E-06, 0.1001E-06, 0.9487E-07, &
  178. 0.9016E-07, 0.8641E-07, 0.8276E-07, 0.7930E-07, 0.7635E-07, &
  179. 0.7347E-07, 0.7065E-07, 0.6821E-07, 0.6593E-07, 0.6368E-07, &
  180. 0.6148E-07, 0.5998E-07, 0.5859E-07, 0.5720E-07, 0.5582E-07, &
  181. 0.5457E-07, 0.5339E-07, 0.5224E-07, 0.5110E-07, 0.4999E-07/
  182. !--------------------------------------------------------------------------------
  183. ! data set 2
  184. ! mid-latitude winter (75 levels) : p(mb) o3(g/g)
  185. ! surface temp = 272.2
  186. !
  187. data (pres(i,2),i=1,np)/ &
  188. 0.0006244, 0.0008759, 0.0012286, 0.0017234, 0.0024174, &
  189. 0.0033909, 0.0047565, 0.0066720, 0.0093589, 0.0131278, &
  190. 0.0184145, 0.0258302, 0.0362323, 0.0508234, 0.0712906, &
  191. 0.1000000, 0.1402710, 0.1967600, 0.2759970, 0.3871430, &
  192. 0.5430, 0.7617, 1.0685, 1.4988, 2.1024, 2.9490, &
  193. 4.1366, 5.8025, 8.1392, 11.4170, 16.0147, 22.4640, &
  194. 31.5105, 44.2001, 62.0000, 85.9000, 109.8000, 133.7000, &
  195. 157.6000, 181.5000, 205.4000, 229.3000, 253.2000, 277.1000, &
  196. 301.0000, 324.9000, 348.8000, 372.7000, 396.6000, 420.5000, &
  197. 444.4000, 468.3000, 492.2000, 516.1000, 540.0000, 563.9000, &
  198. 587.8000, 611.7000, 635.6000, 659.5000, 683.4000, 707.3000, &
  199. 731.2000, 755.1000, 779.0000, 802.9000, 826.8000, 850.7000, &
  200. 874.6000, 898.5000, 922.4000, 946.3000, 970.2000, 994.1000, &
  201. 1018.0000/
  202. !
  203. data (ozone(i,2),i=1,np)/ &
  204. 0.2353E-06, 0.3054E-06, 0.3771E-06, 0.4498E-06, 0.5236E-06, &
  205. 0.5984E-06, 0.6742E-06, 0.7511E-06, 0.8290E-06, 0.9080E-06, &
  206. 0.9881E-06, 0.1069E-05, 0.1152E-05, 0.1319E-05, 0.1725E-05, &
  207. 0.2145E-05, 0.2581E-05, 0.3031E-05, 0.3497E-05, 0.3980E-05, &
  208. 0.4478E-05, 0.5300E-05, 0.6725E-05, 0.8415E-05, 0.1035E-04, &
  209. 0.1141E-04, 0.1155E-04, 0.1143E-04, 0.1093E-04, 0.1060E-04, &
  210. 0.9720E-05, 0.8849E-05, 0.7424E-05, 0.6023E-05, 0.4310E-05, &
  211. 0.2820E-05, 0.1990E-05, 0.1518E-05, 0.1206E-05, 0.9370E-06, &
  212. 0.7177E-06, 0.5450E-06, 0.4131E-06, 0.3277E-06, 0.2563E-06, &
  213. 0.2120E-06, 0.1711E-06, 0.1524E-06, 0.1344E-06, 0.1199E-06, &
  214. 0.1066E-06, 0.9516E-07, 0.8858E-07, 0.8219E-07, 0.7598E-07, &
  215. 0.6992E-07, 0.6403E-07, 0.5887E-07, 0.5712E-07, 0.5540E-07, &
  216. 0.5370E-07, 0.5214E-07, 0.5069E-07, 0.4926E-07, 0.4785E-07, &
  217. 0.4713E-07, 0.4694E-07, 0.4676E-07, 0.4658E-07, 0.4641E-07, &
  218. 0.4634E-07, 0.4627E-07, 0.4619E-07, 0.4612E-07, 0.4605E-07/
  219. !--------------------------------------------------------------------------------
  220. ! data set 3
  221. ! sub-arctic summer (75 levels) : p(mb) o3(g/g)
  222. ! surface temp = 287.0
  223. !
  224. data (pres(i,3),i=1,np)/ &
  225. 0.0006244, 0.0008759, 0.0012286, 0.0017234, 0.0024174, &
  226. 0.0033909, 0.0047565, 0.0066720, 0.0093589, 0.0131278, &
  227. 0.0184145, 0.0258302, 0.0362323, 0.0508234, 0.0712906, &
  228. 0.1000000, 0.1402710, 0.1967600, 0.2759970, 0.3871430, &
  229. 0.5430, 0.7617, 1.0685, 1.4988, 2.1024, 2.9490, &
  230. 4.1366, 5.8025, 8.1392, 11.4170, 16.0147, 22.4640, &
  231. 31.5105, 44.2001, 62.0000, 85.7000, 109.4000, 133.1000, &
  232. 156.8000, 180.5000, 204.2000, 227.9000, 251.6000, 275.3000, &
  233. 299.0000, 322.7000, 346.4000, 370.1000, 393.8000, 417.5000, &
  234. 441.2000, 464.9000, 488.6000, 512.3000, 536.0000, 559.7000, &
  235. 583.4000, 607.1000, 630.8000, 654.5000, 678.2000, 701.9000, &
  236. 725.6000, 749.3000, 773.0000, 796.7000, 820.4000, 844.1000, &
  237. 867.8000, 891.5000, 915.2000, 938.9000, 962.6000, 986.3000, &
  238. 1010.0000/
  239. !
  240. data (ozone(i,3),i=1,np)/ &
  241. 0.1728E-06, 0.2131E-06, 0.2537E-06, 0.2944E-06, 0.3353E-06, &
  242. 0.3764E-06, 0.4176E-06, 0.4590E-06, 0.5006E-06, 0.5423E-06, &
  243. 0.5842E-06, 0.6263E-06, 0.6685E-06, 0.7112E-06, 0.7631E-06, &
  244. 0.1040E-05, 0.1340E-05, 0.1660E-05, 0.2001E-05, 0.2362E-05, &
  245. 0.2746E-05, 0.3153E-05, 0.3762E-05, 0.4988E-05, 0.6518E-05, &
  246. 0.8352E-05, 0.9328E-05, 0.9731E-05, 0.8985E-05, 0.7632E-05, &
  247. 0.6814E-05, 0.6384E-05, 0.5718E-05, 0.4728E-05, 0.4136E-05, &
  248. 0.3033E-05, 0.2000E-05, 0.1486E-05, 0.1121E-05, 0.8680E-06, &
  249. 0.6474E-06, 0.5164E-06, 0.3921E-06, 0.2996E-06, 0.2562E-06, &
  250. 0.2139E-06, 0.1723E-06, 0.1460E-06, 0.1360E-06, 0.1267E-06, &
  251. 0.1189E-06, 0.1114E-06, 0.1040E-06, 0.9678E-07, 0.8969E-07, &
  252. 0.8468E-07, 0.8025E-07, 0.7590E-07, 0.7250E-07, 0.6969E-07, &
  253. 0.6694E-07, 0.6429E-07, 0.6208E-07, 0.5991E-07, 0.5778E-07, &
  254. 0.5575E-07, 0.5403E-07, 0.5233E-07, 0.5067E-07, 0.4904E-07, &
  255. 0.4721E-07, 0.4535E-07, 0.4353E-07, 0.4173E-07, 0.3997E-07/
  256. !--------------------------------------------------------------------------------
  257. ! data set 3
  258. ! sub-arctic winter (75 levels) : p(mb) o3(g/g)
  259. ! surface temp = 257.1
  260. !
  261. data (pres(i,4),i=1,np)/ &
  262. 0.0006244, 0.0008759, 0.0012286, 0.0017234, 0.0024174, &
  263. 0.0033909, 0.0047565, 0.0066720, 0.0093589, 0.0131278, &
  264. 0.0184145, 0.0258302, 0.0362323, 0.0508234, 0.0712906, &
  265. 0.1000000, 0.1402710, 0.1967600, 0.2759970, 0.3871430, &
  266. 0.5430, 0.7617, 1.0685, 1.4988, 2.1024, 2.9490, &
  267. 4.1366, 5.8025, 8.1392, 11.4170, 16.0147, 22.4640, &
  268. 31.5105, 44.2001, 62.0000, 85.7750, 109.5500, 133.3250, &
  269. 157.1000, 180.8750, 204.6500, 228.4250, 252.2000, 275.9750, &
  270. 299.7500, 323.5250, 347.3000, 371.0750, 394.8500, 418.6250, &
  271. 442.4000, 466.1750, 489.9500, 513.7250, 537.5000, 561.2750, &
  272. 585.0500, 608.8250, 632.6000, 656.3750, 680.1500, 703.9250, &
  273. 727.7000, 751.4750, 775.2500, 799.0250, 822.8000, 846.5750, &
  274. 870.3500, 894.1250, 917.9000, 941.6750, 965.4500, 989.2250, &
  275. 1013.0000/
  276. !
  277. data (ozone(i,4),i=1,np)/ &
  278. 0.2683E-06, 0.3562E-06, 0.4464E-06, 0.5387E-06, 0.6333E-06, &
  279. 0.7301E-06, 0.8291E-06, 0.9306E-06, 0.1034E-05, 0.1140E-05, &
  280. 0.1249E-05, 0.1360E-05, 0.1474E-05, 0.1855E-05, 0.2357E-05, &
  281. 0.2866E-05, 0.3383E-05, 0.3906E-05, 0.4437E-05, 0.4975E-05, &
  282. 0.5513E-05, 0.6815E-05, 0.8157E-05, 0.1008E-04, 0.1200E-04, &
  283. 0.1242E-04, 0.1250E-04, 0.1157E-04, 0.1010E-04, 0.9063E-05, &
  284. 0.8836E-05, 0.8632E-05, 0.8391E-05, 0.7224E-05, 0.6054E-05, &
  285. 0.4503E-05, 0.3204E-05, 0.2278E-05, 0.1833E-05, 0.1433E-05, &
  286. 0.9996E-06, 0.7440E-06, 0.5471E-06, 0.3944E-06, 0.2852E-06, &
  287. 0.1977E-06, 0.1559E-06, 0.1333E-06, 0.1126E-06, 0.9441E-07, &
  288. 0.7678E-07, 0.7054E-07, 0.6684E-07, 0.6323E-07, 0.6028E-07, &
  289. 0.5746E-07, 0.5468E-07, 0.5227E-07, 0.5006E-07, 0.4789E-07, &
  290. 0.4576E-07, 0.4402E-07, 0.4230E-07, 0.4062E-07, 0.3897E-07, &
  291. 0.3793E-07, 0.3697E-07, 0.3602E-07, 0.3506E-07, 0.3413E-07, &
  292. 0.3326E-07, 0.3239E-07, 0.3153E-07, 0.3069E-07, 0.2987E-07/
  293. !--------------------------------------------------------------------------------
  294. ! data set 4
  295. ! tropical (75 levels) : p(mb) o3(g/g)
  296. ! surface temp = 300.0
  297. !
  298. data (pres(i,5),i=1,np)/ &
  299. 0.0006244, 0.0008759, 0.0012286, 0.0017234, 0.0024174, &
  300. 0.0033909, 0.0047565, 0.0066720, 0.0093589, 0.0131278, &
  301. 0.0184145, 0.0258302, 0.0362323, 0.0508234, 0.0712906, &
  302. 0.1000000, 0.1402710, 0.1967600, 0.2759970, 0.3871430, &
  303. 0.5430, 0.7617, 1.0685, 1.4988, 2.1024, 2.9490, &
  304. 4.1366, 5.8025, 8.1392, 11.4170, 16.0147, 22.4640, &
  305. 31.5105, 44.2001, 62.0000, 85.7750, 109.5500, 133.3250, &
  306. 157.1000, 180.8750, 204.6500, 228.4250, 252.2000, 275.9750, &
  307. 299.7500, 323.5250, 347.3000, 371.0750, 394.8500, 418.6250, &
  308. 442.4000, 466.1750, 489.9500, 513.7250, 537.5000, 561.2750, &
  309. 585.0500, 608.8250, 632.6000, 656.3750, 680.1500, 703.9250, &
  310. 727.7000, 751.4750, 775.2500, 799.0250, 822.8000, 846.5750, &
  311. 870.3500, 894.1250, 917.9000, 941.6750, 965.4500, 989.2250, &
  312. 1013.0000/
  313. !
  314. data (ozone(i,5),i=1,np)/ &
  315. 0.1993E-06, 0.2521E-06, 0.3051E-06, 0.3585E-06, 0.4121E-06, &
  316. 0.4661E-06, 0.5203E-06, 0.5748E-06, 0.6296E-06, 0.6847E-06, &
  317. 0.7402E-06, 0.7959E-06, 0.8519E-06, 0.9096E-06, 0.1125E-05, &
  318. 0.1450E-05, 0.1794E-05, 0.2156E-05, 0.2538E-05, 0.2939E-05, &
  319. 0.3362E-05, 0.3785E-05, 0.4753E-05, 0.6005E-05, 0.7804E-05, &
  320. 0.9635E-05, 0.1023E-04, 0.1067E-04, 0.1177E-04, 0.1290E-04, &
  321. 0.1134E-04, 0.9223E-05, 0.6667E-05, 0.3644E-05, 0.1545E-05, &
  322. 0.5355E-06, 0.2523E-06, 0.2062E-06, 0.1734E-06, 0.1548E-06, &
  323. 0.1360E-06, 0.1204E-06, 0.1074E-06, 0.9707E-07, 0.8960E-07, &
  324. 0.8419E-07, 0.7962E-07, 0.7542E-07, 0.7290E-07, 0.7109E-07, &
  325. 0.6940E-07, 0.6786E-07, 0.6635E-07, 0.6500E-07, 0.6370E-07, &
  326. 0.6244E-07, 0.6132E-07, 0.6022E-07, 0.5914E-07, 0.5884E-07, &
  327. 0.5855E-07, 0.5823E-07, 0.5772E-07, 0.5703E-07, 0.5635E-07, &
  328. 0.5570E-07, 0.5492E-07, 0.5412E-07, 0.5335E-07, 0.5260E-07, &
  329. 0.5167E-07, 0.5063E-07, 0.4961E-07, 0.4860E-07, 0.4761E-07/
  330. !--------------------------------------------------------------------------------
  331. #ifdef WRF_CHEM
  332. IF ( aer_ra_feedback == 1) then
  333. IF ( .NOT. &
  334. ( PRESENT(tauaer300) .AND. &
  335. PRESENT(tauaer400) .AND. &
  336. PRESENT(tauaer600) .AND. &
  337. PRESENT(tauaer999) .AND. &
  338. PRESENT(gaer300) .AND. &
  339. PRESENT(gaer400) .AND. &
  340. PRESENT(gaer600) .AND. &
  341. PRESENT(gaer999) .AND. &
  342. PRESENT(waer300) .AND. &
  343. PRESENT(waer400) .AND. &
  344. PRESENT(waer600) .AND. &
  345. PRESENT(waer999) ) ) THEN
  346. CALL wrf_error_fatal ( 'Warning: missing fields required for aerosol radiation' )
  347. ENDIF
  348. ENDIF
  349. #endif
  350. cldwater = .true.
  351. overcast = .false.
  352. mix=ite-its+1
  353. mkx=kte-kts+1
  354. is_summer=80
  355. ie_summer=265
  356. ! testing, need to change iprof, which is function of lat and julian day
  357. ! iprof = 1 : mid-latitude summer profile
  358. ! = 2 : mid-latitude winter profile
  359. ! = 3 : sub-arctic summer profile
  360. ! = 4 : sub-arctic winter profile
  361. ! = 5 : tropical profile
  362. IF (abs(center_lat) .le. 30. ) THEN ! tropic
  363. iprof = 5
  364. ELSE
  365. IF (center_lat .gt. 0.) THEN
  366. IF (center_lat .gt. 60. ) THEN ! arctic
  367. IF (JULDAY .gt. is_summer .and. JULDAY .lt. ie_summer ) THEN
  368. ! arctic summer
  369. iprof = 3
  370. ELSE
  371. ! arctic winter
  372. iprof = 4
  373. ENDIF
  374. ELSE ! midlatitude
  375. IF (JULDAY .gt. is_summer .and. JULDAY .lt. ie_summer ) THEN
  376. ! north midlatitude summer
  377. iprof = 1
  378. ELSE
  379. ! north midlatitude winter
  380. iprof = 2
  381. ENDIF
  382. ENDIF
  383. ELSE
  384. IF (center_lat .lt. -60. ) THEN ! antarctic
  385. IF (JULDAY .lt. is_summer .or. JULDAY .gt. ie_summer ) THEN
  386. ! antarctic summer
  387. iprof = 3
  388. ELSE
  389. ! antarctic winter
  390. iprof = 4
  391. ENDIF
  392. ELSE ! midlatitude
  393. IF (JULDAY .lt. is_summer .or. JULDAY .gt. ie_summer ) THEN
  394. ! south midlatitude summer
  395. iprof = 1
  396. ELSE
  397. ! south midlatitude winter
  398. iprof = 2
  399. ENDIF
  400. ENDIF
  401. ENDIF
  402. ENDIF
  403. j_loop: DO J=jts,jte
  404. DO K=kts,kte
  405. DO I=its,ite
  406. cwc(i,k,1) = 0.
  407. cwc(i,k,2) = 0.
  408. ENDDO
  409. ENDDO
  410. DO K=1,np
  411. p(k)=pres(k,iprof)
  412. ENDDO
  413. ! reverse vars
  414. !
  415. DO K=kts,kte+1
  416. DO I=its,ite
  417. NK=kme-K+kms
  418. P8W2D(I,K)=p8w3d(i,nk,j)*0.01 ! P8w2D is in mb
  419. ENDDO
  420. ENDDO
  421. DO I=its,ite
  422. P8W2D(I,0)=.0
  423. ENDDO
  424. !
  425. DO K=kts,kte
  426. DO I=its,ite
  427. NK=kme-1-K+kms
  428. TTEN2D(I,K)=0.
  429. T2D(I,K)=T3D(I,NK,J)
  430. ! SH2D specific humidity
  431. SH2D(I,K)=QV3D(I,NK,J)/(1.+QV3D(I,NK,J))
  432. SH2D(I,K)=max(0.,SH2D(I,K))
  433. cwc(I,K,2)=QC3D(I,NK,J)
  434. cwc(I,K,2)=max(0.,cwc(I,K,2))
  435. P2D(I,K)=p3d(i,nk,j)*0.01 ! P2D is in mb
  436. fcld2D(I,K)=CLDFRA3D(I,NK,J)
  437. ENDDO
  438. ENDDO
  439. ! This logic is tortured because cannot test F_QI unless
  440. ! it is present, and order of evaluation of expressions
  441. ! is not specified in Fortran
  442. IF ( PRESENT ( F_QI ) ) THEN
  443. predicate = F_QI
  444. ELSE
  445. predicate = .FALSE.
  446. ENDIF
  447. IF (.NOT. warm_rain .AND. .NOT. predicate ) THEN
  448. DO K=kts,kte
  449. DO I=its,ite
  450. IF (T2D(I,K) .lt. 273.15) THEN
  451. cwc(I,K,1)=cwc(I,K,2)
  452. cwc(I,K,2)=0.
  453. ENDIF
  454. ENDDO
  455. ENDDO
  456. ENDIF
  457. IF ( PRESENT( F_QNDROP ) ) THEN
  458. IF ( F_QNDROP ) THEN
  459. DO K=kts,kte
  460. DO I=its,ite
  461. NK=kme-1-K+kms
  462. qndrop2d(I,K)=qndrop3d(I,NK,j)
  463. ENDDO
  464. ENDDO
  465. qndrop2d(:,kts-1)=0.
  466. END IF
  467. END IF
  468. DO I=its,ite
  469. TTEN2D(I,0)=0.
  470. T2D(I,0)=T2D(I,1)
  471. ! SH2D specific humidity
  472. SH2D(I,0)=0.5*SH2D(i,1)
  473. cwc(I,0,2)=0.
  474. cwc(I,0,1)=0.
  475. P2D(I,0)=0.5*(P8W2D(I,0)+P8W2D(I,1))
  476. fcld2D(I,0)=0.
  477. ENDDO
  478. !
  479. IF ( PRESENT( F_QI ) .AND. PRESENT( qi3d) ) THEN
  480. IF ( (F_QI) ) THEN
  481. DO K=kts,kte
  482. DO I=its,ite
  483. NK=kme-1-K+kms
  484. cwc(I,K,1)=QI3D(I,NK,J)
  485. cwc(I,K,1)=max(0.,cwc(I,K,1))
  486. ENDDO
  487. ENDDO
  488. ENDIF
  489. ENDIF
  490. !
  491. ! ... Vertical profiles for ozone
  492. !
  493. call o3prof (np, p, ozone(1,iprof), its, ite, kts-1, kte, P2D, O3)
  494. ! ... Vertical profiles for effective particle size
  495. !
  496. pi = 4.*atan(1.0)
  497. third=1./3.
  498. rhoh2o=1.e3
  499. relconst=3/(4.*pi*rhoh2o)
  500. ! minimun liquid water path to calculate rel
  501. ! corresponds to optical depth of 1.e-3 for radius 4 microns.
  502. lwpmin=3.e-5
  503. do k = kts-1, kte
  504. do i = its, ite
  505. reff(i,k,2) = 10.
  506. if( PRESENT( F_QNDROP ) ) then
  507. if( F_QNDROP ) then
  508. if ( cwc(i,k,2)*(P8W2D(I,K+1)-P8W2D(I,K)).gt.lwpmin.and. &
  509. qndrop2d(i,k).gt.1000. ) then
  510. reff(i,k,2)=(relconst*cwc(i,k,2)/qndrop2d(i,k))**third ! effective radius in m
  511. ! apply scaling from Martin et al., JAS 51, 1830.
  512. reff(i,k,2)=1.1*reff(i,k,2)
  513. reff(i,k,2)=reff(i,k,2)*1.e6 ! convert from m to microns
  514. reff(i,k,2)=max(reff(i,k,2),4.)
  515. reff(i,k,2)=min(reff(i,k,2),20.)
  516. end if
  517. end if
  518. end if
  519. reff(i,k,1) = 80.
  520. end do
  521. end do
  522. !
  523. ! ... Level indices separating high, middle and low clouds
  524. !
  525. do i = its, ite
  526. p400(i) = 1.e5
  527. p700(i) = 1.e5
  528. enddo
  529. do k = kts-1,kte+1
  530. do i = its, ite
  531. if (abs(P8W2D(i,k) - 400.) .lt. p400(i)) then
  532. p400(i) = abs(P8W2D(i,k) - 400.)
  533. ict(i) = k
  534. endif
  535. if (abs(P8W2D(i,k) - 700.) .lt. p700(i)) then
  536. p700(i) = abs(P8W2D(i,k) - 700.)
  537. icb(i) = k
  538. endif
  539. end do
  540. end do
  541. !wig beg
  542. ! ... Aerosol effects. Added aerosol feedbacks with MOSAIC, Dec. 2005.
  543. !
  544. do ib = 1, 11
  545. do k = kts-1,kte
  546. do i = its,ite
  547. taual(i,k,ib) = 0.
  548. ssaal(i,k,ib) = 0.
  549. asyal(i,k,ib) = 0.
  550. end do
  551. end do
  552. end do
  553. #ifdef WRF_CHEM
  554. IF ( AER_RA_FEEDBACK == 1) then
  555. !wig end
  556. do ib = 1, 11
  557. do k = kts-1,kte-1 !wig
  558. do i = its,ite
  559. ! taual(i,kte-k,ib) = 0.
  560. ! ssaal(i,kte-k,ib) = 0.
  561. ! asyal(i,kte-k,ib) = 0.
  562. !jcb beg
  563. ! convert optical properties at 300,400,600, and 999 to conform to the band wavelengths
  564. ! these are: 200,235,270,287.5,302.5,305,362.5,550,1920,1745,6135; why the emphasis on the UV?
  565. ! taual - use angstrom exponent
  566. if(tauaer300(i,k+1,j).gt.thresh .and. tauaer999(i,k+1,j).gt.thresh) then
  567. ang=log(tauaer300(i,k+1,j)/tauaer999(i,k+1,j))/log(999./300.)
  568. ! write(6,*)i,k,ang,tauaer300(i,k+1,j),tauaer999(i,k+1,j)
  569. taual(i,kte-k,ib)=tauaer400(i,k+1,j)*(0.4/midbands(ib))**ang ! notice reserved variable
  570. ! write(6,10001)i,k,ang,tauaer300(i,k+1,j),tauaer999(i,k+1,j),midbands(ib),taual(i,k,ib)
  571. !10001 format(i3,i3,5f12.6)
  572. ! ssa - linear interpolation; extrapolation
  573. slope=(waer600(i,k+1,j)-waer400(i,k+1,j))/.2
  574. ssaal(i,kte-k,ib) = slope*(midbands(ib)-.6)+waer600(i,k+1,j) ! notice reversed variables
  575. if(ssaal(i,kte-k,ib).lt.0.4) ssaal(i,kte-k,ib)=0.4
  576. if(ssaal(i,kte-k,ib).ge.1.0) ssaal(i,kte-k,ib)=1.0
  577. ! g - linear interpolation;extrapolation
  578. slope=(gaer600(i,k+1,j)-gaer400(i,k+1,j))/.2
  579. asyal(i,kte-k,ib) = slope*(midbands(ib)-.6)+gaer600(i,k+1,j) ! notice reversed varaibles
  580. if(asyal(i,kte-k,ib).lt.0.5) asyal(i,kte-k,ib)=0.5
  581. if(asyal(i,kte-k,ib).ge.1.0) asyal(i,kte-k,ib)=1.0
  582. endif
  583. !jcb end
  584. end do
  585. end do
  586. end do
  587. !wig beg
  588. do ib = 1, 11
  589. do i = its,ite
  590. slope = 0. !use slope as a sum holder
  591. do k = kts-1,kte
  592. slope = slope + taual(i,k,ib)
  593. end do
  594. if( slope < 0. ) then
  595. write(msg,'("ERROR: Negative total optical depth of ",f8.2," at point i,j,ib=",3i5)') slope,i,j,ib
  596. call wrf_error_fatal(msg)
  597. else if( slope > 5. ) then
  598. call wrf_message("-------------------------")
  599. write(msg,'("WARNING: Large total optical depth of ",f8.2," at point i,j,ib=",3i5)') slope,i,j,ib
  600. call wrf_message(msg)
  601. call wrf_message("Diagnostics 1: k, tauaer300, tauaer400, tauaer600, tauaer999")
  602. do k=kts,kte
  603. write(msg,'(i4,4f8.2)') k, tauaer300(i,k,j), tauaer400(i,k,j), &
  604. tauaer600(i,k,j), tauaer999(i,k,j)
  605. call wrf_message(msg)
  606. end do
  607. call wrf_message("Diagnostics 2: k, gaer300, gaer400, gaer600, gaer999")
  608. do k=kts,kte
  609. write(msg,'(i4,4f8.2)') k, gaer300(i,k,j), gaer400(i,k,j), &
  610. gaer600(i,k,j), gaer999(i,k,j)
  611. call wrf_message(msg)
  612. end do
  613. call wrf_message("Diagnostics 3: k, waer300, waer400, waer600, waer999")
  614. do k=kts,kte
  615. write(msg,'(i4,4f8.2)') k, waer300(i,k,j), waer400(i,k,j), &
  616. waer600(i,k,j), waer999(i,k,j)
  617. call wrf_message(msg)
  618. end do
  619. call wrf_message("Diagnostics 4: k, ssaal, asyal, taual")
  620. do k=kts-1,kte
  621. write(msg,'(i4,3f8.2)') k, ssaal(i,k,ib), asyal(i,k,ib), taual(i,k,ib)
  622. call wrf_message(msg)
  623. end do
  624. call wrf_message("-------------------------")
  625. end if
  626. end do
  627. end do
  628. !wig end
  629. endif
  630. #endif
  631. !
  632. ! ... Initialize output arrays
  633. !
  634. do ib = 1, 2
  635. do k = kts-1, kte
  636. do i = its, ite
  637. taucld(i,k,ib) = 0.
  638. end do
  639. end do
  640. end do
  641. !
  642. do k = kts-1,kte+1
  643. do i = its,ite
  644. flx(i,k) = 0.
  645. flxd(i,k) = 0.
  646. end do
  647. end do
  648. !
  649. ! ... Solar zenith angle
  650. !
  651. do i = its,ite
  652. xt24 = mod(xtime + radfrq * 0.5, 1440.)
  653. tloctm = GMT + xt24 / 60. + XLONG(i,j) / 15.
  654. hrang = 15. * (tloctm - 12.) * degrad
  655. xxlat = XLAT(i,j) * degrad
  656. cosz(i) = sin(xxlat) * sin(declin) + &
  657. cos(xxlat) * cos(declin) * cos(hrang)
  658. rsuvbm(i) = ALB(i,j)
  659. rsuvdf(i) = ALB(i,j)
  660. rsirbm(i) = ALB(i,j)
  661. rsirdf(i) = ALB(i,j)
  662. end do
  663. call sorad (mix,1,1,mkx+1,p8w2D,t2D,sh2D,o3, &
  664. overcast,cldwater,cwc,taucld,reff,fcld2D,ict,icb,&
  665. taual,ssaal,asyal, &
  666. cosz,rsuvbm,rsuvdf,rsirbm,rsirdf, &
  667. flx,flxd)
  668. !
  669. ! ... Convert the units of flx and flc from fraction to w/m^2
  670. !
  671. do k = kts, kte
  672. do i = its, ite
  673. nk=kme-1-k+kms
  674. if(present(taucldc)) taucldc(i,nk,j)=taucld(i,k,2)
  675. if(present(taucldi)) taucldi(i,nk,j)=taucld(i,k,1)
  676. enddo
  677. enddo
  678. do k = kts, kte+1
  679. do i = its, ite
  680. if (cosz(i) .lt. thresh) then
  681. flx(i,k) = 0.
  682. else
  683. flx(i,k) = flx(i,k) * SOLCON * cosz(i)
  684. endif
  685. end do
  686. end do
  687. !
  688. ! ... Calculate heating rate (deg/sec)
  689. !
  690. fac = .01 * g / Cp
  691. do k = kts, kte
  692. do i = its, ite
  693. if (cosz(i) .gt. thresh) then
  694. TTEN2D(i,k) = - fac * (flx(i,k) - flx(i,k+1))/ &
  695. (p8w2d(i,k)-p8w2d(i,k+1))
  696. endif
  697. end do
  698. end do
  699. ! upward top of atmosphere
  700. do i = its, ite
  701. if (cosz(i) .le. thresh) then
  702. RSWTOA(i,j) = 0.
  703. else
  704. RSWTOA(i,j) = flx(i,kts) - flxd(i,kts) * SOLCON * cosz(i)
  705. endif
  706. end do
  707. !
  708. ! ... Absorbed part in surface energy budget
  709. !
  710. do i = its, ite
  711. if (cosz(i) .le. thresh) then
  712. GSW(i,j) = 0.
  713. else
  714. GSW(i,j) = (1. - rsuvbm(i)) * flxd(i,kte+1) * SOLCON * cosz(i)
  715. endif
  716. end do
  717. DO K=kts,kte
  718. NK=kme-1-K+kms
  719. DO I=its,ite
  720. ! FIX FROM GODDARD FOR NEGATIVE VALUES
  721. TTEN2D(I,NK)=MAX(TTEN2D(I,NK),0.)
  722. RTHRATEN(I,K,J)=RTHRATEN(I,K,J)+TTEN2D(I,NK)/pi3D(I,K,J)
  723. ENDDO
  724. ENDDO
  725. !
  726. ENDDO j_loop
  727. END SUBROUTINE GSFCSWRAD
  728. !********************* Version Solar-6 (May 8, 1997) *****************
  729. subroutine sorad (m,n,ndim,np,pl,ta,wa,oa, &
  730. overcast,cldwater,cwc,taucld,reff,fcld,ict,icb, &
  731. taual,ssaal,asyal, &
  732. cosz,rsuvbm,rsuvdf,rsirbm,rsirdf, &
  733. flx,flxd)
  734. !************************************************************************
  735. !
  736. ! Version Solar-6 (May 8, 1997)
  737. !
  738. ! New feature of this version is:
  739. ! (1) An option is added for scaling the cloud optical thickness. If
  740. ! the fractional cloud cover, fcld, in an atmospheric model is alway
  741. ! either 1 or 0 (i.e. partly cloudy sky is not allowed), it does
  742. ! not require the scaling of cloud optical thickness, and the
  743. ! option "overcast" can be set to .true. Computation is faster
  744. ! with this option than with overcast=.false.
  745. !
  746. !**********************************************************************
  747. !
  748. ! Version Solar-5 (April 1997)
  749. !
  750. ! New features of this version are:
  751. ! (1) Cloud optical properties can be computed from cloud water/ice
  752. ! amount and the effective particle size.
  753. ! (2) Aerosol optical properties are functions of height and band.
  754. ! (3) A maximum-random cloud overlapping approximation is applied.
  755. !
  756. !*********************************************************************
  757. !
  758. ! This routine computes solar fluxes due to the absoption by water
  759. ! vapor, ozone, co2, o2, clouds, and aerosols and due to the
  760. ! scattering by clouds, aerosols, and gases.
  761. !
  762. ! The solar spectrum is divided into one UV+visible band and three IR
  763. ! bands separated by the wavelength 0.7 micron. The UV+visible band
  764. ! is further divided into eight sub-bands.
  765. !
  766. ! This is a vectorized code. It computes fluxes simultaneously for
  767. ! (m x n) soundings, which is a subset of (m x ndim) soundings.
  768. ! In a global climate model, m and ndim correspond to the numbers of
  769. ! grid boxes in the zonal and meridional directions, respectively.
  770. !
  771. ! Ice and liquid cloud particles are allowed to co-exist in a layer.
  772. !
  773. ! There is an option of providing either cloud ice/water mixing ratio
  774. ! (cwc) or thickness (taucld). If the former is provided, set
  775. ! cldwater=.true., and taucld will be computed from cwc and reff as a
  776. ! function of spectra band. Otherwise, set cldwater=.false., and
  777. ! specify taucld, independent of spectral band.
  778. !
  779. ! If no information is available for reff, a default value of
  780. ! 10 micron for liquid water and 75 micron for ice can be used.
  781. ! For a clear layer, reff can be set to any values except zero.
  782. !
  783. ! The maximum-random assumption is applied for treating cloud
  784. ! overlapping.
  785. ! Clouds are grouped into high, middle, and low clouds separated by
  786. ! the level indices ict and icb. For detail, see subroutine cldscale.
  787. !
  788. ! In a high spatial-resolution atmospheric model, fractional cloud cover
  789. ! might be computed to be either 0 or 1. In such a case, scaling of the
  790. ! cloud optical thickness is not necessary, and the computation can be
  791. ! made faster by setting overcast=.true. The option overcast=.false.
  792. ! can be applied to any values of the fractional cloud cover, but the
  793. ! computation is slower.
  794. !
  795. ! Aerosol optical thickness, single-scattering albaedo, and asymmtry
  796. ! factor can be specified as functions of height and spectral band.
  797. !
  798. !----- Input parameters:
  799. ! units size
  800. ! number of soundings in zonal direction (m) n/d 1
  801. ! number of soundings in meridional direction (n) n/d 1
  802. ! maximum number of soundings in n/d 1
  803. ! meridional direction (ndim>=n)
  804. ! number of atmospheric layers (np) n/d 1
  805. ! level pressure (pl) mb m*ndim*(np+1)
  806. ! layer temperature (ta) k m*ndim*np
  807. ! layer specific humidity (wa) gm/gm m*ndim*np
  808. ! layer ozone concentration (oa) gm/gm m*ndim*np
  809. ! co2 mixing ratio by volumn (co2) pppv 1
  810. ! option for scaling cloud optical thickness n/d 1
  811. ! overcast="true" if scaling is NOT required
  812. ! overcast="fasle" if scaling is required
  813. ! option for cloud optical thickness n/d 1
  814. ! cldwater="true" if cwc is provided
  815. ! cldwater="false" if taucld is provided
  816. ! cloud water mixing ratio (cwc) gm/gm m*ndim*np*2
  817. ! index 1 for ice particles
  818. ! index 2 for liquid drops
  819. ! cloud optical thickness (taucld) n/d m*ndim*np*2
  820. ! index 1 for ice particles
  821. ! index 2 for liquid drops
  822. ! effective cloud-particle size (reff) micrometer m*ndim*np*2
  823. ! index 1 for ice particles
  824. ! index 2 for liquid drops
  825. ! cloud amount (fcld) fraction m*ndim*np
  826. ! level index separating high and middle n/d 1
  827. ! clouds (ict)
  828. ! level index separating middle and low n/d 1
  829. ! clouds (icb)
  830. ! aerosol optical thickness (taual) n/d m*ndim*np*11
  831. ! aerosol single-scattering albedo (ssaal) n/d m*ndim*np*11
  832. ! aerosol asymmetry factor (asyal) n/d m*ndim*np*11
  833. ! in the uv region :
  834. ! index 1 for the 0.175-0.225 micron band
  835. ! index 2 for the 0.225-0.245; 0.260-0.280 micron band
  836. ! index 3 for the 0.245-0.260 micron band
  837. ! index 4 for the 0.280-0.295 micron band
  838. ! index 5 for the 0.295-0.310 micron band
  839. ! index 6 for the 0.310-0.320 micron band
  840. ! index 7 for the 0.325-0.400 micron band
  841. ! in the par region :
  842. ! index 8 for the 0.400-0.700 micron band
  843. ! in the infrared region :
  844. ! index 9 for the 0.700-1.220 micron band
  845. ! index 10 for the 1.220-2.270 micron band
  846. ! index 11 for the 2.270-10.00 micron band
  847. ! cosine of solar zenith angle (cosz) n/d m*ndim
  848. ! uv+visible sfc albedo for beam radiation
  849. ! for wavelengths<0.7 micron (rsuvbm) fraction m*ndim
  850. ! uv+visible sfc albedo for diffuse radiation
  851. ! for wavelengths<0.7 micron (rsuvdf) fraction m*ndim
  852. ! ir sfc albedo for beam radiation
  853. ! for wavelengths>0.7 micron (rsirbm) fraction m*ndim
  854. ! ir sfc albedo for diffuse radiation (rsirdf) fraction m*ndim
  855. !
  856. !----- Output parameters
  857. !
  858. ! all-sky flux (downward minus upward) (flx) fraction m*ndim*(np+1)
  859. ! clear-sky flux (downward minus upward) (flc) fraction m*ndim*(np+1)
  860. ! all-sky direct downward uv (0.175-0.4 micron)
  861. ! flux at the surface (fdiruv) fraction m*ndim
  862. ! all-sky diffuse downward uv flux at
  863. ! the surface (fdifuv) fraction m*ndim
  864. ! all-sky direct downward par (0.4-0.7 micron)
  865. ! flux at the surface (fdirpar) fraction m*ndim
  866. ! all-sky diffuse downward par flux at
  867. ! the surface (fdifpar) fraction m*ndim
  868. ! all-sky direct downward ir (0.7-10 micron)
  869. ! flux at the surface (fdirir) fraction m*ndim
  870. ! all-sky diffuse downward ir flux at
  871. ! the surface (fdifir) fraction m*ndim
  872. !
  873. !----- Notes:
  874. !
  875. ! (1) The unit of "flux" is fraction of the incoming solar radiation
  876. ! at the top of the atmosphere. Therefore, fluxes should
  877. ! be equal to "flux" multiplied by the extra-terrestrial solar
  878. ! flux and the cosine of solar zenith angle.
  879. ! (2) pl(i,j,1) is the pressure at the top of the model, and
  880. ! pl(i,j,np+1) is the surface pressure.
  881. ! (3) the pressure levels ict and icb correspond approximately
  882. ! to 400 and 700 mb.
  883. ! (4) if overcast='true', the clear-sky flux, flc, is not computed.
  884. !
  885. !**************************************************************************
  886. implicit none
  887. !**************************************************************************
  888. !-----input parameters
  889. integer m,n,ndim,np
  890. integer ict(m,ndim),icb(m,ndim)
  891. real pl(m,ndim,np+1),ta(m,ndim,np),wa(m,ndim,np),oa(m,ndim,np)
  892. real cwc(m,ndim,np,2),taucld(m,ndim,np,2),reff(m,ndim,np,2), &
  893. fcld(m,ndim,np)
  894. real taual(m,ndim,np,11),ssaal(m,ndim,np,11),asyal(m,ndim,np,11)
  895. real cosz(m,ndim),rsuvbm(m,ndim),rsuvdf(m,ndim), &
  896. rsirbm(m,ndim),rsirdf(m,ndim)
  897. logical overcast,cldwater
  898. !-----output parameters
  899. real flx(m,ndim,np+1),flc(m,ndim,np+1)
  900. real flxu(m,ndim,np+1),flxd(m,ndim,np+1)
  901. real fdiruv (m,ndim),fdifuv (m,ndim)
  902. real fdirpar(m,ndim),fdifpar(m,ndim)
  903. real fdirir (m,ndim),fdifir (m,ndim)
  904. !-----temporary array
  905. integer i,j,k
  906. real cwp(m,n,np,2)
  907. real dp(m,n,np),wh(m,n,np),oh(m,n,np),scal(m,n,np)
  908. real swh(m,n,np+1),so2(m,n,np+1),df(m,n,np+1)
  909. real sdf(m,n),sclr(m,n),csm(m,n),x
  910. do j= 1, n
  911. do i= 1, m
  912. if (pl(i,j,1) .eq. 0.0) then
  913. pl(i,j,1)=1.0e-4
  914. endif
  915. enddo
  916. enddo
  917. do j= 1, n
  918. do i= 1, m
  919. swh(i,j,1)=0.
  920. so2(i,j,1)=0.
  921. !-----csm is the effective secant of the solar zenith angle
  922. ! see equation (12) of Lacis and Hansen (1974, JAS)
  923. csm(i,j)=35./sqrt(1224.*cosz(i,j)*cosz(i,j)+1.)
  924. enddo
  925. enddo
  926. do k= 1, np
  927. do j= 1, n
  928. do i= 1, m
  929. !-----compute layer thickness and pressure-scaling function.
  930. ! indices for the surface level and surface layer
  931. ! are np+1 and np, respectively.
  932. dp(i,j,k)=pl(i,j,k+1)-pl(i,j,k)
  933. scal(i,j,k)=dp(i,j,k)*(.5*(pl(i,j,k)+pl(i,j,k+1))/300.)**.8
  934. !-----compute scaled water vapor amount, unit is g/cm**2
  935. ! note: the sign prior to the constant 0.00135 was incorrectly
  936. ! set to negative in the previous version
  937. wh(i,j,k)=1.02*wa(i,j,k)*scal(i,j,k)* &
  938. (1.+0.00135*(ta(i,j,k)-240.)) +1.e-11
  939. swh(i,j,k+1)=swh(i,j,k)+wh(i,j,k)
  940. !-----compute ozone amount, unit is (cm-atm)stp
  941. ! the number 466.7 is a conversion factor from g/cm**2 to (cm-atm)stp
  942. oh(i,j,k)=1.02*oa(i,j,k)*dp(i,j,k)*466.7 +1.e-11
  943. !-----compute layer cloud water amount (gm/m**2)
  944. ! the index is 1 for ice crystals and 2 for liquid drops
  945. cwp(i,j,k,1)=1.02*10000.*cwc(i,j,k,1)*dp(i,j,k)
  946. cwp(i,j,k,2)=1.02*10000.*cwc(i,j,k,2)*dp(i,j,k)
  947. enddo
  948. enddo
  949. enddo
  950. !-----initialize fluxes for all-sky (flx), clear-sky (flc), and
  951. ! flux reduction (df)
  952. do k=1, np+1
  953. do j=1, n
  954. do i=1, m
  955. flx(i,j,k)=0.
  956. flc(i,j,k)=0.
  957. flxu(i,j,k)=0.
  958. flxd(i,j,k)=0.
  959. df(i,j,k)=0.
  960. enddo
  961. enddo
  962. enddo
  963. !-----compute solar uv and par fluxes
  964. call soluv (m,n,ndim,np,oh,dp,overcast,cldwater, &
  965. cwp,taucld,reff,ict,icb,fcld,cosz, &
  966. taual,ssaal,asyal,csm,rsuvbm,rsuvdf, &
  967. flx,flc,flxu,flxd,fdiruv,fdifuv,fdirpar,fdifpar)
  968. !-----compute and update solar ir fluxes
  969. call solir (m,n,ndim,np,wh,overcast,cldwater, &
  970. cwp,taucld,reff,ict,icb,fcld,cosz, &
  971. taual,ssaal,asyal,csm,rsirbm,rsirdf, &
  972. flx,flc,flxu,flxd,fdirir,fdifir)
  973. !-----compute scaled o2 amount, unit is (cm-atm)stp.
  974. do k= 1, np
  975. do j= 1, n
  976. do i= 1, m
  977. so2(i,j,k+1)=so2(i,j,k)+165.22*scal(i,j,k)
  978. enddo
  979. enddo
  980. enddo
  981. !-----compute flux reduction due to oxygen following
  982. ! chou (J. climate, 1990). The fraction 0.0287 is the
  983. ! extraterrestrial solar flux in the o2 bands.
  984. do k= 2, np+1
  985. do j= 1, n
  986. do i= 1, m
  987. x=so2(i,j,k)*csm(i,j)
  988. df(i,j,k)=df(i,j,k)+0.0287*(1.-exp(-0.00027*sqrt(x)))
  989. enddo
  990. enddo
  991. enddo
  992. !-----compute scaled co2 amounts. unit is (cm-atm)stp.
  993. do k= 1, np
  994. do j= 1, n
  995. do i= 1, m
  996. so2(i,j,k+1)=so2(i,j,k)+co2*789.*scal(i,j,k)+1.e-11
  997. enddo
  998. enddo
  999. enddo
  1000. !-----compute and update flux reduction due to co2 following
  1001. ! chou (J. Climate, 1990)
  1002. call flxco2(m,n,np,so2,swh,csm,df)
  1003. !-----adjust for the effect of o2 cnd co2 on clear-sky fluxes.
  1004. do k= 2, np+1
  1005. do j= 1, n
  1006. do i= 1, m
  1007. flc(i,j,k)=flc(i,j,k)-df(i,j,k)
  1008. enddo
  1009. enddo
  1010. enddo
  1011. !-----adjust for the all-sky fluxes due to o2 and co2. It is
  1012. ! assumed that o2 and co2 have no effects on solar radiation
  1013. ! below clouds.
  1014. do j=1,n
  1015. do i=1,m
  1016. sdf(i,j)=0.0
  1017. sclr(i,j)=1.0
  1018. enddo
  1019. enddo
  1020. do k=1,np
  1021. do j=1,n
  1022. do i=1,m
  1023. !-----sclr is the fraction of clear sky.
  1024. ! sdf is the flux reduction below clouds.
  1025. if(fcld(i,j,k).gt.0.01) then
  1026. sdf(i,j)=sdf(i,j)+df(i,j,k)*sclr(i,j)*fcld(i,j,k)
  1027. sclr(i,j)=sclr(i,j)*(1.-fcld(i,j,k))
  1028. endif
  1029. flx(i,j,k+1)=flx(i,j,k+1)-sdf(i,j)-df(i,j,k+1)*sclr(i,j)
  1030. flxu(i,j,k+1)=flxu(i,j,k+1)-sdf(i,j)-df(i,j,k+1)*sclr(i,j)
  1031. flxd(i,j,k+1)=flxd(i,j,k+1)-sdf(i,j)-df(i,j,k+1)*sclr(i,j) ! SG: same as flux????
  1032. enddo
  1033. enddo
  1034. enddo
  1035. !-----adjustment for the direct downward ir flux.
  1036. do j= 1, n
  1037. do i= 1, m
  1038. flc(i,j,np+1)=flc(i,j,np+1)+df(i,j,np+1)*rsirbm(i,j)
  1039. flx(i,j,np+1)=flx(i,j,np+1)+(sdf(i,j)+ &
  1040. df(i,j,np+1)*sclr(i,j))*rsirbm(i,j)
  1041. flxu(i,j,np+1)=flxu(i,j,np+1)+(sdf(i,j)+ &
  1042. df(i,j,np+1)*sclr(i,j))*rsirbm(i,j)
  1043. flxd(i,j,np+1)=flxd(i,j,np+1)+(sdf(i,j)+ &
  1044. df(i,j,np+1)*sclr(i,j))*rsirbm(i,j)
  1045. fdirir(i,j)=fdirir(i,j)-(sdf(i,j)+df(i,j,np+1)*sclr(i,j))
  1046. enddo
  1047. enddo
  1048. end subroutine sorad
  1049. !************************************************************************
  1050. subroutine soluv (m,n,ndim,np,oh,dp,overcast,cldwater, &
  1051. cwp,taucld,reff,ict,icb,fcld,cosz, &
  1052. taual,ssaal,asyal,csm,rsuvbm,rsuvdf, &
  1053. flx,flc,flxu,flxd,fdiruv,fdifuv,fdirpar,fdifpar)
  1054. !************************************************************************
  1055. ! compute solar fluxes in the uv+par region. the spectrum is
  1056. ! grouped into 8 bands:
  1057. !
  1058. ! Band Micrometer
  1059. !
  1060. ! UV-C 1. .175 - .225
  1061. ! 2. .225 - .245
  1062. ! .260 - .280
  1063. ! 3. .245 - .260
  1064. !
  1065. ! UV-B 4. .280 - .295
  1066. ! 5. .295 - .310
  1067. ! 6. .310 - .320
  1068. !
  1069. ! UV-A 7. .320 - .400
  1070. !
  1071. ! PAR 8. .400 - .700
  1072. !
  1073. !----- Input parameters: units size
  1074. !
  1075. ! number of soundings in zonal direction (m) n/d 1
  1076. ! number of soundings in meridional direction (n) n/d 1
  1077. ! maximum number of soundings in n/d 1
  1078. ! meridional direction (ndim)
  1079. ! number of atmospheric layers (np) n/d 1
  1080. ! layer ozone content (oh) (cm-atm)stp m*n*np
  1081. ! layer pressure thickness (dp) mb m*n*np
  1082. ! option for scaling cloud optical thickness n/d 1
  1083. ! overcast="true" if scaling is NOT required
  1084. ! overcast="fasle" if scaling is required
  1085. ! input option for cloud optical thickness n/d 1
  1086. ! cldwater="true" if taucld is provided
  1087. ! cldwater="false" if cwp is provided
  1088. ! cloud water amount (cwp) gm/m**2 m*n*np*2
  1089. ! index 1 for ice particles
  1090. ! index 2 for liquid drops
  1091. ! cloud optical thickness (taucld) n/d m*ndim*np*2
  1092. ! index 1 for ice paticles
  1093. ! index 2 for liquid particles
  1094. ! effective cloud-particle size (reff) micrometer m*ndim*np*2
  1095. ! index 1 for ice paticles
  1096. ! index 2 for liquid particles
  1097. ! level indiex separating high and n/d m*n
  1098. ! middle clouds (ict)
  1099. ! level indiex separating middle and n/d m*n
  1100. ! low clouds (icb)
  1101. ! cloud amount (fcld) fraction m*ndim*np
  1102. ! cosine of solar zenith angle (cosz) n/d m*ndim
  1103. ! aerosol optical thickness (taual) n/d m*ndim*np*11
  1104. ! aerosol single-scattering albedo (ssaal) n/d m*ndim*np*11
  1105. ! aerosol asymmetry factor (asyal) n/d m*ndim*np*11
  1106. ! cosecant of the solar zenith angle (csm) n/d m*n
  1107. ! uv+par surface albedo for beam fraction m*ndim
  1108. ! radiation (rsuvbm)
  1109. ! uv+par surface albedo for diffuse fraction m*ndim
  1110. ! radiation (rsuvdf)
  1111. !
  1112. !---- temporary array
  1113. !
  1114. ! scaled cloud optical thickness n/d m*n*np
  1115. ! for beam radiation (tauclb)
  1116. ! scaled cloud optical thickness n/d m*n*np
  1117. ! for diffuse radiation (tauclf)
  1118. !
  1119. !----- output (updated) parameters:
  1120. !
  1121. ! all-sky net downward flux (flx) fraction m*ndim*(np+1)
  1122. ! clear-sky net downward flux (flc) fraction m*ndim*(np+1)
  1123. ! all-sky direct downward uv flux at
  1124. ! the surface (fdiruv) fraction m*ndim
  1125. ! all-sky diffuse downward uv flux at
  1126. ! the surface (fdifuv) fraction m*ndim
  1127. ! all-sky direct downward par flux at
  1128. ! the surface (fdirpar) fraction m*ndim
  1129. ! all-sky diffuse downward par flux at
  1130. ! the surface (fdifpar) fraction m*ndim
  1131. !
  1132. !***********************************************************************
  1133. implicit none
  1134. !***********************************************************************
  1135. !-----input parameters
  1136. integer m,n,ndim,np
  1137. integer ict(m,ndim),icb(m,ndim)
  1138. real taucld(m,ndim,np,2),reff(m,ndim,np,2),fcld(m,ndim,np)
  1139. real cc(m,n,3),cosz(m,ndim)
  1140. real cwp(m,n,np,2),oh(m,n,np),dp(m,n,np)
  1141. real taual(m,ndim,np,11),ssaal(m,ndim,np,11),asyal(m,ndim,np,11)
  1142. real rsuvbm(m,ndim),rsuvdf(m,ndim),csm(m,n)
  1143. logical overcast,cldwater
  1144. !-----output (updated) parameter
  1145. real flx(m,ndim,np+1),flc(m,ndim,np+1)
  1146. real flxu(m,ndim,np+1),flxd(m,ndim,np+1)
  1147. real fdiruv (m,ndim),fdifuv (m,ndim)
  1148. real fdirpar(m,ndim),fdifpar(m,ndim)
  1149. !-----static parameters
  1150. integer nband
  1151. parameter (nband=8)
  1152. real hk(nband),xk(nband),ry(nband)
  1153. real aig(3),awg(3)
  1154. !-----temporary array
  1155. integer i,j,k,ib
  1156. real tauclb(m,n,np),tauclf(m,n,np),asycl(m,n,np)
  1157. real taurs,tauoz,tausto,ssatau,asysto,tauto,ssato,asyto
  1158. real taux,reff1,reff2,g1,g2
  1159. real td(m,n,np+1,2),rr(m,n,np+1,2),tt(m,n,np+1,2), &
  1160. rs(m,n,np+1,2),ts(m,n,np+1,2)
  1161. real fall(m,n,np+1),fclr(m,n,np+1),fsdir(m,n),fsdif(m,n)
  1162. real fallu(m,n,np+1),falld(m,n,np+1)
  1163. real asyclt(m,n)
  1164. real rr1t(m,n),tt1t(m,n),td1t(m,n),rs1t(m,n),ts1t(m,n)
  1165. real rr2t(m,n),tt2t(m,n),td2t(m,n),rs2t(m,n),ts2t(m,n)
  1166. !-----hk is the fractional extra-terrestrial solar flux in each
  1167. ! of the 8 bands. the sum of hk is 0.47074.
  1168. data hk/.00057, .00367, .00083, .00417, &
  1169. .00600, .00556, .05913, .39081/
  1170. !-----xk is the ozone absorption coefficient. unit: /(cm-atm)stp
  1171. data xk /30.47, 187.2, 301.9, 42.83, &
  1172. 7.09, 1.25, 0.0345, 0.0539/
  1173. !-----ry is the extinction coefficient for Rayleigh scattering.
  1174. ! unit: /mb.
  1175. data ry /.00604, .00170, .00222, .00132, &
  1176. .00107, .00091, .00055, .00012/
  1177. !-----coefficients for computing the asymmetry factor of ice clouds
  1178. ! from asycl=aig(*,1)+aig(*,2)*reff+aig(*,3)*reff**2, independent
  1179. ! of spectral band.
  1180. data aig/.74625000,.00105410,-.00000264/
  1181. !-----coefficients for computing the asymmetry factor of liquid
  1182. ! clouds from asycl=awg(*,1)+awg(*,2)*reff+awg(*,3)*reff**2,
  1183. ! independent of spectral band.
  1184. data awg/.82562000,.00529000,-.00014866/
  1185. !-----initialize fdiruv, fdifuv, surface reflectances and transmittances.
  1186. ! cc is the maximum cloud cover in each of the three cloud groups.
  1187. do j= 1, n
  1188. do i= 1, m
  1189. fdiruv(i,j)=0.0
  1190. fdifuv(i,j)=0.0
  1191. rr(i,j,np+1,1)=rsuvbm(i,j)
  1192. rr(i,j,np+1,2)=rsuvbm(i,j)
  1193. rs(i,j,np+1,1)=rsuvdf(i,j)
  1194. rs(i,j,np+1,2)=rsuvdf(i,j)
  1195. td(i,j,np+1,1)=0.0
  1196. td(i,j,np+1,2)=0.0
  1197. tt(i,j,np+1,1)=0.0
  1198. tt(i,j,np+1,2)=0.0
  1199. ts(i,j,np+1,1)=0.0
  1200. ts(i,j,np+1,2)=0.0
  1201. cc(i,j,1)=0.0
  1202. cc(i,j,2)=0.0
  1203. cc(i,j,3)=0.0
  1204. enddo
  1205. enddo
  1206. !-----compute cloud optical thickness
  1207. if (cldwater) then
  1208. do k= 1, np
  1209. do j= 1, n
  1210. do i= 1, m
  1211. taucld(i,j,k,1)=cwp(i,j,k,1)*( 3.33e-4+2.52/reff(i,j,k,1))
  1212. taucld(i,j,k,2)=cwp(i,j,k,2)*(-6.59e-3+1.65/reff(i,j,k,2))
  1213. enddo
  1214. enddo
  1215. enddo
  1216. endif
  1217. !-----options for scaling cloud optical thickness
  1218. if (overcast) then
  1219. do k= 1, np
  1220. do j= 1, n
  1221. do i= 1, m
  1222. tauclb(i,j,k)=taucld(i,j,k,1)+taucld(i,j,k,2)
  1223. tauclf(i,j,k)=tauclb(i,j,k)
  1224. enddo
  1225. enddo
  1226. enddo
  1227. do k= 1, 3
  1228. do j= 1, n
  1229. do i= 1, m
  1230. cc(i,j,k)=1.0
  1231. enddo
  1232. enddo
  1233. enddo
  1234. else
  1235. !-----scale cloud optical thickness in each layer from taucld (with
  1236. ! cloud amount fcld) to tauclb and tauclf (with cloud amount cc).
  1237. ! tauclb is the scaled optical thickness for beam radiation and
  1238. ! tauclf is for diffuse radiation.
  1239. call cldscale(m,n,ndim,np,cosz,fcld,taucld,ict,icb, &
  1240. cc,tauclb,tauclf)
  1241. endif
  1242. !-----compute cloud asymmetry factor for a mixture of
  1243. ! liquid and ice particles. unit of reff is micrometers.
  1244. do k= 1, np
  1245. do j= 1, n
  1246. do i= 1, m
  1247. asyclt(i,j)=1.0
  1248. taux=taucld(i,j,k,1)+taucld(i,j,k,2)
  1249. if (taux.gt.0.05 .and. fcld(i,j,k).gt.0.01) then
  1250. reff1=min(reff(i,j,k,1),130.)
  1251. reff2=min(reff(i,j,k,2),20.0)
  1252. g1=(aig(1)+(aig(2)+aig(3)*reff1)*reff1)*taucld(i,j,k,1)
  1253. g2=(awg(1)+(awg(2)+awg(3)*reff2)*reff2)*taucld(i,j,k,2)
  1254. asyclt(i,j)=(g1+g2)/taux
  1255. endif
  1256. enddo
  1257. enddo
  1258. do j=1,n
  1259. do i=1,m
  1260. asycl(i,j,k)=asyclt(i,j)
  1261. enddo
  1262. enddo
  1263. enddo
  1264. !-----integration over spectral bands
  1265. do 100 ib=1,nband
  1266. do 300 k= 1, np
  1267. do j= 1, n
  1268. do i= 1, m
  1269. !-----compute ozone and rayleigh optical thicknesses
  1270. taurs=ry(ib)*dp(i,j,k)
  1271. tauoz=xk(ib)*oh(i,j,k)
  1272. !-----compute clear-sky optical thickness, single scattering albedo,
  1273. ! and asymmetry factor
  1274. tausto=taurs+tauoz+taual(i,j,k,ib)+1.0e-8
  1275. ssatau=ssaal(i,j,k,ib)*taual(i,j,k,ib)+taurs
  1276. asysto=asyal(i,j,k,ib)*ssaal(i,j,k,ib)*taual(i,j,k,ib)
  1277. tauto=tausto
  1278. ssato=ssatau/tauto+1.0e-8
  1279. ssato=min(ssato,0.999999)
  1280. asyto=asysto/(ssato*tauto)
  1281. !-----compute reflectance and transmittance for cloudless layers
  1282. !- for direct incident radiation
  1283. call deledd (tauto,ssato,asyto,csm(i,j), &
  1284. rr1t(i,j),tt1t(i,j),td1t(i,j))
  1285. !- for diffuse incident radiation
  1286. call sagpol (tauto,ssato,asyto,rs1t(i,j),ts1t(i,j))
  1287. !-----compute reflectance and transmittance for cloud layers
  1288. if (tauclb(i,j,k).lt.0.01 .or. fcld(i,j,k).lt.0.01) then
  1289. rr2t(i,j)=rr1t(i,j)
  1290. tt2t(i,j)=tt1t(i,j)
  1291. td2t(i,j)=td1t(i,j)
  1292. rs2t(i,j)=rs1t(i,j)
  1293. ts2t(i,j)=ts1t(i,j)
  1294. else
  1295. !-- for direct incident radiation
  1296. tauto=tausto+tauclb(i,j,k)
  1297. ssato=(ssatau+tauclb(i,j,k))/tauto+1.0e-8
  1298. ssato=min(ssato,0.999999)
  1299. asyto=(asysto+asycl(i,j,k)*tauclb(i,j,k))/(ssato*tauto)
  1300. call deledd (tauto,ssato,asyto,csm(i,j), &
  1301. rr2t(i,j),tt2t(i,j),td2t(i,j))
  1302. !-- for diffuse incident radiation
  1303. tauto=tausto+tauclf(i,j,k)
  1304. ssato=(ssatau+tauclf(i,j,k))/tauto+1.0e-8
  1305. ssato=min(ssato,0.999999)
  1306. asyto=(asysto+asycl(i,j,k)*tauclf(i,j,k))/(ssato*tauto)
  1307. call sagpol (tauto,ssato,asyto,rs2t(i,j),ts2t(i,j))
  1308. endif
  1309. enddo
  1310. enddo
  1311. do j=1,n
  1312. do i=1,m
  1313. rr(i,j,k,1)=rr1t(i,j)
  1314. enddo
  1315. enddo
  1316. do j=1,n
  1317. do i=1,m
  1318. tt(i,j,k,1)=tt1t(i,j)
  1319. enddo
  1320. enddo
  1321. do j=1,n
  1322. do i=1,m
  1323. td(i,j,k,1)=td1t(i,j)
  1324. enddo
  1325. enddo
  1326. do j=1,n
  1327. do i=1,m
  1328. rs(i,j,k,1)=rs1t(i,j)
  1329. enddo
  1330. enddo
  1331. do j=1,n
  1332. do i=1,m
  1333. ts(i,j,k,1)=ts1t(i,j)
  1334. enddo
  1335. enddo
  1336. do j=1,n
  1337. do i=1,m
  1338. rr(i,j,k,2)=rr2t(i,j)
  1339. enddo
  1340. enddo
  1341. do j=1,n
  1342. do i=1,m
  1343. tt(i,j,k,2)=tt2t(i,j)
  1344. enddo
  1345. enddo
  1346. do j=1,n
  1347. do i=1,m
  1348. td(i,j,k,2)=td2t(i,j)
  1349. enddo
  1350. enddo
  1351. do j=1,n
  1352. do i=1,m
  1353. rs(i,j,k,2)=rs2t(i,j)
  1354. enddo
  1355. enddo
  1356. do j=1,n
  1357. do i=1,m
  1358. ts(i,j,k,2)=ts2t(i,j)
  1359. enddo
  1360. enddo
  1361. 300 continue
  1362. !-----flux calculations
  1363. call cldflx (m,n,np,ict,icb,overcast,cc,rr,tt,td,rs,ts, &
  1364. fclr,fall,fallu,falld,fsdir,fsdif)
  1365. do k= 1, np+1
  1366. do j= 1, n
  1367. do i= 1, m
  1368. flx(i,j,k)=flx(i,j,k)+fall(i,j,k)*hk(ib)
  1369. flxu(i,j,k)=flxu(i,j,k)+fallu(i,j,k)*hk(ib)
  1370. flxd(i,j,k)=flxd(i,j,k)+falld(i,j,k)*hk(ib)
  1371. enddo
  1372. enddo
  1373. do j= 1, n
  1374. do i= 1, m
  1375. flc(i,j,k)=flc(i,j,k)+fclr(i,j,k)*hk(ib)
  1376. enddo
  1377. enddo
  1378. enddo
  1379. !-----compute downward surface fluxes in the UV and par regions
  1380. if(ib.lt.8) then
  1381. do j=1,n
  1382. do i=1,m
  1383. fdiruv(i,j)=fdiruv(i,j)+fsdir(i,j)*hk(ib)
  1384. fdifuv(i,j)=fdifuv(i,j)+fsdif(i,j)*hk(ib)
  1385. enddo
  1386. enddo
  1387. else
  1388. do j=1,n
  1389. do i=1,m
  1390. fdirpar(i,j)=fsdir(i,j)*hk(ib)
  1391. fdifpar(i,j)=fsdif(i,j)*hk(ib)
  1392. enddo
  1393. enddo
  1394. endif
  1395. 100 continue
  1396. end subroutine soluv
  1397. !************************************************************************
  1398. subroutine solir (m,n,ndim,np,wh,overcast,cldwater, &
  1399. cwp,taucld,reff,ict,icb,fcld,cosz, &
  1400. taual,ssaal,asyal,csm,rsirbm,rsirdf, &
  1401. flx,flc,flxu,flxd,fdirir,fdifir)
  1402. !************************************************************************
  1403. ! compute solar flux in the infrared region. The spectrum is divided
  1404. ! into three bands:
  1405. !
  1406. ! band wavenumber(/cm) wavelength (micron)
  1407. ! 1( 9) 14300-8200 0.70-1.22
  1408. ! 2(10) 8200-4400 1.22-2.27
  1409. ! 3(11) 4400-1000 2.27-10.0
  1410. !
  1411. !----- Input parameters: units size
  1412. !
  1413. ! number of soundings in zonal direction (m) n/d 1
  1414. ! number of soundings in meridional direction (n) n/d 1
  1415. ! maximum number of soundings in n/d 1
  1416. ! meridional direction (ndim)
  1417. ! number of atmospheric layers (np) n/d 1
  1418. ! layer scaled-water vapor content (wh) gm/cm^2 m*n*np
  1419. ! option for scaling cloud optical thickness n/d 1
  1420. ! overcast="true" if scaling is NOT required
  1421. ! overcast="fasle" if scaling is required
  1422. ! input option for cloud optical thickness n/d 1
  1423. ! cldwater="true" if taucld is provided
  1424. ! cldwater="false" if cwp is provided
  1425. ! cloud water concentration (cwp) gm/m**2 m*n*np*2
  1426. ! index 1 for ice particles
  1427. ! index 2 for liquid drops
  1428. ! cloud optical thickness (taucld) n/d m*ndim*np*2
  1429. ! index 1 for ice paticles
  1430. ! effective cloud-particle size (reff) micrometer m*ndim*np*2
  1431. ! index 1 for ice paticles
  1432. ! index 2 for liquid particles
  1433. ! level index separating high and n/d m*n
  1434. ! middle clouds (ict)
  1435. ! level index separating middle and n/d m*n
  1436. ! low clouds (icb)
  1437. ! cloud amount (fcld) fraction m*ndim*np
  1438. ! aerosol optical thickness (taual) n/d m*ndim*np*11
  1439. ! aerosol single-scattering albedo (ssaal) n/d m*ndim*np*11
  1440. ! aerosol asymmetry factor (asyal) n/d m*ndim*np*11
  1441. ! cosecant of the solar zenith angle (csm) n/d m*n
  1442. ! near ir surface albedo for beam fraction m*ndim
  1443. ! radiation (rsirbm)
  1444. ! near ir surface albedo for diffuse fraction m*ndim
  1445. ! radiation (rsirdf)
  1446. !
  1447. !---- temporary array
  1448. !
  1449. ! scaled cloud optical thickness n/d m*n*np
  1450. ! for beam radiation (tauclb)
  1451. ! scaled cloud optical thickness n/d m*n*np
  1452. ! for diffuse radiation (tauclf)
  1453. !
  1454. !----- output (updated) parameters:
  1455. !
  1456. ! all-sky flux (downward-upward) (flx) fraction m*ndim*(np+1)
  1457. ! clear-sky flux (downward-upward) (flc) fraction m*ndim*(np+1)
  1458. ! all-sky direct downward ir flux at
  1459. ! the surface (fdirir) fraction m*ndim
  1460. ! all-sky diffuse downward ir flux at
  1461. ! the surface (fdifir) fraction m*ndim
  1462. !
  1463. !**********************************************************************
  1464. implicit none
  1465. !**********************************************************************
  1466. !-----input parameters
  1467. integer m,n,ndim,np
  1468. integer ict(m,ndim),icb(m,ndim)
  1469. real cwp(m,n,np,2),taucld(m,ndim,np,2),reff(m,ndim,np,2)
  1470. real fcld(m,ndim,np),cc(m,n,3),cosz(m,ndim)
  1471. real rsirbm(m,ndim),rsirdf(m,ndim)
  1472. real taual(m,ndim,np,11),ssaal(m,ndim,np,11),asyal(m,ndim,np,11)
  1473. real wh(m,n,np),csm(m,n)
  1474. logical overcast,cldwater
  1475. !-----output (updated) parameters
  1476. real flx(m,ndim,np+1),flc(m,ndim,np+1)
  1477. real flxu(m,ndim,np+1),flxd(m,ndim,np+1)
  1478. real fdirir(m,ndim),fdifir(m,ndim)
  1479. !-----static parameters
  1480. integer nk,nband
  1481. parameter (nk=10,nband=3)
  1482. real xk(nk),hk(nband,nk),aib(nband,2),awb(nband,2)
  1483. real aia(nband,3),awa(nband,3),aig(nband,3),awg(nband,3)
  1484. !-----temporary array
  1485. integer ib,iv,ik,i,j,k
  1486. real tauclb(m,n,np),tauclf(m,n,np)
  1487. real ssacl(m,n,np),asycl(m,n,np)
  1488. real rr(m,n,np+1,2),tt(m,n,np+1,2),td(m,n,np+1,2), &
  1489. rs(m,n,np+1,2),ts(m,n,np+1,2)
  1490. real fall(m,n,np+1),fclr(m,n,np+1)
  1491. real fallu(m,n,np+1),falld(m,n,np+1)
  1492. real fsdir(m,n),fsdif(m,n)
  1493. real tauwv,tausto,ssatau,asysto,tauto,ssato,asyto
  1494. real taux,reff1,reff2,w1,w2,g1,g2
  1495. real ssaclt(m,n),asyclt(m,n)
  1496. real rr1t(m,n),tt1t(m,n),td1t(m,n),rs1t(m,n),ts1t(m,n)
  1497. real rr2t(m,n),tt2t(m,n),td2t(m,n),rs2t(m,n),ts2t(m,n)
  1498. !-----water vapor absorption coefficient for 10 k-intervals.
  1499. ! unit: cm^2/gm
  1500. data xk/ &
  1501. 0.0010, 0.0133, 0.0422, 0.1334, 0.4217, &
  1502. 1.334, 5.623, 31.62, 177.8, 1000.0/
  1503. !-----water vapor k-distribution function,
  1504. ! the sum of hk is 0.52926. unit: fraction
  1505. data hk/ &
  1506. .20673,.08236,.01074, .03497,.01157,.00360, &
  1507. .03011,.01133,.00411, .02260,.01143,.00421, &
  1508. .01336,.01240,.00389, .00696,.01258,.00326, &
  1509. .00441,.01381,.00499, .00115,.00650,.00465, &
  1510. .00026,.00244,.00245, .00000,.00094,.00145/
  1511. !-----coefficients for computing the extinction coefficient of
  1512. ! ice clouds from b=aib(*,1)+aib(*,2)/reff
  1513. data aib/ &
  1514. .000333, .000333, .000333, &
  1515. 2.52, 2.52, 2.52/
  1516. !-----coefficients for computing the extinction coefficient of
  1517. ! water clouds from b=awb(*,1)+awb(*,2)/reff
  1518. data awb/ &
  1519. -0.0101, -0.0166, -0.0339, &
  1520. 1.72, 1.85, 2.16/
  1521. !-----coefficients for computing the single scattering albedo of
  1522. ! ice clouds from ssa=1-(aia(*,1)+aia(*,2)*reff+aia(*,3)*reff**2)
  1523. data aia/ &
  1524. -.00000260, .00215346, .08938331, &
  1525. .00000746, .00073709, .00299387, &
  1526. .00000000,-.00000134,-.00001038/
  1527. !-----coefficients for computing the single scattering albedo of
  1528. ! liquid clouds from ssa=1-(awa(*,1)+awa(*,2)*reff+awa(*,3)*reff**2)
  1529. data awa/ &
  1530. .00000007,-.00019934, .01209318, &
  1531. .00000845, .00088757, .01784739, &
  1532. -.00000004,-.00000650,-.00036910/
  1533. !-----coefficients for computing the asymmetry factor of ice clouds
  1534. ! from asycl=aig(*,1)+aig(*,2)*reff+aig(*,3)*reff**2
  1535. data aig/ &
  1536. .74935228, .76098937, .84090400, &
  1537. .00119715, .00141864, .00126222, &
  1538. -.00000367,-.00000396,-.00000385/
  1539. !-----coefficients for computing the asymmetry factor of liquid clouds
  1540. ! from asycl=awg(*,1)+awg(*,2)*reff+awg(*,3)*reff**2
  1541. data awg/ &
  1542. .79375035, .74513197, .83530748, &
  1543. .00832441, .01370071, .00257181, &
  1544. -.00023263,-.00038203, .00005519/
  1545. !-----initialize surface fluxes, reflectances, and transmittances.
  1546. ! cc is the maximum cloud cover in each of the three cloud groups.
  1547. do j= 1, n
  1548. do i= 1, m
  1549. fdirir(i,j)=0.0
  1550. fdifir(i,j)=0.0
  1551. rr(i,j,np+1,1)=rsirbm(i,j)
  1552. rr(i,j,np+1,2)=rsirbm(i,j)
  1553. rs(i,j,np+1,1)=rsirdf(i,j)
  1554. rs(i,j,np+1,2)=rsirdf(i,j)
  1555. td(i,j,np+1,1)=0.0
  1556. td(i,j,np+1,2)=0.0
  1557. tt(i,j,np+1,1)=0.0
  1558. tt(i,j,np+1,2)=0.0
  1559. ts(i,j,np+1,1)=0.0
  1560. ts(i,j,np+1,2)=0.0
  1561. cc(i,j,1)=0.0
  1562. cc(i,j,2)=0.0
  1563. cc(i,j,3)=0.0
  1564. enddo
  1565. enddo
  1566. !-----integration over spectral bands
  1567. do 100 ib=1,nband
  1568. iv=ib+8
  1569. !-----compute cloud optical thickness
  1570. if (cldwater) then
  1571. do k= 1, np
  1572. do j= 1, n
  1573. do i= 1, m
  1574. taucld(i,j,k,1)=cwp(i,j,k,1)*(aib(ib,1) &
  1575. +aib(ib,2)/reff(i,j,k,1))
  1576. taucld(i,j,k,2)=cwp(i,j,k,2)*(awb(ib,1) &
  1577. +awb(ib,2)/reff(i,j,k,2))
  1578. enddo
  1579. enddo
  1580. enddo
  1581. endif
  1582. !-----options for scaling cloud optical thickness
  1583. if (overcast) then
  1584. do k= 1, np
  1585. do j= 1, n
  1586. do i= 1, m
  1587. tauclb(i,j,k)=taucld(i,j,k,1)+taucld(i,j,k,2)
  1588. tauclf(i,j,k)=tauclb(i,j,k)
  1589. enddo
  1590. enddo
  1591. enddo
  1592. do k= 1, 3
  1593. do j= 1, n
  1594. do i= 1, m
  1595. cc(i,j,k)=1.0
  1596. enddo
  1597. enddo
  1598. enddo
  1599. else
  1600. !-----scale cloud optical thickness in each layer from taucld (with
  1601. ! cloud amount fcld) to tauclb and tauclf (with cloud amount cc).
  1602. ! tauclb is the scaled optical thickness for beam radiation and
  1603. ! tauclf is for diffuse radiation.
  1604. call cldscale(m,n,ndim,np,cosz,fcld,taucld,ict,icb, &
  1605. cc,tauclb,tauclf)
  1606. endif
  1607. !-----compute cloud single scattering albedo and asymmetry factor
  1608. ! for a mixture of ice and liquid particles.
  1609. do k= 1, np
  1610. do j= 1, n
  1611. do i= 1, m
  1612. ssaclt(i,j)=1.0
  1613. asyclt(i,j)=1.0
  1614. taux=taucld(i,j,k,1)+taucld(i,j,k,2)
  1615. if (taux.gt.0.05 .and. fcld(i,j,k).gt.0.01) then
  1616. reff1=min(reff(i,j,k,1),130.)
  1617. reff2=min(reff(i,j,k,2),20.0)
  1618. w1=(1.-(aia(ib,1)+(aia(ib,2)+ &
  1619. aia(ib,3)*reff1)*reff1))*taucld(i,j,k,1)
  1620. w2=(1.-(awa(ib,1)+(awa(ib,2)+ &
  1621. awa(ib,3)*reff2)*reff2))*taucld(i,j,k,2)
  1622. ssaclt(i,j)=(w1+w2)/taux
  1623. g1=(aig(ib,1)+(aig(ib,2)+aig(ib,3)*reff1)*reff1)*w1
  1624. g2=(awg(ib,1)+(awg(ib,2)+awg(ib,3)*reff2)*reff2)*w2
  1625. asyclt(i,j)=(g1+g2)/(w1+w2)
  1626. endif
  1627. enddo
  1628. enddo
  1629. do j=1,n
  1630. do i=1,m
  1631. ssacl(i,j,k)=ssaclt(i,j)
  1632. enddo
  1633. enddo
  1634. do j=1,n
  1635. do i=1,m
  1636. asycl(i,j,k)=asyclt(i,j)
  1637. enddo
  1638. enddo
  1639. enddo
  1640. !-----integration over the k-distribution function
  1641. do 200 ik=1,nk
  1642. do 300 k= 1, np
  1643. do j= 1, n
  1644. do i= 1, m
  1645. tauwv=xk(ik)*wh(i,j,k)
  1646. !-----compute clear-sky optical thickness, single scattering albedo,
  1647. ! and asymmetry factor.
  1648. tausto=tauwv+taual(i,j,k,iv)+1.0e-8
  1649. ssatau=ssaal(i,j,k,iv)*taual(i,j,k,iv)
  1650. asysto=asyal(i,j,k,iv)*ssaal(i,j,k,iv)*taual(i,j,k,iv)
  1651. !-----compute reflectance and transmittance for cloudless layers
  1652. tauto=tausto
  1653. ssato=ssatau/tauto+1.0e-8
  1654. if (ssato .gt. 0.001) then
  1655. ssato=min(ssato,0.999999)
  1656. asyto=asysto/(ssato*tauto)
  1657. !- for direct incident radiation
  1658. call deledd (tauto,ssato,asyto,csm(i,j), &
  1659. rr1t(i,j),tt1t(i,j),td1t(i,j))
  1660. !- for diffuse incident radiation
  1661. call sagpol (tauto,ssato,asyto,rs1t(i,j),ts1t(i,j))
  1662. else
  1663. td1t(i,j)=exp(-tauto*csm(i,j))
  1664. ts1t(i,j)=exp(-1.66*tauto)
  1665. tt1t(i,j)=0.0
  1666. rr1t(i,j)=0.0
  1667. rs1t(i,j)=0.0
  1668. endif
  1669. !-----compute reflectance and transmittance for cloud layers
  1670. if (tauclb(i,j,k).lt.0.01 .or. fcld(i,j,k).lt.0.01) then
  1671. rr2t(i,j)=rr1t(i,j)
  1672. tt2t(i,j)=tt1t(i,j)
  1673. td2t(i,j)=td1t(i,j)
  1674. rs2t(i,j)=rs1t(i,j)
  1675. ts2t(i,j)=ts1t(i,j)
  1676. else
  1677. !- for direct incident radiation
  1678. tauto=tausto+tauclb(i,j,k)
  1679. ssato=(ssatau+ssacl(i,j,k)*tauclb(i,j,k))/tauto+1.0e-8
  1680. ssato=min(ssato,0.999999)
  1681. asyto=(asysto+asycl(i,j,k)*ssacl(i,j,k)*tauclb(i,j,k))/ &
  1682. (ssato*tauto)
  1683. call deledd (tauto,ssato,asyto,csm(i,j), &
  1684. rr2t(i,j),tt2t(i,j),td2t(i,j))
  1685. !- for diffuse incident radiation
  1686. tauto=tausto+tauclf(i,j,k)
  1687. ssato=(ssatau+ssacl(i,j,k)*tauclf(i,j,k))/tauto+1.0e-8
  1688. ssato=min(ssato,0.999999)
  1689. asyto=(asysto+asycl(i,j,k)*ssacl(i,j,k)*tauclf(i,j,k))/ &
  1690. (ssato*tauto)
  1691. call sagpol (tauto,ssato,asyto,rs2t(i,j),ts2t(i,j))
  1692. endif
  1693. enddo
  1694. enddo
  1695. do j=1,n
  1696. do i=1,m
  1697. rr(i,j,k,1)=rr1t(i,j)
  1698. enddo
  1699. enddo
  1700. do j=1,n
  1701. do i=1,m
  1702. tt(i,j,k,1)=tt1t(i,j)
  1703. enddo
  1704. enddo
  1705. do j=1,n
  1706. do i=1,m
  1707. td(i,j,k,1)=td1t(i,j)
  1708. enddo
  1709. enddo
  1710. do j=1,n
  1711. do i=1,m
  1712. rs(i,j,k,1)=rs1t(i,j)
  1713. enddo
  1714. enddo
  1715. do j=1,n
  1716. do i=1,m
  1717. ts(i,j,k,1)=ts1t(i,j)
  1718. enddo
  1719. enddo
  1720. do j=1,n
  1721. do i=1,m
  1722. rr(i,j,k,2)=rr2t(i,j)
  1723. enddo
  1724. enddo
  1725. do j=1,n
  1726. do i=1,m
  1727. tt(i,j,k,2)=tt2t(i,j)
  1728. enddo
  1729. enddo
  1730. do j=1,n
  1731. do i=1,m
  1732. td(i,j,k,2)=td2t(i,j)
  1733. enddo
  1734. enddo
  1735. do j=1,n
  1736. do i=1,m
  1737. rs(i,j,k,2)=rs2t(i,j)
  1738. enddo
  1739. enddo
  1740. do j=1,n
  1741. do i=1,m
  1742. ts(i,j,k,2)=ts2t(i,j)
  1743. enddo
  1744. enddo
  1745. 300 continue
  1746. !-----flux calculations
  1747. call cldflx (m,n,np,ict,icb,overcast,cc,rr,tt,td,rs,ts, &
  1748. fclr,fall,fallu,falld,fsdir,fsdif)
  1749. do k= 1, np+1
  1750. do j= 1, n
  1751. do i= 1, m
  1752. flx(i,j,k) = flx(i,j,k)+fall(i,j,k)*hk(ib,ik)
  1753. flxu(i,j,k) = flxu(i,j,k)+fallu(i,j,k)*hk(ib,ik)
  1754. flxd(i,j,k) = flxd(i,j,k)+falld(i,j,k)*hk(ib,ik)
  1755. enddo
  1756. enddo
  1757. do j= 1, n
  1758. do i= 1, m
  1759. flc(i,j,k) = flc(i,j,k)+fclr(i,j,k)*hk(ib,ik)
  1760. enddo
  1761. enddo
  1762. enddo
  1763. !-----compute downward surface fluxes in the ir region
  1764. do j= 1, n
  1765. do i= 1, m
  1766. fdirir(i,j) = fdirir(i,j)+fsdir(i,j)*hk(ib,ik)
  1767. fdifir(i,j) = fdifir(i,j)+fsdif(i,j)*hk(ib,ik)
  1768. enddo
  1769. enddo
  1770. 200 continue
  1771. 100 continue
  1772. end subroutine solir
  1773. !********************************************************************
  1774. subroutine cldscale (m,n,ndim,np,cosz,fcld,taucld,ict,icb, &
  1775. cc,tauclb,tauclf)
  1776. !********************************************************************
  1777. !
  1778. ! This subroutine computes the high, middle, and
  1779. ! low cloud amounts and scales the cloud optical thickness.
  1780. !
  1781. ! To simplify calculations in a cloudy atmosphere, clouds are
  1782. ! grouped into high, middle and low clouds separated by the levels
  1783. ! ict and icb (level 1 is the top of the model atmosphere).
  1784. !
  1785. ! Within each of the three groups, clouds are assumed maximally
  1786. ! overlapped, and the cloud cover (cc) of a group is the maximum
  1787. ! cloud cover of all the layers in the group. The optical thickness
  1788. ! (taucld) of a given layer is then scaled to new values (tauclb and
  1789. ! tauclf) so that the layer reflectance corresponding to the cloud
  1790. ! cover cc is the same as the original reflectance with optical
  1791. ! thickness taucld and cloud cover fcld.
  1792. !
  1793. !---input parameters
  1794. !
  1795. ! number of grid intervals in zonal direction (m)
  1796. ! number of grid intervals in meridional direction (n)
  1797. ! maximum number of grid intervals in meridional direction (ndim)
  1798. ! number of atmospheric layers (np)
  1799. ! cosine of the solar zenith angle (cosz)
  1800. ! fractional cloud cover (fcld)
  1801. ! cloud optical thickness (taucld)
  1802. ! index separating high and middle clouds (ict)
  1803. ! index separating middle and low clouds (icb)
  1804. !
  1805. !---output parameters
  1806. !
  1807. ! fractional cover of high, middle, and low clouds (cc)
  1808. ! scaled cloud optical thickness for beam radiation (tauclb)
  1809. ! scaled cloud optical thickness for diffuse radiation (tauclf)
  1810. !
  1811. !********************************************************************
  1812. implicit none
  1813. !********************************************************************
  1814. !-----input parameters
  1815. integer m,n,ndim,np
  1816. integer ict(m,ndim),icb(m,ndim)
  1817. real cosz(m,ndim),fcld(m,ndim,np),taucld(m,ndim,np,2)
  1818. !-----output parameters
  1819. real cc(m,n,3),tauclb(m,n,np),tauclf(m,n,np)
  1820. !-----temporary variables
  1821. integer i,j,k,im,it,ia,kk
  1822. real fm,ft,fa,xai,taux
  1823. !-----pre-computed table
  1824. integer nm,nt,na
  1825. parameter (nm=11,nt=9,na=11)
  1826. real dm,dt,da,t1,caib(nm,nt,na),caif(nt,na)
  1827. parameter (dm=0.1,dt=0.30103,da=0.1,t1=-0.9031)
  1828. !-----include the pre-computed table of mcai for scaling the cloud optical
  1829. ! thickness under the assumption that clouds are maximally overlapped
  1830. !
  1831. ! caib is for scaling the cloud optical thickness for direct radiation
  1832. ! caif is for scaling the cloud optical thickness for diffuse radiation
  1833. data ((caib(1,i,j),j=1,11),i=1,9)/ &
  1834. .000,0.068,0.140,0.216,0.298,0.385,0.481,0.586,0.705,0.840,1.000, &
  1835. .000,0.052,0.106,0.166,0.230,0.302,0.383,0.478,0.595,0.752,1.000, &
  1836. .000,0.038,0.078,0.120,0.166,0.218,0.276,0.346,0.438,0.582,1.000, &
  1837. .000,0.030,0.060,0.092,0.126,0.164,0.206,0.255,0.322,0.442,1.000, &
  1838. .000,0.025,0.051,0.078,0.106,0.136,0.170,0.209,0.266,0.462,1.000, &
  1839. .000,0.023,0.046,0.070,0.095,0.122,0.150,0.187,0.278,0.577,1.000, &
  1840. .000,0.022,0.043,0.066,0.089,0.114,0.141,0.187,0.354,0.603,1.000, &
  1841. .000,0.021,0.042,0.063,0.086,0.108,0.135,0.214,0.349,0.565,1.000, &
  1842. .000,0.021,0.041,0.062,0.083,0.105,0.134,0.202,0.302,0.479,1.000/
  1843. data ((caib(2,i,j),j=1,11),i=1,9)/ &
  1844. .000,0.088,0.179,0.272,0.367,0.465,0.566,0.669,0.776,0.886,1.000, &
  1845. .000,0.079,0.161,0.247,0.337,0.431,0.531,0.637,0.749,0.870,1.000, &
  1846. .000,0.065,0.134,0.207,0.286,0.372,0.466,0.572,0.692,0.831,1.000, &
  1847. .000,0.049,0.102,0.158,0.221,0.290,0.370,0.465,0.583,0.745,1.000, &
  1848. .000,0.037,0.076,0.118,0.165,0.217,0.278,0.354,0.459,0.638,1.000, &
  1849. .000,0.030,0.061,0.094,0.130,0.171,0.221,0.286,0.398,0.631,1.000, &
  1850. .000,0.026,0.052,0.081,0.111,0.146,0.189,0.259,0.407,0.643,1.000, &
  1851. .000,0.023,0.047,0.072,0.098,0.129,0.170,0.250,0.387,0.598,1.000, &
  1852. .000,0.022,0.044,0.066,0.090,0.118,0.156,0.224,0.328,0.508,1.000/
  1853. data ((caib(3,i,j),j=1,11),i=1,9)/ &
  1854. .000,0.094,0.189,0.285,0.383,0.482,0.582,0.685,0.788,0.894,1.000, &
  1855. .000,0.088,0.178,0.271,0.366,0.465,0.565,0.669,0.776,0.886,1.000, &
  1856. .000,0.079,0.161,0.247,0.337,0.431,0.531,0.637,0.750,0.870,1.000, &
  1857. .000,0.066,0.134,0.209,0.289,0.375,0.470,0.577,0.697,0.835,1.000, &
  1858. .000,0.050,0.104,0.163,0.227,0.300,0.383,0.483,0.606,0.770,1.000, &
  1859. .000,0.038,0.080,0.125,0.175,0.233,0.302,0.391,0.518,0.710,1.000, &
  1860. .000,0.031,0.064,0.100,0.141,0.188,0.249,0.336,0.476,0.689,1.000, &
  1861. .000,0.026,0.054,0.084,0.118,0.158,0.213,0.298,0.433,0.638,1.000, &
  1862. .000,0.023,0.048,0.074,0.102,0.136,0.182,0.254,0.360,0.542,1.000/
  1863. data ((caib(4,i,j),j=1,11),i=1,9)/ &
  1864. .000,0.096,0.193,0.290,0.389,0.488,0.589,0.690,0.792,0.896,1.000, &
  1865. .000,0.092,0.186,0.281,0.378,0.477,0.578,0.680,0.785,0.891,1.000, &
  1866. .000,0.086,0.174,0.264,0.358,0.455,0.556,0.660,0.769,0.882,1.000, &
  1867. .000,0.074,0.153,0.235,0.323,0.416,0.514,0.622,0.737,0.862,1.000, &
  1868. .000,0.061,0.126,0.195,0.271,0.355,0.449,0.555,0.678,0.823,1.000, &
  1869. .000,0.047,0.098,0.153,0.215,0.286,0.370,0.471,0.600,0.770,1.000, &
  1870. .000,0.037,0.077,0.120,0.170,0.230,0.303,0.401,0.537,0.729,1.000, &
  1871. .000,0.030,0.062,0.098,0.138,0.187,0.252,0.343,0.476,0.673,1.000, &
  1872. .000,0.026,0.053,0.082,0.114,0.154,0.207,0.282,0.391,0.574,1.000/
  1873. data ((caib(5,i,j),j=1,11),i=1,9)/ &
  1874. .000,0.097,0.194,0.293,0.392,0.492,0.592,0.693,0.794,0.897,1.000, &
  1875. .000,0.094,0.190,0.286,0.384,0.483,0.584,0.686,0.789,0.894,1.000, &
  1876. .000,0.090,0.181,0.274,0.370,0.468,0.569,0.672,0.778,0.887,1.000, &
  1877. .000,0.081,0.165,0.252,0.343,0.439,0.539,0.645,0.757,0.874,1.000, &
  1878. .000,0.069,0.142,0.218,0.302,0.392,0.490,0.598,0.717,0.850,1.000, &
  1879. .000,0.054,0.114,0.178,0.250,0.330,0.422,0.529,0.656,0.810,1.000, &
  1880. .000,0.042,0.090,0.141,0.200,0.269,0.351,0.455,0.589,0.764,1.000, &
  1881. .000,0.034,0.070,0.112,0.159,0.217,0.289,0.384,0.515,0.703,1.000, &
  1882. .000,0.028,0.058,0.090,0.128,0.174,0.231,0.309,0.420,0.602,1.000/
  1883. data ((caib(6,i,j),j=1,11),i=1,9)/ &
  1884. .000,0.098,0.196,0.295,0.394,0.494,0.594,0.695,0.796,0.898,1.000, &
  1885. .000,0.096,0.193,0.290,0.389,0.488,0.588,0.690,0.792,0.895,1.000, &
  1886. .000,0.092,0.186,0.281,0.378,0.477,0.577,0.680,0.784,0.891,1.000, &
  1887. .000,0.086,0.174,0.264,0.358,0.455,0.556,0.661,0.769,0.882,1.000, &
  1888. .000,0.075,0.154,0.237,0.325,0.419,0.518,0.626,0.741,0.865,1.000, &
  1889. .000,0.062,0.129,0.201,0.279,0.366,0.462,0.571,0.694,0.836,1.000, &
  1890. .000,0.049,0.102,0.162,0.229,0.305,0.394,0.501,0.631,0.793,1.000, &
  1891. .000,0.038,0.080,0.127,0.182,0.245,0.323,0.422,0.550,0.730,1.000, &
  1892. .000,0.030,0.064,0.100,0.142,0.192,0.254,0.334,0.448,0.627,1.000/
  1893. data ((caib(7,i,j),j=1,11),i=1,9)/ &
  1894. .000,0.098,0.198,0.296,0.396,0.496,0.596,0.696,0.797,0.898,1.000, &
  1895. .000,0.097,0.194,0.293,0.392,0.491,0.591,0.693,0.794,0.897,1.000, &
  1896. .000,0.094,0.190,0.286,0.384,0.483,0.583,0.686,0.789,0.894,1.000, &
  1897. .000,0.089,0.180,0.274,0.369,0.467,0.568,0.672,0.778,0.887,1.000, &
  1898. .000,0.081,0.165,0.252,0.344,0.440,0.541,0.646,0.758,0.875,1.000, &
  1899. .000,0.069,0.142,0.221,0.306,0.397,0.496,0.604,0.722,0.854,1.000, &
  1900. .000,0.056,0.116,0.182,0.256,0.338,0.432,0.540,0.666,0.816,1.000, &
  1901. .000,0.043,0.090,0.143,0.203,0.273,0.355,0.455,0.583,0.754,1.000, &
  1902. .000,0.034,0.070,0.111,0.157,0.210,0.276,0.359,0.474,0.650,1.000/
  1903. data ((caib(8,i,j),j=1,11),i=1,9)/ &
  1904. .000,0.099,0.198,0.298,0.398,0.497,0.598,0.698,0.798,0.899,1.000, &
  1905. .000,0.098,0.196,0.295,0.394,0.494,0.594,0.695,0.796,0.898,1.000, &
  1906. .000,0.096,0.193,0.290,0.390,0.489,0.589,0.690,0.793,0.896,1.000, &
  1907. .000,0.093,0.186,0.282,0.379,0.478,0.578,0.681,0.786,0.892,1.000, &
  1908. .000,0.086,0.175,0.266,0.361,0.458,0.558,0.663,0.771,0.883,1.000, &
  1909. .000,0.076,0.156,0.240,0.330,0.423,0.523,0.630,0.744,0.867,1.000, &
  1910. .000,0.063,0.130,0.203,0.282,0.369,0.465,0.572,0.694,0.834,1.000, &
  1911. .000,0.049,0.102,0.161,0.226,0.299,0.385,0.486,0.611,0.774,1.000, &
  1912. .000,0.038,0.078,0.122,0.172,0.229,0.297,0.382,0.498,0.672,1.000/
  1913. data ((caib(9,i,j),j=1,11),i=1,9)/ &
  1914. .000,0.099,0.199,0.298,0.398,0.498,0.598,0.699,0.799,0.899,1.000, &
  1915. .000,0.099,0.198,0.298,0.398,0.497,0.598,0.698,0.798,0.899,1.000, &
  1916. .000,0.098,0.196,0.295,0.394,0.494,0.594,0.695,0.796,0.898,1.000, &
  1917. .000,0.096,0.193,0.290,0.389,0.488,0.588,0.690,0.792,0.895,1.000, &
  1918. .000,0.092,0.185,0.280,0.376,0.474,0.575,0.678,0.782,0.890,1.000, &
  1919. .000,0.084,0.170,0.259,0.351,0.447,0.547,0.652,0.762,0.878,1.000, &
  1920. .000,0.071,0.146,0.224,0.308,0.398,0.494,0.601,0.718,0.850,1.000, &
  1921. .000,0.056,0.114,0.178,0.248,0.325,0.412,0.514,0.638,0.793,1.000, &
  1922. .000,0.042,0.086,0.134,0.186,0.246,0.318,0.405,0.521,0.691,1.000/
  1923. data ((caib(10,i,j),j=1,11),i=1,9)/ &
  1924. .000,0.100,0.200,0.300,0.400,0.500,0.600,0.700,0.800,0.900,1.000, &
  1925. .000,0.100,0.200,0.300,0.400,0.500,0.600,0.700,0.800,0.900,1.000, &
  1926. .000,0.100,0.200,0.300,0.400,0.500,0.600,0.700,0.800,0.900,1.000, &
  1927. .000,0.100,0.199,0.298,0.398,0.498,0.598,0.698,0.798,0.899,1.000, &
  1928. .000,0.098,0.196,0.294,0.392,0.491,0.590,0.691,0.793,0.896,1.000, &
  1929. .000,0.092,0.185,0.278,0.374,0.470,0.570,0.671,0.777,0.886,1.000, &
  1930. .000,0.081,0.162,0.246,0.333,0.424,0.521,0.625,0.738,0.862,1.000, &
  1931. .000,0.063,0.128,0.196,0.270,0.349,0.438,0.540,0.661,0.809,1.000, &
  1932. .000,0.046,0.094,0.146,0.202,0.264,0.337,0.426,0.542,0.710,1.000/
  1933. data ((caib(11,i,j),j=1,11),i=1,9)/ &
  1934. .000,0.101,0.202,0.302,0.402,0.502,0.602,0.702,0.802,0.901,1.000, &
  1935. .000,0.102,0.202,0.303,0.404,0.504,0.604,0.703,0.802,0.902,1.000, &
  1936. .000,0.102,0.205,0.306,0.406,0.506,0.606,0.706,0.804,0.902,1.000, &
  1937. .000,0.104,0.207,0.309,0.410,0.510,0.609,0.707,0.805,0.902,1.000, &
  1938. .000,0.106,0.208,0.309,0.409,0.508,0.606,0.705,0.803,0.902,1.000, &
  1939. .000,0.102,0.202,0.298,0.395,0.493,0.590,0.690,0.790,0.894,1.000, &
  1940. .000,0.091,0.179,0.267,0.357,0.449,0.545,0.647,0.755,0.872,1.000, &
  1941. .000,0.073,0.142,0.214,0.290,0.372,0.462,0.563,0.681,0.822,1.000, &
  1942. .000,0.053,0.104,0.158,0.217,0.281,0.356,0.446,0.562,0.726,1.000/
  1943. data ((caif(i,j),j=1,11),i=1,9)/ &
  1944. .000,0.099,0.198,0.297,0.397,0.496,0.597,0.697,0.798,0.899,1.000, &
  1945. .000,0.098,0.196,0.294,0.394,0.494,0.594,0.694,0.796,0.898,1.000, &
  1946. .000,0.096,0.192,0.290,0.388,0.487,0.587,0.689,0.792,0.895,1.000, &
  1947. .000,0.092,0.185,0.280,0.376,0.476,0.576,0.678,0.783,0.890,1.000, &
  1948. .000,0.085,0.173,0.263,0.357,0.454,0.555,0.659,0.768,0.881,1.000, &
  1949. .000,0.076,0.154,0.237,0.324,0.418,0.517,0.624,0.738,0.864,1.000, &
  1950. .000,0.063,0.131,0.203,0.281,0.366,0.461,0.567,0.688,0.830,1.000, &
  1951. .000,0.052,0.107,0.166,0.232,0.305,0.389,0.488,0.610,0.770,1.000, &
  1952. .000,0.043,0.088,0.136,0.189,0.248,0.317,0.400,0.510,0.675,1.000/
  1953. !-----clouds within each of the high, middle, and low clouds are assumed
  1954. ! to be maximally overlapped, and the cloud cover (cc) for a group
  1955. ! (high, middle, or low) is the maximum cloud cover of all the layers
  1956. ! within a group
  1957. do j=1,n
  1958. do i=1,m
  1959. cc(i,j,1)=0.0
  1960. cc(i,j,2)=0.0
  1961. cc(i,j,3)=0.0
  1962. enddo
  1963. enddo
  1964. do j=1,n
  1965. do i=1,m
  1966. do k=1,ict(i,j)-1
  1967. cc(i,j,1)=max(cc(i,j,1),fcld(i,j,k))
  1968. enddo
  1969. enddo
  1970. enddo
  1971. do j=1,n
  1972. do i=1,m
  1973. do k=ict(i,j),icb(i,j)-1
  1974. cc(i,j,2)=max(cc(i,j,2),fcld(i,j,k))
  1975. enddo
  1976. enddo
  1977. enddo
  1978. do j=1,n
  1979. do i=1,m
  1980. do k=icb(i,j),np
  1981. cc(i,j,3)=max(cc(i,j,3),fcld(i,j,k))
  1982. enddo
  1983. enddo
  1984. enddo
  1985. !-----scale the cloud optical thickness.
  1986. ! taucld(i,j,k,1) is the optical thickness for ice particles, and
  1987. ! taucld(i,j,k,2) is the optical thickness for liquid particles.
  1988. do j=1,n
  1989. do i=1,m
  1990. do k=1,np
  1991. if(k.lt.ict(i,j)) then
  1992. kk=1
  1993. elseif(k.ge.ict(i,j) .and. k.lt.icb(i,j)) then
  1994. kk=2
  1995. else
  1996. kk=3
  1997. endif
  1998. tauclb(i,j,k) = 0.0
  1999. tauclf(i,j,k) = 0.0
  2000. taux=taucld(i,j,k,1)+taucld(i,j,k,2)
  2001. if (taux.gt.0.05 .and. fcld(i,j,k).gt.0.01) then
  2002. !-----normalize cloud cover
  2003. fa=fcld(i,j,k)/cc(i,j,kk)
  2004. !-----table look-up
  2005. taux=min(taux,32.)
  2006. fm=cosz(i,j)/dm
  2007. ft=(log10(taux)-t1)/dt
  2008. fa=fa/da
  2009. im=int(fm+1.5)
  2010. it=int(ft+1.5)
  2011. ia=int(fa+1.5)
  2012. im=max(im,2)
  2013. it=max(it,2)
  2014. ia=max(ia,2)
  2015. im=min(im,nm-1)
  2016. it=min(it,nt-1)
  2017. ia=min(ia,na-1)
  2018. fm=fm-float(im-1)
  2019. ft=ft-float(it-1)
  2020. fa=fa-float(ia-1)
  2021. !-----scale cloud optical thickness for beam radiation.
  2022. ! the scaling factor, xai, is a function of the solar zenith
  2023. ! angle, optical thickness, and cloud cover.
  2024. xai= (-caib(im-1,it,ia)*(1.-fm)+ &
  2025. caib(im+1,it,ia)*(1.+fm))*fm*.5+caib(im,it,ia)*(1.-fm*fm)
  2026. xai=xai+(-caib(im,it-1,ia)*(1.-ft)+ &
  2027. caib(im,it+1,ia)*(1.+ft))*ft*.5+caib(im,it,ia)*(1.-ft*ft)
  2028. xai=xai+(-caib(im,it,ia-1)*(1.-fa)+ &
  2029. caib(im,it,ia+1)*(1.+fa))*fa*.5+caib(im,it,ia)*(1.-fa*fa)
  2030. xai= xai-2.*caib(im,it,ia)
  2031. xai=max(xai,0.0)
  2032. tauclb(i,j,k) = taux*xai
  2033. !-----scale cloud optical thickness for diffuse radiation.
  2034. ! the scaling factor, xai, is a function of the cloud optical
  2035. ! thickness and cover but not the solar zenith angle.
  2036. xai= (-caif(it-1,ia)*(1.-ft)+ &
  2037. caif(it+1,ia)*(1.+ft))*ft*.5+caif(it,ia)*(1.-ft*ft)
  2038. xai=xai+(-caif(it,ia-1)*(1.-fa)+ &
  2039. caif(it,ia+1)*(1.+fa))*fa*.5+caif(it,ia)*(1.-fa*fa)
  2040. xai= xai-caif(it,ia)
  2041. xai=max(xai,0.0)
  2042. tauclf(i,j,k) = taux*xai
  2043. endif
  2044. enddo
  2045. enddo
  2046. enddo
  2047. end subroutine cldscale
  2048. !*********************************************************************
  2049. subroutine deledd(tau,ssc,g0,csm,rr,tt,td)
  2050. !*********************************************************************
  2051. !
  2052. !-----uses the delta-eddington approximation to compute the
  2053. ! bulk scattering properties of a single layer
  2054. ! coded following King and Harshvardhan (JAS, 1986)
  2055. !
  2056. ! inputs:
  2057. !
  2058. ! tau: the effective optical thickness
  2059. ! ssc: the effective single scattering albedo
  2060. ! g0: the effective asymmetry factor
  2061. ! csm: the effective secant of the zenith angle
  2062. !
  2063. ! outputs:
  2064. !
  2065. ! rr: the layer reflection of the direct beam
  2066. ! tt: the layer diffuse transmission of the direct beam
  2067. ! td: the layer direct transmission of the direct beam
  2068. !
  2069. !*********************************************************************
  2070. implicit none
  2071. !*********************************************************************
  2072. real zero,one,two,three,four,fourth,seven,thresh
  2073. parameter (one =1., three=3.)
  2074. parameter (two =2., seven=7.)
  2075. parameter (four=4., fourth=.25)
  2076. parameter (zero=0., thresh=1.e-8)
  2077. !-----input parameters
  2078. real tau,ssc,g0,csm
  2079. !-----output parameters
  2080. real rr,tt,td
  2081. !-----temporary parameters
  2082. real zth,ff,xx,taup,sscp,gp,gm1,gm2,gm3,akk,alf1,alf2, &
  2083. all,bll,st7,st8,cll,dll,fll,ell,st1,st2,st3,st4
  2084. !---------------------------------------------------------------------
  2085. zth = one / csm
  2086. ! delta-eddington scaling of single scattering albedo,
  2087. ! optical thickness, and asymmetry factor,
  2088. ! K & H eqs(27-29)
  2089. ff = g0*g0
  2090. xx = one-ff*ssc
  2091. taup= tau*xx
  2092. sscp= ssc*(one-ff)/xx
  2093. gp = g0/(one+g0)
  2094. ! gamma1, gamma2, and gamma3. see table 2 and eq(26) K & H
  2095. ! ssc and gp are the d-s single scattering
  2096. ! albedo and asymmetry factor.
  2097. xx = three*gp
  2098. gm1 = (seven - sscp*(four+xx))*fourth
  2099. gm2 = -(one - sscp*(four-xx))*fourth
  2100. ! akk is k as defined in eq(25) of K & H
  2101. akk = sqrt((gm1+gm2)*(gm1-gm2))
  2102. xx = akk * zth
  2103. st7 = one - xx
  2104. st8 = one + xx
  2105. st3 = st7 * st8
  2106. if (abs(st3) .lt. thresh) then
  2107. zth = zth + 0.001
  2108. xx = akk * zth
  2109. st7 = one - xx
  2110. st8 = one + xx
  2111. st3 = st7 * st8
  2112. endif
  2113. ! extinction of the direct beam transmission
  2114. td = exp(-taup/zth)
  2115. ! alf1 and alf2 are alpha1 and alpha2 from eqs (23) & (24) of K & H
  2116. gm3 = (two - zth*three*gp)*fourth
  2117. xx = gm1 - gm2
  2118. alf1 = gm1 - gm3 * xx
  2119. alf2 = gm2 + gm3 * xx
  2120. ! all is last term in eq(21) of K & H
  2121. ! bll is last term in eq(22) of K & H
  2122. xx = akk * two
  2123. all = (gm3 - alf2 * zth )*xx*td
  2124. bll = (one - gm3 + alf1*zth)*xx
  2125. xx = akk * gm3
  2126. cll = (alf2 + xx) * st7
  2127. dll = (alf2 - xx) * st8
  2128. xx = akk * (one-gm3)
  2129. fll = (alf1 + xx) * st8
  2130. ell = (alf1 - xx) * st7
  2131. st2 = exp(-akk*taup)
  2132. st4 = st2 * st2
  2133. st1 = sscp / ((akk+gm1 + (akk-gm1)*st4) * st3)
  2134. ! rr is r-hat of eq(21) of K & H
  2135. ! tt is diffuse part of t-hat of eq(22) of K & H
  2136. rr = ( cll-dll*st4 -all*st2)*st1
  2137. tt = - ((fll-ell*st4)*td-bll*st2)*st1
  2138. rr = max(rr,zero)
  2139. tt = max(tt,zero)
  2140. end subroutine deledd
  2141. !*********************************************************************
  2142. subroutine sagpol(tau,ssc,g0,rll,tll)
  2143. !*********************************************************************
  2144. !-----transmittance (tll) and reflectance (rll) of diffuse radiation
  2145. ! follows Sagan and Pollock (JGR, 1967).
  2146. ! also, eq.(31) of Lacis and Hansen (JAS, 1974).
  2147. !
  2148. !-----input parameters:
  2149. !
  2150. ! tau: the effective optical thickness
  2151. ! ssc: the effective single scattering albedo
  2152. ! g0: the effective asymmetry factor
  2153. !
  2154. !-----output parameters:
  2155. !
  2156. ! rll: the layer reflection of diffuse radiation
  2157. ! tll: the layer transmission of diffuse radiation
  2158. !
  2159. !*********************************************************************
  2160. implicit none
  2161. !*********************************************************************
  2162. real one,three,four
  2163. parameter (one=1., three=3., four=4.)
  2164. !-----output parameters:
  2165. real tau,ssc,g0
  2166. !-----output parameters:
  2167. real rll,tll
  2168. !-----temporary arrays
  2169. real xx,uuu,ttt,emt,up1,um1,st1
  2170. xx = one-ssc*g0
  2171. uuu = sqrt( xx/(one-ssc))
  2172. ttt = sqrt( xx*(one-ssc)*three )*tau
  2173. emt = exp(-ttt)
  2174. up1 = uuu + one
  2175. um1 = uuu - one
  2176. xx = um1*emt
  2177. st1 = one / ((up1+xx) * (up1-xx))
  2178. rll = up1*um1*(one-emt*emt)*st1
  2179. tll = uuu*four*emt *st1
  2180. end subroutine sagpol
  2181. !*******************************************************************
  2182. subroutine cldflx (m,n,np,ict,icb,overcast,cc,rr,tt,td,rs,ts,&
  2183. fclr,fall,fallu,falld,fsdir,fsdif)
  2184. !*******************************************************************
  2185. ! compute upward and downward fluxes using a two-stream adding method
  2186. ! following equations (3)-(5) of Chou (1992, JAS).
  2187. !
  2188. ! clouds are grouped into high, middle, and low clouds which are
  2189. ! assumed randomly overlapped. It involves eight sets of calculations.
  2190. ! In each set of calculations, each atmospheric layer is homogeneous,
  2191. ! either totally filled with clouds or without clouds.
  2192. ! input parameters:
  2193. !
  2194. ! m: number of soundings in zonal direction
  2195. ! n: number of soundings in meridional direction
  2196. ! np: number of atmospheric layers
  2197. ! ict: the level separating high and middle clouds
  2198. ! icb: the level separating middle and low clouds
  2199. ! cc: effective cloud covers for high, middle and low clouds
  2200. ! tt: diffuse transmission of a layer illuminated by beam radiation
  2201. ! td: direct beam tranmssion
  2202. ! ts: transmission of a layer illuminated by diffuse radiation
  2203. ! rr: reflection of a layer illuminated by beam radiation
  2204. ! rs: reflection of a layer illuminated by diffuse radiation
  2205. !
  2206. ! output parameters:
  2207. !
  2208. ! fclr: clear-sky flux (downward minus upward)
  2209. ! fall: all-sky flux (downward minus upward)
  2210. ! fsdir: surface direct downward flux
  2211. ! fsdif: surface diffuse downward flux
  2212. !
  2213. !*********************************************************************c
  2214. implicit none
  2215. !*********************************************************************c
  2216. !-----input parameters
  2217. integer m,n,np
  2218. integer ict(m,n),icb(m,n)
  2219. real rr(m,n,np+1,2),tt(m,n,np+1,2),td(m,n,np+1,2)
  2220. real rs(m,n,np+1,2),ts(m,n,np+1,2)
  2221. real cc(m,n,3)
  2222. logical overcast
  2223. !-----temporary array
  2224. integer i,j,k,ih,im,is,itm
  2225. real rra(m,n,np+1,2,2),tta(m,n,np+1,2,2),tda(m,n,np+1,2,2)
  2226. real rsa(m,n,np+1,2,2),rxa(m,n,np+1,2,2)
  2227. real ch(m,n),cm(m,n),ct(m,n),flxdn(m,n,np+1)
  2228. real flxdnu(m,n,np+1),flxdnd(m,n,np+1)
  2229. real fdndir(m,n),fdndif(m,n),fupdif
  2230. real denm,xx
  2231. !-----output parameters
  2232. real fclr(m,n,np+1),fall(m,n,np+1)
  2233. real fallu(m,n,np+1),falld(m,n,np+1)
  2234. real fsdir(m,n),fsdif(m,n)
  2235. !-----initialize all-sky flux (fall) and surface downward fluxes
  2236. do k=1,np+1
  2237. do j=1,n
  2238. do i=1,m
  2239. fclr(i,j,k)=0.0
  2240. fall(i,j,k)=0.0
  2241. fallu(i,j,k)=0.0
  2242. falld(i,j,k)=0.0
  2243. enddo
  2244. enddo
  2245. enddo
  2246. do j=1,n
  2247. do i=1,m
  2248. fsdir(i,j)=0.0
  2249. fsdif(i,j)=0.0
  2250. enddo
  2251. enddo
  2252. !-----compute transmittances and reflectances for a composite of
  2253. ! layers. layers are added one at a time, going down from the top.
  2254. ! tda is the composite transmittance illuminated by beam radiation
  2255. ! tta is the composite diffuse transmittance illuminated by
  2256. ! beam radiation
  2257. ! rsa is the composite reflectance illuminated from below
  2258. ! by diffuse radiation
  2259. ! tta and rsa are computed from eqs. (4b) and (3b) of Chou
  2260. itm=1
  2261. !-----if overcas.=.true., set itm=2, and only one set of fluxes is computed
  2262. if (overcast) itm=2
  2263. !-----for high clouds. indices 1 and 2 denote clear and cloudy
  2264. ! situations, respectively.
  2265. do 10 ih=itm,2
  2266. do j= 1, n
  2267. do i= 1, m
  2268. tda(i,j,1,ih,1)=td(i,j,1,ih)
  2269. tta(i,j,1,ih,1)=tt(i,j,1,ih)
  2270. rsa(i,j,1,ih,1)=rs(i,j,1,ih)
  2271. tda(i,j,1,ih,2)=td(i,j,1,ih)
  2272. tta(i,j,1,ih,2)=tt(i,j,1,ih)
  2273. rsa(i,j,1,ih,2)=rs(i,j,1,ih)
  2274. enddo
  2275. enddo
  2276. do j= 1, n
  2277. do i= 1, m
  2278. do k= 2, ict(i,j)-1
  2279. denm = ts(i,j,k,ih)/( 1.-rsa(i,j,k-1,ih,1)*rs(i,j,k,ih))
  2280. tda(i,j,k,ih,1)= tda(i,j,k-1,ih,1)*td(i,j,k,ih)
  2281. tta(i,j,k,ih,1)= tda(i,j,k-1,ih,1)*tt(i,j,k,ih) &
  2282. +(tda(i,j,k-1,ih,1)*rr(i,j,k,ih) &
  2283. *rsa(i,j,k-1,ih,1)+tta(i,j,k-1,ih,1))*denm
  2284. rsa(i,j,k,ih,1)= rs(i,j,k,ih)+ts(i,j,k,ih) &
  2285. *rsa(i,j,k-1,ih,1)*denm
  2286. tda(i,j,k,ih,2)= tda(i,j,k,ih,1)
  2287. tta(i,j,k,ih,2)= tta(i,j,k,ih,1)
  2288. rsa(i,j,k,ih,2)= rsa(i,j,k,ih,1)
  2289. enddo
  2290. enddo
  2291. enddo
  2292. !-----for middle clouds
  2293. do 10 im=itm,2
  2294. do j= 1, n
  2295. do i= 1, m
  2296. do k= ict(i,j), icb(i,j)-1
  2297. denm = ts(i,j,k,im)/( 1.-rsa(i,j,k-1,ih,im)*rs(i,j,k,im))
  2298. tda(i,j,k,ih,im)= tda(i,j,k-1,ih,im)*td(i,j,k,im)
  2299. tta(i,j,k,ih,im)= tda(i,j,k-1,ih,im)*tt(i,j,k,im) &
  2300. +(tda(i,j,k-1,ih,im)*rr(i,j,k,im) &
  2301. *rsa(i,j,k-1,ih,im)+tta(i,j,k-1,ih,im))*denm
  2302. rsa(i,j,k,ih,im)= rs(i,j,k,im)+ts(i,j,k,im) &
  2303. *rsa(i,j,k-1,ih,im)*denm
  2304. enddo
  2305. enddo
  2306. enddo
  2307. 10 continue
  2308. !-----layers are added one at a time, going up from the surface.
  2309. ! rra is the composite reflectance illuminated by beam radiation
  2310. ! rxa is the composite reflectance illuminated from above
  2311. ! by diffuse radiation
  2312. ! rra and rxa are computed from eqs. (4a) and (3a) of Chou
  2313. !-----for the low clouds
  2314. do 20 is=itm,2
  2315. do j= 1, n
  2316. do i= 1, m
  2317. rra(i,j,np+1,1,is)=rr(i,j,np+1,is)
  2318. rxa(i,j,np+1,1,is)=rs(i,j,np+1,is)
  2319. rra(i,j,np+1,2,is)=rr(i,j,np+1,is)
  2320. rxa(i,j,np+1,2,is)=rs(i,j,np+1,is)
  2321. enddo
  2322. enddo
  2323. do j= 1, n
  2324. do i= 1, m
  2325. do k=np,icb(i,j),-1
  2326. denm=ts(i,j,k,is)/( 1.-rs(i,j,k,is)*rxa(i,j,k+1,1,is) )
  2327. rra(i,j,k,1,is)=rr(i,j,k,is)+(td(i,j,k,is) &
  2328. *rra(i,j,k+1,1,is)+tt(i,j,k,is)*rxa(i,j,k+1,1,is))*denm
  2329. rxa(i,j,k,1,is)= rs(i,j,k,is)+ts(i,j,k,is) &
  2330. *rxa(i,j,k+1,1,is)*denm
  2331. rra(i,j,k,2,is)=rra(i,j,k,1,is)
  2332. rxa(i,j,k,2,is)=rxa(i,j,k,1,is)
  2333. enddo
  2334. enddo
  2335. enddo
  2336. !-----for middle clouds
  2337. do 20 im=itm,2
  2338. do j= 1, n
  2339. do i= 1, m
  2340. do k= icb(i,j)-1,ict(i,j),-1
  2341. denm=ts(i,j,k,im)/( 1.-rs(i,j,k,im)*rxa(i,j,k+1,im,is) )
  2342. rra(i,j,k,im,is)= rr(i,j,k,im)+(td(i,j,k,im) &
  2343. *rra(i,j,k+1,im,is)+tt(i,j,k,im)*rxa(i,j,k+1,im,is))*denm
  2344. rxa(i,j,k,im,is)= rs(i,j,k,im)+ts(i,j,k,im) &
  2345. *rxa(i,j,k+1,im,is)*denm
  2346. enddo
  2347. enddo
  2348. enddo
  2349. 20 continue
  2350. !-----integration over eight sky situations.
  2351. ! ih, im, is denotes high, middle and low cloud groups.
  2352. do 100 ih=itm,2
  2353. !-----clear portion
  2354. if(ih.eq.1) then
  2355. do j=1,n
  2356. do i=1,m
  2357. ch(i,j)=1.0-cc(i,j,1)
  2358. enddo
  2359. enddo
  2360. else
  2361. !-----cloudy portion
  2362. do j=1,n
  2363. do i=1,m
  2364. ch(i,j)=cc(i,j,1)
  2365. enddo
  2366. enddo
  2367. endif
  2368. do 100 im=itm,2
  2369. !-----clear portion
  2370. if(im.eq.1) then
  2371. do j=1,n
  2372. do i=1,m
  2373. cm(i,j)=ch(i,j)*(1.0-cc(i,j,2))
  2374. enddo
  2375. enddo
  2376. else
  2377. !-----cloudy portion
  2378. do j=1,n
  2379. do i=1,m
  2380. cm(i,j)=ch(i,j)*cc(i,j,2)
  2381. enddo
  2382. enddo
  2383. endif
  2384. do 100 is=itm,2
  2385. !-----clear portion
  2386. if(is.eq.1) then
  2387. do j=1,n
  2388. do i=1,m
  2389. ct(i,j)=cm(i,j)*(1.0-cc(i,j,3))
  2390. enddo
  2391. enddo
  2392. else
  2393. !-----cloudy portion
  2394. do j=1,n
  2395. do i=1,m
  2396. ct(i,j)=cm(i,j)*cc(i,j,3)
  2397. enddo
  2398. enddo
  2399. endif
  2400. !-----add one layer at a time, going down.
  2401. do j= 1, n
  2402. do i= 1, m
  2403. do k= icb(i,j), np
  2404. denm = ts(i,j,k,is)/( 1.-rsa(i,j,k-1,ih,im)*rs(i,j,k,is) )
  2405. tda(i,j,k,ih,im)= tda(i,j,k-1,ih,im)*td(i,j,k,is)
  2406. tta(i,j,k,ih,im)= tda(i,j,k-1,ih,im)*tt(i,j,k,is) &
  2407. +(tda(i,j,k-1,ih,im)*rr(i,j,k,is) &
  2408. *rsa(i,j,k-1,ih,im)+tta(i,j,k-1,ih,im))*denm
  2409. rsa(i,j,k,ih,im)= rs(i,j,k,is)+ts(i,j,k,is) &
  2410. *rsa(i,j,k-1,ih,im)*denm
  2411. enddo
  2412. enddo
  2413. enddo
  2414. !-----add one layer at a time, going up.
  2415. do j= 1, n
  2416. do i= 1, m
  2417. do k= ict(i,j)-1,1,-1
  2418. denm =ts(i,j,k,ih)/(1.-rs(i,j,k,ih)*rxa(i,j,k+1,im,is))
  2419. rra(i,j,k,im,is)= rr(i,j,k,ih)+(td(i,j,k,ih) &
  2420. *rra(i,j,k+1,im,is)+tt(i,j,k,ih)*rxa(i,j,k+1,im,is))*denm
  2421. rxa(i,j,k,im,is)= rs(i,j,k,ih)+ts(i,j,k,ih) &
  2422. *rxa(i,j,k+1,im,is)*denm
  2423. enddo
  2424. enddo
  2425. enddo
  2426. !-----compute fluxes following eq (5) of Chou (1992)
  2427. ! fdndir is the direct downward flux
  2428. ! fdndif is the diffuse downward flux
  2429. ! fupdif is the diffuse upward flux
  2430. do k=2,np+1
  2431. do j=1, n
  2432. do i=1, m
  2433. denm= 1./(1.- rxa(i,j,k,im,is)*rsa(i,j,k-1,ih,im))
  2434. fdndir(i,j)= tda(i,j,k-1,ih,im)
  2435. xx = tda(i,j,k-1,ih,im)*rra(i,j,k,im,is)
  2436. fdndif(i,j)= (xx*rsa(i,j,k-1,ih,im)+tta(i,j,k-1,ih,im))*denm
  2437. fupdif= (xx+tta(i,j,k-1,ih,im)*rxa(i,j,k,im,is))*denm
  2438. flxdn(i,j,k)=fdndir(i,j)+fdndif(i,j)-fupdif
  2439. flxdnu(i,j,k)=-fupdif
  2440. flxdnd(i,j,k)=fdndir(i,j)+fdndif(i,j)
  2441. enddo
  2442. enddo
  2443. enddo
  2444. do j=1, n
  2445. do i=1, m
  2446. flxdn(i,j,1)=1.0-rra(i,j,1,im,is)
  2447. flxdnu(i,j,1)=-rra(i,j,1,im,is)
  2448. flxdnd(i,j,1)=1.0
  2449. enddo
  2450. enddo
  2451. !-----summation of fluxes over all (eight) sky situations.
  2452. do k=1,np+1
  2453. do j=1,n
  2454. do i=1,m
  2455. if(ih.eq.1 .and. im.eq.1 .and. is.eq.1) then
  2456. fclr(i,j,k)=flxdn(i,j,k)
  2457. endif
  2458. fall(i,j,k)=fall(i,j,k)+flxdn(i,j,k)*ct(i,j)
  2459. fallu(i,j,k)=fallu(i,j,k)+flxdnu(i,j,k)*ct(i,j)
  2460. falld(i,j,k)=falld(i,j,k)+flxdnd(i,j,k)*ct(i,j)
  2461. enddo
  2462. enddo
  2463. enddo
  2464. do j=1,n
  2465. do i=1,m
  2466. fsdir(i,j)=fsdir(i,j)+fdndir(i,j)*ct(i,j)
  2467. fsdif(i,j)=fsdif(i,j)+fdndif(i,j)*ct(i,j)
  2468. enddo
  2469. enddo
  2470. 100 continue
  2471. end subroutine cldflx
  2472. !*****************************************************************
  2473. subroutine flxco2(m,n,np,swc,swh,csm,df)
  2474. !*****************************************************************
  2475. !-----compute the reduction of clear-sky downward solar flux
  2476. ! due to co2 absorption.
  2477. implicit none
  2478. !-----input parameters
  2479. integer m,n,np
  2480. real csm(m,n),swc(m,n,np+1),swh(m,n,np+1),cah(22,19)
  2481. !-----output (undated) parameter
  2482. real df(m,n,np+1)
  2483. !-----temporary array
  2484. integer i,j,k,ic,iw
  2485. real xx,clog,wlog,dc,dw,x1,x2,y2
  2486. !********************************************************************
  2487. !-----include co2 look-up table
  2488. data ((cah(i,j),i=1,22),j= 1, 5)/ &
  2489. 0.9923, 0.9922, 0.9921, 0.9920, 0.9916, 0.9910, 0.9899, 0.9882, &
  2490. 0.9856, 0.9818, 0.9761, 0.9678, 0.9558, 0.9395, 0.9188, 0.8945, &
  2491. 0.8675, 0.8376, 0.8029, 0.7621, 0.7154, 0.6647, 0.9876, 0.9876, &
  2492. 0.9875, 0.9873, 0.9870, 0.9864, 0.9854, 0.9837, 0.9811, 0.9773, &
  2493. 0.9718, 0.9636, 0.9518, 0.9358, 0.9153, 0.8913, 0.8647, 0.8350, &
  2494. 0.8005, 0.7599, 0.7133, 0.6627, 0.9808, 0.9807, 0.9806, 0.9805, &
  2495. 0.9802, 0.9796, 0.9786, 0.9769, 0.9744, 0.9707, 0.9653, 0.9573, &
  2496. 0.9459, 0.9302, 0.9102, 0.8866, 0.8604, 0.8311, 0.7969, 0.7565, &
  2497. 0.7101, 0.6596, 0.9708, 0.9708, 0.9707, 0.9705, 0.9702, 0.9697, &
  2498. 0.9687, 0.9671, 0.9647, 0.9612, 0.9560, 0.9483, 0.9372, 0.9221, &
  2499. 0.9027, 0.8798, 0.8542, 0.8253, 0.7916, 0.7515, 0.7054, 0.6551, &
  2500. 0.9568, 0.9568, 0.9567, 0.9565, 0.9562, 0.9557, 0.9548, 0.9533, &
  2501. 0.9510, 0.9477, 0.9428, 0.9355, 0.9250, 0.9106, 0.8921, 0.8700, &
  2502. 0.8452, 0.8171, 0.7839, 0.7443, 0.6986, 0.6486/
  2503. data ((cah(i,j),i=1,22),j= 6,10)/ &
  2504. 0.9377, 0.9377, 0.9376, 0.9375, 0.9372, 0.9367, 0.9359, 0.9345, &
  2505. 0.9324, 0.9294, 0.9248, 0.9181, 0.9083, 0.8948, 0.8774, 0.8565, &
  2506. 0.8328, 0.8055, 0.7731, 0.7342, 0.6890, 0.6395, 0.9126, 0.9126, &
  2507. 0.9125, 0.9124, 0.9121, 0.9117, 0.9110, 0.9098, 0.9079, 0.9052, &
  2508. 0.9012, 0.8951, 0.8862, 0.8739, 0.8579, 0.8385, 0.8161, 0.7900, &
  2509. 0.7585, 0.7205, 0.6760, 0.6270, 0.8809, 0.8809, 0.8808, 0.8807, &
  2510. 0.8805, 0.8802, 0.8796, 0.8786, 0.8770, 0.8747, 0.8712, 0.8659, &
  2511. 0.8582, 0.8473, 0.8329, 0.8153, 0.7945, 0.7697, 0.7394, 0.7024, &
  2512. 0.6588, 0.6105, 0.8427, 0.8427, 0.8427, 0.8426, 0.8424, 0.8422, &
  2513. 0.8417, 0.8409, 0.8397, 0.8378, 0.8350, 0.8306, 0.8241, 0.8148, &
  2514. 0.8023, 0.7866, 0.7676, 0.7444, 0.7154, 0.6796, 0.6370, 0.5897, &
  2515. 0.7990, 0.7990, 0.7990, 0.7989, 0.7988, 0.7987, 0.7983, 0.7978, &
  2516. 0.7969, 0.7955, 0.7933, 0.7899, 0.7846, 0.7769, 0.7664, 0.7528, &
  2517. 0.7357, 0.7141, 0.6866, 0.6520, 0.6108, 0.5646/
  2518. data ((cah(i,j),i=1,22),j=11,15)/ &
  2519. 0.7515, 0.7515, 0.7515, 0.7515, 0.7514, 0.7513, 0.7511, 0.7507, &
  2520. 0.7501, 0.7491, 0.7476, 0.7450, 0.7409, 0.7347, 0.7261, 0.7144, &
  2521. 0.6992, 0.6793, 0.6533, 0.6203, 0.5805, 0.5357, 0.7020, 0.7020, &
  2522. 0.7020, 0.7019, 0.7019, 0.7018, 0.7017, 0.7015, 0.7011, 0.7005, &
  2523. 0.6993, 0.6974, 0.6943, 0.6894, 0.6823, 0.6723, 0.6588, 0.6406, &
  2524. 0.6161, 0.5847, 0.5466, 0.5034, 0.6518, 0.6518, 0.6518, 0.6518, &
  2525. 0.6518, 0.6517, 0.6517, 0.6515, 0.6513, 0.6508, 0.6500, 0.6485, &
  2526. 0.6459, 0.6419, 0.6359, 0.6273, 0.6151, 0.5983, 0.5755, 0.5458, &
  2527. 0.5095, 0.4681, 0.6017, 0.6017, 0.6017, 0.6017, 0.6016, 0.6016, &
  2528. 0.6016, 0.6015, 0.6013, 0.6009, 0.6002, 0.5989, 0.5967, 0.5932, &
  2529. 0.5879, 0.5801, 0.5691, 0.5535, 0.5322, 0.5043, 0.4700, 0.4308, &
  2530. 0.5518, 0.5518, 0.5518, 0.5518, 0.5518, 0.5518, 0.5517, 0.5516, &
  2531. 0.5514, 0.5511, 0.5505, 0.5493, 0.5473, 0.5441, 0.5393, 0.5322, &
  2532. 0.5220, 0.5076, 0.4878, 0.4617, 0.4297, 0.3929/
  2533. data ((cah(i,j),i=1,22),j=16,19)/ &
  2534. 0.5031, 0.5031, 0.5031, 0.5031, 0.5031, 0.5030, 0.5030, 0.5029, &
  2535. 0.5028, 0.5025, 0.5019, 0.5008, 0.4990, 0.4960, 0.4916, 0.4850, &
  2536. 0.4757, 0.4624, 0.4441, 0.4201, 0.3904, 0.3564, 0.4565, 0.4565, &
  2537. 0.4565, 0.4564, 0.4564, 0.4564, 0.4564, 0.4563, 0.4562, 0.4559, &
  2538. 0.4553, 0.4544, 0.4527, 0.4500, 0.4460, 0.4400, 0.4315, 0.4194, &
  2539. 0.4028, 0.3809, 0.3538, 0.3227, 0.4122, 0.4122, 0.4122, 0.4122, &
  2540. 0.4122, 0.4122, 0.4122, 0.4121, 0.4120, 0.4117, 0.4112, 0.4104, &
  2541. 0.4089, 0.4065, 0.4029, 0.3976, 0.3900, 0.3792, 0.3643, 0.3447, &
  2542. 0.3203, 0.2923, 0.3696, 0.3696, 0.3696, 0.3696, 0.3696, 0.3696, &
  2543. 0.3695, 0.3695, 0.3694, 0.3691, 0.3687, 0.3680, 0.3667, 0.3647, &
  2544. 0.3615, 0.3570, 0.3504, 0.3409, 0.3279, 0.3106, 0.2892, 0.2642/
  2545. !********************************************************************
  2546. !-----table look-up for the reduction of clear-sky solar
  2547. ! radiation due to co2. The fraction 0.0343 is the
  2548. ! extraterrestrial solar flux in the co2 bands.
  2549. do k= 2, np+1
  2550. do j= 1, n
  2551. do i= 1, m
  2552. xx=1./.3
  2553. clog=log10(swc(i,j,k)*csm(i,j))
  2554. wlog=log10(swh(i,j,k)*csm(i,j))
  2555. ic=int( (clog+3.15)*xx+1.)
  2556. iw=int( (wlog+4.15)*xx+1.)
  2557. if(ic.lt.2)ic=2
  2558. if(iw.lt.2)iw=2
  2559. if(ic.gt.22)ic=22
  2560. if(iw.gt.19)iw=19
  2561. dc=clog-float(ic-2)*.3+3.
  2562. dw=wlog-float(iw-2)*.3+4.
  2563. x1=cah(1,iw-1)+(cah(1,iw)-cah(1,iw-1))*xx*dw
  2564. x2=cah(ic-1,iw-1)+(cah(ic-1,iw)-cah(ic-1,iw-1))*xx*dw
  2565. y2=x2+(cah(ic,iw-1)-cah(ic-1,iw-1))*xx*dc
  2566. if (x1.lt.y2) x1=y2
  2567. df(i,j,k)=df(i,j,k)+0.0343*(x1-y2)
  2568. enddo
  2569. enddo
  2570. enddo
  2571. end subroutine flxco2
  2572. !*****************************************************************
  2573. subroutine o3prof (np, pres, ozone, its, ite, kts, kte, p, o3)
  2574. !*****************************************************************
  2575. implicit none
  2576. !*****************************************************************
  2577. !
  2578. integer iprof,m,np,its,ite,kts,kte
  2579. integer i,k,ko,kk
  2580. real pres(np),ozone(np)
  2581. real p(its:ite,kts:kte),o3(its:ite,kts:kte)
  2582. ! Statement function
  2583. real Linear, x1, y1, x2, y2, x
  2584. Linear(x1, y1, x2, y2, x) = &
  2585. (y1 * (x2 - x) + y2 * (x - x1)) / (x2 - x1)
  2586. !
  2587. do k = 1,np
  2588. pres(k) = alog(pres(k))
  2589. enddo
  2590. do k = kts,kte
  2591. do i = its, ite
  2592. p(i,k) = alog(p(i,k))
  2593. end do
  2594. end do
  2595. ! assume the pressure at model top is greater than pres(1)
  2596. ! if it is not, this part needs to change
  2597. do i = its, ite
  2598. ko = 1
  2599. do k = kts+1, kte
  2600. do while (ko .lt. np .and. p(i,k) .gt. pres(ko))
  2601. ko = ko + 1
  2602. end do
  2603. o3(i,k) = Linear (pres(ko), ozone(ko), &
  2604. pres(ko-1), ozone(ko-1), &
  2605. p(i,k))
  2606. ko = ko - 1
  2607. end do
  2608. end do
  2609. ! calculate top lay O3
  2610. do i = its, ite
  2611. ko = 1
  2612. k = kts
  2613. do while (ko .le. np .and. p(i,k) .gt. pres(ko))
  2614. ko = ko + 1
  2615. end do
  2616. IF (ko-1 .le. 1) then
  2617. O3(i,k)=ozone(k)
  2618. ELSE
  2619. O3(i,k)=0.
  2620. do kk=ko-2,1,-1
  2621. O3(i,k)=O3(i,k)+ozone(kk)*(pres(kk+1)-pres(kk))
  2622. enddo
  2623. O3(i,k)=O3(i,k)/(pres(ko-1)-pres(1))
  2624. ENDIF
  2625. ! print*,'O3=',i,k,ko,O3(i,k),p(i,k),ko,pres(ko),pres(ko-1)
  2626. end do
  2627. end subroutine o3prof
  2628. !-----------------------------------------
  2629. SUBROUTINE gsfc_swinit(cen_lat, allowed_to_read)
  2630. REAL, INTENT(IN ) :: cen_lat
  2631. LOGICAL, INTENT(IN ) :: allowed_to_read
  2632. center_lat=cen_lat
  2633. END SUBROUTINE gsfc_swinit
  2634. END MODULE module_ra_gsfcsw