UPP  001
 All Data Structures Files Functions Pages
CALPBLREGIME.f
Go to the documentation of this file.
1 
27  SUBROUTINE calpblregime(PBLREGIME)
28 
29 !
30  use vrbls3d, only: uh, vh, pmid, t, q, pint, zmid, zint
31  use vrbls2d, only: ths, qs, smstav, twbs, qwbs, pblh
32  use masks, only: dx
33  use params_mod, only: p1000, capa, d608, h1, g, rd, cp
34  use ctlblk_mod, only: jsta, jend, spval, lm, jsta_m, jend_m, im, &
35  jsta_2l, jend_2u
36  use gridspec_mod, only: gridtype
37 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
38  implicit none
39 !
40 ! INCLUDE,DERIVE,SET PARAMETERS.
41 !
42  REAL , PARAMETER :: vconvc=1.
43 !
44 ! DECLARE VARIABLES.
45 !
46  REAL,dimension(IM,jsta_2l:jend_2u),intent(inout) :: pblregime
47 !
48  integer i,j,ie,iw,ii,jj
49  real ape,thv,thvx,govrth,umass,vmass,wspd,tskv,dthv,rhox,fluxc,tsfc, &
50  vconv,vsgd,br,thx
51 
52 !
53 !
54 !*************************************************************************
55 !
56 ! INITIALIZE ARRAYS.
57 !
58 !$omp parallel do private(i,j)
59  DO j=jsta,jend
60  DO i=1,im
61  pblregime(i,j) = spval
62  ENDDO
63  ENDDO
64 !
65 ! COMPUTE BULK RICHARDSON NUMBER AS CODED IN WRF module_sf_sfclay
66 !
67 !!$omp parallel do
68 !!$omp& private(uhkl,ulkl,vhkl,vlkl,rib,ubot,utop,vbot,vtop,
69 !!$omp& betta,ricr,ustarr,wmin,tvhtop,ztop,
70 !!$omp& wndsl,wndslp,betta,ricr,ustarr,wmin
71 !!$omp& ,IFRSTLEV
72 !!$omp& ,ICALPBL
73 !!$omp& ,LVLP
74 !!$omp& ,RIF
75 !!$omp& ,RIBP
76 !!$omp& ,UBOT1
77 !!$omp& ,VBOT1
78 !!$omp& ,ZBOT1
79 !!$omp& ,THVBOT1)
80 !
81  IF(gridtype /= 'A')THEN
82  call exch(uh(1,jsta_2l,lm))
83  call exch(vh(1,jsta_2l,lm))
84  END IF
85 
86  DO j=jsta_m,jend_m
87  DO i=2,im-1
88 !
89  IF(pmid(i,j,lm)<spval .AND. qs(i,j)<spval .AND. &
90  smstav(i,j)<spval) THEN
91  ape = (p1000/pmid(i,j,lm))**capa
92  thx = t(i,j,lm)*ape
93  thvx = (q(i,j,lm)*d608+h1)*thx
94  govrth = g/thx
95  IF(gridtype == 'E')THEN
96  ie=i+mod(j+1,2)
97  iw=i+mod(j+1,2)-1
98  umass = (uh(i,j-1,lm)+uh(iw,j,lm)+uh(ie,j,lm) &
99  + uh(i,j+1,lm))/4.0
100  vmass = (vh(i,j-1,lm)+vh(iw,j,lm)+vh(ie,j,lm) &
101  + vh(i,j+1,lm))/4.0
102  wspd= sqrt(umass*umass+vmass*vmass)
103  ELSE IF(gridtype == 'B')THEN
104  ie = i
105  iw = i-1
106  umass = (uh(iw,j-1,lm)+uh(iw,j,lm)+uh(ie,j-1,lm) &
107  + uh(i,j,lm))/4.0
108  vmass = (vh(iw,j-1,lm)+vh(iw,j,lm)+vh(ie,j-1,lm) &
109  + vh(i,j,lm))/4.0
110  wspd= sqrt(umass*umass+vmass*vmass)
111  ELSE
112  wspd = sqrt(uh(i,j,lm)*uh(i,j,lm)+vh(i,j,lm)*vh(i,j,lm))
113  END IF
114 
115  tskv = ths(i,j)*(1.+d608*qs(i,j)*smstav(i,j))
116  dthv = (thvx-tskv)
117 ! Convective velocity scale Vc and subgrid-scale velocity Vsg
118 ! following Beljaars (1995, QJRMS) and Mahrt and Sun (1995, MWR)
119 ! ... HONG Aug. 2001
120 !
121  rhox = pint(i,j,lm+1)/rd/(t(i,j,lm)*(q(i,j,lm)*d608+h1)) !density
122  fluxc = max(-twbs(i,j)/rhox/cp - d608*tskv*qwbs(i,j)/rhox,0.)
123  tsfc = ths(i,j)*(pint(i,j,lm+1)/p1000)**capa
124  vconv = vconvc*(g/tsfc*pblh(i,j)*fluxc)**.33
125 ! VCONV comes from Beljaars only
126  vsgd = 0.32 * (max(dx(i,j)/5000.-1.,0.))**.33
127  wspd = sqrt(wspd*wspd+vconv*vconv+vsgd*vsgd)
128  wspd = max(wspd,0.1)
129  br = govrth*(zmid(i,j,lm)-zint(i,j,lm+1))*dthv/(wspd*wspd)
130 
131  IF(br < 0.0) THEN
132  pblregime(i,j) = 4.0
133  ELSE IF(br == 0.0) THEN
134  pblregime(i,j) = 3.0
135  ELSE IF(br < 0.2) THEN
136  pblregime(i,j) = 2.0
137  ELSE
138  pblregime(i,j) = 1.0
139  END IF
140 
141 ! ii=im/2
142 ! jj=(jsta+jend)/2
143 ! if(i==ii.and.j==jj)print*,'Debug: CALPBLREGIME ',i,j,br, &
144 ! PBLREGIME(I,J)
145  END IF !end IF PMID
146 
147  ENDDO
148  ENDDO
149 !
150 ! END OF ROUTINE.
151 !
152  RETURN
153  END
154 
Definition: MASKS_mod.f:1