UPP  V11.0.0
 All Data Structures Files Functions Pages
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(0,*)' 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(0,*)' 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(0,*)' 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