1 |
cnh |
1.16 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/calc_gt.F,v 1.15 1998/08/21 12:29:55 cnh Exp $ |
2 |
cnh |
1.1 |
|
3 |
|
|
#include "CPP_EEOPTIONS.h" |
4 |
|
|
|
5 |
|
|
CStartOfInterFace |
6 |
|
|
SUBROUTINE CALC_GT( |
7 |
|
|
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
8 |
cnh |
1.14 |
I xA,yA,uTrans,vTrans,rTrans,maskup,maskC, |
9 |
|
|
I K13,K23,KappaRT,KapGM, |
10 |
cnh |
1.1 |
U af,df,fZon,fMer,fVerT, |
11 |
|
|
I myThid ) |
12 |
|
|
C /==========================================================\ |
13 |
|
|
C | SUBROUTINE CALC_GT | |
14 |
|
|
C | o Calculate the temperature tendency terms. | |
15 |
|
|
C |==========================================================| |
16 |
|
|
C | A procedure called EXTERNAL_FORCING_T is called from | |
17 |
|
|
C | here. These procedures can be used to add per problem | |
18 |
|
|
C | heat flux source terms. | |
19 |
|
|
C | Note: Although it is slightly counter-intuitive the | |
20 |
|
|
C | EXTERNAL_FORCING routine is not the place to put | |
21 |
|
|
C | file I/O. Instead files that are required to | |
22 |
|
|
C | calculate the external source terms are generally | |
23 |
|
|
C | read during the model main loop. This makes the | |
24 |
|
|
C | logisitics of multi-processing simpler and also | |
25 |
|
|
C | makes the adjoint generation simpler. It also | |
26 |
|
|
C | allows for I/O to overlap computation where that | |
27 |
|
|
C | is supported by hardware. | |
28 |
|
|
C | Aside from the problem specific term the code here | |
29 |
|
|
C | forms the tendency terms due to advection and mixing | |
30 |
|
|
C | The baseline implementation here uses a centered | |
31 |
|
|
C | difference form for the advection term and a tensorial | |
32 |
|
|
C | divergence of a flux form for the diffusive term. The | |
33 |
|
|
C | diffusive term is formulated so that isopycnal mixing and| |
34 |
|
|
C | GM-style subgrid-scale terms can be incorporated b simply| |
35 |
|
|
C | setting the diffusion tensor terms appropriately. | |
36 |
|
|
C \==========================================================/ |
37 |
|
|
IMPLICIT NONE |
38 |
|
|
|
39 |
|
|
C == GLobal variables == |
40 |
|
|
#include "SIZE.h" |
41 |
|
|
#include "DYNVARS.h" |
42 |
|
|
#include "EEPARAMS.h" |
43 |
|
|
#include "PARAMS.h" |
44 |
|
|
#include "GRID.h" |
45 |
cnh |
1.11 |
#include "FFIELDS.h" |
46 |
cnh |
1.1 |
|
47 |
|
|
C == Routine arguments == |
48 |
|
|
C fZon - Work array for flux of temperature in the east-west |
49 |
|
|
C direction at the west face of a cell. |
50 |
|
|
C fMer - Work array for flux of temperature in the north-south |
51 |
|
|
C direction at the south face of a cell. |
52 |
|
|
C fVerT - Flux of temperature (T) in the vertical |
53 |
|
|
C direction at the upper(U) and lower(D) faces of a cell. |
54 |
|
|
C maskUp - Land mask used to denote base of the domain. |
55 |
adcroft |
1.13 |
C maskC - Land mask for theta cells (used in TOP_LAYER only) |
56 |
cnh |
1.1 |
C xA - Tracer cell face area normal to X |
57 |
|
|
C yA - Tracer cell face area normal to X |
58 |
|
|
C uTrans - Zonal volume transport through cell face |
59 |
|
|
C vTrans - Meridional volume transport through cell face |
60 |
cnh |
1.14 |
C rTrans - Vertical volume transport through cell face |
61 |
cnh |
1.1 |
C af - Advective flux component work array |
62 |
|
|
C df - Diffusive flux component work array |
63 |
|
|
C bi, bj, iMin, iMax, jMin, jMax - Range of points for which calculation |
64 |
|
|
C results will be set. |
65 |
|
|
C myThid - Instance number for this innvocation of CALC_GT |
66 |
|
|
_RL fZon (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
67 |
|
|
_RL fMer (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
68 |
|
|
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
69 |
|
|
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
70 |
|
|
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
71 |
|
|
_RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
72 |
|
|
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
73 |
cnh |
1.14 |
_RL rTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
74 |
cnh |
1.1 |
_RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
75 |
adcroft |
1.13 |
_RS maskC (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
76 |
cnh |
1.16 |
_RL K13 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
77 |
|
|
_RL K23 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
78 |
|
|
_RL KappaRT(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
79 |
adcroft |
1.3 |
_RL KapGM (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
80 |
cnh |
1.1 |
_RL af (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
81 |
|
|
_RL df (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
82 |
adcroft |
1.3 |
INTEGER k,kUp,kDown,kM1 |
83 |
cnh |
1.1 |
INTEGER bi,bj,iMin,iMax,jMin,jMax |
84 |
|
|
INTEGER myThid |
85 |
|
|
CEndOfInterface |
86 |
|
|
|
87 |
|
|
C == Local variables == |
88 |
|
|
C I, J, K - Loop counters |
89 |
adcroft |
1.3 |
INTEGER i,j |
90 |
cnh |
1.10 |
LOGICAL TOP_LAYER |
91 |
adcroft |
1.3 |
_RL afFacT, dfFacT |
92 |
|
|
_RL dTdx(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
93 |
|
|
_RL dTdy(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
94 |
cnh |
1.1 |
|
95 |
|
|
afFacT = 1. _d 0 |
96 |
|
|
dfFacT = 1. _d 0 |
97 |
cnh |
1.10 |
TOP_LAYER = K .EQ. 1 |
98 |
cnh |
1.1 |
|
99 |
|
|
C--- Calculate advective and diffusive fluxes between cells. |
100 |
|
|
|
101 |
|
|
C-- Zonal flux (fZon is at west face of "theta" cell) |
102 |
|
|
C Advective component of zonal flux |
103 |
|
|
DO j=jMin,jMax |
104 |
|
|
DO i=iMin,iMax |
105 |
|
|
af(i,j) = |
106 |
|
|
& uTrans(i,j)*(theta(i,j,k,bi,bj)+theta(i-1,j,k,bi,bj))*0.5 _d 0 |
107 |
|
|
ENDDO |
108 |
|
|
ENDDO |
109 |
adcroft |
1.3 |
C Zonal tracer gradient |
110 |
|
|
DO j=jMin,jMax |
111 |
|
|
DO i=iMin,iMax |
112 |
cnh |
1.14 |
dTdx(i,j) = _recip_dxC(i,j,bi,bj)* |
113 |
adcroft |
1.3 |
& (theta(i,j,k,bi,bj)-theta(i-1,j,k,bi,bj)) |
114 |
|
|
ENDDO |
115 |
|
|
ENDDO |
116 |
cnh |
1.1 |
C Diffusive component of zonal flux |
117 |
|
|
DO j=jMin,jMax |
118 |
|
|
DO i=iMin,iMax |
119 |
adcroft |
1.3 |
df(i,j) = -(diffKhT+0.5*(KapGM(i,j)+KapGM(i-1,j)))* |
120 |
|
|
& xA(i,j)*dTdx(i,j) |
121 |
cnh |
1.1 |
ENDDO |
122 |
|
|
ENDDO |
123 |
|
|
C Net zonal flux |
124 |
|
|
DO j=jMin,jMax |
125 |
|
|
DO i=iMin,iMax |
126 |
|
|
fZon(i,j) = afFacT*af(i,j) + dfFacT*df(i,j) |
127 |
|
|
ENDDO |
128 |
|
|
ENDDO |
129 |
|
|
|
130 |
|
|
C-- Meridional flux (fMer is at south face of "theta" cell) |
131 |
|
|
C Advective component of meridional flux |
132 |
|
|
DO j=jMin,jMax |
133 |
|
|
DO i=iMin,iMax |
134 |
|
|
C Advective component of meridional flux |
135 |
|
|
af(i,j) = |
136 |
|
|
& vTrans(i,j)*(theta(i,j,k,bi,bj)+theta(i,j-1,k,bi,bj))*0.5 _d 0 |
137 |
|
|
ENDDO |
138 |
|
|
ENDDO |
139 |
adcroft |
1.3 |
C Zonal tracer gradient |
140 |
|
|
DO j=jMin,jMax |
141 |
|
|
DO i=iMin,iMax |
142 |
cnh |
1.14 |
dTdy(i,j) = _recip_dyC(i,j,bi,bj)* |
143 |
adcroft |
1.3 |
& (theta(i,j,k,bi,bj)-theta(i,j-1,k,bi,bj)) |
144 |
|
|
ENDDO |
145 |
|
|
ENDDO |
146 |
cnh |
1.1 |
C Diffusive component of meridional flux |
147 |
|
|
DO j=jMin,jMax |
148 |
|
|
DO i=iMin,iMax |
149 |
adcroft |
1.3 |
df(i,j) = -(diffKhT+0.5*(KapGM(i,j)+KapGM(i,j-1)))* |
150 |
|
|
& yA(i,j)*dTdy(i,j) |
151 |
cnh |
1.1 |
ENDDO |
152 |
|
|
ENDDO |
153 |
|
|
C Net meridional flux |
154 |
|
|
DO j=jMin,jMax |
155 |
|
|
DO i=iMin,iMax |
156 |
|
|
fMer(i,j) = afFacT*af(i,j) + dfFacT*df(i,j) |
157 |
|
|
ENDDO |
158 |
|
|
ENDDO |
159 |
|
|
|
160 |
adcroft |
1.3 |
C-- Interpolate terms for Redi/GM scheme |
161 |
|
|
DO j=jMin,jMax |
162 |
|
|
DO i=iMin,iMax |
163 |
|
|
dTdx(i,j) = 0.5*( |
164 |
cnh |
1.14 |
& +0.5*(_maskW(i+1,j,k,bi,bj)*_recip_dxC(i+1,j,bi,bj)* |
165 |
adcroft |
1.3 |
& (theta(i+1,j,k,bi,bj)-theta(i,j,k,bi,bj)) |
166 |
cnh |
1.14 |
& +_maskW(i,j,k,bi,bj)*_recip_dxC(i,j,bi,bj)* |
167 |
adcroft |
1.3 |
& (theta(i,j,k,bi,bj)-theta(i-1,j,k,bi,bj))) |
168 |
cnh |
1.14 |
& +0.5*(_maskW(i+1,j,km1,bi,bj)*_recip_dxC(i+1,j,bi,bj)* |
169 |
adcroft |
1.3 |
& (theta(i+1,j,km1,bi,bj)-theta(i,j,km1,bi,bj)) |
170 |
cnh |
1.14 |
& +_maskW(i,j,km1,bi,bj)*_recip_dxC(i,j,bi,bj)* |
171 |
adcroft |
1.3 |
& (theta(i,j,km1,bi,bj)-theta(i-1,j,km1,bi,bj))) |
172 |
|
|
& ) |
173 |
|
|
ENDDO |
174 |
|
|
ENDDO |
175 |
|
|
DO j=jMin,jMax |
176 |
|
|
DO i=iMin,iMax |
177 |
|
|
dTdy(i,j) = 0.5*( |
178 |
cnh |
1.14 |
& +0.5*(_maskS(i,j,k,bi,bj)*_recip_dyC(i,j,bi,bj)* |
179 |
adcroft |
1.3 |
& (theta(i,j,k,bi,bj)-theta(i,j-1,k,bi,bj)) |
180 |
cnh |
1.14 |
& +_maskS(i,j+1,k,bi,bj)*_recip_dyC(i,j+1,bi,bj)* |
181 |
adcroft |
1.3 |
& (theta(i,j+1,k,bi,bj)-theta(i,j,k,bi,bj))) |
182 |
cnh |
1.14 |
& +0.5*(_maskS(i,j,km1,bi,bj)*_recip_dyC(i,j,bi,bj)* |
183 |
adcroft |
1.3 |
& (theta(i,j,km1,bi,bj)-theta(i,j-1,km1,bi,bj)) |
184 |
cnh |
1.14 |
& +_maskS(i,j+1,km1,bi,bj)*_recip_dyC(i,j+1,bi,bj)* |
185 |
adcroft |
1.3 |
& (theta(i,j+1,km1,bi,bj)-theta(i,j,km1,bi,bj))) |
186 |
|
|
& ) |
187 |
|
|
ENDDO |
188 |
|
|
ENDDO |
189 |
|
|
|
190 |
cnh |
1.1 |
C-- Vertical flux (fVerT) above |
191 |
|
|
C Advective component of vertical flux |
192 |
adcroft |
1.3 |
C Note: For K=1 then KM1=1 this gives a barZ(T) = T |
193 |
|
|
C (this plays the role of the free-surface correction) |
194 |
cnh |
1.1 |
DO j=jMin,jMax |
195 |
|
|
DO i=iMin,iMax |
196 |
|
|
af(i,j) = |
197 |
cnh |
1.14 |
& rTrans(i,j)*(theta(i,j,k,bi,bj)+theta(i,j,kM1,bi,bj))*0.5 _d 0 |
198 |
cnh |
1.1 |
ENDDO |
199 |
|
|
ENDDO |
200 |
|
|
C Diffusive component of vertical flux |
201 |
cnh |
1.14 |
C Note: For K=1 then KM1=1 this gives a dT/dr = 0 upper |
202 |
adcroft |
1.3 |
C boundary condition. |
203 |
cnh |
1.1 |
DO j=jMin,jMax |
204 |
|
|
DO i=iMin,iMax |
205 |
cnh |
1.14 |
df(i,j) = _rA(i,j,bi,bj)*( |
206 |
adcroft |
1.3 |
& -KapGM(i,j)*K13(i,j,k)*dTdx(i,j) |
207 |
|
|
& -KapGM(i,j)*K23(i,j,k)*dTdy(i,j) |
208 |
|
|
& ) |
209 |
cnh |
1.1 |
ENDDO |
210 |
|
|
ENDDO |
211 |
adcroft |
1.9 |
IF (.NOT.implicitDiffusion) THEN |
212 |
|
|
DO j=jMin,jMax |
213 |
|
|
DO i=iMin,iMax |
214 |
cnh |
1.14 |
df(i,j) = df(i,j) + _rA(i,j,bi,bj)*( |
215 |
cnh |
1.16 |
& -KappaRT(i,j,k)*recip_drC(k) |
216 |
cnh |
1.15 |
& *(theta(i,j,kM1,bi,bj)-theta(i,j,k,bi,bj))*rkFac |
217 |
adcroft |
1.9 |
& ) |
218 |
|
|
ENDDO |
219 |
|
|
ENDDO |
220 |
|
|
ENDIF |
221 |
cnh |
1.1 |
C Net vertical flux |
222 |
|
|
DO j=jMin,jMax |
223 |
|
|
DO i=iMin,iMax |
224 |
cnh |
1.10 |
fVerT(i,j,kUp) = ( afFacT*af(i,j)+ dfFacT*df(i,j) )*maskUp(i,j) |
225 |
cnh |
1.1 |
ENDDO |
226 |
|
|
ENDDO |
227 |
cnh |
1.10 |
IF ( TOP_LAYER ) THEN |
228 |
|
|
DO j=jMin,jMax |
229 |
|
|
DO i=iMin,iMax |
230 |
|
|
fVerT(i,j,kUp) = afFacT*af(i,j)*freeSurfFac |
231 |
|
|
ENDDO |
232 |
|
|
ENDDO |
233 |
|
|
ENDIF |
234 |
cnh |
1.1 |
|
235 |
|
|
C-- Tendency is minus divergence of the fluxes. |
236 |
|
|
C Note. Tendency terms will only be correct for range |
237 |
|
|
C i=iMin+1:iMax-1, j=jMin+1:jMax-1. Edge points |
238 |
|
|
C will contain valid floating point numbers but |
239 |
|
|
C they are not algorithmically correct. These points |
240 |
|
|
C are not used. |
241 |
|
|
DO j=jMin,jMax |
242 |
|
|
DO i=iMin,iMax |
243 |
cnh |
1.14 |
#define _recip_VolT(i,j,k,bi,bj) _recip_hFacC(i,j,k,bi,bj)*recip_drF(k)/_rA(i,j,bi,bj) |
244 |
cnh |
1.1 |
gT(i,j,k,bi,bj)= |
245 |
cnh |
1.14 |
& -_recip_VolT(i,j,k,bi,bj) |
246 |
cnh |
1.1 |
& *( |
247 |
|
|
& +( fZon(i+1,j)-fZon(i,j) ) |
248 |
|
|
& +( fMer(i,j+1)-fMer(i,j) ) |
249 |
cnh |
1.14 |
& +( fVerT(i,j,kUp)-fVerT(i,j,kDown) )*rkFac |
250 |
cnh |
1.1 |
& ) |
251 |
|
|
ENDDO |
252 |
|
|
ENDDO |
253 |
|
|
|
254 |
|
|
C-- External thermal forcing term(s) |
255 |
cnh |
1.11 |
C o Surface relaxation term |
256 |
|
|
IF ( TOP_LAYER ) THEN |
257 |
|
|
DO j=jMin,jMax |
258 |
|
|
DO i=iMin,iMax |
259 |
|
|
gT(i,j,k,bi,bj)=gT(i,j,k,bi,bj) |
260 |
adcroft |
1.13 |
& +maskC(i,j)*( |
261 |
adcroft |
1.12 |
& -lambdaThetaClimRelax*(theta(i,j,k,bi,bj)-SST(i,j,bi,bj)) |
262 |
|
|
& -Qnet(i,j,bi,bj) ) |
263 |
cnh |
1.11 |
ENDDO |
264 |
|
|
ENDDO |
265 |
|
|
ENDIF |
266 |
cnh |
1.1 |
|
267 |
|
|
RETURN |
268 |
|
|
END |