UPP  001
 All Data Structures Files Functions Pages
CALRCH.f
Go to the documentation of this file.
1 
23  SUBROUTINE calrch(EL,RICHNO)
24 
25 !
26  use vrbls3d, only: pmid, q, t, uh, vh, zmid, q2
27  use masks, only: vtm
28  use params_mod, only: h10e5, capa, d608,h1, epsq2, g, beta
29  use ctlblk_mod, only: jsta, jend, spval, lm1, jsta_m, jend_m, im, &
30  jsta_2l, jend_2u, lm
31  use gridspec_mod, only: gridtype
32 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
33  implicit none
34 !
35 ! DECLARE VARIABLES.
36 !
37  REAL,intent(in) :: el(im,jsta_2l:jend_2u,lm)
38  REAL,intent(inout) :: richno(im,jsta_2l:jend_2u,lm)
39 !
40  REAL, ALLOCATABLE :: thv(:,:,:)
41  integer i,j,l,iw,ie
42  real ape,uhkl,ulkl,vhkl,vlkl,wndsl,wndslp,rdzkl, &
43  dthvkl,dukl,dvkl,ri,ct,cs
44 ! real APE,UHKL,ULKL,VHKL,VLKL,WNDSL,WNDSLP,DZKL,RDZKL,Q2KL,QROOT,ELKL, &
45 ! ELKLSQ,DTHVKL,DUKL,DVKL,RI,CT,CS
46 !
47 !
48 !*************************************************************************
49 ! START CALRCH HERE.
50 !
51  ALLOCATE ( thv(im,jsta_2l:jend_2u,lm) )
52 ! INITIALIZE ARRAYS.
53 !
54 !$omp parallel do
55  DO l = 1,lm
56  DO j=jsta,jend
57  DO i=1,im
58  richno(i,j,l)=spval
59  ENDDO
60  ENDDO
61  ENDDO
62 !
63 ! COMPUTE VIRTUAL POTENTIAL TEMPERATURE.
64 !
65 !$omp parallel do private(i,j,ape)
66  DO l=lm,1,-1
67  DO j=jsta,jend
68  DO i=1,im
69  ape = (h10e5/pmid(i,j,l))**capa
70  thv(i,j,l) = (q(i,j,l)*d608+h1)*t(i,j,l)*ape
71  ENDDO
72  ENDDO
73  ENDDO
74 !
75 ! COMPUTE GRADIENT RICHARDSON NUMBER AS CODED IN ETA MODEL
76 ! SUBROUTINE PROFQ2.F. OUTER LOOP OVER THE VERTICAL.
77 ! INTTER LOOP OVER THE HORIZONTAL.
78 !
79 !!$omp parallel do private(i,j,l,ie,iw,cs,ct,dthvkl,dukl,dvkl, &
80 !!$omp& rdzkl,ri,uhkl,ulkl,vhkl,vlkl,wndsl,wndslp)
81  DO l = 1,lm1
82 !
83  if(gridtype /= 'A')THEN
84  call exch(vtm(1,jsta_2l,l))
85  call exch(uh(1,jsta_2l,l))
86  call exch(vh(1,jsta_2l,l))
87  call exch(vtm(1,jsta_2l,l+1))
88  call exch(uh(1,jsta_2l,l+1))
89  call exch(vh(1,jsta_2l,l+1))
90  end if
91 
92  DO j=jsta_m,jend_m
93  DO i=2,im-1
94 !
95  IF(gridtype == 'A')THEN
96  uhkl = uh(i,j,l)
97  ulkl = uh(i,j,l+1)
98  vhkl = vh(i,j,l)
99  vlkl = vh(i,j,l+1)
100  ELSE IF(gridtype == 'E')THEN
101  ie = i+mod(j+1,2)
102  iw = i+mod(j+1,2)-1
103 !
104 ! WE NEED (U,V) WINDS AT A MASS POINT. FOUR POINT
105 ! AVERAGE (U,V) WINDS TO MASS POINT. NORMALIZE FOUR
106 ! POINT AVERAGE BY THE ACTUAL NUMBER OF (U,V) WINDS
107 ! USED IN THE AVERAGING. VTM=1 IF WIND POINT IS
108 ! ABOVE GROUND. VTM=0 IF BELOW GROUND.
109 !
110  wndsl = vtm(i,j-1,l)+vtm(iw,j,l)+vtm(ie,j,l)+vtm(i,j+1,l)
111  wndslp = vtm(i,j-1,l+1) + vtm(iw,j,l+1)+ &
112  vtm(ie,j,l+1) + vtm(i,j+1,l+1)
113  IF(wndsl == 0. .OR. wndslp == 0.) cycle
114  uhkl = (uh(i,j-1,l)+uh(iw,j,l)+uh(ie,j,l)+uh(i,j+1,l))/wndsl
115  ulkl = (uh(i,j-1,l+1)+uh(iw,j,l+1)+uh(ie,j,l+1)+ &
116  uh(i,j+1,l+1))/wndslp
117  vhkl = (vh(i,j-1,l)+vh(iw,j,l)+vh(ie,j,l)+vh(i,j+1,l))/wndsl
118  vlkl = (vh(i,j-1,l+1)+vh(iw,j,l+1)+vh(ie,j,l+1)+ &
119  vh(i,j+1,l+1))/wndslp
120  ELSE IF(gridtype == 'B')THEN
121  ie = i
122  iw = i-1
123  uhkl = (uh(iw,j-1,l)+uh(iw,j,l)+uh(ie,j-1,l)+uh(i,j,l))/4.0
124  ulkl = (uh(iw,j-1,l+1)+uh(iw,j,l+1)+uh(ie,j-1,l+1)+ &
125  uh(i,j,l+1))/4.0
126  vhkl = (vh(iw,j-1,l)+vh(iw,j,l)+vh(ie,j-1,l)+vh(i,j,l))/4.0
127  vlkl = (vh(iw,j-1,l+1)+vh(iw,j,l+1)+vh(ie,j-1,l+1)+ &
128  vh(i,j,l+1))/4.0
129  END IF
130 
131  rdzkl = 1.0 / (zmid(i,j,l)-zmid(i,j,l+1))
132 
133 ! Q2KL = MAX(Q2(I,J,L),0.00001)
134 ! QROOT = SQRT(Q2KL)
135 ! ELKL = EL(I,J,L)
136 ! ELKL = MAX(ELKL,EPSQ2)
137 ! ELKLSQ = ELKL*ELKL
138 
139  dthvkl = thv(i,j,l)-thv(i,j,l+1)
140  dukl = (uhkl-ulkl) * rdzkl
141  dvkl = (vhkl-vlkl) * rdzkl
142  cs = dukl*dukl + dvkl*dvkl
143 !
144 ! COMPUTE GRADIENT RICHARDSON NUMBER.
145 !
146  IF(cs <= 1.e-8) THEN
147 !
148 ! WIND SHEAR IS VANISHINGLY SMALL - SO SET RICHARDSON
149 ! NUMBER TO POST PROCESSOR SPECIAL VALUE.
150 !
151  richno(i,j,l) = spval
152 !
153  ELSE
154 !
155 ! WIND SHEAR LARGE ENOUGH TO USE RICHARDSON NUMBER.
156 !
157  ct = -1.*g*beta*dthvkl*rdzkl
158  ri = -ct/cs
159  richno(i,j,l) = ri
160  ENDIF
161 !
162  ENDDO
163  ENDDO
164  ENDDO ! end of l loop
165 !
166  DEALLOCATE (thv)
167 ! END OF ROUTINE.
168 !
169  RETURN
170  END
171 
Definition: MASKS_mod.f:1