1 |
jmc |
1.30 |
C $Header: /u/gcmpack/MITgcm/model/src/calc_phi_hyd.F,v 1.29 2003/02/18 15:30:47 jmc Exp $ |
2 |
cnh |
1.16 |
C $Name: $ |
3 |
cnh |
1.1 |
|
4 |
cnh |
1.6 |
#include "CPP_OPTIONS.h" |
5 |
cnh |
1.1 |
|
6 |
cnh |
1.16 |
CBOP |
7 |
|
|
C !ROUTINE: CALC_PHI_HYD |
8 |
|
|
C !INTERFACE: |
9 |
adcroft |
1.9 |
SUBROUTINE CALC_PHI_HYD( |
10 |
jmc |
1.29 |
I bi, bj, iMin, iMax, jMin, jMax, k, |
11 |
mlosch |
1.20 |
I tFld, sFld, |
12 |
jmc |
1.29 |
U phiHydF, |
13 |
|
|
O phiHydC, dPhiHydX, dPhiHydY, |
14 |
jmc |
1.25 |
I myTime, myIter, myThid) |
15 |
cnh |
1.16 |
C !DESCRIPTION: \bv |
16 |
|
|
C *==========================================================* |
17 |
cnh |
1.1 |
C | SUBROUTINE CALC_PHI_HYD | |
18 |
jmc |
1.11 |
C | o Integrate the hydrostatic relation to find the Hydros. | |
19 |
cnh |
1.16 |
C *==========================================================* |
20 |
jmc |
1.29 |
C | Potential (ocean: Pressure/rho ; atmos = geopotential) |
21 |
|
|
C | On entry: |
22 |
|
|
C | tFld,sFld are the current thermodynamics quantities |
23 |
|
|
C | (unchanged on exit) |
24 |
|
|
C | phiHydF(i,j) is the hydrostatic Potential anomaly |
25 |
|
|
C | at middle between tracer points k-1,k |
26 |
|
|
C | On exit: |
27 |
|
|
C | phiHydC(i,j) is the hydrostatic Potential anomaly |
28 |
|
|
C | at cell centers (tracer points), level k |
29 |
|
|
C | phiHydF(i,j) is the hydrostatic Potential anomaly |
30 |
|
|
C | at middle between tracer points k,k+1 |
31 |
|
|
C | dPhiHydX,Y hydrostatic Potential gradient (X&Y dir) |
32 |
|
|
C | at cell centers (tracer points), level k |
33 |
|
|
C | integr_GeoPot allows to select one integration method |
34 |
|
|
C | 1= Finite volume form ; else= Finite difference form |
35 |
cnh |
1.16 |
C *==========================================================* |
36 |
|
|
C \ev |
37 |
|
|
C !USES: |
38 |
cnh |
1.1 |
IMPLICIT NONE |
39 |
|
|
C == Global variables == |
40 |
|
|
#include "SIZE.h" |
41 |
|
|
#include "GRID.h" |
42 |
|
|
#include "EEPARAMS.h" |
43 |
|
|
#include "PARAMS.h" |
44 |
heimbach |
1.13 |
#ifdef ALLOW_AUTODIFF_TAMC |
45 |
|
|
#include "tamc.h" |
46 |
|
|
#include "tamc_keys.h" |
47 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
48 |
adcroft |
1.19 |
#include "SURFACE.h" |
49 |
mlosch |
1.20 |
#include "DYNVARS.h" |
50 |
heimbach |
1.13 |
|
51 |
cnh |
1.16 |
C !INPUT/OUTPUT PARAMETERS: |
52 |
cnh |
1.1 |
C == Routine arguments == |
53 |
jmc |
1.29 |
C bi, bj, k :: tile and level indices |
54 |
|
|
C iMin,iMax,jMin,jMax :: computational domain |
55 |
|
|
C tFld :: potential temperature |
56 |
|
|
C sFld :: salinity |
57 |
|
|
C phiHydF :: hydrostatic potential anomaly at middle between |
58 |
|
|
C 2 centers (entry: Interf_k ; output: Interf_k+1) |
59 |
|
|
C phiHydC :: hydrostatic potential anomaly at cell center |
60 |
|
|
C dPhiHydX,Y :: gradient (X & Y dir.) of hydrostatic potential anom. |
61 |
|
|
C myTime :: current time |
62 |
|
|
C myIter :: current iteration number |
63 |
|
|
C myThid :: thread number for this instance of the routine. |
64 |
|
|
INTEGER bi,bj,iMin,iMax,jMin,jMax,k |
65 |
mlosch |
1.20 |
_RL tFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
66 |
|
|
_RL sFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
67 |
jmc |
1.29 |
c _RL phiHyd(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
68 |
|
|
_RL phiHydF(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
69 |
|
|
_RL phiHydC(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
70 |
jmc |
1.25 |
_RL dPhiHydX(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
71 |
|
|
_RL dPhiHydY(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
72 |
|
|
_RL myTime |
73 |
|
|
INTEGER myIter, myThid |
74 |
jmc |
1.14 |
|
75 |
adcroft |
1.9 |
#ifdef INCLUDE_PHIHYD_CALCULATION_CODE |
76 |
|
|
|
77 |
cnh |
1.16 |
C !LOCAL VARIABLES: |
78 |
cnh |
1.1 |
C == Local variables == |
79 |
jmc |
1.29 |
INTEGER i,j |
80 |
jmc |
1.14 |
_RL zero, one, half |
81 |
adcroft |
1.9 |
_RL alphaRho(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
82 |
jmc |
1.29 |
_RL dRlocM,dRlocP, ddRloc, locAlpha |
83 |
|
|
_RL ddPIm, ddPIp, rec_dRm, rec_dRp |
84 |
|
|
_RL surfPhiFac |
85 |
jmc |
1.25 |
INTEGER iMnLoc,jMnLoc |
86 |
|
|
PARAMETER ( zero= 0. _d 0 , one= 1. _d 0 , half= .5 _d 0 ) |
87 |
jmc |
1.29 |
LOGICAL useDiagPhiRlow, addSurfPhiAnom |
88 |
cnh |
1.16 |
CEOP |
89 |
jmc |
1.27 |
useDiagPhiRlow = .TRUE. |
90 |
jmc |
1.29 |
addSurfPhiAnom = select_rStar.EQ.0 .AND. nonlinFreeSurf.GT.3 |
91 |
|
|
surfPhiFac = 0. |
92 |
|
|
IF (addSurfPhiAnom) surfPhiFac = 1. |
93 |
jmc |
1.14 |
|
94 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
95 |
|
|
C Atmosphere: |
96 |
jmc |
1.24 |
C integr_GeoPot => select one option for the integration of the Geopotential: |
97 |
jmc |
1.29 |
C = 0 : Energy Conserving Form, accurate with Topo full cell; |
98 |
|
|
C = 1 : Finite Volume Form, with Part-Cell, linear in P by Half level; |
99 |
|
|
C =2,3: Finite Difference Form, with Part-Cell, |
100 |
|
|
C linear in P between 2 Tracer levels. |
101 |
|
|
C can handle both cases: Tracer lev at the middle of InterFace_W |
102 |
|
|
C and InterFace_W at the middle of Tracer lev; |
103 |
jmc |
1.14 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
104 |
adcroft |
1.9 |
|
105 |
heimbach |
1.13 |
#ifdef ALLOW_AUTODIFF_TAMC |
106 |
|
|
act1 = bi - myBxLo(myThid) |
107 |
|
|
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
108 |
|
|
|
109 |
|
|
act2 = bj - myByLo(myThid) |
110 |
|
|
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
111 |
|
|
|
112 |
|
|
act3 = myThid - 1 |
113 |
|
|
max3 = nTx*nTy |
114 |
|
|
|
115 |
|
|
act4 = ikey_dynamics - 1 |
116 |
|
|
|
117 |
|
|
ikey = (act1 + 1) + act2*max1 |
118 |
|
|
& + act3*max1*max2 |
119 |
|
|
& + act4*max1*max2*max3 |
120 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
121 |
|
|
|
122 |
jmc |
1.29 |
C-- Initialize phiHydF to zero : |
123 |
|
|
C note: atmospheric_loading or Phi_topo anomaly are incorporated |
124 |
|
|
C later in S/R calc_grad_phi_hyd |
125 |
|
|
IF (k.EQ.1) THEN |
126 |
|
|
DO j=1-Oly,sNy+Oly |
127 |
|
|
DO i=1-Olx,sNx+Olx |
128 |
|
|
phiHydF(i,j) = 0. |
129 |
|
|
ENDDO |
130 |
|
|
ENDDO |
131 |
|
|
ENDIF |
132 |
jmc |
1.25 |
|
133 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
134 |
jmc |
1.29 |
IF ( buoyancyRelation .EQ. 'OCEANIC' ) THEN |
135 |
adcroft |
1.9 |
C This is the hydrostatic pressure calculation for the Ocean |
136 |
|
|
C which uses the FIND_RHO() routine to calculate density |
137 |
|
|
C before integrating g*rho over the current layer/interface |
138 |
jmc |
1.25 |
#ifdef ALLOW_AUTODIFF_TAMC |
139 |
|
|
CADJ GENERAL |
140 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
141 |
adcroft |
1.9 |
|
142 |
jmc |
1.29 |
C--- Calculate density |
143 |
heimbach |
1.13 |
#ifdef ALLOW_AUTODIFF_TAMC |
144 |
heimbach |
1.23 |
kkey = (ikey-1)*Nr + k |
145 |
|
|
CADJ STORE tFld (:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte |
146 |
mlosch |
1.20 |
CADJ STORE sFld (:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte |
147 |
heimbach |
1.13 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
148 |
mlosch |
1.20 |
CALL FIND_RHO( bi, bj, iMin, iMax, jMin, jMax, k, k, |
149 |
|
|
& tFld, sFld, |
150 |
adcroft |
1.9 |
& alphaRho, myThid) |
151 |
adcroft |
1.22 |
|
152 |
|
|
C Quasi-hydrostatic terms are added in as if they modify the buoyancy |
153 |
|
|
IF (quasiHydrostatic) THEN |
154 |
|
|
CALL QUASIHYDROSTATICTERMS(bi,bj,k,alphaRho,myThid) |
155 |
|
|
ENDIF |
156 |
adcroft |
1.9 |
|
157 |
jmc |
1.29 |
#ifdef NONLIN_FRSURF |
158 |
|
|
IF (k.EQ.1 .AND. addSurfPhiAnom) THEN |
159 |
|
|
DO j=jMin,jMax |
160 |
|
|
DO i=iMin,iMax |
161 |
|
|
phiHydF(i,j) = surfPhiFac*etaH(i,j,bi,bj) |
162 |
|
|
& *gravity*alphaRho(i,j)*recip_rhoConst |
163 |
|
|
ENDDO |
164 |
|
|
ENDDO |
165 |
|
|
ENDIF |
166 |
|
|
#endif /* NONLIN_FRSURF */ |
167 |
jmc |
1.27 |
|
168 |
jmc |
1.29 |
C---- Hydrostatic pressure at cell centers |
169 |
jmc |
1.25 |
|
170 |
|
|
IF (integr_GeoPot.EQ.1) THEN |
171 |
|
|
C -- Finite Volume Form |
172 |
|
|
|
173 |
|
|
DO j=jMin,jMax |
174 |
adcroft |
1.9 |
DO i=iMin,iMax |
175 |
|
|
|
176 |
jmc |
1.25 |
C---------- This discretization is the "finite volume" form |
177 |
|
|
C which has not been used to date since it does not |
178 |
|
|
C conserve KE+PE exactly even though it is more natural |
179 |
|
|
C |
180 |
jmc |
1.29 |
phiHydC(i,j)=phiHydF(i,j) |
181 |
|
|
& + half*drF(k)*gravity*alphaRho(i,j)*recip_rhoConst |
182 |
|
|
phiHydF(i,j)=phiHydF(i,j) |
183 |
|
|
& + drF(k)*gravity*alphaRho(i,j)*recip_rhoConst |
184 |
jmc |
1.25 |
ENDDO |
185 |
|
|
ENDDO |
186 |
|
|
|
187 |
|
|
ELSE |
188 |
|
|
C -- Finite Difference Form |
189 |
|
|
|
190 |
jmc |
1.29 |
dRlocM=half*drC(k) |
191 |
|
|
IF (k.EQ.1) dRlocM=rF(k)-rC(k) |
192 |
|
|
IF (k.EQ.Nr) THEN |
193 |
|
|
dRlocP=rC(k)-rF(k+1) |
194 |
|
|
ELSE |
195 |
|
|
dRlocP=half*drC(k+1) |
196 |
|
|
ENDIF |
197 |
|
|
|
198 |
jmc |
1.25 |
DO j=jMin,jMax |
199 |
|
|
DO i=iMin,iMax |
200 |
adcroft |
1.9 |
|
201 |
|
|
C---------- This discretization is the "energy conserving" form |
202 |
|
|
C which has been used since at least Adcroft et al., MWR 1997 |
203 |
|
|
C |
204 |
jmc |
1.29 |
phiHydC(i,j)=phiHydF(i,j) |
205 |
|
|
& +dRlocM*gravity*alphaRho(i,j)*recip_rhoConst |
206 |
|
|
phiHydF(i,j)=phiHydC(i,j) |
207 |
|
|
& +dRlocP*gravity*alphaRho(i,j)*recip_rhoConst |
208 |
adcroft |
1.9 |
ENDDO |
209 |
jmc |
1.25 |
ENDDO |
210 |
|
|
|
211 |
|
|
C -- end if integr_GeoPot = ... |
212 |
|
|
ENDIF |
213 |
adcroft |
1.9 |
|
214 |
jmc |
1.25 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
215 |
jmc |
1.29 |
ELSEIF ( buoyancyRelation .EQ. 'OCEANICP' ) THEN |
216 |
adcroft |
1.19 |
C This is the hydrostatic pressure calculation for the Ocean |
217 |
|
|
C which uses the FIND_RHO() routine to calculate density |
218 |
jmc |
1.25 |
C before integrating (1/rho)'*dp over the current layer/interface |
219 |
mlosch |
1.21 |
#ifdef ALLOW_AUTODIFF_TAMC |
220 |
|
|
CADJ GENERAL |
221 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
222 |
adcroft |
1.19 |
|
223 |
jmc |
1.27 |
C-- Calculate density |
224 |
adcroft |
1.19 |
#ifdef ALLOW_AUTODIFF_TAMC |
225 |
|
|
kkey = (ikey-1)*Nr + k |
226 |
heimbach |
1.23 |
CADJ STORE tFld (:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte |
227 |
mlosch |
1.20 |
CADJ STORE sFld (:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte |
228 |
adcroft |
1.19 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
229 |
mlosch |
1.20 |
CALL FIND_RHO( bi, bj, iMin, iMax, jMin, jMax, k, k, |
230 |
|
|
& tFld, sFld, |
231 |
adcroft |
1.19 |
& alphaRho, myThid) |
232 |
heimbach |
1.23 |
#ifdef ALLOW_AUTODIFF_TAMC |
233 |
|
|
CADJ STORE alphaRho (:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
234 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
235 |
|
|
|
236 |
jmc |
1.27 |
C-- Calculate specific volume anomaly : alpha' = 1/rho - alpha_Cst |
237 |
|
|
DO j=jMin,jMax |
238 |
|
|
DO i=iMin,iMax |
239 |
|
|
locAlpha=alphaRho(i,j)+rhoConst |
240 |
|
|
alphaRho(i,j)=maskC(i,j,k,bi,bj)* |
241 |
|
|
& (one/locAlpha - recip_rhoConst) |
242 |
|
|
ENDDO |
243 |
|
|
ENDDO |
244 |
|
|
|
245 |
jmc |
1.25 |
C---- Hydrostatic pressure at cell centers |
246 |
|
|
|
247 |
|
|
IF (integr_GeoPot.EQ.1) THEN |
248 |
|
|
C -- Finite Volume Form |
249 |
|
|
|
250 |
|
|
DO j=jMin,jMax |
251 |
adcroft |
1.19 |
DO i=iMin,iMax |
252 |
jmc |
1.25 |
|
253 |
|
|
C---------- This discretization is the "finite volume" form |
254 |
|
|
C which has not been used to date since it does not |
255 |
|
|
C conserve KE+PE exactly even though it is more natural |
256 |
|
|
C |
257 |
jmc |
1.29 |
IF (k.EQ.ksurfC(i,j,bi,bj)) THEN |
258 |
|
|
ddRloc = Ro_surf(i,j,bi,bj)-rC(k) |
259 |
|
|
#ifdef NONLIN_FRSURF |
260 |
|
|
ddRloc = ddRloc + surfPhiFac*etaH(i,j,bi,bj) |
261 |
|
|
#endif |
262 |
|
|
phiHydC(i,j) = ddRloc*alphaRho(i,j) |
263 |
|
|
c--to reproduce results of c48d_post: uncomment those 4+1 lines |
264 |
|
|
c phiHydC(i,j)=phiHydF(i,j) |
265 |
|
|
c & +(hFacC(i,j,k,bi,bj)-half)*drF(k)*alphaRho(i,j) |
266 |
|
|
c phiHydF(i,j)=phiHydF(i,j) |
267 |
|
|
c & + hFacC(i,j,k,bi,bj)*drF(k)*alphaRho(i,j) |
268 |
|
|
ELSE |
269 |
|
|
phiHydC(i,j) = phiHydF(i,j) + half*drF(k)*alphaRho(i,j) |
270 |
|
|
c phiHydF(i,j) = phiHydF(i,j) + drF(k)*alphaRho(i,j) |
271 |
|
|
ENDIF |
272 |
|
|
c-- and comment this last one: |
273 |
|
|
phiHydF(i,j) = phiHydC(i,j) + half*drF(k)*alphaRho(i,j) |
274 |
|
|
c----- |
275 |
jmc |
1.25 |
ENDDO |
276 |
|
|
ENDDO |
277 |
|
|
|
278 |
|
|
ELSE |
279 |
jmc |
1.29 |
C -- Finite Difference Form, with Part-Cell Bathy |
280 |
|
|
|
281 |
|
|
dRlocM=half*drC(k) |
282 |
|
|
IF (k.EQ.1) dRlocM=rF(k)-rC(k) |
283 |
|
|
IF (k.EQ.Nr) THEN |
284 |
|
|
dRlocP=rC(k)-rF(k+1) |
285 |
|
|
ELSE |
286 |
|
|
dRlocP=half*drC(k+1) |
287 |
|
|
ENDIF |
288 |
|
|
rec_dRm = one/(rF(k)-rC(k)) |
289 |
|
|
rec_dRp = one/(rC(k)-rF(k+1)) |
290 |
jmc |
1.25 |
|
291 |
|
|
DO j=jMin,jMax |
292 |
|
|
DO i=iMin,iMax |
293 |
adcroft |
1.9 |
|
294 |
adcroft |
1.19 |
C---------- This discretization is the "energy conserving" form |
295 |
mlosch |
1.21 |
|
296 |
jmc |
1.29 |
IF (k.EQ.ksurfC(i,j,bi,bj)) THEN |
297 |
|
|
ddRloc = Ro_surf(i,j,bi,bj)-rC(k) |
298 |
|
|
#ifdef NONLIN_FRSURF |
299 |
|
|
ddRloc = ddRloc + surfPhiFac*etaH(i,j,bi,bj) |
300 |
|
|
#endif |
301 |
|
|
phiHydC(i,j) =( MAX(zero,ddRloc)*rec_dRm*dRlocM |
302 |
|
|
& +MIN(zero,ddRloc)*rec_dRp*dRlocP |
303 |
|
|
& )*alphaRho(i,j) |
304 |
|
|
ELSE |
305 |
|
|
phiHydC(i,j) = phiHydF(i,j) + dRlocM*alphaRho(i,j) |
306 |
|
|
ENDIF |
307 |
|
|
phiHydF(i,j) = phiHydC(i,j) + dRlocP*alphaRho(i,j) |
308 |
adcroft |
1.19 |
ENDDO |
309 |
jmc |
1.25 |
ENDDO |
310 |
|
|
|
311 |
|
|
C -- end if integr_GeoPot = ... |
312 |
|
|
ENDIF |
313 |
adcroft |
1.9 |
|
314 |
jmc |
1.29 |
ELSEIF ( buoyancyRelation .EQ. 'ATMOSPHERIC' ) THEN |
315 |
jmc |
1.14 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
316 |
adcroft |
1.9 |
C This is the hydrostatic geopotential calculation for the Atmosphere |
317 |
|
|
C The ideal gas law is used implicitly here rather than calculating |
318 |
|
|
C the specific volume, analogous to the oceanic case. |
319 |
|
|
|
320 |
jmc |
1.30 |
C-- virtual potential temperature anomaly (including water vapour effect) |
321 |
|
|
DO j=jMin,jMax |
322 |
|
|
DO i=iMin,iMax |
323 |
|
|
alphaRho(i,j)=maskC(i,j,k,bi,bj) |
324 |
|
|
& *( tFld(i,j,k,bi,bj)*(sFld(i,j,k,bi,bj)*atm_Rq+one) |
325 |
|
|
& -tRef(k) ) |
326 |
|
|
ENDDO |
327 |
|
|
ENDDO |
328 |
|
|
|
329 |
jmc |
1.29 |
C--- Integrate d Phi / d pi |
330 |
adcroft |
1.9 |
|
331 |
jmc |
1.29 |
IF (integr_GeoPot.EQ.0) THEN |
332 |
|
|
C -- Energy Conserving Form, accurate with Full cell topo -- |
333 |
jmc |
1.14 |
C------------ The integration for the first level phi(k=1) is the same |
334 |
|
|
C for both the "finite volume" and energy conserving methods. |
335 |
jmc |
1.29 |
C *NOTE* o Working with geopotential Anomaly, the geopotential boundary |
336 |
adcroft |
1.17 |
C condition is simply Phi-prime(Ro_surf)=0. |
337 |
jmc |
1.14 |
C o convention ddPI > 0 (same as drF & drC) |
338 |
|
|
C----------------------------------------------------------------------- |
339 |
jmc |
1.29 |
IF (k.EQ.1) THEN |
340 |
|
|
ddPIm=atm_Cp*( ((rF( k )/atm_Po)**atm_kappa) |
341 |
|
|
& -((rC( k )/atm_Po)**atm_kappa) ) |
342 |
|
|
ELSE |
343 |
|
|
ddPIm=atm_Cp*( ((rC(k-1)/atm_Po)**atm_kappa) |
344 |
|
|
& -((rC( k )/atm_Po)**atm_kappa) )*half |
345 |
|
|
ENDIF |
346 |
|
|
IF (k.EQ.Nr) THEN |
347 |
|
|
ddPIp=atm_Cp*( ((rC( k )/atm_Po)**atm_kappa) |
348 |
|
|
& -((rF(k+1)/atm_Po)**atm_kappa) ) |
349 |
|
|
ELSE |
350 |
|
|
ddPIp=atm_Cp*( ((rC( k )/atm_Po)**atm_kappa) |
351 |
|
|
& -((rC(k+1)/atm_Po)**atm_kappa) )*half |
352 |
|
|
ENDIF |
353 |
jmc |
1.14 |
C-------- This discretization is the energy conserving form |
354 |
jmc |
1.29 |
DO j=jMin,jMax |
355 |
|
|
DO i=iMin,iMax |
356 |
jmc |
1.30 |
phiHydC(i,j) = phiHydF(i,j) +ddPIm*alphaRho(i,j) |
357 |
|
|
phiHydF(i,j) = phiHydC(i,j) +ddPIp*alphaRho(i,j) |
358 |
jmc |
1.14 |
ENDDO |
359 |
jmc |
1.29 |
ENDDO |
360 |
jmc |
1.14 |
C end: Energy Conserving Form, No hFac -- |
361 |
adcroft |
1.9 |
C----------------------------------------------------------------------- |
362 |
jmc |
1.14 |
|
363 |
jmc |
1.29 |
ELSEIF (integr_GeoPot.EQ.1) THEN |
364 |
|
|
C -- Finite Volume Form, with Part-Cell Topo, linear in P by Half level |
365 |
jmc |
1.14 |
C--------- |
366 |
|
|
C Finite Volume formulation consistent with Partial Cell, linear in p by piece |
367 |
|
|
C Note: a true Finite Volume form should be linear between 2 Interf_W : |
368 |
|
|
C phi_C = (phi_W_k+ phi_W_k+1)/2 ; but not accurate in Stratosphere (low p) |
369 |
|
|
C also: if Interface_W at the middle between tracer levels, this form |
370 |
|
|
C is close to the Energy Cons. form in the Interior, except for the |
371 |
|
|
C non-linearity in PI(p) |
372 |
|
|
C--------- |
373 |
jmc |
1.29 |
ddPIm=atm_Cp*( ((rF( k )/atm_Po)**atm_kappa) |
374 |
|
|
& -((rC( k )/atm_Po)**atm_kappa) ) |
375 |
|
|
ddPIp=atm_Cp*( ((rC( k )/atm_Po)**atm_kappa) |
376 |
|
|
& -((rF(k+1)/atm_Po)**atm_kappa) ) |
377 |
|
|
DO j=jMin,jMax |
378 |
|
|
DO i=iMin,iMax |
379 |
|
|
IF (k.EQ.ksurfC(i,j,bi,bj)) THEN |
380 |
|
|
ddRloc = Ro_surf(i,j,bi,bj)-rC(k) |
381 |
|
|
#ifdef NONLIN_FRSURF |
382 |
|
|
ddRloc = ddRloc + surfPhiFac*etaH(i,j,bi,bj) |
383 |
|
|
#endif |
384 |
|
|
phiHydC(i,j) = ddRloc*recip_drF(k)*2. _d 0 |
385 |
jmc |
1.30 |
& *ddPIm*alphaRho(i,j) |
386 |
jmc |
1.29 |
ELSE |
387 |
jmc |
1.30 |
phiHydC(i,j) = phiHydF(i,j) +ddPIm*alphaRho(i,j) |
388 |
jmc |
1.29 |
ENDIF |
389 |
jmc |
1.30 |
phiHydF(i,j) = phiHydC(i,j) +ddPIp*alphaRho(i,j) |
390 |
adcroft |
1.9 |
ENDDO |
391 |
jmc |
1.29 |
ENDDO |
392 |
|
|
C end: Finite Volume Form, with Part-Cell Topo, linear in P by Half level |
393 |
adcroft |
1.9 |
C----------------------------------------------------------------------- |
394 |
|
|
|
395 |
jmc |
1.29 |
ELSEIF ( integr_GeoPot.EQ.2 |
396 |
|
|
& .OR. integr_GeoPot.EQ.3 ) THEN |
397 |
|
|
C -- Finite Difference Form, with Part-Cell Topo, |
398 |
|
|
C works with Interface_W at the middle between 2.Tracer_Level |
399 |
|
|
C and with Tracer_Level at the middle between 2.Interface_W. |
400 |
jmc |
1.14 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
401 |
|
|
C Finite Difference formulation consistent with Partial Cell, |
402 |
|
|
C Valid & accurate if Interface_W at middle between tracer levels |
403 |
|
|
C linear in p between 2 Tracer levels ; conserve energy in the Interior |
404 |
|
|
C--------- |
405 |
jmc |
1.29 |
IF (k.EQ.1) THEN |
406 |
|
|
ddPIm=atm_Cp*( ((rF( k )/atm_Po)**atm_kappa) |
407 |
|
|
& -((rC( k )/atm_Po)**atm_kappa) ) |
408 |
|
|
ELSE |
409 |
|
|
ddPIm=atm_Cp*( ((rC(k-1)/atm_Po)**atm_kappa) |
410 |
|
|
& -((rC( k )/atm_Po)**atm_kappa) )*half |
411 |
|
|
ENDIF |
412 |
|
|
IF (k.EQ.Nr) THEN |
413 |
|
|
ddPIp=atm_Cp*( ((rC( k )/atm_Po)**atm_kappa) |
414 |
|
|
& -((rF(k+1)/atm_Po)**atm_kappa) ) |
415 |
|
|
ELSE |
416 |
|
|
ddPIp=atm_Cp*( ((rC( k )/atm_Po)**atm_kappa) |
417 |
|
|
& -((rC(k+1)/atm_Po)**atm_kappa) )*half |
418 |
|
|
ENDIF |
419 |
|
|
rec_dRm = one/(rF(k)-rC(k)) |
420 |
|
|
rec_dRp = one/(rC(k)-rF(k+1)) |
421 |
|
|
DO j=jMin,jMax |
422 |
|
|
DO i=iMin,iMax |
423 |
|
|
IF (k.EQ.ksurfC(i,j,bi,bj)) THEN |
424 |
|
|
ddRloc = Ro_surf(i,j,bi,bj)-rC(k) |
425 |
|
|
#ifdef NONLIN_FRSURF |
426 |
|
|
ddRloc = ddRloc + surfPhiFac*etaH(i,j,bi,bj) |
427 |
|
|
#endif |
428 |
|
|
phiHydC(i,j) =( MAX(zero,ddRloc)*rec_dRm*ddPIm |
429 |
|
|
& +MIN(zero,ddRloc)*rec_dRp*ddPIp ) |
430 |
jmc |
1.30 |
& *alphaRho(i,j) |
431 |
jmc |
1.29 |
ELSE |
432 |
jmc |
1.30 |
phiHydC(i,j) = phiHydF(i,j) +ddPIm*alphaRho(i,j) |
433 |
jmc |
1.29 |
ENDIF |
434 |
jmc |
1.30 |
phiHydF(i,j) = phiHydC(i,j) +ddPIp*alphaRho(i,j) |
435 |
jmc |
1.14 |
ENDDO |
436 |
jmc |
1.29 |
ENDDO |
437 |
|
|
C end: Finite Difference Form, with Part-Cell Topo |
438 |
jmc |
1.14 |
C----------------------------------------------------------------------- |
439 |
cnh |
1.1 |
|
440 |
jmc |
1.29 |
ELSE |
441 |
|
|
STOP 'CALC_PHI_HYD: Bad integr_GeoPot option !' |
442 |
|
|
ENDIF |
443 |
cnh |
1.6 |
|
444 |
jmc |
1.14 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
445 |
adcroft |
1.9 |
ELSE |
446 |
jmc |
1.24 |
STOP 'CALC_PHI_HYD: Bad value of buoyancyRelation !' |
447 |
jmc |
1.25 |
ENDIF |
448 |
|
|
|
449 |
jmc |
1.29 |
C--- Diagnose Phi at boundary r=R_low : |
450 |
|
|
C = Ocean bottom pressure (Ocean, Z-coord.) |
451 |
|
|
C = Sea-surface height (Ocean, P-coord.) |
452 |
|
|
C = Top atmosphere height (Atmos, P-coord.) |
453 |
|
|
IF (useDiagPhiRlow) THEN |
454 |
|
|
CALL DIAGS_PHI_RLOW( |
455 |
|
|
I k, bi, bj, iMin,iMax, jMin,jMax, |
456 |
|
|
I phiHydF, phiHydC, alphaRho, tFld, sFld, |
457 |
|
|
I myTime, myIter, myThid) |
458 |
|
|
ENDIF |
459 |
|
|
|
460 |
|
|
C--- Diagnose Full Hydrostatic Potential at cell center level |
461 |
|
|
CALL DIAGS_PHI_HYD( |
462 |
|
|
I k, bi, bj, iMin,iMax, jMin,jMax, |
463 |
|
|
I phiHydC, |
464 |
|
|
I myTime, myIter, myThid) |
465 |
|
|
|
466 |
jmc |
1.25 |
IF (momPressureForcing) THEN |
467 |
|
|
iMnLoc = MAX(1-Olx+1,iMin) |
468 |
|
|
jMnLoc = MAX(1-Oly+1,jMin) |
469 |
|
|
CALL CALC_GRAD_PHI_HYD( |
470 |
|
|
I k, bi, bj, iMnLoc,iMax, jMnLoc,jMax, |
471 |
jmc |
1.29 |
I phiHydC, alphaRho, tFld, sFld, |
472 |
jmc |
1.25 |
O dPhiHydX, dPhiHydY, |
473 |
|
|
I myTime, myIter, myThid) |
474 |
cnh |
1.5 |
ENDIF |
475 |
cnh |
1.1 |
|
476 |
jmc |
1.14 |
#endif /* INCLUDE_PHIHYD_CALCULATION_CODE */ |
477 |
cnh |
1.6 |
|
478 |
jmc |
1.11 |
RETURN |
479 |
|
|
END |