PageRenderTime 47ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/wrfv2_fire/phys/module_mp_kessler.F

http://github.com/jbeezley/wrf-fire
FORTRAN Legacy | 244 lines | 140 code | 52 blank | 52 comment | 1 complexity | 43f68b7d3e3a1c12a77ceab06238c02c MD5 | raw file
Possible License(s): AGPL-1.0
  1. !WRF:MODEL_LAYER:PHYSICS
  2. !
  3. MODULE module_mp_kessler
  4. CONTAINS
  5. !----------------------------------------------------------------
  6. SUBROUTINE kessler( t, qv, qc, qr, rho, pii &
  7. ,dt_in, z, xlv, cp &
  8. ,EP2,SVP1,SVP2,SVP3,SVPT0,rhowater &
  9. ,dz8w &
  10. ,RAINNC, RAINNCV &
  11. ,ids,ide, jds,jde, kds,kde & ! domain dims
  12. ,ims,ime, jms,jme, kms,kme & ! memory dims
  13. ,its,ite, jts,jte, kts,kte & ! tile dims
  14. )
  15. !----------------------------------------------------------------
  16. IMPLICIT NONE
  17. !----------------------------------------------------------------
  18. ! taken from the COMMAS code - WCS 10 May 1999.
  19. ! converted from FORTRAN 77 to 90, tiled, WCS 10 May 1999.
  20. !----------------------------------------------------------------
  21. REAL , PARAMETER :: c1 = .001
  22. REAL , PARAMETER :: c2 = .001
  23. REAL , PARAMETER :: c3 = 2.2
  24. REAL , PARAMETER :: c4 = .875
  25. REAL , PARAMETER :: fudge = 1.0
  26. REAL , PARAMETER :: mxfall = 10.0
  27. !----------------------------------------------------------------
  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. REAL , INTENT(IN ) :: xlv, cp
  32. REAL , INTENT(IN ) :: EP2,SVP1,SVP2,SVP3,SVPT0
  33. REAL , INTENT(IN ) :: rhowater
  34. REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
  35. INTENT(INOUT) :: &
  36. t , &
  37. qv, &
  38. qc, &
  39. qr
  40. REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
  41. INTENT(IN ) :: &
  42. rho, &
  43. pii, &
  44. dz8w
  45. REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
  46. INTENT(IN ) :: z
  47. REAL, INTENT(IN ) :: dt_in
  48. REAL, DIMENSION( ims:ime , jms:jme ), &
  49. INTENT(INOUT) :: RAINNC, &
  50. RAINNCV
  51. ! local variables
  52. REAL :: qrprod, ern, gam, rcgs, rcgsi
  53. REAL, DIMENSION( its:ite , kts:kte, jts:jte ) :: prod
  54. REAL, DIMENSION(kts:kte) :: vt, prodk, vtden,rdzk,rhok,factor,rdzw
  55. INTEGER :: i,j,k
  56. INTEGER :: nfall, n, nfall_new
  57. REAL :: qrr, pressure, temp, es, qvs, dz, dt
  58. REAL :: f5, dtfall, rdz, product
  59. REAL :: max_heating, max_condense, max_rain, maxqrp
  60. REAL :: vtmax, ernmax, crmax, factorn, time_sediment
  61. REAL :: qcr, factorr, ppt
  62. REAL, PARAMETER :: max_cr_sedimentation = 0.75
  63. !----------------------------------------------------------------
  64. INTEGER :: imax, kmax
  65. dt = dt_in
  66. ! f5 = 237.3 * 17.27 * 2.5e6 / cp
  67. f5 = svp2*(svpt0-svp3)*xlv/cp
  68. ernmax = 0.
  69. maxqrp = -100.
  70. !------------------------------------------------------------------------------
  71. ! parameters for the time split terminal advection
  72. !------------------------------------------------------------------------------
  73. max_heating = 0.
  74. max_condense = 0.
  75. max_rain = 0.
  76. !-----------------------------------------------------------------------------
  77. ! outer J loop for entire microphysics, outer i loop for sedimentation
  78. !-----------------------------------------------------------------------------
  79. microphysics_outer_j_loop: DO j = jts, jte
  80. sedimentation_outer_i_loop: DO i = its,ite
  81. ! vtmax = 0.
  82. crmax = 0.
  83. !------------------------------------------------------------------------------
  84. ! Terminal velocity calculation and advection, set up coefficients and
  85. ! compute stable timestep
  86. !------------------------------------------------------------------------------
  87. DO k = 1, kte
  88. prodk(k) = qr(i,k,j)
  89. rhok(k) = rho(i,k,j)
  90. qrr = amax1(0.,qr(i,k,j)*0.001*rhok(k))
  91. vtden(k) = sqrt(rhok(1)/rhok(k))
  92. vt(k) = 36.34*(qrr**0.1364) * vtden(k)
  93. ! vtmax = amax1(vt(k), vtmax)
  94. rdzw(k) = 1./dz8w(i,k,j)
  95. crmax = amax1(vt(k)*dt*rdzw(k),crmax)
  96. ENDDO
  97. DO k = 1, kte-1
  98. rdzk(k) = 1./(z(i,k+1,j) - z(i,k,j))
  99. ENDDO
  100. rdzk(kte) = 1./(z(i,kte,j) - z(i,kte-1,j))
  101. nfall = max(1,nint(0.5+crmax/max_cr_sedimentation)) ! courant number for big timestep.
  102. dtfall = dt / float(nfall) ! splitting so courant number for sedimentation
  103. time_sediment = dt ! is stable
  104. !------------------------------------------------------------------------------
  105. ! Terminal velocity calculation and advection
  106. ! Do a time split loop on this for stability.
  107. !------------------------------------------------------------------------------
  108. column_sedimentation: DO WHILE ( nfall > 0 )
  109. time_sediment = time_sediment - dtfall
  110. DO k = 1, kte-1
  111. factor(k) = dtfall*rdzk(k)/rhok(k)
  112. ENDDO
  113. factor(kte) = dtfall*rdzk(kte)
  114. ppt=0.
  115. k = 1
  116. ppt=rhok(k)*prodk(k)*vt(k)*dtfall/rhowater
  117. RAINNCV(i,j)=ppt*1000.
  118. RAINNC(i,j)=RAINNC(i,j)+ppt*1000. ! unit = mm
  119. !------------------------------------------------------------------------------
  120. ! Time split loop, Fallout done with flux upstream
  121. !------------------------------------------------------------------------------
  122. DO k = kts, kte-1
  123. prodk(k) = prodk(k) - factor(k) &
  124. * (rhok(k)*prodk(k)*vt(k) &
  125. -rhok(k+1)*prodk(k+1)*vt(k+1))
  126. ENDDO
  127. k = kte
  128. prodk(k) = prodk(k) - factor(k)*prodk(k)*vt(k)
  129. !------------------------------------------------------------------------------
  130. ! compute new sedimentation velocity, and check/recompute new
  131. ! sedimentation timestep if this isn't the last split step.
  132. !------------------------------------------------------------------------------
  133. IF( nfall > 1 ) THEN ! this wasn't the last split sedimentation timestep
  134. nfall = nfall - 1
  135. crmax = 0.
  136. DO k = kts, kte
  137. qrr = amax1(0.,prodk(k)*0.001*rhok(k))
  138. vt(k) = 36.34*(qrr**0.1364) * vtden(k)
  139. ! vtmax = amax1(vt(k), vtmax)
  140. crmax = amax1(vt(k)*time_sediment*rdzw(k),crmax)
  141. ENDDO
  142. nfall_new = max(1,nint(0.5+crmax/max_cr_sedimentation))
  143. if (nfall_new /= nfall ) then
  144. nfall = nfall_new
  145. dtfall = time_sediment/nfall
  146. end if
  147. ELSE ! this was the last timestep
  148. DO k=kts,kte
  149. prod(i,k,j) = prodk(k)
  150. ENDDO
  151. nfall = 0 ! exit condition for sedimentation loop
  152. END IF
  153. ENDDO column_sedimentation
  154. ENDDO sedimentation_outer_i_loop
  155. !------------------------------------------------------------------------------
  156. ! Production of rain and deletion of qc
  157. ! Production of qc from supersaturation
  158. ! Evaporation of QR
  159. !------------------------------------------------------------------------------
  160. DO k = kts, kte
  161. DO i = its, ite
  162. factorn = 1.0 / (1.+c3*dt*amax1(0.,qr(i,k,j))**c4)
  163. qrprod = qc(i,k,j) * (1.0 - factorn) &
  164. + factorn*c1*dt*amax1(qc(i,k,j)-c2,0.)
  165. rcgs = 0.001*rho(i,k,j)
  166. qc(i,k,j) = amax1(qc(i,k,j) - qrprod,0.)
  167. qr(i,k,j) = (qr(i,k,j) + prod(i,k,j)-qr(i,k,j))
  168. qr(i,k,j) = amax1(qr(i,k,j) + qrprod,0.)
  169. temp = pii(i,k,j)*t(i,k,j)
  170. pressure = 1.000e+05 * (pii(i,k,j)**(1004./287.))
  171. gam = 2.5e+06/(1004.*pii(i,k,j))
  172. ! qvs = 380.*exp(17.27*(temp-273.)/(temp- 36.))/pressure
  173. es = 1000.*svp1*exp(svp2*(temp-svpt0)/(temp-svp3))
  174. qvs = ep2*es/(pressure-es)
  175. ! prod(i,k,j) = (qv(i,k,j)-qvs) / (1.+qvs*f5/(temp-36.)**2)
  176. prod(i,k,j) = (qv(i,k,j)-qvs) / (1.+pressure/(pressure-es)*qvs*f5/(temp-svp3)**2)
  177. ern = amin1(dt*(((1.6+124.9*(rcgs*qr(i,k,j))**.2046) &
  178. *(rcgs*qr(i,k,j))**.525)/(2.55e8/(pressure*qvs) &
  179. +5.4e5))*(dim(qvs,qv(i,k,j))/(rcgs*qvs)), &
  180. amax1(-prod(i,k,j)-qc(i,k,j),0.),qr(i,k,j))
  181. ! Update all variables
  182. product = amax1(prod(i,k,j),-qc(i,k,j))
  183. t (i,k,j) = t(i,k,j) + gam*(product - ern)
  184. qv(i,k,j) = amax1(qv(i,k,j) - product + ern,0.)
  185. qc(i,k,j) = qc(i,k,j) + product
  186. qr(i,k,j) = qr(i,k,j) - ern
  187. ENDDO
  188. ENDDO
  189. ENDDO microphysics_outer_j_loop
  190. RETURN
  191. END SUBROUTINE kessler
  192. END MODULE module_mp_kessler