UPP (develop)
Loading...
Searching...
No Matches
TABLE.f
1!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
2 SUBROUTINE table(PTBL,TTBL,PT &
3 &, RDQ,RDTH,RDP,RDTHE,PL,THL,QS0,SQS,STHE,THE0)
4! ******************************************************************
5! * *
6! * GENERATE VALUES FOR LOOK-UP TABLES USED IN CONVECTION *
7! * *
8! ******************************************************************
9!
10 implicit none ! Moorthi
11!
12 integer,parameter :: ITB=076, jtb=134
13 real, parameter :: THH=365.,ph=105000. &
14 &, pq0=379.90516,a1=610.78,a2=17.2693882,a3=273.16, &
15 a4=35.86, r=287.04,cp=1004.6,eliwv=2.683e6,eps=1.e-9
16!
17 real,dimension(ITB,JTB),intent(out) :: PTBL
18 real,dimension(JTB,ITB),intent(out) :: TTBL
19 real,dimension(JTB),intent(out) :: QS0,SQS
20 real,dimension(ITB),intent(out) :: STHE,THE0
21 real, intent(in) :: PT,THL
22 real, intent(out) :: RDQ,RDTH,RDP,RDTHE,PL
23 real &
24 & qsold(jtb), pold(jtb), qsnew(jtb) &
25 &, y2p(jtb), app(jtb), aqp(jtb), pnew(jtb) &
26 &, told(jtb), theold(jtb) &
27 &, y2t(jtb), thenew(jtb), apt(jtb), aqt(jtb), tnew(jtb)
28!
29 real DTH,DP,TH,P,APE,DENOM,QS0K,SQSK,DQS,QS,THEOK,STHEK &
30 &, the0k, dthe
31 integer LTHM,KPM,KTHM1,KPM1,KP,KMM,KTHM,KTH
32
33!--------------COARSE LOOK-UP TABLE FOR SATURATION POINT----------------
34 kthm = jtb
35 kpm = itb
36 kthm1 = kthm-1
37 kpm1 = kpm-1
38!
39 pl = pt
40!
41 dth = (thh-thl) / real(kthm-1)
42 dp = (ph -pl ) / real(kpm -1)
43!
44 rdth = 1./dth
45 rdp = 1./dp
46 rdq = kpm-1
47!
48 th = thl - dth
49!-----------------------------------------------------------------------
50 DO kth=1,kthm
51 th = th + dth
52 p = pl - dp
53 DO kp=1,kpm
54 p = p + dp
55 if (p <= 0.0) then
56 pold(1) = 0.0
57 qsold(1) = 0.0
58 else
59 ape = (100000./p)**(r/cp)
60 denom = th - a4*ape
61 IF (denom > eps) THEN
62 qsold(kp) = pq0 / p*exp(a2*(th-a3*ape)/denom)
63 ELSE
64 qsold(kp) = 0.
65 ENDIF
66! QSOLD(KP)=PQ0/P*EXP(A2*(TH-A3*APE)/(TH-A4*APE))
67 pold(kp) = p
68 endif
69 enddo
70!
71 qs0k = qsold(1)
72 sqsk = qsold(kpm) - qsold(1)
73 qsold(1 ) = 0.
74 qsold(kpm) = 1.
75!
76 DO kp=2,kpm1
77 qsold(kp) = (qsold(kp)-qs0k)/sqsk
78 IF((qsold(kp)-qsold(kp-1)) < eps) qsold(kp) = qsold(kp-1)+eps
79 enddo
80!
81 qs0(kth) = qs0k
82 sqs(kth) = sqsk
83!-----------------------------------------------------------------------
84 qsnew(1 ) = 0.
85 qsnew(kpm) = 1.
86 dqs = 1./real(kpm-1)
87!
88 DO kp=2,kpm1
89 qsnew(kp) = qsnew(kp-1) + dqs
90 enddo
91!
92 y2p(1 ) = 0.
93 y2p(kpm ) = 0.
94!
95 CALL spline(jtb,kpm,qsold,pold,y2p,kpm,qsnew,pnew,app,aqp)
96!
97 DO kp=1,kpm
98 ptbl(kp,kth) = pnew(kp)
99 enddo
100!-----------------------------------------------------------------------
101 enddo
102!--------------COARSE LOOK-UP TABLE FOR T(P) FROM CONSTANT THE----------
103 p = pl - dp
104! write(*,*)' kpm=',kpm,' P=',P,' DP=',DP,' thl=',thl,' dth=',dth
105 DO kp=1,kpm
106 p = p + dp
107 th = thl - dth
108 DO kth=1,kthm
109 th = th + dth
110 if (p <= 0.0) then
111 told(kth) = th
112 theold(kth) = th
113 else
114 ape = (100000./p)**(r/cp)
115 denom = th - a4*ape
116 IF (denom > eps) THEN
117 qs = pq0/p*exp(a2*(th-a3*ape)/denom)
118 ELSE
119 qs = 0.
120 ENDIF
121! QS=PQ0/P*EXP(A2*(TH-A3*APE)/(TH-A4*APE))
122 told(kth) = th / ape
123! write(*,*)' TH=',TH,' QS=',QS,' TOLD=',TOLD(kth),' kth=',kth
124 theold(kth) = th*exp(eliwv*qs/(cp*told(kth)))
125 endif
126 enddo
127! write(*,*)' theold=',theold
128!
129 the0k = theold(1)
130 sthek = theold(kthm) - theold(1)
131 theold(1 ) = 0.
132 theold(kthm) = 1.
133!
134 DO kth=2,kthm1
135 theold(kth)=(theold(kth)-the0k)/sthek
136 IF((theold(kth)-theold(kth-1))<eps) &
137 theold(kth) = theold(kth-1) + eps
138 enddo
139!
140 the0(kp) = the0k
141 sthe(kp) = sthek
142!-----------------------------------------------------------------------
143 thenew(1 ) = 0.
144 thenew(kthm) = 1.
145 dthe = 1./real(kthm-1)
146 rdthe = 1./dthe
147!
148 DO kth=2,kthm1
149 thenew(kth) = thenew(kth-1) + dthe
150 enddo
151!
152 y2t(1 ) = 0.
153 y2t(kthm) = 0.
154!
155 CALL spline(jtb,kthm,theold,told,y2t,kthm,thenew,tnew,apt,aqt)
156!
157 DO kth=1,kthm
158 ttbl(kth,kp) = tnew(kth)
159 enddo
160!-----------------------------------------------------------------------
161 enddo
162!
163 RETURN
164 END