/[MITgcm]/MITgcm/model/src/calc_phi_hyd.F
ViewVC logotype

Annotation of /MITgcm/model/src/calc_phi_hyd.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.41 - (hide annotations) (download)
Wed Apr 11 04:02:05 2012 UTC (12 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint64a
Changes since 1.40: +69 -29 lines
implement partial cell near the surface also for Z-coordinates (for the
case where uniformFreeSurfLev=F)

1 jmc 1.41 C $Header: /u/gcmpack/MITgcm/model/src/calc_phi_hyd.F,v 1.40 2010/03/16 00:08:27 jmc Exp $
2 cnh 1.16 C $Name: $
3 cnh 1.1
4 jmc 1.32 #include "PACKAGES_CONFIG.h"
5 cnh 1.6 #include "CPP_OPTIONS.h"
6 cnh 1.1
7 cnh 1.16 CBOP
8     C !ROUTINE: CALC_PHI_HYD
9     C !INTERFACE:
10 adcroft 1.9 SUBROUTINE CALC_PHI_HYD(
11 jmc 1.29 I bi, bj, iMin, iMax, jMin, jMax, k,
12 mlosch 1.20 I tFld, sFld,
13 jmc 1.29 U phiHydF,
14     O phiHydC, dPhiHydX, dPhiHydY,
15 jmc 1.38 I myTime, myIter, myThid )
16 cnh 1.16 C !DESCRIPTION: \bv
17     C *==========================================================*
18 cnh 1.1 C | SUBROUTINE CALC_PHI_HYD |
19 jmc 1.36 C | o Integrate the hydrostatic relation to find the Hydros. |
20 cnh 1.16 C *==========================================================*
21 jmc 1.29 C | Potential (ocean: Pressure/rho ; atmos = geopotential)
22     C | On entry:
23     C | tFld,sFld are the current thermodynamics quantities
24     C | (unchanged on exit)
25     C | phiHydF(i,j) is the hydrostatic Potential anomaly
26 jmc 1.36 C | at middle between tracer points k-1,k
27 jmc 1.29 C | On exit:
28     C | phiHydC(i,j) is the hydrostatic Potential anomaly
29     C | at cell centers (tracer points), level k
30     C | phiHydF(i,j) is the hydrostatic Potential anomaly
31 jmc 1.36 C | at middle between tracer points k,k+1
32 jmc 1.29 C | dPhiHydX,Y hydrostatic Potential gradient (X&Y dir)
33     C | at cell centers (tracer points), level k
34     C | integr_GeoPot allows to select one integration method
35     C | 1= Finite volume form ; else= Finite difference form
36 cnh 1.16 C *==========================================================*
37     C \ev
38     C !USES:
39 cnh 1.1 IMPLICIT NONE
40     C == Global variables ==
41     #include "SIZE.h"
42     #include "GRID.h"
43     #include "EEPARAMS.h"
44     #include "PARAMS.h"
45 heimbach 1.13 #ifdef ALLOW_AUTODIFF_TAMC
46     #include "tamc.h"
47     #include "tamc_keys.h"
48     #endif /* ALLOW_AUTODIFF_TAMC */
49 adcroft 1.19 #include "SURFACE.h"
50 mlosch 1.20 #include "DYNVARS.h"
51 heimbach 1.13
52 cnh 1.16 C !INPUT/OUTPUT PARAMETERS:
53 cnh 1.1 C == Routine arguments ==
54 jmc 1.36 C bi, bj, k :: tile and level indices
55 jmc 1.29 C iMin,iMax,jMin,jMax :: computational domain
56     C tFld :: potential temperature
57     C sFld :: salinity
58     C phiHydF :: hydrostatic potential anomaly at middle between
59     C 2 centers (entry: Interf_k ; output: Interf_k+1)
60     C phiHydC :: hydrostatic potential anomaly at cell center
61     C dPhiHydX,Y :: gradient (X & Y dir.) of hydrostatic potential anom.
62     C myTime :: current time
63     C myIter :: current iteration number
64     C myThid :: thread number for this instance of the routine.
65     INTEGER bi,bj,iMin,iMax,jMin,jMax,k
66 mlosch 1.20 _RL tFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
67     _RL sFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
68 jmc 1.29 c _RL phiHyd(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
69     _RL phiHydF(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
70     _RL phiHydC(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
71 jmc 1.41 _RL dPhiHydX(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
72     _RL dPhiHydY(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
73 jmc 1.25 _RL myTime
74     INTEGER myIter, myThid
75 jmc 1.36
76 adcroft 1.9 #ifdef INCLUDE_PHIHYD_CALCULATION_CODE
77    
78 cnh 1.16 C !LOCAL VARIABLES:
79 cnh 1.1 C == Local variables ==
80 jmc 1.29 INTEGER i,j
81 jmc 1.14 _RL zero, one, half
82 adcroft 1.9 _RL alphaRho(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
83 jmc 1.29 _RL dRlocM,dRlocP, ddRloc, locAlpha
84     _RL ddPIm, ddPIp, rec_dRm, rec_dRp
85     _RL surfPhiFac
86 jmc 1.25 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.41 addSurfPhiAnom = select_rStar.EQ.0 .AND. nonlinFreeSurf.GE.4
91 jmc 1.29 surfPhiFac = 0.
92     IF (addSurfPhiAnom) surfPhiFac = 1.
93 jmc 1.14
94     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
95 jmc 1.36 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 jmc 1.36 C =2,3: Finite Difference Form, with Part-Cell,
100 jmc 1.29 C linear in P between 2 Tracer levels.
101 jmc 1.36 C can handle both cases: Tracer lev at the middle of InterFace_W
102 jmc 1.29 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.36 C-- Initialize phiHydF to zero :
123 jmc 1.29 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 jmc 1.41 DO j=1-OLy,sNy+OLy
127     DO i=1-OLx,sNx+OLx
128 jmc 1.29 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.38 #ifdef ALLOW_AUTODIFF_TAMC
139 jmc 1.25 CADJ GENERAL
140 jmc 1.38 #endif /* ALLOW_AUTODIFF_TAMC */
141 adcroft 1.9
142 jmc 1.38 IF ( implicitIntGravWave .OR. myIter.LT.0 ) THEN
143 jmc 1.29 C--- Calculate density
144 heimbach 1.13 #ifdef ALLOW_AUTODIFF_TAMC
145 jmc 1.38 kkey = (ikey-1)*Nr + k
146 heimbach 1.39 CADJ STORE tFld (:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte,
147     CADJ & kind = isbyte
148     CADJ STORE sFld (:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte,
149     CADJ & kind = isbyte
150 heimbach 1.13 #endif /* ALLOW_AUTODIFF_TAMC */
151 jmc 1.38 CALL FIND_RHO_2D(
152     I iMin, iMax, jMin, jMax, k,
153     I tFld(1-OLx,1-OLy,k,bi,bj),
154     I sFld(1-OLx,1-OLy,k,bi,bj),
155     O alphaRho,
156     I k, bi, bj, myThid )
157     ELSE
158     DO j=jMin,jMax
159     DO i=iMin,iMax
160     alphaRho(i,j) = rhoInSitu(i,j,k,bi,bj)
161     ENDDO
162     ENDDO
163     ENDIF
164 jmc 1.36
165 mlosch 1.33 #ifdef ALLOW_SHELFICE
166 jmc 1.36 C mask rho, so that there is no contribution of phiHyd from
167 mlosch 1.33 C overlying shelfice (whose density we do not know)
168 jmc 1.37 IF ( useShelfIce .AND. useDOWN_SLOPE ) THEN
169     C- note: does not work for down_slope pkg which needs rho below the bottom.
170     C setting rho=0 above the ice-shelf base is enough (and works in both cases)
171     C but might be slower (--> keep original masking if not using down_slope pkg)
172     DO j=jMin,jMax
173     DO i=iMin,iMax
174     IF ( k.LT.kSurfC(i,j,bi,bj) ) alphaRho(i,j) = 0. _d 0
175     ENDDO
176     ENDDO
177     ELSEIF ( useShelfIce ) THEN
178 mlosch 1.33 DO j=jMin,jMax
179     DO i=iMin,iMax
180     alphaRho(i,j) = alphaRho(i,j)*maskC(i,j,k,bi,bj)
181     ENDDO
182     ENDDO
183     ENDIF
184     #endif /* ALLOW_SHELFICE */
185 adcroft 1.22
186 jmc 1.34 #ifdef ALLOW_MOM_COMMON
187 adcroft 1.22 C Quasi-hydrostatic terms are added in as if they modify the buoyancy
188     IF (quasiHydrostatic) THEN
189 jmc 1.34 CALL MOM_QUASIHYDROSTATIC(bi,bj,k,uVel,vVel,alphaRho,myThid)
190 adcroft 1.22 ENDIF
191 jmc 1.34 #endif /* ALLOW_MOM_COMMON */
192 adcroft 1.9
193 jmc 1.29 #ifdef NONLIN_FRSURF
194 jmc 1.41 IF ( addSurfPhiAnom .AND.
195     & uniformFreeSurfLev .AND. k.EQ.1 ) THEN
196 jmc 1.29 DO j=jMin,jMax
197     DO i=iMin,iMax
198     phiHydF(i,j) = surfPhiFac*etaH(i,j,bi,bj)
199     & *gravity*alphaRho(i,j)*recip_rhoConst
200     ENDDO
201     ENDDO
202     ENDIF
203     #endif /* NONLIN_FRSURF */
204 jmc 1.27
205 jmc 1.29 C---- Hydrostatic pressure at cell centers
206 jmc 1.25
207     IF (integr_GeoPot.EQ.1) THEN
208     C -- Finite Volume Form
209    
210     C---------- This discretization is the "finite volume" form
211     C which has not been used to date since it does not
212     C conserve KE+PE exactly even though it is more natural
213 jmc 1.41
214     IF ( uniformFreeSurfLev ) THEN
215     DO j=jMin,jMax
216     DO i=iMin,iMax
217     phiHydC(i,j) = phiHydF(i,j)
218     & + half*drF(k)*gravity*alphaRho(i,j)*recip_rhoConst
219     phiHydF(i,j) = phiHydF(i,j)
220     & + drF(k)*gravity*alphaRho(i,j)*recip_rhoConst
221     ENDDO
222     ENDDO
223     ELSE
224     DO j=jMin,jMax
225     DO i=iMin,iMax
226     IF (k.EQ.kSurfC(i,j,bi,bj)) THEN
227     ddRloc = Ro_surf(i,j,bi,bj)-rC(k)
228     #ifdef NONLIN_FRSURF
229     ddRloc = ddRloc + surfPhiFac*etaH(i,j,bi,bj)
230     #endif
231     phiHydC(i,j) = ddRloc*gravity*alphaRho(i,j)*recip_rhoConst
232     ELSE
233     phiHydC(i,j) = phiHydF(i,j)
234     & + half*drF(k)*gravity*alphaRho(i,j)*recip_rhoConst
235     ENDIF
236     phiHydF(i,j) = phiHydC(i,j)
237     & + half*drF(k)*gravity*alphaRho(i,j)*recip_rhoConst
238 jmc 1.25 ENDDO
239     ENDDO
240 jmc 1.41 ENDIF
241 jmc 1.25
242     ELSE
243     C -- Finite Difference Form
244    
245 jmc 1.41 C---------- This discretization is the "energy conserving" form
246     C which has been used since at least Adcroft et al., MWR 1997
247 jmc 1.29
248 jmc 1.41 dRlocM=half*drC(k)
249     IF (k.EQ.1) dRlocM=rF(k)-rC(k)
250     IF (k.EQ.Nr) THEN
251     dRlocP=rC(k)-rF(k+1)
252     ELSE
253     dRlocP=half*drC(k+1)
254     ENDIF
255     IF ( uniformFreeSurfLev ) THEN
256     DO j=jMin,jMax
257     DO i=iMin,iMax
258     phiHydC(i,j) = phiHydF(i,j)
259     & +dRlocM*gravity*alphaRho(i,j)*recip_rhoConst
260     phiHydF(i,j) = phiHydC(i,j)
261     & +dRlocP*gravity*alphaRho(i,j)*recip_rhoConst
262     ENDDO
263     ENDDO
264     ELSE
265     rec_dRm = one/(rF(k)-rC(k))
266     rec_dRp = one/(rC(k)-rF(k+1))
267 jmc 1.25 DO j=jMin,jMax
268     DO i=iMin,iMax
269 jmc 1.41 IF (k.EQ.kSurfC(i,j,bi,bj)) THEN
270     ddRloc = Ro_surf(i,j,bi,bj)-rC(k)
271     #ifdef NONLIN_FRSURF
272     ddRloc = ddRloc + surfPhiFac*etaH(i,j,bi,bj)
273     #endif
274     phiHydC(i,j) =( MAX(zero,ddRloc)*rec_dRm*dRlocM
275     & +MIN(zero,ddRloc)*rec_dRp*dRlocP
276     & )*gravity*alphaRho(i,j)*recip_rhoConst
277     ELSE
278     phiHydC(i,j) = phiHydF(i,j)
279 jmc 1.29 & +dRlocM*gravity*alphaRho(i,j)*recip_rhoConst
280 jmc 1.41 ENDIF
281     phiHydF(i,j) = phiHydC(i,j)
282 jmc 1.29 & +dRlocP*gravity*alphaRho(i,j)*recip_rhoConst
283 adcroft 1.9 ENDDO
284 jmc 1.25 ENDDO
285 jmc 1.41 ENDIF
286 jmc 1.25
287     C -- end if integr_GeoPot = ...
288     ENDIF
289 jmc 1.36
290 jmc 1.25 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
291 jmc 1.29 ELSEIF ( buoyancyRelation .EQ. 'OCEANICP' ) THEN
292 adcroft 1.19 C This is the hydrostatic pressure calculation for the Ocean
293 jmc 1.40 C which uses the FIND_RHO() routine to calculate density before
294     C integrating (1/rho)_prime*dp over the current layer/interface
295 mlosch 1.21 #ifdef ALLOW_AUTODIFF_TAMC
296     CADJ GENERAL
297     #endif /* ALLOW_AUTODIFF_TAMC */
298 adcroft 1.19
299 jmc 1.38 IF ( implicitIntGravWave .OR. myIter.LT.0 ) THEN
300 jmc 1.27 C-- Calculate density
301 adcroft 1.19 #ifdef ALLOW_AUTODIFF_TAMC
302 jmc 1.38 kkey = (ikey-1)*Nr + k
303 heimbach 1.39 CADJ STORE tFld (:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte,
304     CADJ & kind = isbyte
305     CADJ STORE sFld (:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte,
306     CADJ & kind = isbyte
307 adcroft 1.19 #endif /* ALLOW_AUTODIFF_TAMC */
308 jmc 1.38 CALL FIND_RHO_2D(
309     I iMin, iMax, jMin, jMax, k,
310     I tFld(1-OLx,1-OLy,k,bi,bj),
311     I sFld(1-OLx,1-OLy,k,bi,bj),
312     O alphaRho,
313     I k, bi, bj, myThid )
314 heimbach 1.23 #ifdef ALLOW_AUTODIFF_TAMC
315 heimbach 1.39 CADJ STORE alphaRho (:,:) = comlev1_bibj_k, key=kkey, byte=isbyte,
316     CADJ & kind = isbyte
317 heimbach 1.23 #endif /* ALLOW_AUTODIFF_TAMC */
318 jmc 1.38 ELSE
319     DO j=jMin,jMax
320     DO i=iMin,iMax
321     alphaRho(i,j) = rhoInSitu(i,j,k,bi,bj)
322     ENDDO
323     ENDDO
324     ENDIF
325 jmc 1.31
326 jmc 1.40 C-- Calculate specific volume anomaly : alpha_prime = 1/rho - alpha_Cst
327 jmc 1.27 DO j=jMin,jMax
328     DO i=iMin,iMax
329     locAlpha=alphaRho(i,j)+rhoConst
330     alphaRho(i,j)=maskC(i,j,k,bi,bj)*
331     & (one/locAlpha - recip_rhoConst)
332     ENDDO
333     ENDDO
334    
335 jmc 1.25 C---- Hydrostatic pressure at cell centers
336    
337     IF (integr_GeoPot.EQ.1) THEN
338     C -- Finite Volume Form
339    
340     DO j=jMin,jMax
341 adcroft 1.19 DO i=iMin,iMax
342 jmc 1.25
343     C---------- This discretization is the "finite volume" form
344     C which has not been used to date since it does not
345     C conserve KE+PE exactly even though it is more natural
346 jmc 1.41
347 jmc 1.37 IF (k.EQ.kSurfC(i,j,bi,bj)) THEN
348 jmc 1.29 ddRloc = Ro_surf(i,j,bi,bj)-rC(k)
349     #ifdef NONLIN_FRSURF
350     ddRloc = ddRloc + surfPhiFac*etaH(i,j,bi,bj)
351     #endif
352     phiHydC(i,j) = ddRloc*alphaRho(i,j)
353 jmc 1.36 c--to reproduce results of c48d_post: uncomment those 4+1 lines
354 jmc 1.29 c phiHydC(i,j)=phiHydF(i,j)
355     c & +(hFacC(i,j,k,bi,bj)-half)*drF(k)*alphaRho(i,j)
356     c phiHydF(i,j)=phiHydF(i,j)
357     c & + hFacC(i,j,k,bi,bj)*drF(k)*alphaRho(i,j)
358     ELSE
359     phiHydC(i,j) = phiHydF(i,j) + half*drF(k)*alphaRho(i,j)
360     c phiHydF(i,j) = phiHydF(i,j) + drF(k)*alphaRho(i,j)
361     ENDIF
362     c-- and comment this last one:
363     phiHydF(i,j) = phiHydC(i,j) + half*drF(k)*alphaRho(i,j)
364     c-----
365 jmc 1.25 ENDDO
366     ENDDO
367    
368     ELSE
369 jmc 1.29 C -- Finite Difference Form, with Part-Cell Bathy
370    
371     dRlocM=half*drC(k)
372     IF (k.EQ.1) dRlocM=rF(k)-rC(k)
373     IF (k.EQ.Nr) THEN
374     dRlocP=rC(k)-rF(k+1)
375     ELSE
376     dRlocP=half*drC(k+1)
377     ENDIF
378     rec_dRm = one/(rF(k)-rC(k))
379     rec_dRp = one/(rC(k)-rF(k+1))
380 jmc 1.25
381     DO j=jMin,jMax
382     DO i=iMin,iMax
383 adcroft 1.9
384 adcroft 1.19 C---------- This discretization is the "energy conserving" form
385 mlosch 1.21
386 jmc 1.37 IF (k.EQ.kSurfC(i,j,bi,bj)) THEN
387 jmc 1.29 ddRloc = Ro_surf(i,j,bi,bj)-rC(k)
388     #ifdef NONLIN_FRSURF
389     ddRloc = ddRloc + surfPhiFac*etaH(i,j,bi,bj)
390     #endif
391     phiHydC(i,j) =( MAX(zero,ddRloc)*rec_dRm*dRlocM
392     & +MIN(zero,ddRloc)*rec_dRp*dRlocP
393     & )*alphaRho(i,j)
394     ELSE
395     phiHydC(i,j) = phiHydF(i,j) + dRlocM*alphaRho(i,j)
396     ENDIF
397     phiHydF(i,j) = phiHydC(i,j) + dRlocP*alphaRho(i,j)
398 adcroft 1.19 ENDDO
399 jmc 1.25 ENDDO
400    
401     C -- end if integr_GeoPot = ...
402     ENDIF
403 adcroft 1.9
404 jmc 1.29 ELSEIF ( buoyancyRelation .EQ. 'ATMOSPHERIC' ) THEN
405 jmc 1.14 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
406 adcroft 1.9 C This is the hydrostatic geopotential calculation for the Atmosphere
407     C The ideal gas law is used implicitly here rather than calculating
408     C the specific volume, analogous to the oceanic case.
409    
410 jmc 1.30 C-- virtual potential temperature anomaly (including water vapour effect)
411     DO j=jMin,jMax
412     DO i=iMin,iMax
413     alphaRho(i,j)=maskC(i,j,k,bi,bj)
414 jmc 1.36 & *( tFld(i,j,k,bi,bj)*(sFld(i,j,k,bi,bj)*atm_Rq+one)
415 jmc 1.30 & -tRef(k) )
416     ENDDO
417     ENDDO
418    
419 jmc 1.29 C--- Integrate d Phi / d pi
420 adcroft 1.9
421 jmc 1.29 IF (integr_GeoPot.EQ.0) THEN
422     C -- Energy Conserving Form, accurate with Full cell topo --
423 jmc 1.14 C------------ The integration for the first level phi(k=1) is the same
424     C for both the "finite volume" and energy conserving methods.
425 jmc 1.36 C *NOTE* o Working with geopotential Anomaly, the geopotential boundary
426 adcroft 1.17 C condition is simply Phi-prime(Ro_surf)=0.
427 jmc 1.14 C o convention ddPI > 0 (same as drF & drC)
428     C-----------------------------------------------------------------------
429 jmc 1.29 IF (k.EQ.1) THEN
430     ddPIm=atm_Cp*( ((rF( k )/atm_Po)**atm_kappa)
431     & -((rC( k )/atm_Po)**atm_kappa) )
432     ELSE
433     ddPIm=atm_Cp*( ((rC(k-1)/atm_Po)**atm_kappa)
434     & -((rC( k )/atm_Po)**atm_kappa) )*half
435     ENDIF
436     IF (k.EQ.Nr) THEN
437     ddPIp=atm_Cp*( ((rC( k )/atm_Po)**atm_kappa)
438     & -((rF(k+1)/atm_Po)**atm_kappa) )
439     ELSE
440     ddPIp=atm_Cp*( ((rC( k )/atm_Po)**atm_kappa)
441 jmc 1.36 & -((rC(k+1)/atm_Po)**atm_kappa) )*half
442 jmc 1.29 ENDIF
443 jmc 1.14 C-------- This discretization is the energy conserving form
444 jmc 1.29 DO j=jMin,jMax
445     DO i=iMin,iMax
446 jmc 1.30 phiHydC(i,j) = phiHydF(i,j) +ddPIm*alphaRho(i,j)
447     phiHydF(i,j) = phiHydC(i,j) +ddPIp*alphaRho(i,j)
448 jmc 1.14 ENDDO
449 jmc 1.29 ENDDO
450 jmc 1.14 C end: Energy Conserving Form, No hFac --
451 adcroft 1.9 C-----------------------------------------------------------------------
452 jmc 1.14
453 jmc 1.29 ELSEIF (integr_GeoPot.EQ.1) THEN
454     C -- Finite Volume Form, with Part-Cell Topo, linear in P by Half level
455 jmc 1.14 C---------
456     C Finite Volume formulation consistent with Partial Cell, linear in p by piece
457     C Note: a true Finite Volume form should be linear between 2 Interf_W :
458     C phi_C = (phi_W_k+ phi_W_k+1)/2 ; but not accurate in Stratosphere (low p)
459     C also: if Interface_W at the middle between tracer levels, this form
460 jmc 1.36 C is close to the Energy Cons. form in the Interior, except for the
461 jmc 1.14 C non-linearity in PI(p)
462     C---------
463 jmc 1.29 ddPIm=atm_Cp*( ((rF( k )/atm_Po)**atm_kappa)
464     & -((rC( k )/atm_Po)**atm_kappa) )
465     ddPIp=atm_Cp*( ((rC( k )/atm_Po)**atm_kappa)
466     & -((rF(k+1)/atm_Po)**atm_kappa) )
467     DO j=jMin,jMax
468     DO i=iMin,iMax
469 jmc 1.37 IF (k.EQ.kSurfC(i,j,bi,bj)) THEN
470 jmc 1.29 ddRloc = Ro_surf(i,j,bi,bj)-rC(k)
471     #ifdef NONLIN_FRSURF
472     ddRloc = ddRloc + surfPhiFac*etaH(i,j,bi,bj)
473     #endif
474     phiHydC(i,j) = ddRloc*recip_drF(k)*2. _d 0
475 jmc 1.30 & *ddPIm*alphaRho(i,j)
476 jmc 1.29 ELSE
477 jmc 1.30 phiHydC(i,j) = phiHydF(i,j) +ddPIm*alphaRho(i,j)
478 jmc 1.29 ENDIF
479 jmc 1.30 phiHydF(i,j) = phiHydC(i,j) +ddPIp*alphaRho(i,j)
480 adcroft 1.9 ENDDO
481 jmc 1.29 ENDDO
482     C end: Finite Volume Form, with Part-Cell Topo, linear in P by Half level
483 adcroft 1.9 C-----------------------------------------------------------------------
484    
485 jmc 1.29 ELSEIF ( integr_GeoPot.EQ.2
486     & .OR. integr_GeoPot.EQ.3 ) THEN
487 jmc 1.36 C -- Finite Difference Form, with Part-Cell Topo,
488 jmc 1.29 C works with Interface_W at the middle between 2.Tracer_Level
489     C and with Tracer_Level at the middle between 2.Interface_W.
490 jmc 1.14 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
491     C Finite Difference formulation consistent with Partial Cell,
492     C Valid & accurate if Interface_W at middle between tracer levels
493 jmc 1.36 C linear in p between 2 Tracer levels ; conserve energy in the Interior
494 jmc 1.14 C---------
495 jmc 1.29 IF (k.EQ.1) THEN
496     ddPIm=atm_Cp*( ((rF( k )/atm_Po)**atm_kappa)
497     & -((rC( k )/atm_Po)**atm_kappa) )
498     ELSE
499     ddPIm=atm_Cp*( ((rC(k-1)/atm_Po)**atm_kappa)
500     & -((rC( k )/atm_Po)**atm_kappa) )*half
501     ENDIF
502     IF (k.EQ.Nr) THEN
503     ddPIp=atm_Cp*( ((rC( k )/atm_Po)**atm_kappa)
504     & -((rF(k+1)/atm_Po)**atm_kappa) )
505     ELSE
506     ddPIp=atm_Cp*( ((rC( k )/atm_Po)**atm_kappa)
507 jmc 1.36 & -((rC(k+1)/atm_Po)**atm_kappa) )*half
508 jmc 1.29 ENDIF
509     rec_dRm = one/(rF(k)-rC(k))
510     rec_dRp = one/(rC(k)-rF(k+1))
511     DO j=jMin,jMax
512     DO i=iMin,iMax
513 jmc 1.37 IF (k.EQ.kSurfC(i,j,bi,bj)) THEN
514 jmc 1.29 ddRloc = Ro_surf(i,j,bi,bj)-rC(k)
515     #ifdef NONLIN_FRSURF
516     ddRloc = ddRloc + surfPhiFac*etaH(i,j,bi,bj)
517     #endif
518     phiHydC(i,j) =( MAX(zero,ddRloc)*rec_dRm*ddPIm
519     & +MIN(zero,ddRloc)*rec_dRp*ddPIp )
520 jmc 1.30 & *alphaRho(i,j)
521 jmc 1.29 ELSE
522 jmc 1.30 phiHydC(i,j) = phiHydF(i,j) +ddPIm*alphaRho(i,j)
523 jmc 1.29 ENDIF
524 jmc 1.30 phiHydF(i,j) = phiHydC(i,j) +ddPIp*alphaRho(i,j)
525 jmc 1.14 ENDDO
526 jmc 1.29 ENDDO
527     C end: Finite Difference Form, with Part-Cell Topo
528 jmc 1.14 C-----------------------------------------------------------------------
529 cnh 1.1
530 jmc 1.29 ELSE
531     STOP 'CALC_PHI_HYD: Bad integr_GeoPot option !'
532     ENDIF
533 cnh 1.6
534 jmc 1.14 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
535 adcroft 1.9 ELSE
536 jmc 1.24 STOP 'CALC_PHI_HYD: Bad value of buoyancyRelation !'
537 jmc 1.25 ENDIF
538    
539 jmc 1.29 C--- Diagnose Phi at boundary r=R_low :
540     C = Ocean bottom pressure (Ocean, Z-coord.)
541     C = Sea-surface height (Ocean, P-coord.)
542     C = Top atmosphere height (Atmos, P-coord.)
543     IF (useDiagPhiRlow) THEN
544     CALL DIAGS_PHI_RLOW(
545     I k, bi, bj, iMin,iMax, jMin,jMax,
546     I phiHydF, phiHydC, alphaRho, tFld, sFld,
547 jmc 1.36 I myTime, myIter, myThid)
548 jmc 1.29 ENDIF
549    
550     C--- Diagnose Full Hydrostatic Potential at cell center level
551     CALL DIAGS_PHI_HYD(
552     I k, bi, bj, iMin,iMax, jMin,jMax,
553     I phiHydC,
554     I myTime, myIter, myThid)
555    
556 jmc 1.36 IF (momPressureForcing) THEN
557 jmc 1.25 CALL CALC_GRAD_PHI_HYD(
558 jmc 1.35 I k, bi, bj, iMin,iMax, jMin,jMax,
559 jmc 1.29 I phiHydC, alphaRho, tFld, sFld,
560 jmc 1.25 O dPhiHydX, dPhiHydY,
561 jmc 1.36 I myTime, myIter, myThid)
562 cnh 1.5 ENDIF
563 cnh 1.1
564 jmc 1.14 #endif /* INCLUDE_PHIHYD_CALCULATION_CODE */
565 cnh 1.6
566 jmc 1.11 RETURN
567     END

  ViewVC Help
Powered by ViewVC 1.1.22