UPP (develop)
Loading...
Searching...
No Matches
WETBULB.f
1 SUBROUTINE wetbulb(T,Q,PMID,HTM,KARR,TWET)
2!
3! FILE: WETBULB.f
4! WRITTEN: 10 SEPTEMBER 1993, MICHAEL BALDWIN
5! REVISIONS:
6! CONVERSION TO 2-D: 12 JUNE 1998 (T BLACK)
7! MPI VERSION: 04 Jan 2000 ( JIM TUCCILLO )
8! MODIFIED FOR HYBRID: OCT 2001, H CHUANG
9! 02-01-15 MIKE BALDWIN - WRF VERSION
10! 21-07-26 Wen Meng - Restrict compuation from undefined grids
11! 21-09-13 Jesse Meng- 2D DECOMPOSITION
12!
13!-----------------------------------------------------------------------
14! ROUTINE TO COMPUTE WET BULB TEMPERATURES USING THE LOOK UP TABLE
15! APPROACH THAT IS USED IN CUCNVC
16!
17! FOR A GIVEN POINT K AND LAYER L:
18! THETA E IS COMPUTED FROM THETA AND Q BY LIFTING THE PARCEL TO
19! ITS SATURATION POINT.
20! THEN THE WET BULB TEMPERATURE IS FOUND BY FOLLOWING THE THETA E
21! DOWN TO THE ORIGINAL PRESSURE LEVEL (USING SUBROUTINE TTBLEX).
22!
23!
24 use lookup_mod, only: thl, rdth, jtb, qs0, sqs, rdq, itb, ptbl, plq, ttbl,&
25 pl, rdp, the0, sthe, rdthe, ttblq, itbq, jtbq, rdpq, the0q, stheq,&
26 rdtheq
27 use ctlblk_mod, only: jsta, jend, im, jsta_2l, jend_2u, lm, spval, &
28 ista, iend, ista_2l, iend_2u
29 use cuparm_mod, only: h10e5, capa, epsq, d00, elocp
30!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
31 implicit none
32!
33!-----------------------------------------------------------------------
34! LIST OF VARIABLES NEEDED
35! PARAMETERS:
36! INCLUDED IN "cuparm" AND "parm.tbl"
37! INPUT:
38! T,Q,HTM,PMID(3-D),KARR (2-D)
39! OUTPUT:
40! TWET (3-D)
41! SUBROUTINES CALLED:
42! TTBLEX
43!
44 real,dimension(ista_2l:iend_2u,jsta_2l:jend_2u,LM),intent(in) :: T,Q, &
45 pmid,htm
46 integer,dimension(ista:iend,jsta:jend), intent(in) :: KARR
47 real,dimension(ista_2l:iend_2u,jsta_2l:jend_2u,LM),intent(out) :: TWET
48
49
50 real, dimension(ista:iend,jsta:jend) :: THESP, QQ, PP
51 integer, dimension(ista:iend,jsta:jend) :: KLRES,KHRES,IPTB,ITHTB
52!
53 integer I,J,L,ITTB1,ITTBK,IQTBK,IT,KNUML,KNUMH,IQ
54 real TBTK,QBTK,APEBTK,TTHBTK,TTHK,QQK,BQS00K,SQS00K,BQS10K, &
55 sqs10k,bqk,sqk,tqk,ppk,tpspk,apespk,prespk,p00k,p10k,p01k, &
56 p11k,presk
57!
58!--------------COMPUTE WET BULB TEMPERATURES----------------------------
59!!$omp parallel do
60!!$omp& private(apebtk,apespk,bqk,bqs00k,bqs10k,iq,iqtbk,it,ittb1,ittbk,
61!!$omp& karr,khres,klres,knumh,knuml,p00k,p01k,p10k,p11k,ppk,
62!!$omp& presk,qbtk,qqk,sqk,sqs00k,sqs10k,tbtk,thesp,tpspk,
63!!$omp& tqk,tthbtk,tthk)
64!-----------------------------------------------------------------------
65 DO 300 l=1,lm
66 DO 125 j=jsta,jend
67 DO 125 i=ista,iend
68 IF (htm(i,j,l)<1.0) THEN
69 thesp(i,j)=273.15
70 cycle
71 ENDIF
72 IF(t(i,j,l)<spval)THEN
73 tbtk =t(i,j,l)
74 qbtk =q(i,j,l)
75 presk =pmid(i,j,l)
76 apebtk=(h10e5/presk)**capa
77 IF(qbtk<epsq) qbtk=htm(i,j,l)*epsq
78!--------------SCALING POTENTIAL TEMPERATURE & TABLE INDEX--------------
79 tthbtk =tbtk*apebtk
80 tthk =(tthbtk-thl)*rdth
81 qqk =tthk-aint(tthk)
82 ittb1 =int(tthk)+1
83!--------------KEEPING INDICES WITHIN THE TABLE-------------------------
84 IF(ittb1<1) THEN
85 ittb1 =1
86 qqk =d00
87 ENDIF
88!
89 IF(ittb1>=jtb) THEN
90 ittb1 =jtb-1
91 qqk =d00
92 ENDIF
93!--------------BASE AND SCALING FACTOR FOR SPEC. HUMIDITY---------------
94 ittbk=ittb1
95 bqs00k=qs0(ittbk)
96 sqs00k=sqs(ittbk)
97 bqs10k=qs0(ittbk+1)
98 sqs10k=sqs(ittbk+1)
99!--------------SCALING SPEC. HUMIDITY & TABLE INDEX---------------------
100 bqk=(bqs10k-bqs00k)*qqk+bqs00k
101 sqk=(sqs10k-sqs00k)*qqk+sqs00k
102 tqk=(qbtk-bqk)/sqk*rdq
103 ppk=tqk-aint(tqk)
104 iqtbk=int(tqk)+1
105!--------------KEEPING INDICES WITHIN THE TABLE-------------------------
106 IF(iqtbk<1) THEN
107 iqtbk =1
108 ppk =d00
109 ENDIF
110!
111 IF(iqtbk>=itb) THEN
112 iqtbk=itb-1
113 ppk =d00
114 ENDIF
115!--------------SATURATION PRESSURE AT FOUR SURROUNDING TABLE PTS.-------
116 iq=iqtbk
117 it=ittb1
118 p00k=ptbl(iq ,it )
119 p10k=ptbl(iq+1,it )
120 p01k=ptbl(iq ,it+1)
121 p11k=ptbl(iq+1,it+1)
122!--------------SATURATION POINT VARIABLES AT THE BOTTOM-----------------
123 tpspk=p00k+(p10k-p00k)*ppk+(p01k-p00k)*qqk &
124 +(p00k-p10k-p01k+p11k)*ppk*qqk
125 apespk=(h10e5/tpspk)**capa
126 thesp(i,j)=tthbtk*exp(elocp*qbtk*apespk/tthbtk)
127 ELSE
128 thesp(i,j)=spval
129 ENDIF !end t(i,j,l)<spval
130! ENDIF
131 125 CONTINUE
132!--------------SCALING PRESSURE & TT TABLE INDEX------------------------
133 knuml=0
134 knumh=0
135!
136 DO 280 j=jsta,jend
137 DO 280 i=ista,iend
138 klres(i,j)=0
139 khres(i,j)=0
140!
141! IF(KARR(I,J)>0)THEN
142 IF(pmid(i,j,l)==spval)cycle
143 presk=pmid(i,j,l)
144!
145 IF(presk<plq)THEN
146 knuml=knuml+1
147 klres(i,j)=1
148 ELSE
149 knumh=knumh+1
150 khres(i,j)=1
151 ENDIF
152! ENDIF
153 280 CONTINUE
154!***
155!*** COMPUTE PARCEL TEMPERATURE ALONG MOIST ADIABAT FOR PRESSURE<PL
156!**
157 IF(knuml>0)THEN
158 CALL ttblex(twet(ista_2l,jsta_2l,l),ttbl,itb,jtb,klres &
159 ,pmid(ista_2l,jsta_2l,l),pl,qq,pp,rdp,the0,sthe &
160 ,rdthe,thesp,iptb,ithtb)
161 ENDIF
162!***
163!*** COMPUTE PARCEL TEMPERATURE ALONG MOIST ADIABAT FOR PRESSURE>PL
164!**
165 IF(knumh>0)THEN
166 CALL ttblex(twet(ista_2l,jsta_2l,l),ttblq,itbq,jtbq,khres &
167 ,pmid(ista_2l,jsta_2l,l),plq,qq,pp,rdpq,the0q,stheq &
168 ,rdtheq,thesp,iptb,ithtb)
169 ENDIF
170!-----------------------------------------------------------------------
171!-----------------------------------------------------------------------
172 300 CONTINUE
173 RETURN
174 END